# chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university architecture

> Architecture diagram of the GitHub repository chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university
- Repository: https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university

## Overview

This repository implements single-camera crowd-movement classification. Its main workflow reads a video, detects pedestrians, converts detections into positions, and classifies 10-second segments from spatial-dispersion slopes. Separate scripts evaluate predictions, visualize results, and train an auxiliary Random Forest from segment statistics. The graph follows calls visible in sampled source and capabilities described in the README; unsampled data wiring is omitted where it cannot be verified.

Main entry points: [`main.py`](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/main.py) (Pipeline runner), [`detector.py`](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/detector.py) (Person detector), [`utils.py`](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/utils.py) (Position loader), [`heuristics.py`](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/heuristics.py) (Segment classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Classification Pipeline"]
  node_runner["Pipeline runner<br/>[main.py]"]
  node_video_reader["Frame reader<br/>[utils.py]"]
  node_person_detector["Person detector<br/>[detector.py]"]
  node_bbox_csv["Detection CSV"]
  node_position_loader["Position loader<br/>[utils.py]"]
  node_slope_classifier["Segment classifier<br/>[heuristics.py]"]
  node_segment_results["Segment results"]
end

subgraph group_learning["ML Extension"]
  node_segment_reader["Feature data reader<br/>[random_forest.py]"]
  node_random_forest["Random Forest<br/>[random_forest.py]"]
  node_rf_model["Saved model"]
end

subgraph group_evaluation["Evaluation and Reports"]
  node_accuracy["Accuracy evaluator"]
  node_report_plotter["Report plotter<br/>[plot.py]"]
end

node_operator(("Video and labels"))
node_yolo["YOLOv8"]

node_operator -->|"starts with"| node_runner
node_runner -->|"reads frames"| node_video_reader
node_runner -->|"requests boxes"| node_person_detector
node_person_detector -.->|"runs inference"| node_yolo
node_runner -->|"saves boxes"| node_bbox_csv
node_runner -->|"loads positions"| node_position_loader
node_position_loader -->|"reads boxes"| node_bbox_csv
node_runner -->|"classifies segments"| node_slope_classifier
node_slope_classifier -->|"writes labels"| node_segment_results
node_segment_reader -->|"provides features"| node_random_forest
node_random_forest -->|"saves model"| node_rf_model
node_accuracy -->|"reads predictions"| node_segment_results
node_report_plotter -->|"reads labels"| node_segment_results

click node_runner "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/main.py"
click node_video_reader "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/utils.py"
click node_person_detector "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/detector.py"
click node_position_loader "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/utils.py"
click node_slope_classifier "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/heuristics.py"
click node_segment_reader "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/random_forest.py"
click node_random_forest "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/random_forest.py"
click node_accuracy "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/compute_accuracy.py"
click node_report_plotter "https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/plot.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runner,node_video_reader,node_person_detector,node_bbox_csv,node_position_loader,node_slope_classifier,node_segment_results toneBlue
class node_segment_reader,node_random_forest,node_rf_model toneAmber
class node_accuracy,node_report_plotter toneMint
class node_operator,node_yolo toneIndigo
```

## Components

### Classification Pipeline

- [Pipeline runner](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/main.py): `main.py`
- [Frame reader](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/utils.py): `utils.py`
- [Person detector](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/detector.py): `detector.py`
- **Detection CSV**
- [Position loader](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/utils.py): `utils.py`
- [Segment classifier](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/heuristics.py): `heuristics.py`
- **Segment results**

### ML Extension

- [Feature data reader](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/random_forest.py): `random_forest.py`
- [Random Forest](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/random_forest.py): `random_forest.py`
- **Saved model**

### Evaluation and Reports

- [Accuracy evaluator](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/compute_accuracy.py): `compute_accuracy.py`
- [Report plotter](https://github.com/chandanay-24/crowd-movement-classification-in-single-camera-system_msc_calcutta-university/blob/main/plot.py): `plot.py`

### Other components

- **Video and labels**
- **YOLOv8**

## Connections

- Video and labels → Pipeline runner: starts with (evidence: `README.md`)
- Pipeline runner → Frame reader: reads frames (evidence: `main.py`)
- Pipeline runner → Person detector: requests boxes (evidence: `main.py`)
- Person detector → YOLOv8: runs inference
- Pipeline runner → Detection CSV: saves boxes (evidence: `main.py`)
- Pipeline runner → Position loader: loads positions (evidence: `main.py`)
- Position loader → Detection CSV: reads boxes
- Pipeline runner → Segment classifier: classifies segments (evidence: `main.py`)
- Segment classifier → Segment results: writes labels (evidence: `heuristics.py`)
- Feature data reader → Random Forest: provides features (evidence: `random_forest.py`)
- Random Forest → Saved model: saves model (evidence: `random_forest.py`)
- Accuracy evaluator → Segment results: reads predictions (evidence: `compute_accuracy.py`)
- Report plotter → Segment results: reads labels (evidence: `plot.py`)
