Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The simple way to detect frequency would be to average the frames over a second or so. The light that is On, Off, On will be twice as bright as the one that is Off,On,Off.

The trick is that you have to be able to keep track of where it is while the camera is moving. One of the lights is always on, so that's ok, but you need to keep track of where the other light should be to do your math. A Kalman filter is a good choice for predicting that.

If your camera isn't exactly a multiple of 30 FPS you'll need to keep track and synchronize your time.

All of this is complicated, so what you probably should do is the red and green lights. You don't need to add much. Just an inRange(greenFilter) then bitwise_or with the red results. You do find contours to get the two lights just as you do now. Then telling red and green lights apart is simple. Pick the pixel value at the X,Y coordinates and check it against your green and red filters. It's just two pixel comparisons so it's very quick.