# dash-cop/dashcop architecture

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

- Interactive diagram: https://gitdiagram.com/dash-cop/dashcop
- Repository: https://github.com/dash-cop/dashcop

## Overview

##### Core Project Type and Purpose
- DashCop is designed for automated e-ticket generation for two-wheeler traffic violations using dashcam videos.
- The methodology is divided into four major components (as also outlined in the README):
– SAC Module (Segmentation and Cross-Association)
– Tracking Module (Cross-Association-based Tracking)
– Helmet/No-Helmet Detection Module
– ANPR Module (Automatic Number Plate Recognition)
- Additionally, the repository contains separate directories for “inference” (for running pre-trained models on videos) and “training” (for understanding and training each module).

##### Out the Major Directories and their Roles
- Top-Level Components:
– “inference” directory: Contains code for running the different modules in production on input dashcam videos. It includes pipelines, instance functions, evaluation scripts, tracker modules, and even submodules like “ultralytics” for object detection.
– “training” directory: Contains separate folders (e.g., ANPR, CA-SORT, SAC, HNH) which correspond to training procedures and dataset handling for each module.
– “RideSafe”: Possibly a wrapper or an interface module (check its README) that may integrate results for e-ticket generation.
- Within “training” there are subdirectories that directly map to the four modules (e.g., training/ANPR for number plate recognition, training/HNH for helmet detection, training/SAC for segmentation and cross-association, and training/CA-SORT for tracking).

##### Main Components
- Input: Dashcam Video Stream
- Preprocessing: Video frame extraction (likely handled by common utilities in both inference and training pipelines)
- SAC Module:
– Segmentation of frames and cross-association to separate regions of interest (e.g., vehicles, riders).
– Highlight “training/SAC” and “inference” pipelines that might trigger SAC-specific processing.
- Tracking Module:
– Uses cross-association-based tracking for linking detections across frames.
– Represent the “inference/tracker” and “training/CA-SORT” modules here.
- Helmet/No-Helmet Detection Module:
– Detection logic to classify helmet usage.
– Components in “inference/evaluation” and training/HNH directories become parts of this module.
- ANPR Module:
– Automatic Number Plate Recognition to capture license plate information.
– Represent “training/ANPR” and the corresponding inference pipeline components.
- Output: Automated E-ticket Generation (possibly integrated via the “RideSafe” directory or a post-processing step)

##### Relationships and Data Flow
- Next, lead into the SAC module where segmentation happens and “association” information is output.
- Feed the segmented output into the Tracking module (which might also share data/cross-association info with the helmet/ANPR modules).
- Parallel flows where—based on the same or later data—the Helmet Detection and ANPR modules run.
- Finally, combine outputs from Tracking, Helmet detection, and ANPR to trigger automatic ticket generation.

##### Architectural Patterns and Technologies
- That the project follows a modular design:
– Each module (SAC, Tracking, Helmet Detection, ANPR) has its own training and inference pipelines.
– There is a clear separation between the training-time components (data preparation, weight training, configuration files in “training”) and the inference-time pipelines (in “inference”).
- Mention key frameworks or libraries:
– “ultralytics” components suggest use of YOLO variants for object detection.
– “fast_reid” directories (found under tracker folders) indicate the use of person/vehicle re-identification frameworks.
– Other deep learning frameworks (implied by PyTorch-related files) and C++ based real-time inference directories (as in FastRT) could be referenced.

## Diagram (Mermaid)

```mermaid
graph TD
    Input["Input: Dashcam Video Stream"]:::input
    Preproc["Preprocessing & Frame Extraction"]:::preproc

    subgraph "SAC Module – Segmentation & CrossAssociation"
        SAC1["Training: SAC"]:::sac
        SAC2["Ultralytics"]:::sac
    end

    subgraph "Tracking Module – CrossAssociation Tracking"
        TRACK_T["Training: CA-SORT"]:::tracking
        TRACK_I["Inference: Tracker"]:::tracking
    end

    subgraph "Helmet/No-Helmet Detection Module"
        HELMET_T["Training: HNH"]:::helmet
        HELMET_I["Inference: Evaluation"]:::helmet
    end

    subgraph "ANPR Module – Automatic Number Plate Recognition"
        ANPR_T["Training: ANPR"]:::anpr
        ANPR_I["Inference: Pipeline"]:::anpr
    end

    Integration["Ticket Generation / RideSafe Integration"]:::integration

    Input --> Preproc
    Preproc --> SAC1
    SAC2 --> TRACK_T
    SAC2 --> HELMET_T
    SAC2 --> ANPR_T
    TRACK_I --> Integration
    HELMET_I --> Integration
    ANPR_I --> Integration

    click SAC1 "https://github.com/dash-cop/dashcop/tree/main/training/SAC"
    click SAC2 "https://github.com/dash-cop/dashcop/tree/main/training/SAC/ultralytics"
    click TRACK_T "https://github.com/dash-cop/dashcop/tree/main/training/CA-SORT"
    click TRACK_I "https://github.com/dash-cop/dashcop/tree/main/inference/tracker"
    click HELMET_T "https://github.com/dash-cop/dashcop/tree/main/training/HNH"
    click HELMET_I "https://github.com/dash-cop/dashcop/tree/main/inference/evaluation"
    click ANPR_T "https://github.com/dash-cop/dashcop/tree/main/training/ANPR"
    click ANPR_I "https://github.com/dash-cop/dashcop/tree/main/inference/pipeline_comp"
    click Integration "https://github.com/dash-cop/dashcop/tree/main/RideSafe"

    classDef input fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef preproc fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef sac fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef tracking fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef helmet fill:#d1ecf1,stroke:#333,stroke-width:2px;
    classDef anpr fill:#e2e3e5,stroke:#333,stroke-width:2px;
    classDef integration fill:#c3e6cb,stroke:#333,stroke-width:2px;
```
