基于mediapipe的手势识别

安装opencv:pip install opencv-python

安装mediapipe:pip install mediapipe

基于mediapipe的手势识别_第1张图片

 

基于mediapipe的手势识别_第2张图片

 

draw_utils.py:

import cv2
import numpy as np


def draw_line(img, width, height,  hand, start_index, stop_index):
    for i in range(start_index, stop_index):
        x1, y1 = int(hand.landmark[i].x * width), int(hand.landmark[i].y * height)
        x2, y2 = int(hand.landmark[i + 1].x * width), int(hand.landmark[i + 1].y * height)
        cv2.line(img, (x1, y1), (x2, y2), (255, 255, 255), 2)


def draw_hand(img, width, height, hand):
    # 画圆
    for i in range(21):
        pos_x = hand.landmark[i].x * width  # hand.landmark[i].x为归一化后的

你可能感兴趣的:(pytorch,tensorflow,mediapipe,人手关键点检测,手势识别)