# cggos/ccv architecture

> Architecture diagram of the GitHub repository cggos/ccv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cggos/ccv
- Repository: https://github.com/cggos/ccv

## Overview

##### Main Components
- Core Library: Represent the core computer vision modules (e.g., Maths, Computer Vision, Kinematics) built in C++ along with header files (in “include” and “src” directories) that implement low-level algorithms.
- External/Demo Libraries: Indicate the integration points for third-party libraries and dependencies such as OpenCV, FFTW, PCL, OpenGL, and Pangolin. Group these as “Dependencies/External Libraries.”
- Apps/Demos: Create separate nodes for the different application suites. For instance:
– Camera Kit: Further divided into Android Camera App, ROS-based camera utilities, calibration tools (with submodules like “calib_rectify”, “cam_ros”, “rs_cam”, “stereo_cam_mipi”, and “v4l_sdk”).
– CVStudio (GUI on Qt)
– DIP Demos in C# and Java
– Stereo Matching (OpenCL based) and Stereo Reconstruction (ROS based)
– Other smaller demos (e.g., Face Detection)
- Language-Specific Modules: Optionally denote that parts of the project are implemented in multiple languages. For example, a node for “Python LibCCV” and blocks for Matlab, Java, and C# demos.
- Configuration and Build System: Represent the build processes (plain CMake workflows, catkin build for ROS, gradle for Android) as an auxiliary component that ties these components together.

##### Relationships and Interactions
- For the ROS parts (like cam_ros, stereo_reconstruct, etc.), illustrate how these wrap the core-computer vision functionalities and interact with ROS middleware.
- In the Android and other language-specific modules, indicate that wrappers or bindings link the core C++ functionality with higher-level interfaces.
- Build and deployment flows: e.g., CMake configurations and custom scripts (shell scripts in calibration modules) facilitating various use cases.

