Overview
Real-time computer vision system detecting traffic violations including red-light running, speeding, and helmet violations using YOLOv8 and custom tracking algorithms.
The Problem
Manual traffic monitoring is inefficient, costly, and prone to human error. Cities need automated systems to enforce traffic rules, reduce accidents, and improve road safety at scale.
The Solution
Developed an end-to-end traffic violation detection system using YOLOv8 for vehicle detection, DeepSORT for tracking, and custom rule engines for violation classification. The system processes multiple camera feeds simultaneously and generates automated alerts with evidence (video clips, timestamps, license plates).
Project Gallery
Technical Architecture
Multi-stream video processing pipeline with real-time violation detection
YOLOv8 Detector
Detects vehicles, motorcycles, pedestrians, and traffic signals in real-time
DeepSORT Tracker
Maintains consistent vehicle IDs across frames for trajectory analysis
Violation Classifier
Rule-based engine detecting red-light running, speeding, wrong-way driving
License Plate Recognition
OCR system for automatic number plate extraction
Methodology
- Dataset: Custom dataset of 10K+ annotated traffic images from local intersections
- Fine-tuned YOLOv8-l on traffic-specific classes (cars, bikes, trucks, signals)
- Implemented virtual tripwires for red-light detection
- Speed estimation using perspective transformation and tracking
- Helmet detection for motorcycle riders using separate classifier
Results & Impact
Key Impact
- Deployed at 3 major intersections in pilot program
- Detected 500+ violations in first month
- Reduced manual monitoring costs by 70%
- Improved traffic compliance by 35% at monitored intersections
Challenges & Solutions
Varying Lighting Conditions
Extensive augmentation and adaptive histogram equalization preprocessing
Occlusion Handling
Kalman filter-based prediction for temporarily occluded vehicles
License Plate Recognition
Two-stage approach: detection with YOLO, recognition with CRNN
Key Implementation
Red Light Violation Detection
class RedLightDetector:
def __init__(self, stop_line_coords):
self.stop_line = stop_line_coords
self.violations = {}
def check_violation(self, track_id, bbox, signal_state):
"""
Detect if vehicle crossed stop line during red signal
"""
vehicle_center = self.get_bbox_center(bbox)
# Check if vehicle crossed stop line
if self.crossed_line(vehicle_center, self.stop_line):
if signal_state == 'RED':
if track_id not in self.violations:
self.violations[track_id] = {
'timestamp': time.time(),
'bbox': bbox,
'signal': signal_state
}
return True
return False
def crossed_line(self, point, line):
# Point-line crossing detection
return point[1] > line['y'] # Simplified