A real-time Computer Vision system for intelligent traffic monitoring, vehicle detection, tracking, and congestion analysis β built for smart city infrastructure.
Features β’ Demo β’ Installation β’ Usage β’ Architecture β’ Roadmap
Upload your own traffic video and watch the AI detect, track, and count vehicles in real-time.
π Vehicle detected β π’ Unique ID assigned β π Stats updated β π¦ Dashboard live
| Feature | Description | Status |
|---|---|---|
| π― Real-time Detection | YOLOv8 Nano for fast, accurate vehicle detection | β Live |
| π’ Multi-Object Tracking | ByteTrack assigns persistent IDs across frames | β Live |
| π Vehicle Counting | Counts vehicles crossing a virtual tripwire | β Live |
| π Vehicle Classification | Detects cars, trucks, buses, motorcycles | β Live |
| π Live Dashboard | Real-time Streamlit web interface with metrics | β Live |
| π₯ Webcam Support | Works with live webcam feed | β Live |
| β‘ FPS Monitoring | Real-time performance tracking | β Live |
| π Emergency Detection | Ambulance/police vehicle prioritization | π Coming Soon |
| πΊοΈ Heatmap Analysis | Traffic density heatmaps per lane | π Coming Soon |
| βοΈ Cloud Deployment | AWS/Railway deployment ready | π Coming Soon |
π TrafficMonitor/
βββ π app.py # Streamlit web dashboard (Frontend)
βββ π detector.py # YOLOv8 detection engine (Backend)
βββ π requirements.txt # Python dependencies
βββ π README.md # You are here
βββ π₯ traffic.mp4 # Sample test video
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER BROWSER β
β (Streamlit Dashboard) β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββ
β STREAMLIT SERVER β
β (app.py) β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββ
β DETECTION ENGINE β
β (detector.py) β
β β
β ββββββββββββ βββββββββββββ ββββββββββββββ β
β β YOLOv8n ββ β ByteTrack ββ β OpenCV β β
β βDetection β β Tracking β β Annotation β β
β ββββββββββββ βββββββββββββ ββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.9 or higher
- MacOS / Linux / Windows
- 4GB RAM minimum (8GB recommended)
git clone https://github.com/YOUR_USERNAME/Computer-Vision-System-for-Traffic-MonitoringTrafficMonitor.git
cd TrafficMonitorpython3 -m venv traffic_env
source traffic_env/bin/activate # MacOS/Linux
# traffic_env\Scripts\activate # Windowspip install --upgrade pip
pip install -r requirements.txtcurl -L -o traffic.mp4 "https://videos.pexels.com/video-files/5834623/5834623-hd_1920_1080_25fps.mp4"streamlit run app.pyThen open your browser at: http://localhost:8501
python3 detector.py- Upload Video β Upload any MP4 traffic video from the sidebar
- Select Source β Choose between video file or live webcam
- Click Start β Begin real-time AI analysis
- Monitor Stats β Watch live FPS, vehicle counts, and crossing data
YOLOv8 Nano scans each video frame and draws bounding boxes around detected vehicles. It classifies them into:
- π Car
- π Bus
- π Truck
- ποΈ Motorcycle
Each detected vehicle gets a unique persistent ID (#1, #2, #3...). ByteTrack is smart enough to keep the same ID even if a vehicle temporarily disappears behind another object (occlusion).
A virtual line is drawn across the road. Every time a vehicle crosses this line, the IN or OUT counter increments depending on direction of travel.
All data streams live into a professional web dashboard showing:
- Live annotated video feed
- Active vehicle count
- IN / OUT crossing totals
- Real-time FPS
ultralytics==8.1.0 # YOLOv8 object detection
opencv-python==4.9.0 # Video processing
streamlit==1.30.0 # Web dashboard
supervision==0.18.0 # Tracking & annotation utilities
numpy==1.26.0 # Numerical computing
pandas==2.1.0 # Data handling- Real-time vehicle detection
- Multi-object tracking with unique IDs
- Vehicle counting (IN/OUT)
- Live Streamlit dashboard
- Webcam support
- Speed estimation (km/h)
- Lane-specific counting
- Emergency vehicle alerts (ambulance priority)
- Traffic density heatmaps
- Congestion alerts
- REST API endpoints
- Docker containerization
- AWS/Railway deployment
- Indian traffic dataset fine-tuning (rickshaws, autos)
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/SpeedEstimation) - Commit your changes (
git commit -m 'Add speed estimation') - Push to the branch (
git push origin feature/SpeedEstimation) - Open a Pull Request
*Debadri Das
Third-year CS Student | AI/ML Enthusiast
π Kolkata, India
This project is licensed under the MIT License β see the LICENSE file for details.
- Ultralytics YOLOv8 β Object detection model
- Supervision β CV utility library by Roboflow
- Streamlit β Web dashboard framework
- ByteTrack β Multi-object tracking algorithm
β If this project helped you, please give it a star!
Built with β€οΈ for smart city infrastructure and Indian traffic management