2024-05-14T16:47:19.png

from XEdu.hub import Workflow as wf
import cv2

cap = cv2.VideoCapture(0)
det = wf(task='det_hand')#bodydetect')  # 实例化detect模型
hand = wf(task='pose_hand21') # 实例化关键点检测模型

while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break

    bboxs = det.inference(data=frame, thr=0.3)
    img = frame

    for i in bboxs:
        keypoints,img = hand.inference(data=frame,img_type='cv2',bbox=i) # 关键点检测推理

    cv2.imshow('video', img)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

发表评论