Python OpenCV Tracking Points


Question

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.

1
4
4/20/2011 5:38:31 AM

Below is a simple example to track a yellow object.

https://github.com/abidrahmank/OpenCV-Python/blob/master/Other_Examples/track_yellow_draw_line.py

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.

Over.

4
1/16/2012 10:33:27 AM

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