
Citizen uses OpenCV to track speeders near his home - danso
http://www.cvilletomorrow.org/news/article/22908-locust-avenue-speeding/
======
gus_massa
I'll copy a very interesting comment by Anton Largiader
[http://www.cvilletomorrow.org/news/article/22908-locust-
aven...](http://www.cvilletomorrow.org/news/article/22908-locust-avenue-
speeding/#comment-2489875608)

> _One very interesting approach I have seen overseas is a traffic light that
> turns red if you are speeding as you approach it. It 's incredibly
> effective; instant feedback on your behavior, and immediate loss of any time
> you gained by speeding. No ticket, unless you run the light. Drivers quickly
> conclude they're better off by not speeding._

~~~
Someone1234
I like that idea but I do worry about it causing rear-end collisions.

In an ideal world drivers wouldn't speed and they also wouldn't tailgate, but
in the world we currently occupy both are extremely common (even amongst law
enforcement).

So while this would act to reduce speeding, the unpredictability may increase
accidents and it is definitely going to reduce traffic flow.

~~~
mikeash
Rear end collisions like this tend to be pretty benign. For example, one of
the arguments against red light cameras is that they actually _increase_ the
number of accidents. However, they also increase safety. How? Because while
they increase the number of rear end collisions, they decrease the number of
side impact collisions, which are much more deadly. Net result: more bent
metal, less bent flesh.

I'd also be surprised if speed-sensing lights really increased collisions
much. They still go through a full yellow before turning red. They are only
more unpredictable if you know the light's cycle time, watched it turn green,
and are carefully timing it so you could otherwise predict it.

~~~
ape4
Yes, I thought that about this issue too. Perhaps more distinct signage and
early warning lights might get cars to slow before the red.

~~~
mikeash
That's how I've seen them installed. For example:

[https://www.google.com/maps/@38.8393523,-77.0661647,3a,75y,3...](https://www.google.com/maps/@38.8393523,-77.0661647,3a,75y,332.5h,91.34t/data=!3m6!1e1!3m4!1sUyF8MMUp2_K4oCZnH3eOkg!2e0!7i13312!8i6656)

Of course, if I've seen them _without_ any signs then I wouldn't even know
it....

------
jurassic
Some commenters here are commenting as if speeding is some petty thing that
doesn't matter.

Speeding kills. Something as small as 10 miles over a 30mph may mean a
doubling in fatality rate for pedestrians and bicyclists.

One source:
[https://www.aaafoundation.org/sites/default/files/2011Pedest...](https://www.aaafoundation.org/sites/default/files/2011PedestrianRiskVsSpeed.pdf)

~~~
GFischer
Not all speeding is created equal. I agree that 10 miles over a 30 mph zone is
probably deadly, if it was properly zoned and not a money-grabbing move (it
looks from the article that it was a correct limit, maybe even too high).

However, many speeding tickets (at least in my country and others) are due to
low maximum speeds on roads intended as main thoroughfares.

I read here in HN that plenty of U.S. towns live off speeding tickets, see

[http://www.foxbusiness.com/features/2011/10/19/town-that-
liv...](http://www.foxbusiness.com/features/2011/10/19/town-that-lived-off-
speeding-tickets.html)

[http://www.9news.com/story/news/local/investigations/2015/05...](http://www.9news.com/story/news/local/investigations/2015/05/01/citation-
nation-tickets/26590321/)

In my country they have some similar systems, and made even worse because they
specifically target tourists and foreigners (especially Argentineans) for the
ticketing revenue.

I work for an insurance company, and I've read some research that suggests
that speed limits are improperly sent more often than not (a few times too
high, but most often too low). Interestingly, accidents are going steadily
down due to better cars. Other factors are much bigger influences than just
speed (alcohol, stress, etc.), and insurance companies are introducing
monitors for that. Hopefully self-driving cars will continue the downward
trend :) .

IMO, dynamic speed limits, based on weather and road conditions and other
stuff (lower on school days?), should be the default in the 21st century :) .
Germany already does it.

Another problem was improperly planned roads, as in the article (another
comment mentions that the road in question is a "feeder" road).

~~~
upofadown
The safety here is not on or off. Each increment of speed causes a
corresponding increase of risk. That increase might be small, but that misses
the point.

The speed limits are a social contract. If someone feels they should increase
the risk to others above and beyond that agreement then they can at least fund
some civic infrastructure to balance things out.

~~~
michaelt
I don't drive and I don't have a car - but if 85% of cars are exceeding the
speed limit, it sounds like that law doesn't have the moral legitimacy that
comes from the consent of the governed.

~~~
JoeAltmaier
Speed limits might not fit that 'moral legitimacy' model very well. We don't
even think much about speed limits. We just drive. So morals don't enter into
it.

I'd say the street must not be posted right, or maybe its got an unusual speed
limit for the type of road. That fools people. We have a local road on the
West side that should be a thoroughfare. But its zoned residential, so 30MPH.
Everybody speeds - there are no driveways, no slow traffic, no pedestrian
traffic, no risk. I'd argue they just got the signs wrong.

------
webjprgm
I don't know if people share this opinion, but to me speeding is due to the
inadequacy and inconsistency of speed limits.

Near my home there is a major thoroughfare with a 35 MPH speed limit. It has
no homes facing the road, just a few fenced backyards some fair distance away
but mostly it has farms, ponds, and golf courses. People regularly go 40-50
MPH down this road.

Another major road that crosses this one has a speed limit of 55 MPH. It has
several houses directly on it. I've stopped once to let an old man cross the
street to get to his mail box. It has a school (where the speed limit drops to
45 MPH). It is too narrow and dark in my opinion to have a 55 MPH speed limit.

I believe both roads should be 45 MPH.

Furthermore, the freeways through town are 55 MPH speed limit. Ridiculous.
Most states have 65 MPH limits even within a city. (I didn't grow up here,
obviously.) So naturally there is a lot of speeding.

There are probably several rules and reasons for these limits. The 35 MPH road
is within city limits while the 55 MPH road is technically in a different
township and would once have been considered a farm/country road though it is
now a major road to an office building complex and school. We also have to
deal with snow and other weather conditions part of the year, and we don't
have electronic speed limit signs to change the speed limit or something based
on changing conditions.

Then there's also the fact that city planners never manage to build sufficient
roads until the current ones are overcrowded. So this 35 MPH road probably was
not originally intended to be such a major road, but there isn't any other
good way to go N-S through that part of town because the rest is all winding
back and forth through neighborhoods.

I would definitely be in favor of having speed limits that were consistent and
actually made sense, then enforcing them very carefully.

(Note that the article doesn't say how much over 25 counted as speeding. Did
he count 26 as speeding? My own metric is that if it is less than 5 over then
it is not speeding.)

~~~
JoeAltmaier
Sounds about right. I'd add, I want the app that tells me in a HUD what the
speed limit actually is. Maybe an audible boop if I cross the line. Help me
actually try to be in conformance when I think that's helpful.

~~~
phredphish
This exists in many non-Google/Apple smartphone navigation apps. HERE maps
(formerly Nokia HERE maps) has it with configurable over-speed limits (in
addition to its freely downloadable offline maps, with points of interest).
The HUD aspect is a bit more difficult to muster at the moment.

[https://maps.here.com/](https://maps.here.com/)

------
dpflan
"Locust (Avenue) is classified as a collector road, which means the city
prefers not to install stop signs or speed humps. The city is working on
alternatives that could include painting new parking spaces, installing
planters or narrowing lanes."

The road by (unintentional) design seems promotes higher traffic speeds by
having few impediments; it is also intersects a highway (BVP 250 via Google
Maps), which I suspect could influence drivers near the highway to be
increasing speeds or maintaining speeds they had while on the highway. I'd
like to know where the speeding is occurring in relation to proximity to the
highway.

This made me want to explore how speed limits are set.

I found this "Methods and Practices for Setting Speed Limits: An Informational
Report" by the U.S. Department of Transportation: Federal Highway
Administration.

\-
[http://safety.fhwa.dot.gov/speedmgt/ref_mats/fhwasa12004/](http://safety.fhwa.dot.gov/speedmgt/ref_mats/fhwasa12004/)
\-
[http://safety.fhwa.dot.gov/speedmgt/ref_mats/fhwasa12004/fhw...](http://safety.fhwa.dot.gov/speedmgt/ref_mats/fhwasa12004/fhwasa12004.pdf)

------
masklinn
A pretty common sight around here (western europe) which seems to work pretty
well are dynamic reminder signs: electronic signposts with a speed radar,
which simply displays your speed in green if you're under the limit, orange if
you're a bit over and blinking red if you're way over (using fairly bright led
arrays so it's visible in most conditions)

Anecdotally, it seems to work pretty well, drivers do slow down when they
approach the sign and don't seem to speed back up afterwards. I do not know if
it's the personal reminder or the shame of showing your speeding to everybody
around.

Sign've been here a while and seem to keep their effect, they don't seem to
become part of the scenery and ignored over time as regular static signs are
wont to do. And that applies to both car and bus drivers.

~~~
bryanlarsen
The article shows evidence for the contrary, the city actually installed such
a sign. It slowed motorists for a while, but they eventually sped back up
again.

~~~
mikeash
I think people hope that they work by shaming. Remind people that they're
breaking the law, and they'll break the law less.

I think they _actually_ work by intimidation. Remind them that The Man is
watching and they could get a speeding ticket. Once people realize that this
is an empty threat and nobody is handing out tickets, they'll go back to their
usual behavior.

------
pc86
> _At 4:27 p.m. last Wednesday, the system caught a Route 11 city bus doing 34
> mph._

Which isn't even fast enough to get a ticket from local police.

In my state (which is not Virginia, and it will vary everywhere), local police
are prohibited from using radar and need to use an actual stopwatch to track
your speed. Obviously very error prone, and they're supposed to basically give
you 10 mph leeway - meaning on that road you basically _couldn 't_ get a
ticket for going under 36 mph.

Also it doesn't say what they determine speeding to be. Based on his
description the vehicle should be wholly between both markers for 40 frames at
exactly 25 mph. Are cars that touch the mark on frame 39/40 considered
speeders since they're going ~25.025 mph? There is a reason many states do not
start issuing tickets until 5, 6, 9, 10+ mph over the posted limit.

~~~
dc_new
I live in Va, just not that part, and the rule of thumb is anything less then
10mph over and you generally won't get a ticket. The only exception to this is
places like school zones.

~~~
bargl
Unless you're on 495 then it's like 20mph over and the police may still pass
you....

~~~
mikeash
My car can warn me if I exceed the local speed limit by more than a set
amount. I had to turn it off after a while, because it was just getting
annoying on 495.

It's pretty funny to drive back into the city from points west on I-66 as the
speed limit drops 70-65-60-55. I usually maintain a steady 7 over and that
makes me go from one of the fastest cars on the road to one of the slowest.

------
abhv
Paul (the Citizen) was a former professor in the CS dept at U. of Virginia.

As the story says, the motivation was that a kid was hit by a car on that
street in October.

------
OhHeyItsE
I wonder how the HN commentariat would feel about this if it was a government
agency behind this rather than a fellow hacker...

~~~
pc86
It's one thing to just get the data and make an argument (in this case, "slow
down") - it's an entirely separate thing to do that and start issuing
citations or impounding vehicles.

~~~
ryandrake
> Reynolds and neighbor Bruce Odell will make a presentation on the software
> to the council Monday night.

It's not just a neat tech hobby--this is a busybody pitching what amounts to
ubiquitous rule-enforcement to the local government.

~~~
JoeAltmaier
Yeah I'd say that too - except its speed limits in residential neighborhoods.
We're not talking about what color they're painting their front doors. We're
talking injuring people. All sorts of desperate measures are taken to try to
control this - speed bumps, no-car zones, cameras. This seems cheaper and
maybe more effective than all that?

~~~
ryandrake
What's even cheaper is not wasting money on "all sorts of desperate measures"
and instead, crack down severely on the people actually out there injuring
people with their cars (which is also against the law).

------
notacoward
I think an even better application of this technology would be to catch people
who aren't stopping at signs/lights, or not yielding at merges. Radar-equipped
signs can handle the speeding case fairly well, but are useless in these other
- and often more dangerous - cases.

~~~
pc86
Red light cameras increase rear-end collisions as well as injury because
people would rather lock up their brakes one car length before the
intersection than get a ticket.

I haven't seen any information on the effect of cameras at merging sites,
though.

~~~
notacoward
I wasn't suggesting anything that triggers red lights or leads directly to a
citation. Just gathering the data would often be useful, to drive design of
intersections and allocation of other resources in a quantitative way.

Also, if people aren't maintaining a safe distance from the car in front of
them, then that's useful information too. So is video of people illegally
using their celphones while driving, which this technology could also provide.

~~~
pc86
Well if you rear end someone you will be cited for it 99% of the time.

But surely your answer to something that quantifiably increases injury rates
isn't "who cares it's their own fault" is it?

But since you asked for a citation: [http://bfy.tw/4343](http://bfy.tw/4343)

~~~
notacoward
Putting words in someone else's mouth is a tactic commonly used by those who
can only formulate stupid statements. Of course I care about things that
increase or decrease injury rates. That's why I would like to encourage safer
behavior. You should haved added "debunked" to your snarky citation, and you
might have found this.

[http://www.cnet.com/roadshow/news/red-light-camera-myths-
deb...](http://www.cnet.com/roadshow/news/red-light-camera-myths-debunked/)

Also, as I said, if people are tailgating then that's a separate problem that
can also be addressed by this technology. It's insane to say that we shouldn't
discourage one dangerous behavior because of some other equally-addressable
dangerous behavior. People respond to the knowledge that they're more likely
to be caught when they do something wrong or stupid. An actual police officer
issuing citations _for exactly these offenses_ is effective, but costly.
Having the information about frequency of offense at different locations
allows those scarce resources to be allocated to greatest effect. What's your
problem with that?

------
edwhitesell
I've often thought of doing the same thing. Our current and previous houses
are/were on corner intersections of our neighborhood.

I'd love to see an open source implementation of this. I'd put it up to get
data on speeding and see if it could be adapted to catch people running the
stop sign in front of my house. I see at least 2 cars per day run it and
that's just in the time I'm outside to do quick things like checking the mail.

~~~
pc86
This seems like it would be harder. Would you have to lock onto the tires to
catch a certain number of frames without movement?

I would thinking rolling through a stop sign (especially at an intersection
that is not a 4-way stop) would be much more dangerous than going 30 in a 25.

~~~
edwhitesell
> I would thinking rolling through a stop sign (especially at an intersection
> that is not a 4-way stop) would be much more dangerous than going 30 in a
> 25.

This is exactly the scenario I have outside of my house. The speed limit on
both streets is 25mph, but when most people don't stop at the stop signs and
everyone is going too fast...

The issue is even worse at certain times of the year (right now) because,
depending on the direction you are going, the cars with no stop signs are
mostly blinded by the position of the sun between trees and houses. Just last
Monday a neighbor stopped by to say he turned the corner and side-swiped my
mailbox because he couldn't see anything.

------
dsfyu404ed
Speed limits are very much consensus based. The rule of thumb is "set the
speed limit so that if you didn't have any signs only 10% of people would be
in excess of it if left to their own devices. Adjustments for things like high
traffic intersections, pedestrian traffic, school zones, (speed traps the
local PD insists upon having) etc are made after that. Typically they're much
lower than people consider reasonable and IMO this has resulted in two
generations of drivers being trained to always exceed the posted speed limit
and instead of thinking about how fast they should be going think about how
best to speed (e.g "I'm driving on a 4 lane boulevard at 1AM and I'm the only
one around, I can do 10-20 over" or "It's a school zone on a week day, better
do 0-5 over")

Looks like Mr. Reynolds has begun building a data-set to support what the
handful of highway engineers I've spoken to on the subject just assume based
on observation.

------
garrettgrimsley
It's interesting to look back at the responses [0] from just two years ago to
Ford's admission that they know exactly who is breaking the law while driving
their cars or what people were writing [1] in 2002 when ubiquitous
surveillance of public space was becoming a reality.

[0]
[https://news.ycombinator.com/item?id=7036525](https://news.ycombinator.com/item?id=7036525)

[1]
[http://www2.law.ucla.edu/volokh/cameras.htm](http://www2.law.ucla.edu/volokh/cameras.htm)

------
mdip
I've taken a bit of my lunchtime to comment on this post in various places but
one that kept coming up is "is there code for this, somewhere?"

I have a camera setup on my RPi for this purpose, but never got around to
tying in OpenCV (though it's something that's been on my list for some time).
At the time I couldn't find/didn't look hard enough for a good open source
implementation.

It looks like this can be done relatively easily using an RPi and Python:
[https://www.raspberrypi.org/forums/viewtopic.php?p=813535#p8...](https://www.raspberrypi.org/forums/viewtopic.php?p=813535#p813535)

The Github repo for the code is here: [https://github.com/pageauc/motion-
track/tree/master/speed-tr...](https://github.com/pageauc/motion-
track/tree/master/speed-track)

Video with a code walk-through and demo is here:
[https://youtu.be/eRi50BbJUro](https://youtu.be/eRi50BbJUro)

I know what I'll be doing tonight. :o)

------
tombrossman
NB if you use a dash cam, realize that it can also be used to very precisely
calculate your speed in exactly the same way. Good if you are fighting a
speeding ticket you didn't deserve, bad if you get into a wreck and were
speeding.

------
hellofunk
I'd love to catch all the people who don't clean up after their dogs here on
the streets of the Netherlands. This is a high-tech country, they should do
something like this to remove a well-known public annoyance.

~~~
speps
[http://www.bbc.co.uk/news/uk-england-
london-35363991](http://www.bbc.co.uk/news/uk-england-london-35363991)

------
wott
Is it allowed in the USA for an individual to film public space?

~~~
otoburb
Generally it seems you may photograph and film public property, assuming you
believe Wikipedia.[1]

[1]
[https://en.wikipedia.org/wiki/Photography_and_the_law#Public...](https://en.wikipedia.org/wiki/Photography_and_the_law#Public_property)

~~~
lorenzhs
This wouldn't fly at all in Germany. If your surveillance camera films public
ground, even if it's not the primary object being photographed, you're acting
illegally. If, for example, you're trying to monitor your front door to catch
a potential burglar and you can see the pavement and the people on it on the
video, that's not allowed. You won't be able to use the footage in court even
if it shows the burglar clearly. Others, including the state, can also sue to
have the camera removed.

Even dummy cameras can get you in trouble (e.g. employer installing them in
the office kitchen, etc).

~~~
pc86
This seems bizarre to me. Why would you have any expectation of privacy
walking down a public street?

~~~
mindslight
Because of the law that prohibits systematic surveillance and archival of your
activities?

------
specialdragon
In summary, he's made a speed camera and is now proposing the use of it to his
local council. Are speed cameras not as ubiquitous in the USA as over here in
the UK?

~~~
danso
They are common, but not ubiquitous by any means. They're usually used in
prominent intersections/stretches in which speeding is observed to be common.

~~~
pc86
To add to this in some areas they cannot legally be used to generate
citations. They can, however, be used to direct law enforcement on which
intersections would be best served by increased enforcement.

------
lamontcg
Eliminate all the drivers.

\- No more speeding

\- No more tickets for speeding

\- No more driver's licenses or DMV waits

\- No more car insurance

\- No more "Driving While Black"

\- No more DUI

\- No more merging too slow

\- No more not signaling

\- No more cutting you off

\- No more rear end collisions

\- No more speeding to make the light

\- No more driving too slow

etc, etc, etc...

------
jrowley
I was assuming from the title that he was going to actually track down the
speeders using OCR on their license plate. Cool read though

~~~
otoburb
Presumably that's next via Tesseract + OpenCV. There's even a license plate
library called OpenALPR[1] already available that the professor is probably
itching to use if he ever gets city approval.

[1]
[https://github.com/openalpr/openalpr](https://github.com/openalpr/openalpr)

~~~
jrowley
Just needs to get the right angle for the camera. I don't know if he'd need
any approval for capturing. Looking up license plates/acting on the data could
get one into trouble I imagine though.

------
jld89
Another problem in _my opinion_ is the fact that the metrics in the US are in
imperial measures. 30 mph is 50 kph, it's about pure numbers.

50 is higher than 30 so common sense tells you that you are going faster. Even
if it is not true. There is a subconscious reaction of people to numbers, no
matter the metrics.

------
anjc
Wonder if he's using template matching or classification or background
subtraction and moving blob detection or what. And I wonder how it deals with
different lighting. I wonder also how out it'd be if the car was a foot or two
closer to the camera.

------
rem7
At my last job I had the chance to use OpenCV quite a bit. Every time I would
discover new things in OpenCV my brain just fired off with ideas. I remember
trying to write a blur function and then finding about integral images, that
was awesome.

------
__luke
Let's open source it!

~~~
mdip
Completely agree - does anyone know if there are similar open source projects
around this? I already have an RPi camera setup for this exactly purpose, but
I estimate speed manually (I've measured distance between two visible points
on the camera and do a quick calculation as the front bumper passes each
point).

I've had it on my "list of side projects" to solve this problem with OpenCV,
but haven't gotten enough "Tuits" to get it done, yet since the camera footage
has been enough to get me a police car in front of my house monitoring speed.
My cousin is a cop in my county and he's indicated that the spot is basically
a "ticket-writing factory" \-- they don't even bother with cars going 5-10
over since there are so many going 15+ and parking right in front of my house,
across the street, puts the cop in a spot where he's not able to be noticed
until the car is too close to slow down enough to avoid a ticket.

For a while, the spot was even marked as a speed trap on Waze (not sure if it
still is, nor whether or not I was the one who marked it :), but I haven't
looked in a while).

When I get it done, I'll be sure to post the complete code along with a blog
post on how to set it up, but if there's anything already out there that could
get me close, I'd love to know about it.

------
euroclydon
I wish he'd give me the source code. I could really use this in our
neighborhood. Next step would be to have second and third cameras (if
necessary) to get the license tag and a picture of the drive. Then erect a
hall of shame board.

------
Spooky23
Welcome to the age of nitpicking busybodies.

Next month, he'll have a facial recognition system for dog walkers who fail to
curb their dog.

~~~
akgerber
'Unintentional injuries', among which car crashes are a leading type, are the
most common cause of death among those ages 1-44:
[http://www.cdc.gov/injury/wisqars/leadingcauses.html](http://www.cdc.gov/injury/wisqars/leadingcauses.html)

~~~
modoc
Based on that there were 130,557 deaths from unintentional injury in the USA
in 2013. In that same year there were 32,719 fatalities resulting from auto
accident. So 25% of the unintentional injury fatalities were car crashes.
Which puts the car crash risk lower than most of the other major causes, and
lower than either suicide or homicide for every age group I believe.

------
sergiotapia
This is gross, and reminds me of the nosy old ladies that 'patrol' the
neighbourhood around here, only this guy knows C.

~~~
ryandrake
Or the retiree condo commanders going around measuring people's shrubs to make
sure they comply with condo bylaws section 4, subsection 65, paragraph 5. For
some people, ubiquitous rule enforcement is a utopia, not a Orwellian
nightmare.

~~~
oneeyedpigeon
You're seriously equating speeding on a road on which a child has been killed
by a speeding vehicle to keeping shrubs tidy?

~~~
ryandrake
My guess is that 99.9% of the people on the road exceeding the speed limit
this morning are not going to kill a child (or hurt anyone) with their car
today just from speeding. It could be 99.99%. I don't have the statistics, but
there are probably a lot of 9's there. No matter what that number is, there
are already laws against hitting kids with your car. Enforce them. Why do we
need to ruthlessly enforce something that the majority of drivers do and in
most cases does not result in injury?

What I'm equating is the mental state of the busybody: The need to go out
looking for rules being broken that otherwise would, in all likelihood, go
unnoticed.

