-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (39 loc) · 1.2 KB
/
main.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
import cv2
from cvzone.HandTrackingModule import HandDetector
import time
detector = HandDetector(maxHands=1, detectionCon=0.8)
video = cv2.VideoCapture(0)
while True:
_, img = video.read()
img = cv2.flip(img, 1)
hand = detector.findHands(img, draw=False)
if hand:
lmlist = hand[0]
if lmlist:
fingerup = detector.fingersUp(lmlist)
if fingerup == [0, 0, 0, 0, 0]:
print("0")
if fingerup == [0, 1, 0, 0, 0]:
print("1")
if fingerup == [0, 1, 1, 0, 0]:
print("2")
if fingerup == [0, 1, 1, 1, 0]:
print("3")
if fingerup == [0, 1, 1, 1, 1]:
print("4")
if fingerup == [1, 1, 1, 1, 1]:
print("5")
if fingerup == [1, 0, 0, 0, 0]:
print("6")
if fingerup == [1, 1, 0, 0, 0]:
print("7")
if fingerup == [1, 1, 1, 0, 0]:
print("8")
if fingerup == [1, 1, 1, 1, 0]:
print("9")
cv2.imshow("Video",img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
time.sleep(0.3)
video.release()
cv2.destroyAllWindows()