Drawing the tracking results and masking the tracked object

We will implement one helper method, _draw_object_axes, to draw a visualization of the tracked object's X, Y, and Z axes. We will also implement another helper method, _make_and_draw_object_mask, to project the object's vertices from 3D to 2D, create a mask based on the object's silhouette, and tint this masked region yellow as a visualization.

Let's start with the implementation of _draw_object_axes. We can consider it in three stages:

  1. First, we want to take a set of 3D points located along the axes, and project these points to the 2D image space. Remember that we defined the 3D axis points in our __init__ method, in the Initializing the tracker section. They will simply serve ...

Get Learning OpenCV 4 Computer Vision with Python 3 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.