mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
Merging from master
This commit is contained in:
commit
08988fcd0d
@ -19,9 +19,12 @@ def detect_face(face_detector, img, align=True):
|
|||||||
|
|
||||||
results = face_detector.process(img)
|
results = face_detector.process(img)
|
||||||
|
|
||||||
if results.detections:
|
# If no face has been detected, return an empty list
|
||||||
for detection in results.detections:
|
if results.detections is None:
|
||||||
|
return resp
|
||||||
|
|
||||||
|
# Extract the bounding box, the landmarks and the confidence score
|
||||||
|
for detection in results.detections:
|
||||||
(confidence,) = detection.score
|
(confidence,) = detection.score
|
||||||
|
|
||||||
bounding_box = detection.location_data.relative_bounding_box
|
bounding_box = detection.location_data.relative_bounding_box
|
||||||
@ -32,8 +35,9 @@ def detect_face(face_detector, img, align=True):
|
|||||||
y = int(bounding_box.ymin * img_height)
|
y = int(bounding_box.ymin * img_height)
|
||||||
h = int(bounding_box.height * img_height)
|
h = int(bounding_box.height * img_height)
|
||||||
|
|
||||||
right_eye = (int(landmarks[0].x * img_width), int(landmarks[0].y * img_height))
|
# Extract landmarks
|
||||||
left_eye = (int(landmarks[1].x * img_width), int(landmarks[1].y * img_height))
|
left_eye = (int(landmarks[0].x * img_width), int(landmarks[0].y * img_height))
|
||||||
|
right_eye = (int(landmarks[1].x * img_width), int(landmarks[1].y * img_height))
|
||||||
# nose = (int(landmarks[2].x * img_width), int(landmarks[2].y * img_height))
|
# nose = (int(landmarks[2].x * img_width), int(landmarks[2].y * img_height))
|
||||||
# mouth = (int(landmarks[3].x * img_width), int(landmarks[3].y * img_height))
|
# mouth = (int(landmarks[3].x * img_width), int(landmarks[3].y * img_height))
|
||||||
# right_ear = (int(landmarks[4].x * img_width), int(landmarks[4].y * img_height))
|
# right_ear = (int(landmarks[4].x * img_width), int(landmarks[4].y * img_height))
|
||||||
@ -44,9 +48,7 @@ def detect_face(face_detector, img, align=True):
|
|||||||
img_region = [x, y, w, h]
|
img_region = [x, y, w, h]
|
||||||
|
|
||||||
if align:
|
if align:
|
||||||
detected_face = FaceDetector.alignment_procedure(
|
detected_face = FaceDetector.alignment_procedure(detected_face, left_eye, right_eye)
|
||||||
detected_face, left_eye, right_eye
|
|
||||||
)
|
|
||||||
|
|
||||||
resp.append((detected_face, img_region, confidence))
|
resp.append((detected_face, img_region, confidence))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user