自学内容网 自学内容网

Opencv学习项目4——手部跟踪

上一篇博客我们介绍了mediapipe库和对手部进行了检测,这次我们进行手部关键点的连线

代码实现 

import cv2
import  mediapipe as mp

cap = cv2.VideoCapture(1)
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)
    #对RGB图像进行手部检测
    results = hands.process(imgRGB)
    print(results.multi_hand_landmarks)
    #检查是否检测到任何手部关键点
    if results.multi_hand_landmarks:
        #遍历每个检测到的手部
        for handLms in results.multi_hand_landmarks:
            mpDraw.draw_landmarks(img, handLms,mpHands.HAND_CONNECTIONS)
    cv2.imshow("image", img)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

效果演示

这样手部关键点和连接线就画好了,有兴趣的可以关注一下,谢谢 


原文地址:https://blog.csdn.net/weixin_72749746/article/details/140727021

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!