forked from antoinelame/GazeTracking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions_Navee.py
88 lines (70 loc) · 2.62 KB
/
Functions_Navee.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import cv2
from gaze_tracking import GazeTracking
import time
from playsound import playsound
def workingTime(time1,newTime,attention,timeLeft):
#todo esto se define en la primera iteracion SOLAMENTE
_, frame = webcam.read()
gaze.refresh(frame)
located= gaze.pupils_located
preLoop=time.time()
while located == False:
noPupilTime=time.time()
if (noPupilTime-preLoop) > 10:
#Aqui lanzamos la alerta de tiempo sin ver la pantalla
playsound(attention)
print("pon atencion!")
break
_, frame = webcam.read()
gaze.refresh(frame)
located= gaze.pupils_located
if located == True:
break
if (times-newTime)> 1200:
if timeLeft == 0:
print("solo quedan 5 minutos, tu puedes!")
#aqui se muestra una notificacion de que "solo quedan 5 minutos mas! Tu puedes!"
#Breaktime es un contador de descanso, sea largo o corto
def breakTime(shortTime,longTime): #hay que ver como incorporar los ciclos
print("Time for a short break!")
time1=time.time()
time2=time.time()
while (time2-time1)<shortTime:
time2=time.time()
print("Time for work again!")
print("Time for a long break!")
while(time2-time1)<longTime:
time2=time.time()
#falta arreglar la funcion de calibracion
def calibration():
gaze=GazeTracking()
webcam = cv2.VideoCapture(0)
while True:
# We get a new frame from the webcam
_, frame = webcam.read()
# We send this frame to GazeTracking to analyze it
gaze.refresh(frame)
if gaze.is_blinking():
text = "Blinking"
elif gaze.is_right():
text = "Looking right"
elif gaze.is_left():
text = "Looking left"
elif gaze.is_center():
text = "Looking center"
else:
text="Not Detected"
exit='Press ESC to exit'
cv2.putText(frame, text, (90, 60), cv2.FONT_HERSHEY_DUPLEX, 1.6, (147, 58, 31), 2)
cv2.putText(frame, exit, (0, 400), cv2.FONT_HERSHEY_DUPLEX, 1.6, (147, 58, 31), 2)
left_pupil = gaze.pupil_left_coords()
right_pupil = gaze.pupil_right_coords()
cv2.putText(frame, "Left pupil: " + str(left_pupil), (90, 130), cv2.FONT_HERSHEY_DUPLEX, 0.9, (147, 58, 31), 1)
cv2.putText(frame, "Right pupil: " + str(right_pupil), (90, 165), cv2.FONT_HERSHEY_DUPLEX, 0.9, (147, 58, 31), 1)
cv2.imshow("Demo", frame)
if cv2.waitKey(1)==27:
break
webcam.release()
cv2.destroyAllWindows()
#def soundSelect():
#definir los sonidos como variables globales