Most active commenters
  • zodPod(8)
  • post_break(8)
  • (4)
  • rubyfan(4)
  • khedoros(3)
  • fudged71(3)

Raspberry Pi Car Speed Detector

(gregtinkers.wordpress.com)
187 points mhss | 73 comments | | HN request time: 3.911s | source | bottom
1. finnn ◴[] No.11714994[source]
"Linux Car Speed Detector" might be a more accurate description, since nothing about this seems to be specific raspberry pi hardware. Honestly, could just say "Car Speed Detector" since I'd imagine this would be pretty easy to replicate on other platforms and the OS isn't really part of it either.

Really cool project though. Now I want to start playing with OpenCV. I wish i had something more constructive to add :/

replies(6): >>11715278 #>>11715382 #>>11715503 #>>11715937 #>>11716065 #>>11718005 #
2. mayoff ◴[] No.11715278[source]
That it can be done on a Raspberry Pi using the Pi camera is of interest, because cheap small hardware makes it feasible to buy and install hardware dedicated to the task.
replies(1): >>11715377 #
3. peatmoss ◴[] No.11715341[source]
Nice! Combine this with license plate recognition, and you have the start of an open platform for traffic safety that is both awesome and deeply creepy.

I've thought about a platform that collects speeds of vehicles and then publishes a database of speeds matched to license plates as an open data set. Police would likely not touch it, but a large enough database might be a tantalizing prize for automobile insurance companies. And then my desire for more disincentives for speeding runs afoul of my feelings about dragnet surveillance, and so I abandon it.

In terms of having the potential to effect direct action against speeders, I don't know how effective simply monitoring speeds would be. That said, some cities (such as Seattle) will lend speed profiling equipment to community groups in order to establish whether or not a given segment of road might be a candidate for traffic calming: http://www.seattle.gov/transportation/ntcp_calming.htm

replies(3): >>11716787 #>>11717383 #>>11718178 #
4. ◴[] No.11715377{3}[source]
5. squizzel ◴[] No.11715382[source]
Maybe cut out the "car" because what if a van or truck passes by?!
replies(2): >>11715518 #>>11715533 #
6. teh_klev ◴[] No.11715409[source]
Pretty sure this similar project appeared on HN a while back, though I can't find the original thread in Algolia:

https://github.com/pfr/VideoSpeedTracker

A more detailed overview of how it works:

https://github.com/pfr/VideoSpeedTracker/blob/master/docs/Vi...

http://eyetach.github.io/CharlottesvilleSpeeds/

7. zodPod ◴[] No.11715484[source]
I've been considering building something like this for a while. We live by a busy highway and a TON of cars pass on a daily basis. I'm really just interested in counting the number of them though I love data so anything that I could get I'd love to get. That said, I did the typical "hit a wall" thing and just performed it all in my head until I realized that I'd have trouble when this or that happened and stalled. Guess I probably should've just started. This still has some bugs to work out for my situation but seems like an awesome start!
8. zodPod ◴[] No.11715503[source]
I agree. As someone with some small computers laying around but non of which are pis NOR have I any pis available, I saw the title and lost a bit of interest but figured I'd read on anyway. Turns out, the pi isn't even necessary. But then how would you use a buzz word?! lol
9. ptaipale ◴[] No.11715518{3}[source]
Alas, that story about a bypassing Harrier locking its missiles to a speed radar is not true.

http://www.snopes.com/horrors/techno/radar.asp

replies(1): >>11715619 #
10. zodPod ◴[] No.11715533{3}[source]
And it really is more of a measurement device than a detector. The car is there one way or another, it's measuring the speed of it.

Maybe a "Linux Speed Measurer" however that starts to sound like it's related to measuring the speed of your OS.

Maybe "Linux-based External Object Speed Measurer"

replies(2): >>11715840 #>>11717350 #
11. ck2 ◴[] No.11715540[source]
Useless in court but might get a cop to put down their donuts and come look-see.

If you want to get them to slow down, buy a radar gun off ebay and put it on some kind of timer to randomly turn it on and off a few times per minute, pointed at your street.

12. zodPod ◴[] No.11715619{4}[source]
Wow. Reading that story annoyed me. Someone really wrote that with all of those obvious inaccuracies in it and someone actually believed it? THen I remember that people share shit 10x worse than this on FB and I got sad instead of annoyed.

Someone please educate someone. Please. lol

replies(2): >>11715661 #>>11715970 #
13. zodPod ◴[] No.11715631[source]
From this, you need an LED sign in your yard "Your speed is: [speed] MPH and your car is being photographed"
replies(3): >>11716541 #>>11716850 #>>11718963 #
14. ptaipale ◴[] No.11715661{5}[source]
Well, at least that Harrier story was somehow good-natured, and not just uneducated filth like the glyphosate thing.
replies(1): >>11716245 #
15. ◴[] No.11715718[source]
16. post_break ◴[] No.11715818[source]
I need a raspberry pi that can monitor parking spots so I know if I have a spot waiting for me when I get off of work. Of course I don't know how to code so it will probably never happen.

