import mediapipe as mp
import cv2
cap = cv2.VideoCapture(0)
mphands = mp.solutions.hands
hands = mphands.Hands()
mpdrow = mp.solutions.drawing_utils
while True:
succes,img = cap.read()
img = cv2.flip(img,1)
image_weith,image_hieth,_ = img.shape
imgRGB = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
results = hands.process(imgRGB)
if results.multi_hand_landmarks:
for hand in results.multi_hand_landmarks:
for i in range(21):
x = hand.landmark[i].x*image_weith
y = hand.landmark[i].y*image_hieth
mpdrow.draw_landmarks(img,hand,mphands.HAND_CONNECTIONS)
cv2.imshow("hands",img)
key = cv2.waitKey(1)
if key == 27:
break
cap.release()