Skip to main content
TrafficGuard AI

TrafficGuard AI

Prince Thakur Projects

An enterprise-grade urban traffic management system combining YOLOv8 Computer Vision, hyper-adaptive signal algorithms, asynchronous WebSockets, and Arduino IoT hardware integration.

Cross-Platform (Linux / Windows / macOS)Open Source Architecturev1.0.0

Preview(2 screenshots)

1 of 2
Command Center & Live Intersection Feeds
Click to enlarge
1 / 2

Command Center & Live Intersection Feeds

Real-time 4-way intersection camera feeds with active signal states, telemetry, and manual emergency override controls.

Computer Vision YOLOv8 Vehicle Analytics
Click to enlarge
2 / 2

Computer Vision YOLOv8 Vehicle Analytics

Real-time vehicle detection with bounding boxes, lane density counters, vehicle classification, and adaptive countdown timers.

Overview

What is TrafficGuard AI?

TrafficGuard AI is a next-generation, hardware-integrated traffic control system engineered to eliminate urban intersection congestion. Rather than relying on traditional fixed-timer signals, TrafficGuard uses real-time Computer Vision (YOLOv8) and a proprietary Weighted Fairness Algorithm to dynamically adjust traffic light timings in real time based on actual vehicular density and wait times.

The system is optimized to run on standard consumer CPUs without requiring expensive GPUs, making it viable for physical lab prototypes, academic exhibitions, and real-world municipal deployment.

Core Architectural Pillars

1. 🧬 Hyper-Adaptive Signal Logic

Our custom-built TrafficController continuously evaluates 4-way intersection dynamics:

  • Dynamic Green Duration: Signal green windows scale dynamically (30s, 60s, 90s) based on vehicle density.
  • Empty-Lane Optimization (Early Switch): If a lane clears out, the vision engine detects it within 1 second and immediately transfers control to the next waiting lane, saving thousands of hours of idling time.
  • Anti-Starvation Priority Scoring: Uses a weighted scoring formula:

$$\text{Priority Score} = (V \times \lambda) + (W / \mu)$$

where $V$ is vehicle count, $W$ is cumulative wait time, $\lambda = 2.5$ is the density multiplier, and $\mu = 8.0$ is the wait-time stabilizer. Even a lane with just 1 car will never be starved indefinitely.

2. 📸 Computer Vision Engine (YOLOv8 & ONNX)

  • Real-Time Edge Detection: Detects and classifies cars, buses, trucks, and motorcycles across all four intersection cameras simultaneously.
  • ONNX Runtime Acceleration: Delivers a 3x inference speedup on standard CPUs, completely eliminating the need for expensive enterprise GPUs.
  • Automatic Camera Discovery: Automatically maps connected USB webcams to North, East, South, and West lanes, with graceful fallback to Intel sample video streams when cameras are disconnected.

3. 🔌 IoT & Physical Hardware Integration

  • Arduino Uno Serial Bridge: Direct bi-directional Serial communication over USB at 115200 baud.
  • 12-Channel Signal Array: Controls physical 12-lamp traffic signal arrays (Red, Yellow, Green for North, East, South, West).
  • Physical Relay Support: Ready for benchtop breadboard prototypes or 12V/220V industrial relay setups.

4. ⚡ Modern Command Center Dashboard

  • Built with Next.js 14 (App Router), TailwindCSS, and Zustand reactive store.
  • Sub-50ms WebSocket Streaming: Asynchronous broadcasting from Python FastAPI backend pushes live vehicle counts, active signal states, and countdown timers to connected browser clients with zero lag.
  • Simulation Mode: Includes a virtual vehicle generator ("SIM ON") enabling complete live testing and exhibition demonstrations without needing physical camera feeds.
  • Manual Emergency Override: Instant single-click manual override to force GREEN on any lane for emergency vehicle priority.

Technical Stack

  • Computer Vision & AI: Ultralytics YOLOv8, ONNX Runtime, OpenCV
  • Backend & Logic: Python 3.10+, FastAPI, Uvicorn, Multiprocessing, PySerial
  • Frontend Dashboard: Next.js 14, React, Zustand, TailwindCSS, Lucide Icons
  • Hardware Layer: Arduino C++ (ATmega328P), 12-Pin Digital Array, USB Serial Bridge
  • Launcher: One-click Master Batch Launcher (Launch_Traffic_AI.bat) for synchronized orchestration.

Additional Information

Published by

Prince Thakur

Release Date

Sep 15, 2026

Type / Size

Source Repository

Version

1.0.0

Platform

Cross-Platform (Linux / Windows / macOS)

Architecture

Python 3.10+ • Next.js 14 • Arduino C++

Tags
AIComputer VisionYOLOv8FastAPINext.jsArduinoIoTPythonZustandTraffic Management
Git Repository
https://github.com/prince19112003/Traffic-Guard-Ultra