forked from freedomwebtech/hand-distance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hand.py
32 lines (24 loc) · 712 Bytes
/
hand.py
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
27
28
29
30
31
32
import cv2
from cvzone.HandTrackingModule import HandDetector
detector=HandDetector(detectionCon=0.5,maxHands=2)
cap=cv2.VideoCapture(0)
while True:
ret,frame=cap.read()
frame=cv2.flip(frame,1)
hands,frame=detector.findHands(frame)
if hands:
hands1=hands[0]
bbox=hands1["bbox"]
x,y,w,h=bbox
fingers1=detector.fingersUp(hands1)
# print(fingers1)
print(bbox)
if len(hands)==2:
hands2=hands[1]
fingers2=detector.fingersUp(hands2)
# print(fingers1,fingers2)
frame=cv2.imshow("FRAME",frame)
if cv2.waitKey(1)&0xFF==27:
break
cap.relase()
cv2.destroyAllWindows()