from hermes_face.gaze import Target, gaze_from_pixel, pick_target def test_centre_is_straight_ahead(): assert gaze_from_pixel(648, 486, 1296, 972) == (0.0, 0.0) def test_person_on_the_image_right_is_the_viewers_left_on_the_display(): gx, gy = gaze_from_pixel(1296, 486, 1296, 972) assert gx == -1.0 and gy == 0.0 def test_person_high_in_the_image_is_up_on_the_display(): assert gaze_from_pixel(648, 0, 1296, 972) == (0.0, -1.0) def test_off_image_positions_are_clamped(): assert gaze_from_pixel(5000, -5000, 1296, 972) == (-1.0, -1.0) def test_pick_target_prefers_a_recognised_face_then_the_biggest(): small_known = Target(100, 100, 50, 60, 0.9, 'owner') big_unknown = Target(500, 400, 300, 400, 0.9, '') mid_unknown = Target(300, 300, 200, 250, 0.9, '') assert pick_target([big_unknown, small_known]) is small_known assert pick_target([mid_unknown, big_unknown]) is big_unknown assert pick_target([]) is None