How sreeharshit/smart-traffic-management-ai works
Smart Traffic Management AI processes video frames into tracked vehicle detections, traffic decisions and signal state, then presents an annotated live view and analytics through Flask. The main web workflow and detection/rendering calls are visible in app.py; main.py also provides a separate OpenCV desktop runner. Emergency priority and violation detection are handled in the web frame workflow. Some app.py frame-processing calls are in omitted excerpts, so those links are marked unverified rather than asserted as inspected.
Main entry points: app.py Flask service · main.py Desktop runner · detector.py Vehicle detection · traffic_light.py Signal control
Components 17
Traffic Runtime
- Demo videos
videos - Vehicle detection
detector.py - YOLO model
yolov8n.pt - Runtime settings
config.py - Desktop runner
main.py
Web Experience
- Flask service
app.py - Frame dashboard
dashboard.py - Analytics endpoint
app.py - Traffic page
templates/index.html - Live controls
static/script.js - Analytics charts
static/analytics.js
Traffic Policy
- Traffic analysis
traffic_controller.py - Signal control
traffic_light.py - Emergency priority
app.py - Violation detection
app.py
Other components
- Traffic operator
- Browser
Connections 25
- Traffic operator → Browser: views
README.md - Browser → Flask service: requests pages
README.md - Flask service → Traffic page: renders
app.py - Flask service → Demo videos: reads demo
- Flask service → Vehicle detection: detects vehicles
app.py - Vehicle detection → YOLO model: loads model
detector.py - Vehicle detection → Runtime settings: reads settings
detector.py - Traffic analysis → Runtime settings: reads thresholds
traffic_controller.py - Signal control → Runtime settings: reads timing
traffic_light.py - Frame dashboard → Runtime settings: reads display settings
dashboard.py - Flask service → Traffic analysis: analyzes detections
app.py - Flask service → Signal control: updates signal
app.py - Flask service → Emergency priority: checks emergency vehicles
app.py - Emergency priority → Signal control: prioritizes direction
app.py - Flask service → Violation detection: checks crossings
app.py - Flask service → Frame dashboard: draws frame
app.py - Flask service → Analytics endpoint: serves statistics
app.py - Browser → Live controls: uses controls
static/script.js - Live controls → Flask service: switches demo
static/script.js - Browser → Analytics charts: views charts
static/analytics.js - Analytics charts → Analytics endpoint: fetches stats
static/analytics.js - Desktop runner → Vehicle detection: detects vehicles
main.py - Desktop runner → Traffic analysis: analyzes detections
main.py - Desktop runner → Signal control: updates signal
main.py - Desktop runner → Frame dashboard: draws frame
main.py