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?
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.
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!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With