Spaces:
Sleeping
Sleeping
Ziv Pollak
commited on
Commit
•
49bd2e1
1
Parent(s):
15b346a
open eyes detector
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ def isEyeOpen(image):
|
|
25 |
|
26 |
return np.mean(colors)
|
27 |
|
28 |
-
if np.mean(colors) <
|
29 |
return True
|
30 |
else:
|
31 |
return False
|
@@ -90,10 +90,12 @@ def findIris(input_img1, input_img2, input_img3, input_img4, input_img5):
|
|
90 |
rightIris_leftside[0] - sizeIncrease: rightIris_rightside[0] + sizeIncrease]
|
91 |
rightEyeOpen = isEyeOpen(rightEye)
|
92 |
|
|
|
93 |
cv2.putText(annotated_image, "Left " + str(int(leftEyeOpen)),
|
94 |
(rightIris_leftside[0] - 20, leftIris_top[1] - 10), cv2.FONT_HERSHEY_SIMPLEX,
|
95 |
1, (255, 255, 0), 1, cv2.LINE_AA)
|
96 |
'''
|
|
|
97 |
if leftEyeOpen:
|
98 |
cv2.putText(annotated_image, "Left Open " + str(leftEyeOpen),
|
99 |
(rightIris_leftside[0] - 20, leftIris_top[1] - 10), cv2.FONT_HERSHEY_SIMPLEX,
|
@@ -132,7 +134,7 @@ def findIris(input_img1, input_img2, input_img3, input_img4, input_img5):
|
|
132 |
# int(abs(rightIris_leftside[0] - rightIris_rightside[0]) / 2
|
133 |
1,
|
134 |
(0, 255, 255), 2)
|
135 |
-
|
136 |
|
137 |
|
138 |
|
@@ -154,7 +156,7 @@ def findIris(input_img1, input_img2, input_img3, input_img4, input_img5):
|
|
154 |
#cv2.imwrite(filename, annotated_image)
|
155 |
|
156 |
left = leftIris_leftside[0] - 150
|
157 |
-
right = rightIris_rightside[0] + 150
|
158 |
up = leftIris_top[1] - 50
|
159 |
down = leftIris_bottom[1] + 50
|
160 |
|
@@ -186,7 +188,6 @@ def findIris(input_img1, input_img2, input_img3, input_img4, input_img5):
|
|
186 |
cv2.drawContours(img, [contour], -1, color, 3)
|
187 |
|
188 |
|
189 |
-
|
190 |
elif (id == 2): # Looking Right so we want the left limbus
|
191 |
annotated_image = annotated_image[
|
192 |
leftIris_top[1]: leftIris_bottom[1],
|
|
|
25 |
|
26 |
return np.mean(colors)
|
27 |
|
28 |
+
if np.mean(colors) < 15:
|
29 |
return True
|
30 |
else:
|
31 |
return False
|
|
|
90 |
rightIris_leftside[0] - sizeIncrease: rightIris_rightside[0] + sizeIncrease]
|
91 |
rightEyeOpen = isEyeOpen(rightEye)
|
92 |
|
93 |
+
'''
|
94 |
cv2.putText(annotated_image, "Left " + str(int(leftEyeOpen)),
|
95 |
(rightIris_leftside[0] - 20, leftIris_top[1] - 10), cv2.FONT_HERSHEY_SIMPLEX,
|
96 |
1, (255, 255, 0), 1, cv2.LINE_AA)
|
97 |
'''
|
98 |
+
|
99 |
if leftEyeOpen:
|
100 |
cv2.putText(annotated_image, "Left Open " + str(leftEyeOpen),
|
101 |
(rightIris_leftside[0] - 20, leftIris_top[1] - 10), cv2.FONT_HERSHEY_SIMPLEX,
|
|
|
134 |
# int(abs(rightIris_leftside[0] - rightIris_rightside[0]) / 2
|
135 |
1,
|
136 |
(0, 255, 255), 2)
|
137 |
+
|
138 |
|
139 |
|
140 |
|
|
|
156 |
#cv2.imwrite(filename, annotated_image)
|
157 |
|
158 |
left = leftIris_leftside[0] - 150
|
159 |
+
right = rightIris_rightside[0] + 150 + 150
|
160 |
up = leftIris_top[1] - 50
|
161 |
down = leftIris_bottom[1] + 50
|
162 |
|
|
|
188 |
cv2.drawContours(img, [contour], -1, color, 3)
|
189 |
|
190 |
|
|
|
191 |
elif (id == 2): # Looking Right so we want the left limbus
|
192 |
annotated_image = annotated_image[
|
193 |
leftIris_top[1]: leftIris_bottom[1],
|