add unit test to check left eye is on the left with respect to the person instead of observer

This commit is contained in:
Sefik Ilkin Serengil 2024-03-24 16:32:59 +00:00
parent ad80a31807
commit 519c48e58d
2 changed files with 16 additions and 1 deletions

View File

@ -19,6 +19,12 @@ def test_different_detectors():
assert "y" in img_obj["facial_area"].keys()
assert "w" in img_obj["facial_area"].keys()
assert "h" in img_obj["facial_area"].keys()
# is left eye set with respect to the person instead of observer
assert "left_eye" in img_obj["facial_area"].keys()
assert "right_eye" in img_obj["facial_area"].keys()
right_eye = img_obj["facial_area"]["right_eye"]
left_eye = img_obj["facial_area"]["left_eye"]
assert left_eye[0] > right_eye[0]
assert "confidence" in img_obj.keys()
img = img_obj["face"]

View File

@ -57,7 +57,7 @@ for df in dfs:
logger.info(df)
expand_areas = [0, 25]
expand_areas = [0]
img_paths = ["dataset/img11.jpg", "dataset/img11_reflection.jpg"]
for expand_area in expand_areas:
for img_path in img_paths:
@ -86,6 +86,15 @@ for expand_area in expand_areas:
assert isinstance(face_obj["facial_area"]["right_eye"][0], int)
assert isinstance(face_obj["facial_area"]["right_eye"][1], int)
# left eye is really the left eye of the person
if (
face_obj["facial_area"]["left_eye"] is not None
and face_obj["facial_area"]["right_eye"] is not None
):
re_x = face_obj["facial_area"]["right_eye"][0]
le_x = face_obj["facial_area"]["left_eye"][0]
assert re_x < le_x, "right eye must be the right eye of the person"
assert isinstance(face_obj["confidence"], float)
assert face_obj["confidence"] <= 1