Skip to content

Commit

Permalink
update alignment logic
Browse files Browse the repository at this point in the history
now, left eye is the one on the left with respect to the person
instead of observer
  • Loading branch information
serengil committed Mar 24, 2024
1 parent 519c48e commit 2b5c139
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions deepface/modules/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def align_face(
Align a given image horizantally with respect to their left and right eye locations
Args:
img (np.ndarray): pre-loaded image with detected face
left_eye (list or tuple): coordinates of left eye with respect to the you
right_eye(list or tuple): coordinates of right eye with respect to the you
left_eye (list or tuple): coordinates of left eye with respect to the person itself
right_eye(list or tuple): coordinates of right eye with respect to the person itself
Returns:
img (np.ndarray): aligned facial image
"""
Expand All @@ -214,6 +214,6 @@ def align_face(
if img.shape[0] == 0 or img.shape[1] == 0:
return img, 0

angle = float(np.degrees(np.arctan2(right_eye[1] - left_eye[1], right_eye[0] - left_eye[0])))
angle = float(np.degrees(np.arctan2(left_eye[1] - right_eye[1], left_eye[0] - right_eye[0])))
img = np.array(Image.fromarray(img).rotate(angle))
return img, angle

0 comments on commit 2b5c139

Please sign in to comment.