AI Traffic Management System
- Role
- Computer Vision / Backend Project
- Timeline
- Prototype
- Status
- Completed - prototype
- Category
- Computer Vision / AI
A real-time traffic-management prototype that uses computer vision to detect traffic density and emergency vehicles, calculate lane priority, and simulate adaptive signal timing.
This system replaces fixed-timer traffic signals with a computer-vision pipeline that inspects each lane, counts vehicles, detects emergency vehicles, and calculates which lane gets the green light and for how long. It is a prototype demonstrating adaptive signal control logic, not a system deployed in any live municipal network.
The problem
Fixed-cycle traffic signals cannot respond to real-time conditions - a single vehicle waiting while three queued lanes sit red, or an ambulance blocked behind a normal green cycle. This prototype demonstrates how vehicle detection and priority logic can make signal timing reactive rather than predetermined.
Approach
Lane input
Up to three lanes can be analysed simultaneously. Each lane accepts an uploaded image or video file (.jpg, .jpeg, .png, .mp4). The system processes them through the detection pipeline on submission.
Vehicle detection
YOLOv8 nano (yolov8n.pt via Ultralytics) runs on each frame, detecting and counting cars, trucks, buses, motorcycles, and bicycles per lane.
Emergency detection
Each frame is also sent to a specialised emergency vehicle model hosted on the Roboflow Inference API. The model identifies ambulances, fire trucks, and police vehicles with a confidence threshold of 40%.
Priority and green-time calculation
Green time is proportional to vehicle count (vehicle_count × 2 seconds), clamped between 10 and 60 seconds. Emergency vehicles in any lane trigger immediate priority for that lane. Without an emergency, the lane with the most vehicles goes first. Accident detection is noted in the repository as reserved for future expansion and is not implemented in the current version.
Simulation interface
A Flask + HTML/JavaScript/Tailwind CSS frontend renders animated traffic lights with a real-time countdown timer. Lights transition green → yellow (last 3 seconds) → red automatically. Each lane has a Force Green manual override button. A decision log records every priority calculation.
Stack
Backend
Computer Vision
Frontend
What it changes
- Vehicle detection and counting across up to three lanes via YOLOv8.
- Emergency vehicle detection (ambulance, fire truck, police) via Roboflow API.
- Congestion-based adaptive green-time calculation (10-60 seconds per lane).
- Emergency priority override logic - immediate green for the affected lane.
- Animated traffic-light simulation with real-time countdown and decision log.
- Manual Force Green override per lane.
This is an academic prototype. It is not deployed in or connected to any live traffic infrastructure. Accident detection is explicitly marked as a future expansion item in the repository and is not present in the current implementation.