基本信息
源码名称:opencv手部检测
源码大小:0.74KB
文件格式:.py
开发语言:Python
更新时间:2024-05-09
   源码介绍

通过mediapipe识别手部

import cv2 import numpy as np import mediapipe as mp import time #检测手部关键点 hand0hand1效果一样 # hand1彩色绘制 # hand3在左上角显示手指个数 # hand4将手框起来,显示手指个数 #hand5 控制音量 # hand6可以显示左右手left right cap = cv2.VideoCapture(0)
mpHands = mp.solutions.hands
hands = mpHands.Hands()
mpDraw = mp.solutions.drawing_utils while True:
    success, img = cap.read()
    imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    result = hands.process(imgRGB) if result.multi_hand_landmarks: for handLms in result.multi_hand_landmarks:
            mpDraw.draw_landmarks(img, handLms, mpHands.HAND_CONNECTIONS)
    cv2.imshow("Image", img)
    cv2.waitKey(1)