# microy/stereovision architecture

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

- Interactive diagram: https://gitdiagram.com/microy/stereovision
- Repository: https://github.com/microy/stereovision

## Overview

Based on our analysis of the file tree and the README, this project is a stereo vision research application implemented in Python. It centers around capturing images from a stereo camera setup, performing calibration, computing disparity for depth reconstruction, and generating a 3D point cloud – with a graphical interface likely provided through PySide and OpenGL. There’s also an Arduino sketch (Trigger/Trigger.ino) suggesting that external hardware control (such as triggering the cameras) is part of the system.

##### Main Components Identification
- StereoVision Core Library: Represented by the "StereoVision" directory, which houses the key modules:
– Camera.py: Handles live image capture from the two cameras.
– Calibration.py: Contains code for calibrating the stereo camera pair.
– Disparity.py: Responsible for computing disparity maps between images.
– PointCloud.py: Uses the computed disparity and calibration data to reconstruct a 3D scene.
– Widget.py: Likely provides the UI components using PySide (and integrates with OpenGL).
- Entry Points and Utility Scripts:
– stereovision.py: Likely the main driver or command-line interface to launch the application.
– setup.py: For installation and dependency management.
– stereovision.desktop: Integration file for Linux desktops.
– disable-autofocus.sh and uvcvideo.conf: Configuration and setup scripts for camera settings.
- External Control:
– Trigger/Trigger.ino: An Arduino sketch for triggering the cameras (external hardware integration).

##### Relationships and Interactions
- The Camera component acquires stereo images which are then fed into the Calibration module to adjust for any misalignments or lens distortions.
- Once the cameras are calibrated, images are processed by the Disparity module to generate depth information. This processed data is subsequently used by the PointCloud module to render a 3D reconstruction.
- The Widget module ties the components together with a graphical user interface, allowing users to interact with debugging, visualization, or configuration tools.
- The external trigger (Arduino sketch) interacts with the camera controls to ensure synchronized capture of images (thereby initiating the image capture process).
- Supporting scripts and configuration files (disable-autofocus.sh, uvcvideo.conf) ensure that the cameras’ settings are optimal for stereo image capture.

##### Architectural Patterns and Technologies
- The design follows a modular structure: Each main functionality (capturing, calibrating, computing, rendering) is encapsulated in its own module.
- Dependency management and installation are handled by setup.py.
- UI and visualization leverage PySide and PyOpenGL.
- Core processing utilizes OpenCV and NumPy.

## Diagram (Mermaid)

```mermaid
flowchart TD
    B["Dependency Manager (setup.py)"]:::script
    A["Entry Point (stereovision.py)"]:::internal
    E["Arduino Trigger (Trigger/Trigger.ino)"]:::hardware
    D1["Camera Config Script: disable-autofocus.sh"]:::script
    D2["Camera Config Script: uvcvideo.conf"]:::script
    C["Desktop Integration (stereovision.desktop)"]:::interface

    B --> A
       
    subgraph "StereoVision Core Library"
        A1["Camera Module (StereoVision/Camera.py)"]:::internal
        A2["Calibration Module (StereoVision/Calibration.py)"]:::internal
        A3["Disparity Module (StereoVision/Disparity.py)"]:::internal
        A4["PointCloud Module (StereoVision/PointCloud.py)"]:::internal
        A5["GUI/Widget Module (StereoVision/Widget.py)"]:::interface
    end

    A --> A1
    D1 --> A1
    D2 --> A1
    E  --> A1
    A1 --> A2
    A2 --> A3
    A3 --> A4
    A4 --> A5
    A5 --> C

    click A "https://github.com/microy/stereovision/blob/master/stereovision.py"
    click B "https://github.com/microy/stereovision/blob/master/setup.py"
    click A1 "https://github.com/microy/stereovision/blob/master/StereoVision/Camera.py"
    click A2 "https://github.com/microy/stereovision/blob/master/StereoVision/Calibration.py"
    click A3 "https://github.com/microy/stereovision/blob/master/StereoVision/Disparity.py"
    click A4 "https://github.com/microy/stereovision/blob/master/StereoVision/PointCloud.py"
    click A5 "https://github.com/microy/stereovision/blob/master/StereoVision/Widget.py"
    click C "https://github.com/microy/stereovision/blob/master/stereovision.desktop"
    click D1 "https://github.com/microy/stereovision/blob/master/disable-autofocus.sh"
    click D2 "https://github.com/microy/stereovision/blob/master/uvcvideo.conf"
    click E "https://github.com/microy/stereovision/blob/master/Trigger/Trigger.ino"

    classDef internal fill:#cce5ff,stroke:#000,stroke-width:2px;
    classDef interface fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef script fill:#f9f9a3,stroke:#000,stroke-width:2px;
    classDef hardware fill:#ffcccc,stroke:#000,stroke-width:2px;
```