edit: I meant parking spaces outside of my apartment.

replies(2): >>11715921 #>>11716295 #
17. yoavm ◴[] No.11715840{4}[source]
What about "YAM" - Yet Another Measurer?
18. mandeepj ◴[] No.11715921[source]
You at least need a drone with camera for it. You would need to implement some object recognition on the images transmitted by the drone
replies(1): >>11715935 #
19. post_break ◴[] No.11715935{3}[source]
Wut. The parking spaces are viewable by my apartment window.
replies(2): >>11715969 #>>11716111 #
20. lijason ◴[] No.11715937[source]
Isn't that true for all Raspberry Pi projects by the very nature of Raspberry Pis? They're just a different form factor and cost than other Linux machines, but otherwise are just a Linux box.
replies(2): >>11716044 #>>11716047 #
21. lightbritefight ◴[] No.11715969{4}[source]
Point a camera at the spots when unoccupied.Specify the spots exact coordinates to the camera. Set color as baseline. If the color changes by 50% or more, they are occupied. Send alert when all occupied, or when not all occupied.

Now, learn to code it.

replies(4): >>11715989 #>>11716002 #>>11717052 #>>11717274 #
22. ricardobeat ◴[] No.11715970{5}[source]
Great timing: https://theintercept.com/2016/05/17/new-evidence-about-the-d...
replies(2): >>11716193 #>>11716239 #
23. Negative1 ◴[] No.11715988[source]
Very simple and fun little project. Great job.

The main problems to solve that I see are; 1- does not actually detect a vehicle, just motion 2- can only detect motion for one vehicle at a time 3- so now you know cars are going fast, but, what do you do with this data (how do you alert or punish them)

1 is a little tough to solve since it requires training some kind of classifier. 2 is not so bad if you use a velocity field and track individual objects via bounding box. 3 is basically another project. On that note, is it legal to have a speed meter on your front lawn?

24. post_break ◴[] No.11715989{5}[source]
Well I've got the raspberry pi, mjpeg, a camera that works. Just need to make the logic work. Here is what I'm stuck on. http://i.imgur.com/pIy3QNt.jpg
replies(1): >>11716553 #
25. Pxtl ◴[] No.11716002{5}[source]
The challenge, of course, is snow.
replies(1): >>11716093 #
26. khedoros ◴[] No.11716044{3}[source]
To a degree. Most Linux boxes don't have a couple dozen programmable IO pins and the other connectivity options for external sensors and such.

In the case of this project, you'd also have to do some modifications on the image-grabbing code. They're using a module that's specific to the Raspberry Pi camera module.

27. finnn ◴[] No.11716047{3}[source]
No. There are some that actually use the Raspberry Pi hardware, such as PiFM[0]. Others merely use GPIO, which of course can work on a number of other SBCs (eg a Beaglebone Black) or anything with GPIOs. The only Raspberry Pi specific thing here is how it connects to the webcam, because the Raspberry Pi doesn't expose the camera as a standard v4l device, they have their own way of doing it.

[0]: https://github.com/ChristopheJacquet/PiFmRds

replies(1): >>11716060 #
28. khedoros ◴[] No.11716060{4}[source]
Well...there is a V4L2 driver for the Pi camera. Strictly speaking, they didn't have to use the picamera module.
29. morganvachon ◴[] No.11716065[source]
Actually this project is pretty specific to the Pi and its camera, though it can of course be modded for other hardware.

"So it just happens that the horizontal distance covered by the Picamera’s image is roughly equal to the distance from the lens. If you are 10 feet from the lens, the image is about 10 feet across, 47 feet from the lens, about 47 feet across, and so on.

Of course, other cameras may have a different field of view and won’t have this easy to determine correspondence."

30. khedoros ◴[] No.11716093{6}[source]
Also: clouds, nighttime, people walking across the lot, and any other color changes that aren't related to other vehicles being parked in the spots.
replies(1): >>11716345 #
31. mandeepj ◴[] No.11716111{4}[source]
Did not you said "I need a raspberry pi that can monitor parking spots so I know if I have a spot waiting for me when I get off of work."
32. zodPod ◴[] No.11716193{6}[source]
lol shit I picked some random GMO related shareable. Guess I picked the wrong one..
33. zodPod ◴[] No.11716239{6}[source]
That said, the image I linked specifically named Glyphosate while the story you posted appears to be saying that it wasn't Glyphosate, it was the co-formulants that are a problem, unless I'm misunderstanding?
34. zodPod ◴[] No.11716245{6}[source]
That's true!
35. lovelearning ◴[] No.11716295[source]
I'll give it a shot, if you can shoot a couple of short stable videos and images of your parking spaces and upload them somewhere.
replies(5): >>11716500 #>>11718177 #>>11719065 #>>11723864 #>>11724510 #
36. TheOtherHobbes ◴[] No.11716345{7}[source]
Plug in a webcam, and upload a photo to a server every minute or so. Or put the Pi online.

