Inspiration

Traffic violations contribute significantly to road accidents, while manually monitoring CCTV footage is time-consuming and inefficient. We wanted to build an AI-powered solution that automates traffic surveillance, identifies violations, and simplifies generating evidence and e-challans. This idea led to TRAFIX AI, initially developed for Flipkart Gridlock Hackathon 2.0.

What it does

TRAFIX AI is an intelligent traffic violation detection system that analyzes camera footage and detects six types of violations:

  • Red-light jumping
  • Overspeeding
  • Riding without a helmet
  • Wrong-side driving
  • Improper lane changes
  • Triple riding

It also performs automatic number plate recognition using OCR, captures image evidence for every detected violation, and generates e-challan PDFs automatically.

How we built it

We used YOLOv8 ensemble models for violation detection and PaddleOCR for number plate recognition. The backend is built with FastAPI, with a dedicated CameraWorker thread per camera so each video stream is processed independently.

A thread-pool-based queue handles PDF challan generation using ReportLab. PostgreSQL manages persistent data, while Redis handles caching, with SQLite and in-memory fallbacks for environments where these services are unavailable.

We containerized the backend with Docker Compose alongside PostgreSQL 16 and Redis 7. For quality, we wrote automated tests with pytest, set up GitHub Actions CI, used Ruff for formatting, and added a secret-scanning script.

Challenges we ran into

The biggest challenge was integrating multiple computer vision components into a reliable end-to-end system. Coordinating object detection, number plate recognition, evidence collection, and PDF generation required careful backend architecture. Managing concurrent camera-processing threads and background tasks added further complexity.

Accomplishments that we're proud of

  • Built a complete pipeline from video input to detected violation, number plate, image evidence, and e-challan PDF
  • Covered six different violation types in a single system
  • Made the system resilient with SQLite and in-memory fallbacks when PostgreSQL or Redis are unavailable
  • Reached 28 passing automated tests, with CI, linting, and secret scanning in place

What we learned

We learned how to manage concurrent camera-processing threads, handle background tasks, integrate databases and caching systems, and improve reliability through automated testing and CI/CD. The project strengthened our practical understanding of Python, computer vision, machine learning, FastAPI, multithreading, databases, Docker, and software engineering practices.

What's next for TRAFIX AI

The initial version focused on uploaded video footage. We are now extending TRAFIX AI towards real-time traffic monitoring using live camera feeds. Future improvements include AWS deployment, Terraform-based infrastructure automation, and system monitoring to make the application more scalable and production-ready.

Built With

Share this project:

Updates

Submission history