# dyfcalid/cameracalibration architecture

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

- Interactive diagram: https://gitdiagram.com/dyfcalid/cameracalibration
- Repository: https://github.com/dyfcalid/cameracalibration

## Overview

##### Main Components

a) Core Modules (represented as large rectangular blocks):
- Intrinsic Calibration Module
- Extrinsic Calibration Module
- Surround Bird's Eye View Module
- Tools Module

- Camera/Video/Image Input Sources
- Calibration Parameters Storage (.npy files)
- Output Images/Video

##### Specific Module Details

For each core module, create sub-components showing:

IntrinsicCalibration:
- Input Handler (camera/video/image)
- Calibrator Engine (InCalibrator class)
- Calibration Modes Manager (CalibMode class)
- Parameter Storage (K, D matrices)

ExtrinsicCalibration:
- Image Pair Processor
- Homography Calculator (ExCalibrator class)
- Transformation Engine
- Parameter Storage (H matrices)

SurroundBirdEyeView:
- Multi-Camera Input Handler
- BEV Generator Engine
- Image Blending Module
- Balance Processor (brightness/white balance)
- Parameter Loader (K, D, H matrices)

Tools:
- Data Collection Utility
- Undistortion Processor
- H Matrix Decomposer
- Time Alignment Tool
- Image-to-Video Converter

##### Connection and Data Flow

- Raw image flow from input sources
- Parameter flow between modules
- Processing pipeline direction
- Output generation paths

##### Additional Elements

Include:
- Version information
- Required dependencies (OpenCV, NumPy)
- Input/Output format specifications
- Processing mode indicators (online/offline)

- Modular architecture allowing independent use of components
- Clear data flow between calibration stages
- Parameter sharing between modules
- Tool integration points
- API accessibility for external use

Keep the abstraction level focused on the main processing components while maintaining enough detail to show the relationship between calibration stages and the final bird's eye view generation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        I1[Camera Feed]
        I2[Video Files]
        I3[Image Files]
    end

    subgraph "Core Processing"
        subgraph IC[Intrinsic Calibration]
            IH[Input Handler]
            CE[Calibrator Engine]
            CM[Calibration Modes]
            PS1[Parameter Storage]:::storage
        end

        subgraph EC[Extrinsic Calibration]
            IPP[Image Pair Processor]
            HC[Homography Calculator]
            TE[Transformation Engine]
            PS2[Parameter Storage]:::storage
        end

        subgraph BEV[Surround Bird's Eye View]
            MCI[Multi-Camera Input]
            BG[BEV Generator]
            IB[Image Blending]
            BP[Balance Processor]
            PL[Parameter Loader]
        end
    end

    subgraph "Tools Suite"
        T1[Data Collection]:::tool
        T2[Undistortion Processor]:::tool
        T3[H Matrix Decomposer]:::tool
        T4[Time Alignment]:::tool
        T5["Image-to-Video"]:::tool
    end

    subgraph "Parameter Storage"
        D1["Front Camera Data"]:::storage
        D2["Back Camera Data"]:::storage
        D3["Left Camera Data"]:::storage
        D4["Right Camera Data"]:::storage
    end

    subgraph Output
        O1[Calibrated Images]
        O2[Bird's Eye View]
        O3[Parameter Files]
    end

    I1 & I2 & I3 --> IH
    IH --> CE
    CE --> CM
    CM --> PS1
    PS1 --> IPP
    IPP --> HC
    HC --> TE
    TE --> PS2
    PS2 --> PL
    MCI --> BG
    BG --> IB
    IB --> BP
    PL --> BG
    BP --> O2
    PS1 & PS2 --> O3
    PS1 & PS2 --> D1 & D2 & D3 & D4

    classDef storage fill:#FFE5CC,stroke:#FF9933
    classDef tool fill:#E6E6E6,stroke:#666666
    classDef main fill:#CCE5FF,stroke:#3399FF

    %% Click events for component mapping
    click IC "https://github.com/dyfcalid/CameraCalibration/blob/master/IntrinsicCalibration/intrinsicCalib.py"
    click EC "https://github.com/dyfcalid/CameraCalibration/blob/master/ExtrinsicCalibration/extrinsicCalib.py"
    click BEV "https://github.com/dyfcalid/CameraCalibration/blob/master/SurroundBirdEyeView/surroundBEV.py"
    click T1 "https://github.com/dyfcalid/CameraCalibration/blob/master/Tools/collect.py"
    click T2 "https://github.com/dyfcalid/CameraCalibration/blob/master/Tools/undistort.py"
    click T3 "https://github.com/dyfcalid/CameraCalibration/blob/master/Tools/decomposeH.py"
    click T4 "https://github.com/dyfcalid/CameraCalibration/blob/master/Tools/timeAlign.py"
    click T5 "https://github.com/dyfcalid/CameraCalibration/blob/master/Tools/img2vid.py"
    click D1 "https://github.com/dyfcalid/CameraCalibration/tree/master/SurroundBirdEyeView/data/front/"
    click D2 "https://github.com/dyfcalid/CameraCalibration/tree/master/SurroundBirdEyeView/data/back/"
    click D3 "https://github.com/dyfcalid/CameraCalibration/tree/master/SurroundBirdEyeView/data/left/"
    click D4 "https://github.com/dyfcalid/CameraCalibration/tree/master/SurroundBirdEyeView/data/right/"
```
