
Raspberry Pi Car Speed Detector - moises_silva
https://gregtinkers.wordpress.com/2016/03/25/car-speed-detector/
======
peatmoss
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](http://www.seattle.gov/transportation/ntcp_calming.htm)

~~~
pjc50
The UK has an insurance lookup database, although you're only supposed to use
it on your own car:
[http://ownvehicle.askmid.com/](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.

~~~
ddmf
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

------
teh_klev
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](https://github.com/pfr/VideoSpeedTracker)

A more detailed overview of how it works:

[https://github.com/pfr/VideoSpeedTracker/blob/master/docs/Vi...](https://github.com/pfr/VideoSpeedTracker/blob/master/docs/Video%20Speed%20Tracker%20Overview%20and%20User%20Manual.md)

[http://eyetach.github.io/CharlottesvilleSpeeds/](http://eyetach.github.io/CharlottesvilleSpeeds/)

------
finnn
"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 :/

~~~
lijason
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.

~~~
finnn
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](https://github.com/ChristopheJacquet/PiFmRds)

~~~
khedoros
Well...there _is_ a V4L2 driver for the Pi camera. Strictly speaking, they
didn't have to use the picamera module.

------
post_break
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.

~~~
lovelearning
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.

~~~
post_break
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...](https://www.dropbox.com/s/w0q6frn9bxufy8m/2016-05-18%2011.34.11.mov?dl=0)

~~~
lovelearning
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?

------
Negative1
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?

------
zodPod
From this, you need an LED sign in your yard "Your speed is: [speed] MPH and
your car is being photographed"

~~~
spydum
I am seriously considering implementing this and tying it into the
nextdoor.com API to creating a wall of shame in my neighborhood.

------
zodPod
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!

------
soared
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.

------
rubyfan
I wonder if one could figure out other vehicle speeds from a dashboard camera.
His method looks like it assumes a stationary view.

~~~
dan_quixote
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.

~~~
rubyfan
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.

------
rubyfan
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?

~~~
HiroshiSan
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.

~~~
rubyfan
Good point but definitely nice to have something credible to have a discussion
about the jerk driving 75 on your 25mph street.

------
vladsanchez
AWESOME!!! I wanted to work on such project to police my neighborhood
speedsters. :-)

------
ck2
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.

------
pravda
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%.

~~~
morganvachon
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...](http://www.ghsa.org/html/media/pressreleases/2016/20160412speedlimit.html)
[2]
[http://www.iihs.org/iihs/sr/statusreport/article/51/4/3](http://www.iihs.org/iihs/sr/statusreport/article/51/4/3)

