def test_check_if_correct_directive_for_staying(self): directive1 = ns.scroll_pdf(250, [220, 180, 260, 270, 290, 275]) self.assertEqual(directive1, 0) directive2 = ns.scroll_pdf(250, [220, 240, 260, 270, 200]) self.assertEqual(directive2, 0) directive3 = ns.scroll_pdf(250, [490, 400, 460, 320, 290]) self.assertEqual(directive3, 0) directive4 = ns.scroll_pdf(250, [80, 160, 180, 200, 240]) self.assertEqual(directive4, 0)
y_window_eyes = [-2000] if len(y_window_eyes) <= 10: if not positions[1] == -2000: if y_window_eyes == -2000: y_window_eyes[:] = [] y_window_eyes.append(positions[1]) else: y_window_eyes.append(positions[1]) else: y_avg_eyes = np.mean(y_window_eyes) / 3 + y_avg_eyes * 2 / 3 y_window_eyes[:] = [-2000] if len(x_window_face) <= 10: if not positions[2] == -2000: if x_window_face == -2000: x_window_face[:] = [] x_window_face.append(positions[1]) else: x_window_face.append(positions[1]) else: x_avg_face = np.mean(x_window_face) / 3 + x_avg_face * 2 / 3 x_window_face[:] = [-2000] scroll_flag = ns.scroll_pdf(y_avg_eyes, y_window_eyes) nod_flag = ns.next_page(x_avg_face, x_window_face) pickle.dump(scroll_flag, open("save.p", "wb")) video.release()
def test_check_if_correct_directive_for_scrollingdown(self): directive = ns.scroll_pdf(250, [260, 200, 160, 110, 100, 75]) self.assertEqual(directive, -1)
def test_check_if_correct_directive_for_scrollingup(self): directive = ns.scroll_pdf(250, [220, 380, 360, 400, 390, 415]) self.assertEqual(directive, 1)