Humans are still better at parking spot recognition than $35 hardware.

Of course you'll need a camera with a time machine so you know the spot will be free when you arrive, and not just when you set out.

replies(1): >>11717015 #
37. post_break ◴[] No.11716500{3}[source]
That would be cool, I'll get them to you in about 4 hours when I'm home.
38. jason_slack ◴[] No.11716541[source]
I just posted about this today: https://news.ycombinator.com/item?id=11714378

I'm trying to work on a setup to handle this. I ordered a PiCamera instead of the connect though. I just happen to have a connect laying around.

39. cake ◴[] No.11716553{6}[source]
Or just remotely send yourself a photo of your parking lot.
40. rubyfan ◴[] No.11716696[source]
Is it practical enough that you could do anything with it, like give it to the police for a citation?

Or is it just awesome in a nerdy sort of way?

replies(1): >>11719056 #
41. rubyfan ◴[] No.11716752[source]
I wonder if one could figure out other vehicle speeds from a dashboard camera. His method looks like it assumes a stationary view.
replies(2): >>11717265 #>>11718195 #
42. Perixoog ◴[] No.11716787[source]
You could just use licence plate recognition x2 and measure average speeds instead.
43. Perixoog ◴[] No.11716850[source]
A camera flash also gets the message across.
44. post_break ◴[] No.11717015{8}[source]
IFTTT api to create geo fence on my route home to poll the Pi "are there spaces left?" with an email or response yes or no with a photo at the current time.
45. oh_sigh ◴[] No.11717052{5}[source]
You could also zoom in so you would be looking at a car if it is parked there, and then upload the image to the microsoft caption bot service. It's pretty good at recognizing cars already, and you can just search the result for the word "car"
46. dan_quixote ◴[] No.11717265[source]
Definitely. The code here assumes that the vehicle's vector is perpendicular to the optical axis. If you had enough information to calculate the vector it would just be a little extra trig to measure the relative speed minus the offset of your vehicle's instantaneous speed. This is easy for side to side movement, a little harder in the depth direction - though you could get some depth info by comparing the size of the car contour at two or more snapshots (smaller indicating that it's moving away). The framerate/resolution of the RasPi setup probably wouldn't make it a good choice for this though.
replies(1): >>11720724 #
47. awesomerobot ◴[] No.11717274{5}[source]
Couldn't you just get a decent security camera and uh, well... look?
48. awqrre ◴[] No.11717350{4}[source]
How about "Object speed measured by image processing (extracted from video input)" or osmbipefvi for short....
replies(1): >>11718172 #
49. pjc50 ◴[] No.11717383[source]
The UK has an insurance lookup database, although you're only supposed to use it on your own car: http://ownvehicle.askmid.com/

I've been wondering if it would be possible to combine that with ANPR to give a dashboard-level indicator of uninsured vehicles to watch out for.

replies(2): >>11718067 #>>11720555 #
50. pravda ◴[] No.11717608[source]
It would seem to me the best way to reduce speeding on this road is to raise the speed limit.

Doubling the speed limit to 50mph would probably reduce speeding by 75%.

replies(2): >>11717843 #>>11719420 #
51. soperj ◴[] No.11717843[source]
It wouldn't reduce the noise inside my house though.
52. scottlamb ◴[] No.11718005[source]
I strongly disagree. He made the project on a Raspberry Pi 2 and mentioned how this affected his design in several ways:

* he used Raspbian Jessie (almost but not quite Debian Jessie) and followed instructions for setting up the necessary packages on that distribution

* he tweaked his code to perform adequately on the Pi2 and described the performance limits on that hardware

* his code uses the Raspberry Pi camera library

* he used the Pi camera's field of view in his distance calculations

It's true that you could adapt it to different hardware, a different operating system, a different distance, or a different purpose. Even if you're doing so, it's still useful to have a concrete example to work from. (For example, knowing that the Pi2's performance is marginal for what he's trying to do may help you set expectations for performance of your hardware in your situation.) Without including the specifics you object to, the article would be short, abstract, and basically useless.

53. ◴[] No.11718067{3}[source]
54. fudged71 ◴[] No.11718172{5}[source]
This thread is so pedantic it hurts
replies(1): >>11718993 #
55. fudged71 ◴[] No.11718177{3}[source]
You are truly living up to your username! :)
56. kmm ◴[] No.11718178[source]
That sounds insanely illegal as well. I don't know about the US, but I think in most places in the EU it's illegal to even post videos of people driving dangerously or way too fast online.
replies(1): >>11718528 #
57. fudged71 ◴[] No.11718195[source]
If you had an OBDII adapter and a camera this should be possible! I'm not sure if there is OBDII communication code for RPI, though
replies(1): >>11719253 #
58. toomuchtodo ◴[] No.11718528{3}[source]
No expectation of privacy in public in the US. Its fair game.

