Skip to content

Commit

Permalink
Revert OpenCvWrapper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent-Stragier committed Jun 23, 2023
1 parent 0c50eb7 commit 205eb0e
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions deepface/detectors/OpenCvWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,27 @@ def detect_face(detector, img, align=True):
detected_face = None
img_region = [0, 0, img.shape[1], img.shape[0]]

# Initialize faces and scores to empty lists
faces = []
scores = []
try:
# faces = detector["face_detector"].detectMultiScale(img, 1.3, 5)

# note that, by design, opencv's haarcascade scores are >0 but not capped at 1
faces, _, scores = detector["face_detector"].detectMultiScale3(
img, 1.1, 10, outputRejectLevels=True
)
except:
pass

# except alone is too broad and will catch keyboard interrupts
# Exception should be changed to something more specific in the future
except Exception: # pylint: disable=broad-except
import traceback
if len(faces) > 0:
for (x, y, w, h), confidence in zip(faces, scores):
detected_face = img[int(y) : int(y + h), int(x) : int(x + w)]

print(traceback.format_exc())
if align:
detected_face = align_face(detector["eye_detector"], detected_face)

# For each face and associated score, append face,
# bounding box, and score to resp
for (x, y, w, h), confidence in zip(faces, scores):
detected_face = img[int(y) : int(y + h), int(x) : int(x + w)]
img_region = [x, y, w, h]

if align:
detected_face = align_face(detector["eye_detector"], detected_face)

img_region = [x, y, w, h]

resp.append((detected_face, img_region, confidence))
resp.append((detected_face, img_region, confidence))

return resp

Expand Down

0 comments on commit 205eb0e

Please sign in to comment.