# hafidh561/multi-camera-people-tracking architecture

> Architecture diagram of the GitHub repository hafidh561/multi-camera-people-tracking, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hafidh561/multi-camera-people-tracking
- Repository: https://github.com/hafidh561/multi-camera-people-tracking

## Overview

##### Project type and purpose
- This is a Python-based computer-vision pipeline for multi-camera people tracking.
- It uses YOLOv4-tiny for object detection, Omni-Scale models for person re-identification, and combines detections across multiple camera feeds to label and track individuals over time.

##### File structure
- Top-level scripts:
- download_model.py – downloads object-detection & re-ID model weights and class files
- object_detection.py – wraps the YOLOv4-tiny inference logic
- feature_extraction.py – wraps the Omni-Scale re-ID model inference
- main.py – entry point that loads config, initializes components, processes video streams, aggregates results, and handles display/save logic
- config.yaml – user-supplied settings (paths, thresholds, camera layout, device selection, output options)
- requirements.txt – Python dependencies
- results/ – sample output GIF and saved videos

##### Key insights from README
- Single entry point with `python3 main.py -s config.yaml`
- Configurable thresholds for detection/re-ID, multi-camera layout, display and save options
- Two major model families: detection (YOLOv4-tiny) and feature extraction (Omni-Scale)

##### Main components and their interactions
a. Components:
1. Configuration Loader
2. Model Downloader
3. Object Detection Engine
4. Feature Extraction / Re-ID Engine
5. Multi-Camera Frame Manager
6. Tracker & Cross-Camera Matcher
7. Visualization & Output Manager
b. Data flow:
- The Config Loader reads config.yaml →
- Downloader (optionally) fetches model files →
- Multi-Camera Frame Manager opens video(s), splits to individual camera streams →
- For each frame:
– Feature Extraction Engine computes person embeddings →
– Tracker / Matcher assigns consistent IDs across frames and cameras →
- Visualization & Output Manager overlays IDs/bboxes, displays live windows and/or writes output video →
c. Architectural patterns:
– Pipeline pattern (modular stages: load, detect, embed, match, display)
– Manager/Worker separation (frame manager vs. detection/extraction workers)
– Config-driven behavior for thresholds, device selection, and I/O paths
d. Key technologies/libraries:
– Python 3.7+
– OpenCV or similar (video I/O and drawing)
– PyTorch / TensorFlow (model inference)
– YOLOv4-tiny weights & class files
– Omni-Scale person re-ID model

## Diagram (Mermaid)

```mermaid
flowchart TD
    Orchestrator["Entry Point / Pipeline Orchestrator"]:::io

    subgraph "Initialization"
        ConfigLoader["Config Loader"]:::io
        ModelDownloader["Model Downloader"]:::engine
        DependencySpec["Dependency Specification"]:::storage
    end

    Orchestrator-->ConfigLoader
    ConfigLoader-->ModelDownloader
    ModelDownloader-->DependencySpec

    subgraph "Runtime Pipeline"
        FrameManager["Multi-Camera Frame Manager"]:::io
        ObjectDetectionEngine["Object Detection Engine"]:::engine
        FeatureExtractionEngine["Feature Extraction / Re-ID Engine"]:::engine
        TrackerMatcher["Tracker & Cross-Camera Matcher"]:::tracker
        VisualizationManager["Visualization & Output Manager"]:::visualization
        SampleOutputs["Sample Outputs (results/)"]:::storage
    end

    ModelDownloader-->FrameManager
    FrameManager-->ObjectDetectionEngine
    ObjectDetectionEngine-->FeatureExtractionEngine
    FeatureExtractionEngine-->TrackerMatcher
    TrackerMatcher-->VisualizationManager
    VisualizationManager-->SampleOutputs

    click Orchestrator "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/main.py"
    click ConfigLoader "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/config.yaml"
    click ModelDownloader "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/download_model.py"
    click FrameManager "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/helpers.py"
    click ObjectDetectionEngine "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/object_detection.py"
    click FeatureExtractionEngine "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/feature_extraction.py"
    click TrackerMatcher "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/helpers.py"
    click VisualizationManager "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/main.py"
    click DependencySpec "https://github.com/hafidh561/multi-camera-people-tracking/blob/main/requirements.txt"
    click SampleOutputs "https://github.com/hafidh561/multi-camera-people-tracking/tree/main/results/"

    classDef io fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef engine fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32;
    classDef tracker fill:#FFF3E0,stroke:#EF6C00,color:#E65100;
    classDef visualization fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C;
    classDef storage fill:#ECEFF1,stroke:#607D8B,color:#37474F;
```
