Watch the full system analysis:
The demonstration shows real-time vehicle detection, persistent tracking IDs, and automated speed violation detection.
This project implements a computer vision traffic monitoring system capable of detecting and tracking vehicles in real-time road footage.
Using YOLOv8 Nano and OpenCV, the system performs frame-level vehicle detection and tracking while estimating speed based on calibrated distance measurements.
Vehicles exceeding the speed threshold trigger a simulated e-challan event, which is logged automatically.
The traffic monitoring engine is built using a modular pipeline:
Traffic footage is processed frame-by-frame using OpenCV.
YOLOv8 Nano detects vehicles belonging to COCO classes:
- Car
- Motorcycle
- Bus
- Truck
The tracking system assigns persistent IDs to vehicles using YOLO tracking with persist=True.
This ensures each vehicle maintains the same ID across frames.
Vehicle speed is calculated by measuring the frame difference between two predefined lines representing a calibrated real-world distance.
Speed is computed using:
Distance / Time → km/h conversion.
Vehicles exceeding the speed threshold trigger a violation event.
Violations are logged into a structured dataset using Pandas.
• Real-time vehicle detection using YOLOv8 Nano
• Multi-object tracking with persistent IDs
• Speed estimation using calibrated frame geometry
• Automated violation detection logic
• CSV-based analytical reporting
• Memory-safe tracking using stale ID eviction
traffic-surveillance-ai/
├── data/
│ ├── input/ # Source video files for processing
│ └── output/ # Generated e-evidence and reports
├── models/
│ └── yolov8n.pt # Pre-trained YOLOv8 weights
├── src/
│ ├── main.py # Core execution engine
│ └── utils.py # Geometry and speed calculation helpers
├── requirements.txt # Production dependencies
├── .gitignore # Excludes large binaries and caches
└── README.md # Project documentation
- File:
data/output/echallan_evidence.mp4 - Description: A high-definition reconstructed video featuring the YOLOv8 annotation layer, persistent tracking IDs, and real-time speed violation "CHALLAN" HUD overlays.
📁 Project Output 🎥 Produced Evidence Input Video (Raw): data/input/traffic_sample.mp4 ➜ Original unprocessed traffic footage used as input Processed Video (E-Challan Output): data/output/echallan_evidence.mp4 ➜ YOLOv8 annotated video with tracking IDs + speed violation overlays Violation Report (CSV): data/output/violations_report.csv ➜ Structured log of detected speed violations (vehicle ID, speed, timestamp, penalty status)
pip install -r requirements.txt
Run the Engine
python src/main.py