##### Architectural Patterns and Design Principles
- Modularization: Emphasize the separation between core vision functionalities and higher-level application-specific code. The project is organized in a modular fashion where each demo or application is a “client” of the core library.
- Multi-language/Platform support: The architecture is layered such that a fundamental C++ vision library can be accessed via language-specific wrappers (Java, C#, Python).
- ROS and Embedded Integration: Some modules are designed as ROS packages with nodelets that wrap the C++ core, demonstrating a plugin/service-oriented design.
- Use of External Libraries: The design leverages industry-standard libraries (OpenCV, PCL, etc.) to abstract hardware interactions and advanced algorithms.

##### Technologies, Frameworks, and Libraries
- C++/OpenCV: For core image processing and computer vision routines.
- Build Systems: CMake, Gradle for Android, and ROS catkin tools.
- Scripting and Testing: Shell scripts for calibration routines and unit tests via Google Test.
- Additional graphics/visualization: Qt for CVStudio, Pangolin and OpenGL for visual demos, and GraphViz used in one of the Python demos.

##### Essential Elements
- Use clear, distinctly labeled nodes for each major component (Core Library, each App Suite, External Libraries, Build/Configuration).
– Data flow (e.g., images processed by the core, then consumed by apps)
– Dependencies (core library depends on external libraries; apps depend on both core library and middleware like ROS)

##### Construction
- Branch out to connect to external libraries (OpenCV, FFTW, etc.) that serve as dependencies.
- On one side, list all apps (Camera Kit, CVStudio, etc.) built on top of the core. Within the “Camera Kit” node, you may further segment sub-components (calibration, ROS wrappers, Android implementation, etc.).
- Peripheral nodes for language-specific wrappers/demos (Java DIP Demo, C# DIP Demo, Python LibCCV).
- On a separate side, include configuration and build modules (CMakeLists, catkin build commands, Gradle files) to indicate the build and integration process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External/Dependency Libraries
    subgraph "External/Dependency Libraries"
        DE1["OpenCV"]:::dependency
        DE2["FFTW"]:::dependency
        DE3["PCL"]:::dependency
        DE4["OpenGL"]:::dependency
        DE5["Pangolin"]:::dependency
    end

    %% Core Library Modules
    subgraph "Core Library"
        CL4["Headers"]:::core
        CL1["Maths"]:::core
        CL2["Computer Vision"]:::core
        CL3["Kinematics"]:::core
    end

    %% Build System and Configuration
    BS["Build & Config"]:::build

    %% Apps / Demos
    subgraph "Apps / Demos"
        subgraph "Camera Kit"
            CA1["Android Camera App"]:::app
            CA2["ROS Camera Utilities"]:::app
            CA3["Calibration Tools"]:::app
            CA4["RS Camera"]:::app
            CA5["Stereo Cam MIPI"]:::app
            CA6["V4L SDK"]:::app
        end
        CV["CVStudio (GUI)"]:::app
        subgraph "DIP Demos"
            DIP_CSHARP["C# DIP Demo"]:::app
            DIP_JAVA["Java DIP Demo"]:::app
        end
        subgraph "Stereo Modules"
            SM["Stereo Matching (OpenCL)"]:::app
            SR["Stereo Reconstruction (ROS)"]:::app
        end
        FD["Face Detection Demo"]:::app
    end

    %% Language-Specific Modules
    subgraph "Language-Specific Modules"
        PY["Python LibCCV"]:::language
        MATLAB["Matlab Demos"]:::language
    end

    %% ROS Middleware
    ROS["ROS Middleware"]:::dependency

    %% External Dependencies -> Core Library
    DE1 -->|"uses"| CL2
    DE2 -->|"uses"| CL2
    DE3 -->|"uses"| CL2
    DE4 -->|"uses"| CL2
    DE5 -->|"uses"| CL2

    %% Core Library -> Apps / Demos (using the Computer Vision module as the representative)
    CL2 -->|"provides"| CA1
    CL2 -->|"provides"| CA2
    CL2 -->|"provides"| CA3
    CL2 -->|"provides"| CA4
    CL2 -->|"provides"| CA5
    CL2 -->|"provides"| CA6
    CL2 -->|"provides"| CV
    CL2 -->|"provides"| DIP_CSHARP
    CL2 -->|"provides"| DIP_JAVA
    CL2 -->|"provides"| SM
    CL2 -->|"provides"| SR
    CL2 -->|"provides"| FD

    %% Core Library -> Language-Specific Modules
    CL2 -->|"wrappedBy"| PY
    CL2 -->|"wrappedBy"| MATLAB

    %% Build System connections
    BS -->|"builds"| CL2
    BS -->|"builds"| CA1
    BS -->|"builds"| CA2
    BS -->|"builds"| SM
    BS -->|"builds"| DIP_CSHARP
    BS -->|"builds"| DIP_JAVA
    BS -->|"builds"| CV

    %% ROS Middleware interactions
    CA2 -->|"ROS_wrapper"| ROS
    SR -->|"ROS_wrapper"| ROS
    ROS -->|"integrates"| CL2

    %% Click Events for Core Library
    click CL4 "https://github.com/cggos/ccv/tree/main/include/ccv"
    click CL1 "https://github.com/cggos/ccv/tree/main/src/maths"
    click CL2 "https://github.com/cggos/ccv/tree/main/src/cv"
    click CL3 "https://github.com/cggos/ccv/tree/main/src/kinematics"

    %% Click Events for External/Dependency Libraries
    click DE1 "https://github.com/cggos/ccv/tree/main/libs/opencv"
    click DE2 "https://github.com/cggos/ccv/tree/main/libs/fftw"
    click DE3 "https://github.com/cggos/ccv/tree/main/libs/pcl"
    click DE4 "https://github.com/cggos/ccv/tree/main/libs/opengl"
    click DE5 "https://github.com/cggos/ccv/tree/main/libs/pangolin"

    %% Click Events for Camera Kit Applications
    click CA1 "https://github.com/cggos/ccv/tree/main/apps/camkit/cam_android"
    click CA2 "https://github.com/cggos/ccv/tree/main/apps/camkit/cam_ros"
    click CA3 "https://github.com/cggos/ccv/tree/main/apps/camkit/calib_rectify"
    click CA4 "https://github.com/cggos/ccv/tree/main/apps/camkit/rs_cam"
    click CA5 "https://github.com/cggos/ccv/tree/main/apps/camkit/stereo_cam_mipi"
    click CA6 "https://github.com/cggos/ccv/tree/main/apps/camkit/v4l_sdk"

    %% Click Event for CVStudio
    click CV "https://github.com/cggos/ccv/blob/main/java/src/ghc/windows/MainWindow.java"

    %% Click Events for DIP Demos
    click DIP_CSHARP "https://github.com/cggos/ccv/tree/main/csharp/dip_csharp"
    click DIP_JAVA "https://github.com/cggos/ccv/tree/main/java/src/ghc/dip/java"

    %% Click Events for Stereo Modules
    click SM "https://github.com/cggos/ccv/tree/main/apps/stereo_match"
    click SR "https://github.com/cggos/ccv/tree/main/apps/stereo_reconstruct"

    %% Click Event for Face Detection Demo
    click FD "https://github.com/cggos/ccv/tree/main/libs/opencv/face_detection"

    %% Click Events for Language-Specific Modules
    click PY "https://github.com/cggos/ccv/tree/main/python/libccv"
    click MATLAB "https://github.com/cggos/ccv/tree/main/matlab/CircleDetect"

    %% Styles
    classDef core fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef dependency fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef app fill:#abebc6,stroke:#1e8449,stroke-width:2px;
    classDef build fill:#f5cba7,stroke:#af601a,stroke-width:2px;
    classDef language fill:#f9c5d1,stroke:#c0392b,stroke-width:2px;
```
