March 2020
Intermediate to advanced
366 pages
9h 8m
English
As is evident from the preceding screenshot, not all points on the convex hull belong to the segmented hand region. In fact, all the fingers and the wrist cause severe convexity defects—that is, points of the contour that are far away from the hull.
We can find these defects by looking at both the largest contour (max_contour) and the corresponding convex hull (hull), as follows:
defects = cv2.convexityDefects(max_contour, hull)
The output of this function (defects) is a NumPy array containing all defects. Each defect is an array of four integers that are start_index (index of the point in the contour where the defect begins), end_index (index of the point in the contour where the defect ends), ...