https://www.reddit.com/r/Roadcam

59. spydum ◴[] No.11718963[source]
I am seriously considering implementing this and tying it into the nextdoor.com API to creating a wall of shame in my neighborhood.
60. vladsanchez ◴[] No.11718986[source]
AWESOME!!! I wanted to work on such project to police my neighborhood speedsters. :-)
61. ◴[] No.11718993{6}[source]
62. HiroshiSan ◴[] No.11719056[source]
I would think that it's just awesome in a nerdy sort of way...the programmer could just fudge the numbers and output an incorrect reading, to screw with someone they didn't like for instance.

Plus I don't think promoting vigilantism is a good thing.

replies(1): >>11720700 #
63. post_break ◴[] No.11719065{3}[source]
Sorry I got home late so it's too dark, I'll get you those first thing tomorrow morning.
64. Sanddancer ◴[] No.11719253{3}[source]
There is. There are obd boards that use the standard uarts, and dongles that use bluetooth that you can read from the pi. Here's one guy's project on it. http://fabcirablog.weebly.com/blog/reading-a-cars-obdii-port...
65. morganvachon ◴[] No.11719420[source]
I think you're seeing this from a "what is legal" standpoint versus the author's issue with "what is safe". If the speed limit is 25 MPH and people regularly go 50 MPH, endangering the lives of the residents, raising the limit so they can legally go 50 MPH only means they are legally endangering the lives of the residents. They don't slow down at all and are rather likely to speed up, as many drivers view the speed limit as a minimum instead of a maximum.

For example, on my road, which is not in a neighborhood and is a country road that serves as a connector between two highways, the speed limit was raised from 35 MPH to 45 MPH several years ago. Accordingly, traffic went from averaging 50-55 MPH to now averaging 65-70 MPH with occasional amateur race car drivers going by so fast you can't tell the type of car they drive. I have found it treacherous to check my mailbox and mow my lawn at certain times of the day (mainly "rush hour" and, oddly enough, Sunday afternoons). Twice in the past five years my mailbox has been obliterated by a speeder losing control of their vehicle and running off the road because they were driving too fast and/or distracted, one time right in front of my eyes as I was walking to the mailbox.

Generally, if you set a speed limit on a long straight road, you can expect the public to exceed it by at least 10 MPH. This effect has been observed by the GHSA[1] and IIHS[2] and is easily researched privately if one is so inclined.

[1] http://www.ghsa.org/html/media/pressreleases/2016/20160412sp... [2] http://www.iihs.org/iihs/sr/statusreport/article/51/4/3

66. ddmf ◴[] No.11720555{3}[source]
That's an excellent idea. Far too often the driver in front appears to be driving strangely so you drop back a bit and hope they or you turn off so you don't have to be hypervigilant about their driving.

If there was an automated way of dobbing a driver in to the police then this would be useful too - quick tweet/email/text with the message: uninsured vehicle AB12 CDE travelling at 35mph location 51°29'51.3"N 0°08'06.4"W

67. rubyfan ◴[] No.11720700{3}[source]
Good point but definitely nice to have something credible to have a discussion about the jerk driving 75 on your 25mph street.
68. rubyfan ◴[] No.11720724{3}[source]
So you definitely need to know your own speed to calculate relative speed of other drivers?

I have a dumb dash cam that's just awesome for video but is nothing more than video to a sd card, ie, not a computer. I've always wondered if I could use just the video using familiar objects like stop signs, mile markers or lane markers to determine my own speed.

69. soared ◴[] No.11723346[source]
I've always thought about attaching one of these to a longboard or bike with and LED readout so anyone behind me (or filming edits) could see the exact speed.
70. post_break ◴[] No.11723864{3}[source]
I don't know how to send PM's. Here is a short video of the three spots. https://www.dropbox.com/s/w0q6frn9bxufy8m/2016-05-18%2011.34...
replies(1): >>11724487 #
71. lovelearning ◴[] No.11724487{4}[source]
Great! I had a look, and already have some ideas I'll try out.

If possible, I think it'll be be helpful if you can shoot a second video or image with all 3 spots empty. I'll probably need it because I plan to use the curb's edges and surface colors of the slots.

Just to confirm, are these videos shot from the same spot where you'll eventually fix your camera?

72. post_break ◴[] No.11724510{3}[source]
Can you find me on twitter so I can PM you easier? Same username. I can get you way more data if you want. I need to bust out the raspberry pi so I can get you actual video from the camera I'm going to use.