From 2cbfc417a45704fd675e81a7a60f17bb20dd4e53 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Tue, 19 Mar 2024 08:31:41 +0000 Subject: [PATCH] issue 1123 resolved for opencv and ssd, we were finding eyes from the detected faces. that is why, eye coordinates were inccorrect with respect to the image itself. we added the x and y coordinates of the detected face into the eye coordinates. --- deepface/detectors/OpenCv.py | 6 ++++++ deepface/detectors/Ssd.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/deepface/detectors/OpenCv.py b/deepface/detectors/OpenCv.py index cf0e8d7..15bdcf3 100644 --- a/deepface/detectors/OpenCv.py +++ b/deepface/detectors/OpenCv.py @@ -53,6 +53,12 @@ class OpenCvClient(Detector): for (x, y, w, h), confidence in zip(faces, scores): detected_face = img[int(y) : int(y + h), int(x) : int(x + w)] left_eye, right_eye = self.find_eyes(img=detected_face) + + # eyes found in the detected face instead image itself + # detected face's coordinates should be added + left_eye = (x + left_eye[0], y + left_eye[1]) + right_eye = (x + right_eye[0], y + right_eye[1]) + facial_area = FacialAreaRegion( x=x, y=y, diff --git a/deepface/detectors/Ssd.py b/deepface/detectors/Ssd.py index f21d44c..b427b4d 100644 --- a/deepface/detectors/Ssd.py +++ b/deepface/detectors/Ssd.py @@ -132,6 +132,11 @@ class SsdClient(Detector): left_eye, right_eye = opencv_module.find_eyes(detected_face) + # eyes found in the detected face instead image itself + # detected face's coordinates should be added + left_eye = (x + left_eye[0], y + left_eye[1]) + right_eye = (x + right_eye[0], y + right_eye[1]) + facial_area = FacialAreaRegion( x=x, y=y,