# that-coding-kid/bhedchaal architecture

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

- Interactive diagram: https://gitdiagram.com/that-coding-kid/bhedchaal
- Repository: https://github.com/that-coding-kid/bhedchaal

## Overview

##### Project type and purpose
- This is a video‐analytics and crowd‐simulation pipeline written in Python.
- It ingests raw video, preprocesses frames, runs person/object detection, estimates crowd density, flags anomalies, simulates panic scenarios, enhances those simulations, and finally visualizes and writes out annotated/enhanced videos.

##### File structure
- All Python modules live at the root—no separate “src” or “lib” folder, but each .py is a logical stage in the pipeline.
- Key directories:
- video_data/ – raw video metadata for areas, densities, objects, perspectives
- output_videos_*.mp4 – final rendered videos
- Configuration/artifacts:
- best_re_final.pt, weights.pth – pretrained PyTorch models
- main.py – orchestrator that ties all stages together

##### README
- Minimal README (“# BhedChaal”) but file names and directory structure reveal the pipeline’s flow and purposes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    subgraph "Input Layer"
        RawVideo[/14.mp4/]:::input
        DataBB[(bounding_box_data/)]:::metadata
        DataVideo[(video_data/)]:::metadata
        Weights[/weights.pth/]:::input
        BestRe[/best_re_final.pt/]:::input
    end

    %% Preprocessing
    subgraph "Preprocessing"
        VideoPreprocessor["Video Preprocessor"]:::processing
    end

    %% Analysis
    subgraph "Detection & Analysis"
        PersonDetection["Person/Object Detector"]:::processing
        DensityEstimation["Density Estimator"]:::processing
        AnomalyDetection["Anomaly Detector"]:::processing
    end

    %% Simulation
    subgraph "Simulation"
        PanicSimulation["Panic Simulator"]:::simulation
        SimulationEnhancement["Simulation Enhancer"]:::simulation
    end

    %% Visualization & Output
    subgraph "Visualization & Output"
        Visualization["Visualizer"]:::visualization
        Output1[/output_videos_14_enhanced_density.mp4/]:::visualization
        Output2[/output_videos_14_enhanced_original.mp4/]:::visualization
        Output3[/output_videos_14_enhanced_top_view.mp4/]:::visualization
    end

    %% Orchestrator
    Main["Orchestrator (main.py)"]:::orchestrator

    %% Data Flow
    RawVideo --> VideoPreprocessor
    VideoPreprocessor --> PersonDetection
    PersonDetection --> DensityEstimation
    DensityEstimation --> AnomalyDetection
    AnomalyDetection --> PanicSimulation
    PanicSimulation --> SimulationEnhancement
    SimulationEnhancement --> Visualization
    Visualization --> Output1
    Visualization --> Output2
    Visualization --> Output3

    %% Metadata & Models
    DataBB -.-> DensityEstimation
    DataVideo -.-> DensityEstimation
    DataBB -.-> Visualization
    DataVideo -.-> Visualization
    Weights -.-> PersonDetection
    BestRe -.-> SimulationEnhancement

    %% Orchestration
    Main --> VideoPreprocessor
    Main --> PersonDetection
    Main --> DensityEstimation
    Main --> AnomalyDetection
    Main --> PanicSimulation
    Main --> SimulationEnhancement
    Main --> Visualization

    %% Click Events
    click RawVideo "https://github.com/that-coding-kid/bhedchaal/blob/main/14.mp4"
    click DataBB "https://github.com/that-coding-kid/bhedchaal/tree/main/bounding_box_data/"
    click DataVideo "https://github.com/that-coding-kid/bhedchaal/tree/main/video_data/"
    click VideoPreprocessor "https://github.com/that-coding-kid/bhedchaal/blob/main/video_preprocessor.py"
    click PersonDetection "https://github.com/that-coding-kid/bhedchaal/blob/main/person_detection.py"
    click DensityEstimation "https://github.com/that-coding-kid/bhedchaal/blob/main/density_estimation.py"
    click AnomalyDetection "https://github.com/that-coding-kid/bhedchaal/blob/main/anomaly_detection.py"
    click PanicSimulation "https://github.com/that-coding-kid/bhedchaal/blob/main/panic_simulation.py"
    click SimulationEnhancement "https://github.com/that-coding-kid/bhedchaal/blob/main/simulation_enhancement.py"
    click Visualization "https://github.com/that-coding-kid/bhedchaal/blob/main/visualization.py"
    click Main "https://github.com/that-coding-kid/bhedchaal/blob/main/main.py"
    click Weights "https://github.com/that-coding-kid/bhedchaal/blob/main/weights.pth"
    click BestRe "https://github.com/that-coding-kid/bhedchaal/blob/main/best_re_final.pt"
    click Output1 "https://github.com/that-coding-kid/bhedchaal/blob/main/output_videos_14_enhanced_density.mp4"
    click Output2 "https://github.com/that-coding-kid/bhedchaal/blob/main/output_videos_14_enhanced_original.mp4"
    click Output3 "https://github.com/that-coding-kid/bhedchaal/blob/main/output_videos_14_enhanced_top_view.mp4"

    %% Styles
    classDef input fill:#a6e22e,stroke:#000,color:#000
    classDef metadata fill:#a6e22e,stroke:#000,color:#000
    classDef processing fill:#66d9ef,stroke:#000,color:#000
    classDef simulation fill:#e6db74,stroke:#000,color:#000
    classDef visualization fill:#fd971f,stroke:#000,color:#000
    classDef orchestrator fill:#f92672,stroke:#000,color:#fff
```
