TraViol

Automatic traffic-violation detection from one roadside camera. Electronics in Service to Society project, VJTI Mumbai, 2018.

India sees at least 22 traffic violations a minute and one road death every four minutes (figures from our 2018 presentation), yet enforcement still depends on an officer being there. TraViol watches a fixed traffic camera, finds each moving vehicle, measures its speed, checks whether it jumps the red light, and for every violation saves the evidence, locates the licence plate, reads it and sends it to the cloud. It uses classical computer vision only, so it needs no training data and runs on modest hardware.

88.4 km/h car measured and flagged for overspeeding on our 2018 test clip
±0.1 km/h error recovering a known speed on a synthetic clip, after the 2026 Python 3 rebuild
5 stages detect, measure speed, check red light, find the plate, notify the police

Build the bird's-eye view

The camera sees the road at an angle, so a metre near the camera covers more pixels than a metre far away. Drag the four yellow corners onto a stretch of road that is rectangular in reality; the right panel shows the road from directly above, where distances are even and the stop line is a straight row. Move the stop line and watch it map back into the camera's perspective.

Frame from our 2018 test clip. Corners start where our 2018 script put them.
Bird's-eye view

A vehicle whose front crosses this row while the signal is red is flagged.

Run the speed trap

ORB feature matching finds the same corners on the car in two frames and measures how far they moved. Set the measurement and calibration to see what the system decides.

Time between frames
–
Distance travelled
–
Speed
–

How the pipeline works

  1. Find moving vehicles. A Mixture-of-Gaussians model learns what the empty road looks like at every pixel, so anything moving stands out. Erosion and dilation clean the mask, and each large blob becomes a vehicle box.
  2. Measure speed. ORB finds distinctive corners on the car in two frames n apart and matches them. The median shift, in metres, divided by n / fps is the speed.
  3. Check the red light. A perspective transform gives the bird’s-eye view above; a vehicle whose front crosses the stop line on red is flagged.
  4. Find and read the plate. Sobel edges, Otsu’s threshold and a wide closing kernel merge each plate into a blob, filtered by shape and edge density. Tesseract OCR reads the crop.
  5. Notify. The frame and plate are uploaded to Dropbox for the traffic police.

Results

  • 2018: on our test clip, the system measured a car at 88.4 km/h and flagged it for overspeeding.
  • 2026 rebuild: on a synthetic clip with a known speed, the pipeline recovered 58.3 km/h and 38.9 km/h exactly, flagged red-light crossings only while the signal was red, and located the plate on the real frame as the only candidate.
  • Honest limit: the plate in our footage is only 13 pixels tall, too small for OCR to read; reading needs closer or higher-resolution video.

Details

  • Team: Dipti Kulkarni, Aditi Sharma and Ruhi Dongre, Electronics in Service to Society project, Veermata Jijabai Technological Institute (VJTI), Mumbai, 2018.
  • Built with: Python, OpenCV (Mixture of Gaussians, ORB, perspective transforms, morphology), Tesseract OCR, the Dropbox API. Rebuilt in 2026 as a Python 3 package with tests; this page recreates the bird’s-eye and speed steps in JavaScript.
  • Code: github.com/cyberdrk/TraViol, with the original 2018 scripts, the Python 3 pipeline, tests and a full write-up.
  • Next steps: detect the signal colour from the camera, track vehicles in dense traffic, and add zebra-crossing obstruction, the third violation in our presentation.