mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
Revert OpenCvWrapper.py
This commit is contained in:
parent
0c50eb7178
commit
205eb0e23d
@ -44,9 +44,7 @@ def detect_face(detector, img, align=True):
|
|||||||
detected_face = None
|
detected_face = None
|
||||||
img_region = [0, 0, img.shape[1], img.shape[0]]
|
img_region = [0, 0, img.shape[1], img.shape[0]]
|
||||||
|
|
||||||
# Initialize faces and scores to empty lists
|
|
||||||
faces = []
|
faces = []
|
||||||
scores = []
|
|
||||||
try:
|
try:
|
||||||
# faces = detector["face_detector"].detectMultiScale(img, 1.3, 5)
|
# faces = detector["face_detector"].detectMultiScale(img, 1.3, 5)
|
||||||
|
|
||||||
@ -54,25 +52,19 @@ def detect_face(detector, img, align=True):
|
|||||||
faces, _, scores = detector["face_detector"].detectMultiScale3(
|
faces, _, scores = detector["face_detector"].detectMultiScale3(
|
||||||
img, 1.1, 10, outputRejectLevels=True
|
img, 1.1, 10, outputRejectLevels=True
|
||||||
)
|
)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# except alone is too broad and will catch keyboard interrupts
|
if len(faces) > 0:
|
||||||
# Exception should be changed to something more specific in the future
|
for (x, y, w, h), confidence in zip(faces, scores):
|
||||||
except Exception: # pylint: disable=broad-except
|
detected_face = img[int(y) : int(y + h), int(x) : int(x + w)]
|
||||||
import traceback
|
|
||||||
|
|
||||||
print(traceback.format_exc())
|
if align:
|
||||||
|
detected_face = align_face(detector["eye_detector"], detected_face)
|
||||||
|
|
||||||
# For each face and associated score, append face,
|
img_region = [x, y, w, h]
|
||||||
# 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)]
|
|
||||||
|
|
||||||
if align:
|
resp.append((detected_face, img_region, confidence))
|
||||||
detected_face = align_face(detector["eye_detector"], detected_face)
|
|
||||||
|
|
||||||
img_region = [x, y, w, h]
|
|
||||||
|
|
||||||
resp.append((detected_face, img_region, confidence))
|
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user