Commit 6c50c4e8 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Added margin in the detect_crop method

parent 47a16905
Pipeline #12972 passed with stages
in 10 minutes and 9 seconds
......@@ -147,7 +147,7 @@ class FaceDetector(object):
extractor = bob.ip.base.FaceEyesNorm((CROPPED_IMAGE_HEIGHT, CROPPED_IMAGE_WIDTH), RIGHT_EYE_POS, LEFT_EYE_POS)
return extractor(image, landmark['reye'], landmark['leye'])
def detect_crop(self, image, final_image_size=(160, 160) ):
def detect_crop(self, image, final_image_size=(182, 182), margin=44):
"""
Detects the biggest face and crop it
......@@ -165,8 +165,17 @@ class FaceDetector(object):
if face is None:
return None
cropped = image[face.top:face.bottom, face.left:face.right]
return cropped
top = numpy.maximum(face.top - margin/2, 0)
left = numpy.maximum(face.left - margin/2, 0)
bottom = numpy.minimum(face.bottom + margin/2, image.shape[1])
right = numpy.minimum(face.right + margin/2, image.shape[2])
cropped = image[:, top:bottom, left:right]
dst = numpy.zeros(shape=(3, final_image_size[0], final_image_size[1]))
bob.ip.base.scale(cropped, dst)
return dst
@staticmethod
def get_mtcnn_model_path():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment