skywrace

chore: Adjust pin group to set right bound

...@@ -44,6 +44,11 @@ def main(): ...@@ -44,6 +44,11 @@ def main():
44 pred = prob.argmax(axis=-1) 44 pred = prob.argmax(axis=-1)
45 return True if pred[0] == 1 else False 45 return True if pred[0] == 1 else False
46 46
47 + def get_eye_open_dlib(frame, bound):
48 + l, r = min(map(lambda x: x[0], bound)), max(map(lambda x: x[0], bound))
49 + t, b = min(map(lambda x: x[1], bound)), max(map(lambda x: x[1], bound))
50 + cv2.rectangle(frame, (l,t), (r,b), (0,255,0), 2)
51 +
47 while True: 52 while True:
48 frame = video.read() 53 frame = video.read()
49 frame = imutils.resize(frame, width=640) 54 frame = imutils.resize(frame, width=640)
...@@ -64,13 +69,12 @@ def main(): ...@@ -64,13 +69,12 @@ def main():
64 shape = predictor(gray, rect) 69 shape = predictor(gray, rect)
65 shape = face_utils.shape_to_np(shape) 70 shape = face_utils.shape_to_np(shape)
66 71
67 - r_eye = shape[36:43] 72 + r_eye = shape[36:42]
68 l_eye = shape[42:48] 73 l_eye = shape[42:48]
69 - mouth = shape[48:69] 74 + mouth = shape[48:]
70 - for (x, y) in l_eye: 75 + get_eye_open_dlib(frame, r_eye)
71 - cv2.circle(frame, (x, y), 2, (0, 255, 0), -1) 76 + get_eye_open_dlib(frame, l_eye)
72 - for (x, y) in r_eye: 77 +
73 - cv2.circle(frame, (x, y), 2, (0, 255, 0), -1)
74 for (x, y) in mouth: 78 for (x, y) in mouth:
75 cv2.circle(frame, (x, y), 2, (0, 255, 0), -1) 79 cv2.circle(frame, (x, y), 2, (0, 255, 0), -1)
76 80
......