-
Notifications
You must be signed in to change notification settings - Fork 2
/
runwNotes.py
38 lines (32 loc) · 1.07 KB
/
runwNotes.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
import cv2
import pynput
from pynput.keyboard import Key, Controller
from ContinuousGesturePredictor import continuousGesturePredictor
#Open notes and test inputs
#Requires pynput installed -> pip install pynput
#Instead of pynput, other libraries can be used according to your preference: keyboard, pyautogui
keyboard = Controller()
camera=cv2.VideoCapture(0)
predizGesto=continuousGesturePredictor()
while(True):
_, frame = camera.read()
predizGesto.main(frame)
prediction = predizGesto.className
if predizGesto.keypress == ord("q"): #Press 'q' to exit
break
#Assign actions for each prediction
if prediction == "Fist":
keyboard.press('a')
keyboard.release('a')
elif prediction == "Joinha":
keyboard.press('b')
keyboard.release('b')
elif prediction == "Ok":
keyboard.press('c')
keyboard.release('c')
elif prediction == "Palm":
keyboard.press(Key.space)
keyboard.release(Key.space)
elif prediction == "Swing":
keyboard.press('d')
keyboard.release('d')