How to do it...

The visual object-tracking problem generally assumes that no prior knowledge about the objects to be tracked is available. Tracking is, therefore, initiated by identifying the object in a frame, and tracking must start at this point. The initial identification of the object is achieved by specifying a bounding box inside which the target is inscribed. The objective of the tracker module is to reidentify this object in a subsequent frame.

The cv::Tracker class of OpenCV that defines the object-tracking framework has, therefore, two main methods. The first one is the init method that is used to define the initial target bounding box. The second one is the update method that outputs a new bounding box, given a new frame. Both ...

Get OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.