Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openCV detect blinking lights

my question is similar to this one: OpenCV: Detect blinking lights in a video feed

I have a LED light, and my camera runs at 30fps. At each frame, I ant to know whether the light is on or not. Similar to the previous question I also want to get the location of that point.

I now wonder how to use openCV for this instance (I am new). It would be easy if the light would just be one pixel, but given considerable background noise and the size of the LED, how can I detect the greatest light source in the image. I have to assume that I cannot set the exposure freely (on an iPhone).

I am new to image processing so how would I got about it?

like image 687
nambrot Avatar asked Jan 16 '12 08:01

nambrot


2 Answers

if the background is just noisy, but does not change so much you can you backgroudn subtraction:

you have 2 frames, and you do Frame2-Frame1, then you apply a threshold (the value of the threshold depends on the intensity of the LED so you should test it), and you set to black the pixles lower than the threshold and to white the pixels higher than the threshold.

this is very easy if you convert your image in a grayscale one.

should be somenthign like this:

cvAbsDiff(img2, img1, img2);
cvThreshold(img2, img2, (double)threshold_value, 255 (if you are using an rgb image), CV_THRESH_BINARY);

if your led is off you should fine just noise, while if you led is on you will expect to find a white region where your light is illuminting.

like image 184
andrea Avatar answered Dec 17 '22 02:12

andrea


I guess you cant just substract the two images to remove the noise, because there is always some movement with the camera....it cant be steady.....so u end up making a mess instead...

My call would be use "inrange" function, if a pixel is fully bright, i.e. 255 or say above 200, leave it as it is otherwise just make it zero..... thus you end up with just the led part...background gone!!

like image 38
sumit Avatar answered Dec 17 '22 02:12

sumit