- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHandTrackingRealTimeCPU.py
More file actions
Latest commit
26 lines (19 loc) · 940 Bytes
/
Copy pathHandTrackingRealTimeCPU.py
File metadata and controls
26 lines (19 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
importcv2
importmediapipeasmp
# Initializing Hand Tracking Modules
mpHands=mp.solutions.hands
Hands=mpHands.Hands()
mpDraw=mp.solutions.drawing_utils
# Capturing Video From Camera
cap=cv2.VideoCapture(0)
# Checking Camera is Opened or Not
while (cap.isOpened()):
success , img=cap.read() # reading Frame
converted_image=cv2.cvtColor(img,cv2.COLOR_BGR2RGB) # converting BGR to RGB
results=Hands.process(converted_image) # Processing Image for Tracking
ifresults.multi_hand_landmarks: # Getting Landmark(location) of Hands if Exists
forhand_in_frameinresults.multi_hand_landmarks: # looping through hands exists in the Frame
mpDraw.draw_landmarks(img,hand_in_frame, mpHands.HAND_CONNECTIONS) # drawing Hand Connections
cv2.imshow("Hand Tracking - Code Terra", img) # showing Video
ifcv2.waitKey(1) ==113: # 113 - Q : press on Q : Close Video
break