def _are_eyes_correct()

in source/backend/chalicelib/pose.py [0:0]


def _are_eyes_correct(expected, face):
    are_open = face['EyesOpen']['Value']
    _log.debug(f'Eyes open: {are_open}')
    if (expected == 'CLOSED' and are_open) or (expected != 'CLOSED' and not are_open):
        return False

    eye_left, eye_right = _get_eyes_coordinates(face['Landmarks'])
    _log.debug(f'Eyes coordinates - Left: {eye_left} Right: {eye_right}')
    eye_left_direction = _get_eye_direction(eye_left)
    _log.debug(f'Left eye direction: {eye_left_direction}')
    if _is_eye_opposite_direction(eye_left_direction, expected):
        _log.debug(f'Wrong left eye direction. Expected: {expected} Actual: {eye_left_direction}')
        return False
    eye_right_direction = _get_eye_direction(eye_right)
    _log.debug(f'Right eye direction: {eye_right_direction}')
    if _is_eye_opposite_direction(eye_right_direction, expected):
        _log.debug(f'Wrong right eye direction. Expected: {expected} Actual: {eye_right_direction}')
        return False
    return True