Skip to content

Commit

Permalink
restore coordinates to version before border added
Browse files Browse the repository at this point in the history
  • Loading branch information
serengil committed Jun 2, 2024
1 parent dcd15cf commit dcd1e80
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions deepface/detectors/DetectorWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ def detect_faces(

# If faces are close to the upper boundary, alignment move them outside
# Add a black border around an image to avoid this.
height_border = int(0.5 * height)
width_border = int(0.5 * width)
if align is True:
img = cv2.copyMakeBorder(
img,
int(0.5 * height),
int(0.5 * height),
int(0.5 * width),
int(0.5 * width),
height_border,
height_border,
width_border,
width_border,
cv2.BORDER_CONSTANT,
value=[0, 0, 0], # Color of the border (black)
)
Expand Down Expand Up @@ -150,6 +152,13 @@ def detect_faces(
int(rotated_y1) : int(rotated_y2), int(rotated_x1) : int(rotated_x2)
]

# restore x, y, le and re before border added
x = x - width_border
y = y - height_border
# w and h will not change
left_eye = (left_eye[0] - width_border, left_eye[1] - height_border)
right_eye = (right_eye[0] - width_border, right_eye[1] - height_border)

result = DetectedFace(
img=detected_face,
facial_area=FacialAreaRegion(
Expand Down

0 comments on commit dcd1e80

Please sign in to comment.