Python OpenCV Tracking Points


Using Python, OpenCV, and live webcam input, I can't figure out how to set a point based on an x y coordinate and track where it moves.

4/20/2011 5:38:31 AM

Below is a simple example to track a yellow object.

Here is the method to track yellow color:

1) Extract the first frame of video

2) Convert frame into HSV color space. Take H plane and threshold it for yellow color so that you get binary image with yellow object as white (also called blob) and remaining as black.

3) Now you find centre point of blob. You can use moments or contours(especially if you have more than one blob. In the example above, very simple logic is used. Just find leftmost,rightmost,topmost and bottommost points on blob and draw a rectangle around it). And store this values.

4) Extract next frame and follow all above steps to get new position. Join these two position and draw a line.


1/16/2012 10:33:27 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow