Hand Tracking using Python Step By Step

 Hand Tracking Using Python

#1 Installing Requirements 

Open CMD and Type 

# pip install mediapipe
# pip install open cv

then press enter

#2 Creating a folder and files

First, make one and give a name to the folder


Then open the folder on Code Editor and create .py file


#3 Write code and run it

import cv2
import mediapipe as mp 

cap = cv2.VideoCapture(0) 
mpHands = mp.solutions.hands
hands = mpHands.Hands()
mpDraw = mp.solutions.drawing_utils 
while True: 
 ret,img=cap.read() 
 imgBGR = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
 result = hands.process(imgBGR)
 print(result.multi_hand_landmarks) 
 if result.multi_hand_landmarks:
  for handLms in result.multi_hand_landmarks:
   mpDraw.draw_landmarks   (img, handLms,mpHands.HAND_CONNECTIONS)

 cv2.imshow('Image',img) 
 if cv2.waitKey(1)==13:
  break
cv2.destroyAllWindows()



Result




If you have any problem then contact me on telegram @odewithyash


0 Comments