views:

121

answers:

3

Hi all, I want to track a laser light dot(which is on a wall) with a webcam and i am using openCV to do this task. can anybody suggest me a way to do it with C++.

Thank you !

+3  A: 

Let say you use a laser of one of these colors: red, green, blue. If the laser dot appears very bright (at least in one channel, e.g. red) then simply thresholding the image/channel at, say greyvalue of 200, will leave you with a few candidates for the laser light. If the other channels are dark(er) in this area, then you know it is a bright light of the right color. A little filtering by size, and you have a good chance of finding the spot.

Adi
@Adi: thanks for the reply i have a wall and it is being projected so, when i treshold the image and look for the red channel sometimes the red color in the projected surface may cause some trouble.
Keshan
+1  A: 

If you stick a IR filter on your webcam, your projection will not be picked up, making the detection of the laser point much easier (using simple background subtraction e.t.c) That's assuming the laser pointer emits IR light...

max
+1  A: 

You have three options depending on the stability of your background, and the other things you want to do with the image.

You can make your image so dark that the only thing you can see is the laser-point. You do this by closing the diaphragm and/or reducing the shutter time. Even with cheap webcams this can usually be done in the driver. Once you've done this the job of finding the laser point is very easy. You make the image as dark as possible because usually the point where the laser shines is way too bright for the camera to pick up. This means (as you have experienced) that you cant discern between the light laser dot and other light objects in the image. By making it darker you now can do this.

If you have other uses for your image (showing it to people) and your background is stable you can also use the average of the last few video images as a "background" and then find the spot where there is a large difference between that background and the newest image. This is usually where the laser is pointed (again, if your background is stable enough) .

Finally, if your background is not stable and you don't want to make your image very dark your final option is to look for all pixels that are both very bright, and brighter in the red channel than they are in green and blue (if you are using a red laser). This system will still be distracted by white spots, but not as much as just finding the bright pixels. If the centre of your laser-pointer spot is indeed showing up as bright white regardles of laser colour then this technique will allow you to find "rings" around this bringht spot (the outerpart of the dot where the laser is not as bright as it is in the centre so that it shows up with the actual colour of the laser in the image). You can then use simple morphological operations, (probably closing is enough) to fill these circles.

jilles de wit
I think i'd better try the first two options and seems it is possible :). Thank you very much.
Keshan