March 2020
Intermediate to advanced
366 pages
9h 8m
English
In OpenCV, we can easily draw matches using cv2.drawMatches. Here, we create our own function for educational purposes as well as for ease of customization of function behavior:
def draw_good_matches(img1: np.ndarray, kp1: Sequence[cv2.KeyPoint], img2: np.ndarray, kp2: Sequence[cv2.KeyPoint], matches: Sequence[cv2.DMatch]) -> np.ndarray:
The function accepts two images, namely, in our case, the image of the object of interest and the current video frame. It also accepts keypoints from both images as well as the matches. It will draw the images next to each other on a single illustration image, illustrate the matches on the image, and return the image. The latter is achieved with the following steps:
Read now
Unlock full access