开发者

Python OpenCV Tracking Points

开发者 https://www.devze.com 2023-02-27 11:09 出处:网络
Using Python, OpenCV, and live webcam input, I can\'t figure out how to set a point based on 开发者_JS百科an x y coordinate and track where it moves.Below is a simple example to track a yellow object.

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


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.


There are a few blogs that explain the basics. Check out this one: Object tracking in OpenCV and Python 2.6.

Edit: I don't think you can track arbitrary points. To be able to make a correspondence between one point in two images, you need to know something unique about the point to track. This is often done with interest points, which are "unique enough" to be compared across images. Other methods are based making the point easy to detect using a projection scheme.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号