Detect Multiple LEDs and their flashing frequency

asked 2015-06-06 02:16:30 -0600

Prem gravatar image

updated 2015-06-11 02:03:33 -0600

C:\fakepath\code.pngimage descriptionimage description(/upfiles/14337421785288362.jpg)Hi All,

I am new to openCV. I am trying to detect the position and frequency of multiple LEDs using OpenCV. Kindly guide me how can I achieve the same? I couldn't use the HSV conversion method because there may be other lights brighter than LED as well. Here is the basic logic. 1. LEDs are flashing at predefined rate. My camera has been set to 90 fps and the LEDs have frequency of 90Hz, 45Hz, 30Hz and 15Hz ( these frequencies and camera frame rate are known parameters ) 2. Now I need to find the location of these lights within camera frame in any lightning condition. Be it night where the light is the brightest in the room or be it sunlight where it may not be the brightest object in the scene.

I would appreciate the help.

edit retag flag offensive close merge delete

Comments

1

are the LEDS colorful or not? if yes then color segmentation I think should be your first try...

theodore gravatar imagetheodore ( 2015-06-06 08:16:39 -0600 )edit

Is the camera synchronized with the LEDs?

FooBar gravatar imageFooBar ( 2015-06-06 11:39:37 -0600 )edit
1

You like Shannon. How long led are flashing ? what is time integration of your camera?

LBerger gravatar imageLBerger ( 2015-06-06 16:04:15 -0600 )edit

@theodore: the LEDs are all white, I tried color segmentation and was just able to detect the position of LEDs in an environment where there are no other illuminations that have same or more brightness than LEDs. With my limited programming skills I was not able to find a logic to detect frequency in this controlled environment as well. I need this to work in any environment. @FooBar Though the camera is not synchronized with the LEDs, Camera fps has been set as multiple of LED frequency. As stated in my question camera frame rate is 90fps and LED frequency has been set as 90, 45, 30 and 15 hz. @LBerger LEDs will be flashing indefinitely. I would like to detect LED positions and frequency as efficiently as possible ( processing wise and time wise ) after the camera is focused on the LEDs.

Prem gravatar imagePrem ( 2015-06-06 20:34:53 -0600 )edit

@LBerger pardon my ignorance, i couldn't find time integration of my camera model in it's data sheet. This is my camera http://www.ptgrey.com/grasshopper3-41...

Prem gravatar imagePrem ( 2015-06-07 01:43:09 -0600 )edit

So my english is bad it was exposure time p46 If your FPS is 90Hz and your led flash at frequency F then there is no problem with 15 and 30 hz you will see a spot for 15 hz3 images on and three images off for 30Hz 1 images on and two images off (or 2 and 1) and for 45Hz I don't know like 90Hz may be sometime 90 images on and 90 images off. You cannot detect your LED in 1 second you need time and its depends of image context

LBerger gravatar imageLBerger ( 2015-06-07 03:17:32 -0600 )edit
1

@Prem, do you have control on the signal that is attached to the LED? Because simply grabbing that signal and looking for its edges can be way more efficient and far more correct than simply using computer vision for this. As to the detection of the LEDS, the most applied technique in machine vision is to add a filter before your camera lens, which has a band pass filter around the frequency of your LED. This will remove about all other signals. This is again far more effective and robust than simply using segmentation techniques like you experienced yourself.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-06-07 04:11:36 -0600 )edit

@LBerger I have control over frequency of LED so the frequency is not an issue. I can bring down (or change) the frequency so that the LED with maximum frequency has one image on and one image off. You mentioned exactly what I want to achieve. Here is what i thought, 1st LED has one image on, one image off, 2nd LED has two image on and two image off, 3rd LED has three image on and 3 image off and the 4th LED has four image on and four image off. I am planning to capture say 20 images and check for the pattern and spot four LEDs. My problem is I lack the OpenCV knowledge to do so. Can you please guide me how can I achieve this?

Prem gravatar imagePrem ( 2015-06-07 09:13:48 -0600 )edit

@StevenPuttemans thanks a lot for the insight. As you pointed out band pass filter attached to the camera would be the most efficient way to achieve this. Unfortunately I am not allowed to use the hardware band pass filter so I need software band pass filter implementation in OpenCV to locate and calculate frequency of these LEDs.

Prem gravatar imagePrem ( 2015-06-07 09:22:59 -0600 )edit

Can you click at led position at begining of your process ? if yes it's not image processing but pixel processing. If you don't know position may be you can start with threshold difference of two frames. it can work if nothing is moving in your video. if something is moving then you should post two images...

LBerger gravatar imageLBerger ( 2015-06-07 09:35:49 -0600 )edit

@LBerger, No I can not click at LED position at the beginning of the process. LEDs are fixed however camera might be moving. Kindly bear with me and explain what do you mean by "if something is moving then you should post two images...".

Prem gravatar imagePrem ( 2015-06-07 09:52:02 -0600 )edit

Insert an image in your post with one led on and another image with led off and some moving object : an example of your problem

LBerger gravatar imageLBerger ( 2015-06-07 09:56:15 -0600 )edit

In karma it shows I can upload file... but where is the link to upload file??

Prem gravatar imagePrem ( 2015-06-08 00:36:20 -0600 )edit
1

You have to make difference between two frames and threshold your result after look for connectedComponents with stat. For example your led is blinking at (1178,1136) and surface is 24096 pixels. May be you can look for led coordinates at the beginning and after you do not need to this operation : only track pixel at coordinate 1178,1136. It looks like a good exercise to learn opencv!

LBerger gravatar imageLBerger ( 2015-06-08 01:43:50 -0600 )edit

@LBerger I tried the difference and threshold method. It worked if there was no other light source within the frame. How can I isolate the 5th light source which is not blinking or blinking at some random frequency? Kindly give me some more hint on counting the frequency as well. Thanks a lot for your time and interest in my query.

Prem gravatar imagePrem ( 2015-06-08 06:09:51 -0600 )edit

5th light source. Is it light comming from the window? With difference you can only detect pixels changing. You must detect light position first using may be 270 frames (3s) and after track pixels. May be you can try example opencv_contrib\modules\optflow\samples\motempl.cpp to locate your led.

LBerger gravatar imageLBerger ( 2015-06-08 07:10:46 -0600 )edit

Yes it may be coming from the window... or entire setup may be outside... where there are many illuminations with or without frequency. I will go through the sample you mentioned and will ask for help in case of confusions. :). This sample is too complicated for me to understand on my own. Is there any URL that explains it in detail?

Prem gravatar imagePrem ( 2015-06-08 07:39:21 -0600 )edit

@LBerger I wrote attached code just to detect the contours in each Threshold Image. I decided to work on static images first then I would work with video. Up to this point contours from all the frames (as you suggested 270 frames) is stored in vector. Now kindly guide me how can I check for the value of pixel at each contour? then select the contours of interest from this list.

Prem gravatar imagePrem ( 2015-06-11 01:49:18 -0600 )edit