# vinn369/sign-language-detection-system architecture

> Architecture diagram of the GitHub repository vinn369/sign-language-detection-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vinn369/sign-language-detection-system
- Repository: https://github.com/vinn369/sign-language-detection-system

## Overview

##### Project Type and Purpose
- This is a stand-alone computer-vision tool (a single-service Python application) for real-time sign-language gesture detection and classification. It provides two main workflows:
- Data Collection (datacollection.py)
- Real-Time Detection and Classification (test.py)

##### Main Components
a. Input Devices and Data Sources
- Webcam (Video Stream)
b. Preprocessing & Hand-Tracking Pipeline
- OpenCV (cv2) Video Capture
- cvzone Hand-Tracking Module
- Frame preprocessing (cropping, resizing, normalization)
c. Model Inference Layer
- Keras Model (keras_model.h5)
- NumPy for tensor manipulation
d. Postprocessing & Presentation
- Window (cv2.imshow)
e. Data Collection Subsystem
- datacollection.py script
- Local file storage for raw/processed images
f. Model Training (External)
- Retraining workflow (outside of real-time app)
- Dataset directory (generated by datacollection.py)
g. Storage & Configuration
- labels.txt (gesture class definitions)
- keras_model.h5 (model weights)

##### Relationships & Data Flow
1) Webcam → OpenCV Capture → Frame Buffer
2) Frame → cvzone Hand-Tracker → Extracted Hand ROI
3) ROI → Preprocessor (resize, normalize) → NumPy Array
4) Array → Keras Model → Prediction Vector
5) Prediction → labels.txt lookup → Gesture Label
6) Label + ROI → Overlay → Display Window
7) (In Data Collection mode)
- Press ‘s’ → Save processed ROI → Local Dataset Folder
8) (External) Dataset Folder → Model Training Script → keras_model.h5

##### Architectural Patterns & Design Principles
- Pipeline Pattern: clearly separated stages (capture → detect → infer → render).
- Single Responsibility: distinct scripts for data collection vs inference.
- Modularity: interchangeable model file and label set for extensibility.

##### Technologies & Libraries
- Python 3.x
- OpenCV (cv2) for capture and display
- cvzone for robust hand detection
- NumPy for array manipulation
- Keras (TensorFlow backend) for deep learning inference
- File I/O for labels and data storage

##### Detail & Granularity
- Parameters (e.g., input size to model, number of classes).
- Make clear the trigger points (e.g., “press ‘s’ → save image,” “press ‘q’ → exit”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Collection Subsystem
    subgraph "Data Collection Mode"
        DC["datacollection.py"]:::script
        DC -->|"start capture"| DC_Capture
        DC_Capture["Capture (Webcam)"]:::io
        DC_Capture -->|"frame"| DC_Tracker
        DC_Tracker["Hand Tracker (cvzone)"]:::processing
        DC_Tracker -->|"ROI"| DC_Pre
        DC_Pre["Preprocessor"]:::processing
        DC_Pre -->|"save ROI (press 's')"| Dataset
    end

    %% Real-Time Inference Subsystem
    subgraph "Real-Time Inference Mode"
        RT["test.py"]:::script
        RT -->|"start capture"| Capture
        Capture["Capture (Webcam)"]:::io
        Capture -->|"frame"| Tracker
        Tracker["Hand Tracker (cvzone)"]:::processing
        Tracker -->|"ROI"| Pre
        Pre["Preprocessor"]:::processing
        Pre -->|"tensor"| Model
        Model["Model Inference (Keras)"]:::processing
        Model -->|"prediction vector"| Lookup
        Lookup["Label Lookup"]:::processing
        Lookup -->|"label+ROI"| Renderer
        Renderer["Overlay Renderer"]:::processing
        Renderer -->|"frame"| Display
        Display["Display Window (cv2.imshow)"]:::io
    end

    %% Storage Components
    Dataset[(Dataset Folder)]:::storage
    ModelFile[(keras_model.h5)]:::storage
    LabelsFile[(labels.txt)]:::storage
    Readme[(README.md)]:::doc

    %% Data & Configuration Flows
    Dataset -.->|retraining| ModelFile
    ModelFile -.->|load weights| Model
    LabelsFile -.->|load labels| Lookup

    %% External Libraries
    subgraph "Libraries"
        CV2["OpenCV (cv2)"]:::lib
        CVZ["cvzone"]:::lib
        NP["NumPy"]:::lib
        KERAS["Keras"]:::lib
    end

    %% Library Usage Links
    Capture --> CV2
    Display --> CV2
    DC_Tracker --> CVZ
    Tracker --> CVZ
    Pre --> NP
    Model --> KERAS

    %% Click Events
    click DC "https://github.com/vinn369/sign-language-detection-system/blob/main/datacollection.py"
    click RT "https://github.com/vinn369/sign-language-detection-system/blob/main/test.py"
    click ModelFile "https://github.com/vinn369/sign-language-detection-system/blob/main/keras_model.h5"
    click LabelsFile "https://github.com/vinn369/sign-language-detection-system/blob/main/labels.txt"
    click Readme "https://github.com/vinn369/sign-language-detection-system/blob/main/README.md"

    %% Styles
    classDef processing fill:#ADD8E6,stroke:#333;
    classDef io fill:#90EE90,stroke:#333;
    classDef script fill:#FFA500,stroke:#333;
    classDef storage fill:#FFE4B5,stroke:#333;
    classDef lib fill:#D3D3D3,stroke:#333;
    classDef doc fill:#E6E6FA,stroke:#333;
```
