This is a quick attempt to track the dot from a red laser pointer.
Right now, the code performs the following steps, and displays the results in several HighGUI windows. The general idea is to:
- Grab the video frame.
- Convert it to HSV
- Split the frame into individual components (separate images for H, S, and V)
- Apply a threshold to each compenent (hopefully keeping just the dot from the laser)
- Perform an AND operation on the 3 images (which "should" cut down on false positives)
- Identify the _best_ location for the identified laser. ie: x,y coordinates in the image.
- Do something interesting with it; e.g. draw a circle around it, control the mouse cursor, build a game, etc.
This requires Python and the Python wrapper for OpenCV.
You'll need to look at the source, but there are global constants at the top
of the laser_tracker.py
file. You may need to adjust these to suite your
situation.
This code is MIT-licensed. You can basically do whatever you want with it.