Urban traffic is unpredictable. Congestion spikes during peak hours, emergency vehicles get stuck, and intersections often operate on outdated static timers.
So, we asked ourselves:
Can AI help manage traffic more intelligently, in real time?
That’s what led to the creation of Traffic-Vision — an AI-powered traffic monitoring and signal optimization system. Using YOLOv8, real-time video analysis, and adaptive traffic control, we built a platform that helps optimize urban mobility, improve road safety, and offer real-time insights.
🧠 The Idea
Most traffic lights today still operate on fixed cycles, regardless of how congested or empty a junction is. That inefficiency inspired a core question:
What if traffic signals could adapt based on live road conditions?
Traffic-Vision was built to answer that — by detecting live congestion, recognizing emergencies, and adjusting traffic flow dynamically.
🔍 Key Features at a Glance
- 🚘 Real-time vehicle & pedestrian detection
- 🚑 Emergency vehicle and accident detection (powered by YOLOv8)
- 🔁 Adaptive signal control based on traffic load
- 🔥 Heatmap-based congestion visualization
- 📩 Telegram alerts for critical events
- 📊 Dashboards for live and historical traffic metrics
🧩 System Architecture: How It Works
At its core, Traffic-Vision processes video streams through a smart computer vision pipeline and wraps that intelligence in a clean, modular interface.
Here’s the typical flow:
Live video feeds are ingested from traffic cameras or footage.
YOLOv8 models detect objects like cars, bikes, Bicycle, Truck, pedestrians, ambulances, firetruck and accidents.- Based on the real-time analysis, the system:
- Adjusts virtual traffic signal logic
- Generates heatmaps
- Sends automated alerts
- Logs all analytics into an SQLite database
- Adjusts virtual traffic signal logic
- A Streamlit dashboard visualizes everything — from congestion zones to emergency events.
🧪 Under the Hood: Tech Stack Breakdown
🤖 Machine Learning
YOLOv8m: For object, emergency vehicle, and accident detection- Multiple detection models tailored for high accuracy & moderate speed
🧱 Backend
PyQt6: Graphical user interface for managing zones and controls
SQLite: Light, file-based DB for storing traffic data
Streamlit: Interactive dashboard for data analytics
💬 Messaging
Telegram Bot API: Sends real-time alerts on crashes or emergencies
🛠️ Step-by-Step Functionality
1. 🎯 Monitoring Zones
- Users draw zones over any video feed: road lanes, sidewalks, intersections.
- These zones help classify traffic density and enable fine-grained analytics.
2. 📦 Inference in Action
Real-time detection overlays show:
- Vehicle/pedestrian counts
- Congestion levels
- Emergency vehicle detections
- Accident alerts
3. 🚦 Adaptive Signal Control
Virtual signals respond to live data:
- Congested zones get longer greens
- Routes are cleared for ambulances or fire trucks
- Accidents trigger instant alerts
4. 📊 Data & Dashboards
- All events are stored with timestamps.
Streamlit dashboards visualize:
- Heatmaps
- Zone-specific metrics
- Incident logs
💻 Hardware & Performance Notes
Though no physical hardware is required, this system processes video at real-time or near real-time speeds, so we recommend:
GPU acceleration: NVIDIA (CUDA ≥ 12.4) or Apple Silicon (M2)
RAM: Minimum 8 GB, ideally 16 GB+
Python: Version 3.9 or newer
🔬 What We Learned
Here are some insights from development:
✅ Spatial context matters: Smart zoning leads to smarter decisions.
✅ Model size vs. speed: YOLOv8m hit the sweet spot in terms of balance.
✅ Visualization is key: Congestion data must be understandable at a glance.
✅ Real-time feedback loops elevate traffic systems from passive to adaptive.
📦 Try It Yourself
Get started with just a few commands:
git clone https://github.com/Wydoinn/Traffic-Vision
cd Traffic-Vision
pip install -r requirements.txt
python app.py
Then launch the dashboard with:
streamlit run visualizer.py
📎 GitHub: github.com/Wydoinn/Traffic-Vision
💬 Feedback or ideas? Drop a comment — I’d love to connect!