An intelligent, end-to-end computer vision web application to detect and analyze traffic violations.
Traffic Violation AI is a comprehensive AI-powered application designed to automate the detection, classification, documentation, and reporting of traffic violations from surveillance footage. Designed for high accuracy, scalability, and robustness in real-world conditions, it identifies common infractions and creates actionable evidence records automatically.
- Massive Image Volume: Thousands of images per camera daily make manual review impossible.
- Delayed Enforcement: Violations discovered hours or days later.
- Human Errors: Missed violations, fatigue-related mistakes, and inconsistent judgments.
- Difficult Conditions: Reduced accuracy due to rain, nighttime environments, and motion blur.
- Missing Plates: Vehicle identification challenges when number plates are unreadable.
- Road Safety Impact: Reduces accident risks and improves compliance with traffic laws.
- Administrative Efficiency: Drastically lowers manpower costs and evidence management burden.
- Automated Evidence Generation: Captures violation frames, annotates bounding boxes, and securely logs timestamps/vehicle details.
- Dashboard Analytics: Aggregates statistics, visualizes violation trends over time, and provides searchable records for authorities.
To handle extreme weather, motion blur, and low-light scenarios, we apply a robust preprocessing pipeline before running inference:
- Normalization: Images resized to 640x640 and normalized for consistent YOLO inference.
- Low Light & Shadow Fix: Gamma Correction and CLAHE (Contrast Limited Adaptive Histogram Equalization) applied to restore visibility.
- Weather & Blur Reduction: Bilateral filtering reduces rain/sensor noise, followed by Unsharp Masking to correct motion blur.
How it works: Analyzes motorcycle riders to verify helmet usage. Identifies motorcycles, isolates riders, and uses a specialized model to detect unhelmeted heads. Examples:
How it works: Enforces capacity limits on two-wheelers by counting the number of riders overlapping with the motorcycle's bounding box. Exceeding two passengers flags a violation. Examples:
How it works: Scans the windshield area of detected cars to monitor driver compliance. Identifies if the driver is fastened with a seatbelt and flags mobile phone usage while driving. Example:
How it works: Once a violation is confirmed, the system extracts the license plate crop, applying preprocessing (grayscale, adaptive thresholding) before running an OCR engine (PaddleOCR/EasyOCR) to accurately extract alphanumeric text. A minimal crop is saved for evidence. Examples:
- Stop-line Crossing: Automatically captures frames and generates evidence when vehicles cross designated stop-lines at signals.
- No-Parking Detection: Identifies stationary vehicles in restricted zones, tracks their parking duration, and logs illegal parking evidence automatically. Examples:
How it works: Identifying a vehicle without a visible number plate is a significant challenge. Our solution leverages visual embeddings and Facebook's similarity search algorithm (FAISS) to instantly find similar vehicles across millions of images, reducing manual investigation efforts.
The application features a comprehensive dashboard for traffic authorities:
- Violation frequency statistics.
- Heatmap-based traffic risk assessment and trends over time.
- Searchable violation records categorized by violation type.
The models are evaluated on metrics like Accuracy, Precision, Recall, F1-Score, and mAP.
Future Developments:
- Cloud-based tamper-proof evidence management.
- Real-time city-wide deployment on edge devices.
- Automated challan (ticket) generation.
- Fine-tuning YOLO models on larger, localized, real-world challan image datasets.
- Python 3.10+
- Node.js 18+ & npm
- FFmpeg (Required for video frame extraction)
git clone https://github.com/akashch1512/Traffic-Violations-Using-Computer-Vision.git
cd Traffic-Violations-Using-Computer-Visioncd backend
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Note: API health check available at
http://localhost:8000/. Interactive docs athttp://localhost:8000/docs.
cd frontend
npm install
npm run dev -- --port 5173Access the web application at http://localhost:5173/.
- Open the frontend URL in your browser.
- Upload a sample
.mp4traffic clip. - Click Analyze video to extract frames, run YOLO/OCR, and generate violation evidence.
- Maintainer: Abhay Kale & Akash Chaudhari
- Contributing: We love pull requests! Please open an issue to discuss proposed changes before submitting a PR.
- Issues: Check the GitHub Issues tab.
- Documentation: Visit the Swagger UI at
http://localhost:8000/docswhile the server is running.
Built with ❤️ for safer roads.












