AI-Driven Traffic Monitoring & Control

A comprehensive, AI-driven traffic monitoring and control solution designed to process multi-directional video feeds and live IP camera streams in real time.

PythonYOLOv8OpenCVNumPyFastAPIWebSocketsReact.jsViteTailwind CSS
AI-Driven Traffic Monitoring & Control main view

Project Overview

Developed a comprehensive, AI-driven traffic monitoring and control solution designed to process both pre-recorded multi-directional video feeds and live IP camera streams at 4-way intersections in real time. The core of the system dynamically calculates vehicle density across all lanes to intelligently control traffic signal switching, significantly reducing city congestion. The backend simultaneously monitors for critical incidents, broadcasting live updates to an interactive, React-based web dashboard via WebSockets.

Technical Challenges & Solutions

Dynamic Signal Synchronization

Ensuring the traffic light controller seamlessly adapted to suddenly spiking vehicle densities required a highly optimized control loop that weighed density inputs from 4 concurrent high-definition video feeds.

False Positives in Accident Detection

Implemented a centroid distance check combined with bounding box overlap thresholds, ensuring accidents are only triggered on true physical intersections.

Ambulance 'Flickering'

Re-engineered detection to use temporal smoothing, requiring the siren heuristics to be consistently present over multiple frames before committing to an incident alert.

Key Features

  • Live IP Camera & WebCam Integration Ingests and processes RTSP/HTTP streams from live IP cameras directly.
  • AI-Based Signal Decongestion Dynamically adjusts traffic light switching and green-light duration times based on real-time vehicle density.
  • Real-Time Vehicle Tracking & Counting Uses YOLOv8 and OpenCV to accurately detect, track, and count vehicles across multiple lanes.
  • Emergency Vehicle Detection Custom heuristics using spatial color detection to identify ambulances and trigger lane-clearing protocols.
  • Accident Detection Centroid-distance and overlapping bounding-box formula to detect potential vehicle collisions.
  • Crowd & Illegal Parking Detection Flags when pedestrians gather or vehicles stop in restricted zones.
  • Live Interactive Dashboard Highly responsive React frontend featuring a City Map, Lane Analytics, Congestion Heatmaps, and interactive traffic simulation.
  • WebSocket Event Streaming FastAPI backend continuously streams traffic state updates and critical incident alerts.