Hacker News new | ask | show | jobs
by ambicapter 3222 days ago
Or could you just post two posts near the road in view of the camera with a known distance between them...
1 comments

I wonder if you could even use road markings or kerb stones as your calibration to save the effort of measuring things out.

I'm admittedly rather unqualified in this area (I don't even know what the ITS industry is!) but I have experience in estimating distances from video and calculating speeds from pixel displacement (particle image velocimetry) and at first pass it seems to me this would be a fairly straightforward problem to solve.

Obviously radar or lidar would be preferable but a quick search for "OpenCV speed estimation" shows people having success with simple single <$50 camera setups.

I'd use two infrared laser LEDs on a PCB with a low-res-but-high-speed infrared light detector, and set up a retroreflector across the street.

If the LEDs are 10cm apart, and parallel to the street, and left dot vanishes 7.45645 ms after the right dot, then something was moving through the beams from right to left at 30 miles per hour (13.4112 m/s). If right dot vanishes 4.06716 ms after left dot, something was moving left to right at 55 mph (24.5872 m/s).

You can even get an estimate of vehicle length and acceleration if you watch for the dots to reappear.

The frame rates and resolutions of most cameras aren't great for precisely estimating speed. You would need a high-speed camera, which is wasted on a surveillance application. So you just use two cameras, one that sees 16 infrared pixels with an ultra high frame rate, and one that sees many RGB pixels at 24 fps.

I disagree with you regarding resolution and frame rates, I don't see why you would need a high speed camera. Something like a raspberry pi camera would be perfectly sufficient for this, assuming you still just want to get someone's speed to within say +/- 1mph to shame them, as in the original comment.

Set up your RPi camera about 20m from the road, with it's FOV that'll give you about 20 m of road coverage. Rule of thumb in my world is that the items of interest should not move more than 1/4 of window width between frames. So that's 5m, to move 5m between frames at 30Hz you'd need to be doing about 300 mph. More realistically the car might be doing 25m/s giving you an inter-frame displacement of 0.8m ~130px. If that's too little for your software to register just up the inter-frame time.

You only need high-speed if you're mounting a device immediately adjacent to the road with a low-resolution light sensor.

An ordinary surveillance camera certainly can estimate speed, especially with good software, but a dedicated device would likely give a better performance to price ratio or performance to power ratio. Maybe I'm just too old, and still think that a RPi and enough resolution for a human to actually discern an image is overkill, because I'm used to computing power and image resolution being expensive.

But then again, if you're already using that setup to read license plate numbers, you're not actually starting from zero. The marginal effort to estimate speed on top of that is likely less than a purpose-built device.

> The frame rates and resolutions of most cameras aren't great for precisely estimating speed.

How good do you think the numbers would be? For example, the speed limit on my road is 25 mph but I know people routinely drive through at 40 mph. Would a camera system be good enough to record, say, 30 mph with error bars equal to +/- 5 mph?

That is highly application dependent.

If you can set up clear distance markers 100m apart on the road itself, a regular surveillance camera set up with its line-of-sight perpendicular to the road could probably estimate speeds between 5 and 80 mph with at least 1 mph precision, and adding some image processing software could probably give you 0.1 mph precision or better.

Oblique views, curved roads, unclear markers, or even differently colored cars could produce false results, or no results at all.

It may be enough to convince your local cop shop to set up a radar trailer on your street for a few days, but you're not going to be convicting anyone of reckless driving with it.

I reckon an RPi type camera would be perfectly sufficient to estimate speeds, probably to a higher accuracy than you ask.

Edit: a quick search led me to this https://gregtinkers.wordpress.com/2016/03/25/car-speed-detec...

and this https://github.com/pageauc/speed-camera

Wow! That's perfect. Thanks for the links.