Skip to content

Commit

Permalink
Amend quirk behavior of mod operator
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaLanfranchi committed Feb 27, 2024
1 parent 923f2cf commit d0ffc1b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions deepface/detectors/DetectorWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ def rotate_facial_area(
"""

# Normalize the witdh of the angle so we don't have to
# worry about rotations greater than 360 degrees
angle = angle % 360
# worry about rotations greater than 360 degrees.
# We workaround the quirky behavior of the modulo operator
# for negative angle values.
direction = (1, -1)[angle < 0]
angle = abs(angle) % 360
if angle == 0:
return facial_area # No rotation needed
direction = 1 if angle > 0 else -1
return facial_area

# Angle in radians
angle = angle * np.pi / 180
Expand Down

0 comments on commit d0ffc1b

Please sign in to comment.