Friday, April 19, 2024

Vehicle Speed Monitoring Device with High-Speed Imaging Capabilities

ashwiniIt is essential to maintain the speed limit on the roads for safe driving, but most of the time, people ignore it and drive at very high speeds even in speed-restricted areas and road crossings.

To avoid this, the government deploys traffic assistants and officers with doppler radars that can record the speed of vehicles. This equipment enables them to charge fines and take action against people who violate the law.

But deploying the officers with such equipment is quite complicated. It is also a very tiring job for the officers, as speed reading of all the vehicles for 24 hours is not possible.

So we decided to build a vehicle speed detector device with Raspberry Pi.

Here we designed a smart camera with a radar that is automated and will help in maintaining the speed limit and compel people to follow the traffic speed rules. We will integrate the camera with the doppler radar. The radar will continuously take the speed reading.

- Advertisement -

If it detects very high speed, then the camera captures a picture and a video of that instance of time with the label of the time stamp. This will allow the government to automatically charge a fine and take action based on the data received by the camera about the vehicle.

DIY Vehicle Speed Detector Device
DIY Vehicle Speed Detector Device

Bill of Materials

Vehicle Speed Detector Parts
Bill of Material

Programming Vehicle Speed Detector

First write a code for the device to read the radar sensor data and convert the data to speed, and then use the camera to capture the picture and video when high speed is detected.

We need to install the latest version of the Python 3 IDE and then install the OpenCV library to process the video and frames from the camera.

- Advertisement -

Now capture the video and pictures of the high-speed vehicle. To install those modules, open the terminal and then run the following command-

sudo pip3  install opencv

Now write the code.

In the first part of the code, we import the libraries for using the GPIO of the Raspberry Pi to take the doppler radar sensor data.

Then we import the OpenCV library to capture the video and save the video frames and then process them with high-speed detection by doppler radar.

Now we import the time library for calculating the time and speed of the vehicle based on the doppler radar signal.

Next, we will devise the GPIO pin number for the doppler radar signal input. Here you can use any free GPIO. I have used pin number 27.

Further, we need to set the GPIO as input and also set the GPIO pin number as board pin number, as we are using the pin numbering as board pin numbering. 

Raspberry Pi GPIO Configuration
Setting up Vehicle Speed Detector System

Now we will check the signal of the doppler radar and extract the frequency that changes with proportional to the doppler radar wave.

After that, we convert the frequency to the speed. Here, according to the doppler radar datasheet, the wave speed is 31.36, so we divide the frequency of the radar with 31.36 and we obtain the speed of a moving vehicle. 

Vehicle Speed Detector Code
Programming Vehicle Speed Detector Device

Now we create a while loop where we continuously check the speed of the vehicle. Here you can set any desired speed that you want to limit, and if the vehicle speed is greater than the set speed limit, we will capture the video and save it to a file where the code is saved.

Next, we will display the live video from a camera and then we will overlay the speed of the vehicle on the video using OpenCV on each frame. We can see the live video output from the camera with the detected speed data on the video. 

Vehicle Speed Monitoring System Coding
Vehicle Speed Monitoring System Coding

Circuit Diagram

Now we connect the components according to the following circuit diagram.

Vehicle Speed Detector Circuit Diagram
Circuit Diagram

After completing connections, we fix the camera of the Raspberry Pi in any custom-designed case and then the radar over the case. Here I have designed the case for our device with a small hole behind the case for the camera. 

Vehicle Speed Tracking Device
Camera and radar fixed

Testing:

Raspberry Pi with Camera and Doppler Radar
After Connecting Hardwares
Testing

Now power the Raspberry Pi and run the code. Move your hand very fast so the speed is detected and also shown on the camera output video. Now keep the radar near the road. Whenever it detects the speed exceeding the speed, set in the code, it will automatically capture the video and pictures of the high-speed vehicle.

If you have questions/doubts or face any issues while trying your hands on this project, please feel free to ask in the comments below. You can also use our Forum to discuss with the community of engineers and experts.

Ashwini Sinha
Ashwini Sinha
A tech journalist at EFY, with hands-on expertise in electronics DIY. He has an extraordinary passion for AI, IoT, and electronics. Holder of two design records and two times winner of US-China Makers Award.

2 COMMENTS

SHARE YOUR THOUGHTS & COMMENTS

Unique DIY Projects

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Calculators

×