# kazuhito00/image-processing-node-editor architecture

> Architecture diagram of the GitHub repository kazuhito00/image-processing-node-editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kazuhito00/image-processing-node-editor
- Repository: https://github.com/kazuhito00/image-processing-node-editor

## Overview

##### Project type and purpose
- This is a desktop image-processing “node editor” application written in Python.
- Key technologies: dearpygui for the GUI, OpenCV for classical image ops, onnxruntime for DL inference, Mediapipe/filterpy for specialized nodes, plus a plugin-style node architecture.

##### File structure
- Top level:
- main.py: application entry point
- node/…: all node implementations, grouped by category (input_node, process_node, deep_learning_node, analysis_node, draw_node, other_node, preview_release_node)
- node_editor/: GUI and graph-editor code (node_editor.py, util.py, setting.json)
- docker/: Dockerfiles to containerize the app with GPU support
- setup.py, requirements.txt: packaging and dependencies
- Patterns:
- Plugin architecture: each node category is a folder of self-contained modules.
- MVC/Event-driven: node_editor acts as View/Controller, core graph (in main.py and node_abc.py) acts as Model.
- Each node inherits from a base (node/node_abc.py) and is dynamically discovered/instantiated.

##### Insights from README
- The README enumerates dozens of node types, showing purpose, I/O types, and dependencies.
- Usage instructions highlight command-line flags, Docker support, and pip packaging.
- Emphasis on extensibility: adding new nodes requires dropping a new module under the node/ hierarchy.

a. Main components:
- GUI Layer (node_editor): DearPyGui-based graph editor UI
- Core Graph Engine:
– Node Manager/Factory: discovers/imports node classes
– Graph Data Model: stores nodes, links, execution order
– Scheduler/Executor: runs node update loops (async or sync)
- Node Modules: categorized plugins
– Input Nodes (video, image, webcam, RTSP, values)
– Deep Learning Nodes (classification, detection, enhancement, pose, etc.)
– Analysis Nodes (FPS, histograms, BRISQUE)
– Other/Preview Nodes (switch, writer, MOT, code exec, screen capture)
- Compute Libraries:
– OpenCV (cv2) for traditional image processing
– ONNX Runtime for model inference
– Mediapipe & Protobuf for certain DL nodes
– filterpy for MOTpy nodes
- Persistence & I/O: JSON export/import of graph configs, VideoWriter for output files
- CLI & Docker packaging (optional deployment containers)

b. Relationships and interactions
- GUI <--> Core Engine:
– GUI emits “create node”, “connect pins”, “delete node” events
– Core Engine updates the graph model, triggers re-execution
– Engine pushes processed frames back to GUI for display
- Core Engine --> Node Modules:
– For each node in execution order, Engine calls node.update(inputs)
– Node uses Compute Libraries (OpenCV, ONNX, etc.) to process and returns outputs
- Node Modules <--> Compute Libraries:
– Deep-learning nodes load ONNX models from disk and call onnxruntime
– Process nodes invoke OpenCV functions (cv2.blur, cv2.Canny, etc.)
- Persistence: Engine serializes graph state (nodes, parameters, connections) to JSON; can load it back

c. Architectural patterns & principles
- Plugin / Factory pattern: node discovery and instantiation at runtime
- MVC or MVVM: separating GUI (View) from graph model and execution logic
- Strategy pattern: each node encapsulates its own algorithm/behavior
- Event-driven & observer pattern: graph changes trigger re-computation/display updates
- Containerization: Docker directory for reproducible GPU-accelerated environments

