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

Tracking hand gestures in real time

Hand gestures are analyzed by the recognize function; this is where the real magic takes place. This function handles the entire process flow, from the raw grayscale image to a recognized hand gesture. It returns the number of fingers and the illustration frame. It implements the following procedure:

  1. It extracts the user's hand region by analyzing the depth map (img_gray), and returns a hand region mask (segment), like this:
def recognize(img_gray: np.ndarray) -> Tuple[int,np.ndarray]:
# segment arm region
segment = segment_arm(img_gray)
  1. It performs contour analysis on the hand region mask (segment). Then, it returns the largest contour found in the image (contour) and any convexity defects (defects), as follows:
# find the hull of the segmented area, and based on that find the
# convexity defects
contour, defects = find_hull_defects(segment)
  1. Based on the contour found and the convexity defects, it detects the number of extended fingers (num_fingers) in the image. Then, it creates an illustration image (img_draw) using (segment) image as a template, and annotates it with contour and defect points, like this:
img_draw = cv2.cvtColor(segment, cv2.COLOR_GRAY2RGB)
num_fingers, img_draw = detect_num_fingers(contour,
defects, img_draw)
  1. Finally, the estimated number of extended fingers (num_fingers), as well as the annotated output image (img_draw), are returned, as follows:
return num_fingers, img_draw

In the next section, let's learn how to accomplish hand region segmentation, which we used at the beginning of the procedure.

主站蜘蛛池模板: 新巴尔虎右旗| 桃江县| 大城县| 阳曲县| 孟津县| 民勤县| 团风县| 灵丘县| 民权县| 高邑县| 九龙县| 桃园县| 沧州市| 墨脱县| 盘山县| 渝中区| 湾仔区| 阜新市| 进贤县| 金湖县| 宜阳县| 安阳县| 巩义市| 邹城市| 左云县| 方山县| 新民市| 西城区| 苗栗县| 仁寿县| 祁阳县| 明光市| 杭锦后旗| 南皮县| 宜川县| 新乡县| 额敏县| 普定县| 固镇县| 黄浦区| 汉中市|