Merge pull request #411 from sotirismos/fix-cropped-faces-dlib

Enhanced cropping of detected faces using dlib
This commit is contained in:
Sefik Ilkin Serengil 2022-01-19 11:54:48 +03:00 committed by GitHub
commit 71ffe92186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,7 +55,7 @@ def detect_face(detector, img, align = True):
for idx, d in enumerate(detections): for idx, d in enumerate(detections):
left = d.left(); right = d.right() left = d.left(); right = d.right()
top = d.top(); bottom = d.bottom() top = d.top(); bottom = d.bottom()
detected_face = img[top:bottom, left:right] detected_face = img[max(0, top): min(bottom, img.shape[0]), max(0, left): min(right, img.shape[1])]
img_region = [left, top, right - left, bottom - top] img_region = [left, top, right - left, bottom - top]
if align: if align: