Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat task 2403 eye coordinates in biology #1140

Merged
merged 5 commits into from
Mar 24, 2024

Conversation

serengil
Copy link
Owner

Tickets

#1139

What has been done

With this PR, we are now setting left and right eye with respect to the person instead of observer. This approach is adopted in biology as well.

How to test

make lint && make test

now, left eye is the one on the left with respect to the person
instead of observer
@serengil
Copy link
Owner Author

Proof of concept

from deepface import DeepFace
import matplotlib.pyplot as plt
import cv2

img_path = "/Users/sefik/Desktop/target.jpg"
img = cv2.imread(img_path)

detector_backends = [
    "opencv",
    "ssd",
    "dlib",
    "mtcnn",
    "fastmtcnn",
    "retinaface",
    # "mediapipe"
    "yunet",
    "yolov8"
]

for detector_backend in detector_backends:
    face_objs = DeepFace.extract_faces(
        img_path=img_path,
        detector_backend=detector_backend,
        target_size=None,
        # expand_percentage=0,
    )
    fig = plt.figure(figsize=(10, 10))
    for face_obj in face_objs:
        face = face_obj["face"]

        print(detector_backend)
        facial_area = face_obj["facial_area"]
        x = facial_area["x"]
        y = facial_area["y"]
        w = facial_area["w"]
        h = facial_area["h"]
        le = facial_area["left_eye"]
        re = facial_area["right_eye"]
        current_img = img.copy()
        current_img = cv2.rectangle(current_img, (x, y), (x + w, y + h), (67, 67, 67), 1)
        current_img = cv2.circle(current_img, (le), radius=5, color=(0, 0, 255), thickness=-1) # red
        current_img = cv2.circle(current_img, (re), radius=5, color=(255, 0, 0), thickness=-1) # blue

        plt.imshow(current_img[:,:,::-1])
        plt.axis("off")
        plt.show()
       
        print("-----------")

Proof of work

Screen Shot 2024-03-24 at 16 32 09

@serengil serengil merged commit 329606f into master Mar 24, 2024
4 checks passed
@serengil serengil deleted the feat-task-2403-eye-coordinates-in-biology branch March 24, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant