安装opencv:pip install opencv-python
安装mediapipe:pip install mediapipe
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为归一化后的