官术网_书友最值得收藏!

Finding the convexity defects of a convex hull

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), farthest_pt_index (the index of the farthest point from the convex hull within the defect), and fixpt_depth (the distance between the farthest point and the convex hull).

We will make use of this information in just a moment when we try to estimate the number of extended fingers.

For now, though, our job is done. The extracted contour (max_contour) and convexity defects (defects) can be returned to recognize, where they will be used as inputs to detect_num_fingers, as follows:

return max_contour, defects 

So, now that we have found the defects, let's move on and learn how to perform hand gesture recognition using the convexity defects, which will bring us toward the completion of the app.

主站蜘蛛池模板: 略阳县| 河池市| 马关县| 贺兰县| 桂东县| 东城区| 天柱县| 新民市| 玛曲县| 将乐县| 南投县| 信阳市| 定州市| 安福县| 勐海县| 阳城县| 武山县| 阿拉尔市| 汝城县| 延川县| 右玉县| 阜新| 灵宝市| 武宣县| 临高县| 连州市| 麻江县| 西充县| 兴仁县| 大竹县| 龙州县| 巧家县| 阳信县| 绥芬河市| 鄂伦春自治旗| 阿鲁科尔沁旗| 桃园县| 中江县| 白山市| 古浪县| 常山县|