# ahmz1833/csl-vision-project architecture

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

- Interactive diagram: https://gitdiagram.com/ahmz1833/csl-vision-project
- Repository: https://github.com/ahmz1833/csl-vision-project

## Overview

##### File Structure
- The file tree is minimal: there is a README.md, a single main.py file, and a pictures directory containing screenshots.

##### Main Components
a. Hardware Components:
- Raspberry Pi Board: the central controller of the system.
- Camera: the image capture device that provides the live video feed.
- LCD Display: the output device that displays processed visual feedback (live image along with calculated areas, debug info, and calibration screens).

b. Software Components (all handled within the main.py codebase):
- Image Acquisition Module: This sub-component interfaces with the camera and can be configured (via constructor parameters) to choose the image source (camera, file, URL).
- UI / Window Management Modules:
- Main Window Module: Displays the live feed with contours and area values.
- Debug Window Module: Shows various filtered images (for debugging, edge detection, and adjustments) and lets users tweak parameters.
- Reference Line Selection Window: Facilitates selection of calibration lines from the captured image.
- User Interaction Module: Manages input events linked to keystrokes (M, D, S, N, Q, R, L, Enter) which control window switching and selection actions.

##### Relationships and Interactions
- The Camera hardware feeds raw images into the Image Acquisition Module.
- The processed images and related information are displayed on the LCD display across the four distinct software windows.
- The user interacts via key presses to switch between windows and adjust processing parameters—the Interaction Module routes these events to the correct processing or UI sub-components.

##### Architectural Patterns and Design Principles
- Separation of concerns: Although implemented in a single entry file, logical separation exists between hardware interfacing, image processing, and UI handling.
- Modular design: Each window (Main, Debug, Reference Area, Reference Line) behaves as an independent module yet integrates seamlessly with the processing pipeline.
- Clear data flow: From image capture through processing to display, with real-time user feedback influencing processing parameters.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Components
    subgraph "Hardware Components"
        RP("Raspberry Pi Board"):::hardware
        Cam("Camera"):::hardware
        LCD("LCD Display"):::hardware
    end

    %% Software Components (main.py)
    subgraph "Software Components (main.py)"
        IA("Image Acquisition Module"):::software
        IP("Image Processing & Analysis Module"):::software
        IU("User Interaction Module"):::software
        subgraph "UI / Window Management Modules"
            MW("Main Window Module"):::ui
            DW("Debug Window Module"):::ui
            RASW("Reference Area Selection Window Module"):::ui
            RLSW("Reference Line Selection Window Module"):::ui
        end
    end

    %% Documentation
    Doc("Screenshots and Visual Documentation"):::doc

    %% Data Flow and Interactions
    RP -->|"powers"| Cam
    Cam -->|"captures"| IA
    IA -->|"sends_data"| IP
    IP -->|"displays"| MW
    IP -->|"displays"| DW
    IP -->|"displays"| RASW
    IP -->|"displays"| RLSW
    MW -->|"outputs"| LCD
    DW -->|"outputs"| LCD
    RASW -->|"outputs"| LCD
    RLSW -->|"outputs"| LCD
    IU -->|"controls"| IP
    IU -->|"logs"| Doc

    %% Click Events
    click IA "https://github.com/ahmz1833/csl-vision-project/blob/main/main.py"
    click IP "https://github.com/ahmz1833/csl-vision-project/blob/main/main.py"
    click MW "https://github.com/ahmz1833/csl-vision-project/blob/main/main.py"
    click DW "https://github.com/ahmz1833/csl-vision-project/blob/main/main.py"
    click RASW "https://github.com/ahmz1833/csl-vision-project/blob/main/main.py"
    click RLSW "https://github.com/ahmz1833/csl-vision-project/blob/main/main.py"
    click IU "https://github.com/ahmz1833/csl-vision-project/blob/main/main.py"
    click Doc "https://github.com/ahmz1833/csl-vision-project/tree/main/pictures"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef software fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef ui fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef doc fill:#FFFF99,stroke:#000,stroke-width:2px;
```
