Hi All,
A little project I have been working on recently, after getting frustrated with the number of vehicles speeding down our road.
Problem Statement:
How to capture the number plate of vehicles that have no regard for the 50 km/hr posted speed in our street.
With no footpaths and people walking their dogs, riding their horses, it won't be long before a serious accident occurs.
What technologies are available:
Radar - Available and not too expensive
Outdoor Security Camera - Found in a box in the garage
ESP32 - Have a few of these laying around
Computer for processing - Yep can repurpose an old box with linux
I looked at different technologies for speed detection.
1) Camera and then map a known distance on the road and then use opencv to calculate the distance travelled by a vehicle over a certain time.
* Not very reliable due to dropped frames from network camera and sun glare etc.
2) Vehicle crossing two points (detectors) and then calculating the time to travel etc.
* Only have access to my side of the road, nowhere to put reflectors in etc.
3) Radar 24Ghz - LD2451 from HLK
*Not too expensive
*Small
*Easy enough to setup and read with ESP32
*Pretty accurate (some claim 1km/hr error rate if setup parallel to road surface.
LD2451 Module
Easy to get hold of 'Aliexpress'
Outputs serial data
Lots of options to 'tweak' the output (angle, min speed, sensitivity)
Legal to use as low power
The LD2451 module is connected to an esp32 via the second serial input.
The ESP32 takes the data stream from the ld2451 module, and converts it to 'something useful'. Decodes the packets and outputs
Speed - Distance - Angle - SNR
The ESP32 then sends this via a webhook to the linux machine
On the linux machine I have a webhook listener
The webhook listener is also capturing a continual 5 second camera buffer. Camera is mounted on fence looking up the road.
When the webhook listener gets speed information from the esp32 it buffers this also, waiting for the packet transmission to end and then does the following...
Looks at the speeds received
Balances them and gives them a weight according to the SNR. Better SNR then a higher rating value.
Takes the values, then as the sensor is not completely parallel to the road, I apply an offset using some formulas to come up with the best speed.
It then takes the video capture, and saves it as an mp4 of the event.
I then have another script that takes the video, looks through it and using opencv decides on the best frame to capture a still image. It then uses Yolo to extract the numberplate.
The numberplate is then OCR matched on the machine using Panda OCR
The script will output an image with the date/time - Estimated Speed and the Numberplate.
It also outputs all data to a CSV file as well.
Accuracy:
Having driven the road in two different vehicles and using Ways on phone and doing 30 and 50, both times and both directions the accuracy was within 2 km/hr.
It is never going to be exact speed, but gives a good indication of how the road is being 'used' .