-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo.py
36 lines (25 loc) · 879 Bytes
/
demo.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
"""View finger tracker results live."""
from main import get_index_finger_predictor
from main import get_index_finger_bin_predictor
import cv2
def main():
cap = cv2.VideoCapture(0)
# get emotion predictor
predictor = get_index_finger_predictor()
# predictor = get_index_finger_bin_predictor()
while True:
# Capture frame-by-frame
ret, frame = cap.read()
frame = cv2.flip(frame, 1) # flip across vertical axis
frame_h, frame_w, _ = frame.shape
x, y = predictor(frame)
cv2.circle(frame, (x, y), 10, color=(0, 0, 255), thickness=-1)
# Display the resulting frame
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
if __name__ == '__main__':
main()