Wesley King said:
Hi,
I am using a webcam with an Infrared filter covering its lense
blocking all ambient light. I must track the movement of one pulsed
LED. I've tried looking for help on the web, however the articles I
find talk about motion detection with multiple cameras and sensors,
they are simply overcomplicated. Can anyone please direct me to more
suitable help,
Cheers,
Wesley.
Here is an outline for you...
Capture images from the webcam
Logitech provide a free SDK for their cameras that is easy to use
You could look at video for windows and MCI, or DirectShow
You could start from Intel OpenCV (
www.sourceforge.net/opencv) or MS
VisionSDK (
http://research.microsoft.com/projects/VisSDK/) both provide
video capture frameworks
If you have control of the LED I would suggest that you take pairs of
images. One with the LED off and one with it on.
Subtract one image from the other and you should have a black scene with a
bright LED.
Given that you are IR filtering the camera the background may be much darker
than the LED anyway and you can skip the subtraction.
Given a dark image with one bright spot you can examine every pixel (or
every nth pixel for speed) looking for the brightest pixel in the image. If
you don't need much accuracy that might be enough. More likely you will want
to find the centroid or centre of gravity (COG) of the bright spot. If all
LED pixels are brighter than all other pixels in the image you can simply
average the x and y coordinates of all the pixels brighter than X (the
threshold, set to distinguish between background and LED).
If you have bright reflections and other clutter you may want to measure the
size of the spots you find and discard any bigger than A1 and smaller than
A2. You can measure area using a flood-fill algorithm centred on your
brightest pixel but the normal method is connected component labelling,
contour finding or blob labelling. OpenCV has functions to do this. Search
for those terms for more info. From a labelled blob or contour you can get
area and centroid.
If your scene is cluttered or the LED may be occluded by other objects in
the scene you may need to do motion track filtering. A filter commonly used
for this is a Kalman filter. This can predict where a tracked object will be
at a given time from now based on its motion so far. A simpler option is to
assume the new position is the bright spot closest to the previous position.
All that gets you the x,y position of the target in the image plane. If you
just want to move the camera to follow the light you can calculate the
off-centre error and feed it to your pan and tilt servos to centre the LED
in the image.
If you need to relate the LED's position to the real world that is a bit
more involved.
Graham