When I can get my hands on a Raspberry Pi with 5 megapixel camera I'd like to experiment with it as a tool for measuring traffic speeds. The basic algorithm would be to capture each frame of video (live), detect a pair of headlights, and track them through subsequent frames in order to rebuild a vehicle's path through the device's field of vision. From there is should be a relatively simple procedure to build a speed and acceleration profile for each trip. The camera cannot see in 3D but the distance between points in the image can be determined manually then used to compute speed and acceleration.
If successful a solar powered Pi could be mounted somewhere and left to track trips for a day or two or three. For about $100 a lay-person could be equipped to capture traffic counts and speed data for their local street. We would be able to know just how fast do they go anywhere in the city, for little cost.
First up is filtering away noise and uninteresting parts of the image. Thankfully headlights are bright and white, so let's filter away anything that isn't white. What's it look like? Using the Bank and Heron traffic camera I grabbed a few hundred images and passed them through the filter. Here's a side-by-side animated GIF of the results. Click to embiggen.
Sadly, snow is white, so I had to turn the filter very high, and it's still catching the red/yellow/green traffic light. This might be easier in summer when there is more contrast. Nighttime might be even better.
Also: Enduro flashbacks.
Detecting what constitues a pair of headlights is next. Ideally I can write something that is fully automated to detect any pair of headlights.
If that fails I can cheat by giving the code a hint for where to look for "new pairs of headlights". For example, all of the approaching cars in the above example originate from a fixed point in the image, on the horizon, then descend straight down, or slightly diagonally depending on what lane they are in. If my Pi has a WiFi dongle it would be easy to mount it, then remote in for calibration and "hinting" until it was detecting cars correctly.
I wonder if the city has higher frame-rate and better resolution video for the traffic cameras?
Anyway, holiday hacking complete.