opencv实现手势识别

简单测试:

部分代码:

import time

from PIL import ImageGrab
from cvzone.FaceMeshModule import FaceMeshDetector
import numpy as np
import cv2

# cv2.waitKey(1)

# detector = HandDetector(detectionCon=0.5)
cap = cv2.VideoCapture(0)
detector = FaceMeshDetector(minDetectionCon=0.4)

while True:
    ImageGrab.grab().save('screen_capture.jpg', "JPEG")
    img = cv2.imread('screen_capture.jpg')
    success, photo = cap.read()
    x, y, _ = photo.shape
    img[100:100+x, 100: 100+y] = photo
    imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    imgRGB, faces = detector.findFaceMesh(imgRGB)
    #  找到图片中的手
    if faces:
        for hand in faces:
            print(hand)
    img = cv2.cvtColor(imgRGB, cv2.COLOR_RGB2BGR)
    img = cv2.resize(img, (1920 // 2, 1080 // 2))

    cv2.imshow("video", img)
    # time.sleep(1)
    key = cv2.waitKey(1)
    if key == ord('q'):
        cv2.destroyAllWindows()
        break

完整代码:

https://download.csdn.net/download/weixin_55771290/87527061

猜你喜欢

转载自blog.csdn.net/qq_38735017/article/details/129318321