How it works...
To create the Median Flow tracker, we need to use cv2.TrackerMedianFlow_create. This function returns an instance of our tracker. Next, the tracker should be initialized with the object to follow. This can be done with the init function call. This function should be invoked for the tracker instance with the following arguments: the frame with the object to track and the bounding box of the object in an (x, y, width, height) format. The function returns True if initialization has been completed successfully.
When we have a new frame, we want to get a new bounding box for the object. To do this, we need to call the tracker instance's update function, with the new frame as an argument. The values returned from this routine are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access