mediapipe 发表于 2025-03-06 分类于 it midiapipe是一个实时计算机视觉框架 能够高效处理 手势识别、姿态估计、物体检测、语音处理 等任务 用计算图进行数据处理 预训练模型有这些: 手部跟踪 MediaPipe Hands 人体姿势估计 MediaPipe Pose 面部检测 MediaPipe Face Detection 面部网格 MediaPipe Face Mesh 物体检测 MediaPipe Objectron语音处理 MediaPipe Audio 主要看手部跟踪部分 MediaPipe Hands 是一个 高效的手部关键点检测模型,可检测 21 个关键点,用于手势识别。 12345678910111213141516171819202122232425262728import cv2import mediapipe as mpmp_hands = mp.solutions.handsmp_draw = mp.solutions.drawing_utilshands = mp_hands.Hands()cap = cv2.VideoCapture(0)while cap.isOpened(): success, frame = cap.read() if not success: continue frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) results = hands.process(frame_rgb) if results.multi_hand_landmarks: for hand_landmarks in results.multi_hand_landmarks: mp_draw.draw_landmarks(frame, hand_landmarks, mp_hands.HAND_CONNECTIONS) cv2.imshow('MediaPipe Hands', frame) if cv2.waitKey(1) & 0xFF == ord('q'): breakcap.release()cv2.destroyAllWindows()