-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetector.py
46 lines (32 loc) · 818 Bytes
/
detector.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import cv2
from cvzone.HandTrackingModule import HandDetector
import keyboard
from objects import setJson
detector=HandDetector(
detectionCon=0.8,
maxHands=1
)
video = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_SIMPLEX
while(True):
ret, frame = video.read()
hand, img= detector.findHands(frame, draw=True)
if (hand):
fingers=hand[0]
fingerUp=detector.fingersUp(fingers)
setJson({
"handCount":fingerUp,
"hand":True
})
fingerCount = fingerUp.count(1)
if(fingerCount == 0):
keyboard.press_and_release("space")
else:
setJson({
"hand":False
})
cv2.imshow("Frame",frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video.release()
cv2.destroyAllWindows()