d. Key technologies, frameworks, libraries
– Python 3.x
– dearpygui (GUI)
– OpenCV (cv2)
– onnxruntime-gpu
– Mediapipe, Protobuf
– filterpy, MOTpy, Norfair (tracking)
– JSON (graph export/import)
– Docker (nvidia-gpu support)
– setuptools (setup.py), pip

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% GUI Layer
    subgraph "GUI Layer"
        GUI["DearPyGui Graph Editor UI"]:::gui
        Util["Utility Functions"]:::gui
        Settings["node_editor/setting.json"]:::gui
        Font["Font Files"]:::gui
    end

    %% Core Engine
    subgraph "Core Graph Engine"
        Entry["main.py"]:::engine
        BaseNode["node_abc.py"]:::engine
    end

    %% Persistence & I/O
    subgraph "Persistence & I/O"
        Serialize["Graph JSON Serialization"]:::io
    end

    %% Node Modules
    subgraph "Node Modules"
        subgraph "Input Nodes"
            Input["node/input_node/*"]:::node
        end
        subgraph "Process Nodes"
            Process["node/process_node/*"]:::node
        end
        subgraph "Deep Learning Nodes"
            DL["node/deep_learning_node/*"]:::node
        end
        subgraph "Analysis Nodes"
            Analysis["node/analysis_node/*"]:::node
        end
        subgraph "Draw Nodes"
            Draw["node/draw_node/*"]:::node
        end
        subgraph "Other Nodes"
            Other["node/other_node/*"]:::node
        end
        subgraph "Preview/Release Nodes"
            Preview["node/preview_release_node/*"]:::node
        end
    end

    %% Compute Libraries
    subgraph "Compute Libraries"
        CV2["OpenCV (cv2)"]:::lib
        ONNX["ONNX Runtime"]:::lib
        MP["Mediapipe & Protobuf"]:::lib
        FP["filterpy / MOTpy / Norfair"]:::lib
        LibDeps["requirements.txt / setup.py"]:::lib
    end

    %% Docker & CLI
    subgraph "Docker / CLI Packaging"
        Docker["GPU Container (Docker)"]:::docker
        CLI["CLI & Packaging"]:::docker
    end

    %% Connections
    GUI -->|"user actions"| Entry
    Entry -->|"loads base class"| BaseNode
    Entry -->|"create/connect/delete"| Util
    Entry -->|"save/load graph"| Serialize
    Serialize -->|"provides JSON to"| Entry
    Entry -->|"push frames/results"| GUI

    Entry -->|"executes"| Input
    Entry -->|"executes"| Process
    Entry -->|"executes"| DL
    Entry -->|"executes"| Analysis
    Entry -->|"executes"| Draw
    Entry -->|"executes"| Other
    Entry -->|"executes"| Preview

    Process -->|"uses"| CV2
    DL -->|"uses"| ONNX
    DL -->|"uses"| MP
    Other -->|"uses"| FP
    Input -->|"dependencies"| LibDeps
    Process -->|"dependencies"| LibDeps
    DL -->|"dependencies"| LibDeps
    Analysis -->|"dependencies"| LibDeps
    Draw -->|"dependencies"| LibDeps
    Other -->|"dependencies"| LibDeps
    Preview -->|"dependencies"| LibDeps

    Entry -->|"CLI flags"| CLI
    CLI -->|"build container"| Docker

    %% Click Events
    click GUI "https://github.com/kazuhito00/image-processing-node-editor/blob/main/node_editor/node_editor.py"
    click Util "https://github.com/kazuhito00/image-processing-node-editor/blob/main/node_editor/util.py"
    click Settings "https://github.com/kazuhito00/image-processing-node-editor/blob/main/node_editor/setting/setting.json"
    click Font "https://github.com/kazuhito00/image-processing-node-editor/tree/main/node_editor/font/YasashisaAntiqueFont"
    click Entry "https://github.com/kazuhito00/image-processing-node-editor/blob/main/main.py"
    click BaseNode "https://github.com/kazuhito00/image-processing-node-editor/blob/main/node/node_abc.py"
    click Serialize "https://github.com/kazuhito00/image-processing-node-editor/blob/main/node_editor/util.py"
    click Input "https://github.com/kazuhito00/image-processing-node-editor/tree/main/node/input_node/"
    click Process "https://github.com/kazuhito00/image-processing-node-editor/tree/main/node/process_node/"
    click DL "https://github.com/kazuhito00/image-processing-node-editor/tree/main/node/deep_learning_node/"
    click Analysis "https://github.com/kazuhito00/image-processing-node-editor/tree/main/node/analysis_node/"
    click Draw "https://github.com/kazuhito00/image-processing-node-editor/tree/main/node/draw_node/"
    click Other "https://github.com/kazuhito00/image-processing-node-editor/tree/main/node/other_node/"
    click Preview "https://github.com/kazuhito00/image-processing-node-editor/tree/main/node/preview_release_node/"
    click LibDeps "https://github.com/kazuhito00/image-processing-node-editor/blob/main/requirements.txt"
    click LibDeps "https://github.com/kazuhito00/image-processing-node-editor/blob/main/setup.py"
    click Docker "https://github.com/kazuhito00/image-processing-node-editor/tree/main/docker/nvidia-gpu/Dockerfile"
    click Docker "https://github.com/kazuhito00/image-processing-node-editor/blob/main/docker/nvidia-gpu/README.md"
    click CLI "https://github.com/kazuhito00/image-processing-node-editor/blob/main/setup.py"
    click CLI "https://github.com/kazuhito00/image-processing-node-editor/blob/main/requirements.txt"

    %% Styles
    classDef gui fill:#FFDDC1,stroke:#E69A8D,color:#000
    classDef engine fill:#D1E8FF,stroke:#7FB3FF,color:#000
    classDef io fill:#E8E8E8,stroke:#C0C0C0,color:#000
    classDef node fill:#D5FFD1,stroke:#7FE77F,color:#000
    classDef lib fill:#FFF5C2,stroke:#FFE066,color:#000
    classDef docker fill:#F0D9FF,stroke:#D57FFF,color:#000
```
