Detect Speed with a Raspberry Pi, Camera and OpenCV

Many thanks Liam.

It’s definitely possible that the contract between cars and background is an issue, detection of white cars/vans is better for sure. Not sure there is a great deal that can be done about that.

Thanks for the link, it had a couple of things to try :+1:

I have this problem, what can I do? I’ve tried multiple times to let something pass in front of the camera, but it only captured one vehicle, and to display it under images, it takes 20 minutes. There’s nothing under recent even when I refresh.

Hey @Loki269894, welcome to the forum!

Would you be able to tell us a bit more about your problem and setup?

Some people above you in this post have had issues with both the hardware and software part of this project. Could you give us an idea of your physical setup as well as the software setup steps you have gotten through so far.

The error message you have sent doesn’t tell us much without that context.

Thanks!
Sam

Hey Sam,

Thank you very much for your response. Following the instructions on the website, I’ve installed the project. I’m using the Raspberry Pi 4 4GB, and for the camera, I’m using a Logitech Webcam (HD 1080p) (I adjusted this in the Config.py file PLUGIN_NAME = “webcam720”). When I start the program, the snapshots are displayed in the web view under “images”, but nothing appears under “recent”. From my screenshot, you can see that at the bottom right it says “No drive status avail”, meaning it can’t retrieve the drive status even though I’ve adjusted the path correctly. But I don’t find this too concerning because the screenshots are at least landing in the “image” folder.

However, my bigger question now is, how can I modify my config.py file, etc. to measure the speed of cars on a highway? To explain it better: For example, I want to stand on a bridge and measure the speeds of cars passing underneath the bridge (For school project lol). For this, I would need to adjust the code so that the program can detect cars coming vertically (from above). And how should I best calibrate it to ensure accurate speeds?

Sorry, I’m still a beginner, thank you for your patience and support.

Loki

Wouldn’t you just turn the camera sideways? Sometimes a hardware solution is simpler than trying to adjust the software. :thinking:

Hi Loki
Excuse me for butting in here. I have not read all the history on this thread as I have no personal interest.
But one thing stood out which is physical in nature.

The first thing is you would be measuring the “slope” speed. That is the hypotenuse of a right angle triangle. If this remained constant there would be no problem calculating the ground speed.
But as the car is coming toward or away from you the “slope” angle is constantly changing if you are tracking it keeping the image in the centre of frame. So in this case calibration for “accurate” speed would be almost impossible.

I might get interested enough (and get enough time) to go back to the beginning here and find out how this is intended to be done. I just can’t see at the moment how the current crop of hobby processors could be fast enough to process an image, do it again, decide how far the target has moved and elapsed time, finally calculate the speed.

I think (could be wrong) traffic cameras are actually Doppler Radar measuring target speed and a still camera set to trigger when a set speed is exceeded. Tree branches swaying in the wind have been known to produce false speeding photos. One in Carlingford Rd, Sydney a few years ago springs to mind.
Cheers Bob