- OpenCV 4 with Python Blueprints
- Dr. Menua Gevorgyan Arsen Mamikonyan Michael Beyeler
- 242字
- 2021-06-24 16:50:04
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.
- Java語言程序設(shè)計
- 程序員面試白皮書
- Python數(shù)據(jù)分析入門與實戰(zhàn)
- 軟件架構(gòu)設(shè)計:大型網(wǎng)站技術(shù)架構(gòu)與業(yè)務(wù)架構(gòu)融合之道
- Machine Learning with R Cookbook(Second Edition)
- Mastering Kotlin
- 新手學(xué)Visual C# 2008程序設(shè)計
- MySQL數(shù)據(jù)庫基礎(chǔ)實例教程(微課版)
- Python編程從0到1(視頻教學(xué)版)
- Python極簡講義:一本書入門數(shù)據(jù)分析與機器學(xué)習(xí)
- Linux C編程:一站式學(xué)習(xí)
- Emgu CV Essentials
- Hands-On Kubernetes on Windows
- Buildbox 2.x Game Development
- 區(qū)塊鏈項目開發(fā)指南