AhmedSouley01/traffic-monitoring
π¦ Traffic Monitoring System
<div align="center"> ...
Real-time road traffic object detection, tracking and counting system
Developed as part of the Computer Vision course β AIMS Senegal β April 2026
Demo β’ Installation β’ Usage β’ Structure β’ Results
</div>
π Table of Contents
- Description
- Features
- Demo
- Architecture
- Installation
- Usage
- Project Structure
- Model
- Detected Classes
- Log Format
- Results
- Authors
- License
π Description
This project implements a computer vision system dedicated to real-time road traffic monitoring. It is capable of:
- Detecting vehicles and pedestrians in traffic videos
- Tracking each object uniquely using ByteTrack
- Counting the number of unique objects passing through the scene
- Visualizing results via an interactive web interface
- Analyzing data through a statistical dashboard
This system fits into a Senegalese national context where transport authorities are looking for reliable and automated methods to understand how traffic evolves across different regions and times of day.
β¨ Features
- β Real-time detection with fine-tuned YOLOv11
- β Persistent tracking with ByteTrack (unique ID per object)
- β Unique object counting (not just per-frame counting)
- β Support for local video upload and online URL
- β Class selection directly from the interface
- β Color-coded bounding boxes per class with ID and confidence score
- β Visual alert when no object is detected in the scene
- β Automatic logs in CSV and JSON format
- β Interactive dashboard with charts and statistics
- β CSV export of filtered detection data
- β Frame-by-frame processing with timestamps
π¬ Demo
πΈ Screenshots available in the `results/images/` folder
ποΈ Architecture
Video (local or URL)
β
βΌ
βββββββββββββββββ
β Pre-processingβ OpenCV β frame-by-frame reading
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
β Detection β YOLOv11 β object detection
β (YOLOv11) β conf=0.3, iou=0.45
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
β Tracking β ByteTrack β unique and persistent
β (ByteTrack) β ID per object across frames
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
β Counting β ObjectCounter β unique object
β β counting per class
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
β Logging β CSV + JSON β timestamps,
β β classes, bbox, track IDs
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
β Web Interfaceβ Flask β annotated video stream
β β + statistical dashboard
ββββββββββββββββββοΈ Installation
Prerequisites
- Python 3.10+
- pip
- GPU recommended (CUDA 11.8+) β also works on CPU
Steps
1. Clone the repository
git clone https://github.com/your-username/traffic-monitoring-project.git
cd traffic-monitoring-project2. Create a virtual environment
python -m venv venv
# Linux / macOS
source venv/bin/activate
# Windows
venv\Scripts\activate3. Install dependencies
pip install -r requirements.txt4. Place the trained model
# Copy your fine-tuned model to:
models/traffic_yolo11_best.ptIf you do not have a fine-tuned model, the pre-trained YOLOv11 model will be downloaded automatically.
5. Launch the application
python app.py6. Open in your browser
http://127.0.0.1:5000
http://192.168.1.41:5000π Usage
Via the web interface
- Open
http://192.168.1.41:5000 - Choose a video source:
- Upload: select a
.mp4,.avi, or.movfile - URL: paste a link to an online video
- Select the classes to detect
- Enter a scene identifier (e.g.
dakar_intersection) - Click βΆ Start Detection
- View real-time results at
/live - Click βΉ Stop to save the logs
- Open the Dashboard for analysis
Available arguments
π Project Structure
traffic-monitoring-project/
β
βββ π data/
β βββ raw_videos/ # Original raw videos
β βββ processed_videos/ # Annotated output videos
β βββ annotations/ # Annotations for fine-tuning
β βββ schema.json # Shared log schema
β
βββ π models/
β βββ traffic_yolo11_best.pt # Fine-tuned model
β
βββ π src/
β βββ detector.py # YOLOv11 detection
β βββ tracker.py # ByteTrack tracking
β βββ counter.py # Unique object counting
β βββ logger.py # Log generation
β
β βββ templates/
β β βββ base.html
β β βββ index.html # Home page
β β βββ live.html # Real-time detection
β β βββ dashboard.html # Statistics
β βββ static/
β βββ css/style.css
β βββ js/main.js
β
βββ π app.py # Flask application
βββ π requirements.txt # Python dependencies
βββ π README.md # This file
βββ π LICENSE # MIT License
βββ π report.pdf # Final reportπ€ Model
YOLOv11 β Fine-tuning
Performance Metrics
Metrics will be updated after final training.
π― Detected Classes
π Log Format
CSV (logs/detections_*.csv)
scene_id, frame, timestamp, track_id, class, confidence, x1, y1, x2, y2
scene_01, 142, 00:04.73, 7, car, 0.912, 120,340,280,420JSON (logs/tracking_*.json)
{
"scene_id": "scene_01",
"frame": 142,
"timestamp": "00:04.73",
"detections": [
{
"track_id": 7,
"class": "car",
"confidence": 0.912,
"bbox": [120, 340, 280, 420]
}
]
}π Results
Analyzed Scenes
Results will be filled in after testing on the selected videos.
π οΈ Dependencies
flask>=3.0.0
ultralytics>=8.3.0
opencv-python>=4.8.0
numpy>=1.24.0
werkzeug>=3.0.0
PyYAML>=6.0π₯ Authors
Supervisor: Jordan F. Masakuna β AIMS Senegal
π License
This project is licensed under the MIT License. See the LICENSE file for details.
MIT License β Copyright (c) 2026 β AIMS Senegalπ Acknowledgements
- Ultralytics for YOLOv11
- Kaggle for the datasets
- Pexels for the traffic videos
- AIMS Senegal for supervision and support
<div align="center"> <i>Built with β€οΈ at AIMS Senegal β Computer Vision 2026</i> </div>
