上一篇博客我们介绍了mediapipe库和对手部进行了检测,这次我们进行手部关键点的连线
代码实现
import cv2
import mediapipe as mpcap = cv2.VideoCapture(1)
mpHands = mp.solutions.hands
hands = mpHands.Hands()
mpDraw = mp.solutions.drawing_utilswhile 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()
效果演示
这样手部关键点和连接线就画好了,有兴趣的可以关注一下,谢谢