Python API for bob.ip.mtcnn¶
-
class
bob.ip.mtcnn.
FaceDetector
[source]¶ Bases:
object
Detects face and 5 landmarks using the MTCNN (https://github.com/kpzhang93/MTCNN_face_detection_alignment) from the paper.
Zhang, Kaipeng, et al. “Joint face detection and alignment using multitask cascaded convolutional networks.” IEEE Signal Processing Letters 23.10 (2016): 1499-1503.
-
detect_all_faces
(image, return_bob_bb=True)[source]¶ Detect all the faces with its respective landmarks, if any, in a COLORED image
Parameters: - image (numpy.array) – The color image [c, w, h]
- return_bob_bb (bool, optional) – If true, will return faces wrapped using
bob.ip.facedetect.BoundingBox
.
Returns: Returns two lists; the first on contains the bounding boxes with the detected faces and the second one contains list with the faces landmarks. The CNN returns 5 facial landmarks (leye, reye, nose, mouthleft, mouthright). If there’s no face, None will be returned
Return type: Raises: ValueError
– When image.ndim is not 3.
-
detect_crop
(image, final_image_size=(182, 182), margin=44)[source]¶ Detects the biggest face and crop it
- Parameters
- image: numpy array with color image [c, w, h] final_image_size: Image dimensions [w, h]
- Returns
- The cropped image. If there’s no face, None will be returned
-
detect_crop_align
(image, final_image_size=(160, 160))[source]¶ Detects the biggest face and crop it based in the eyes location using py:class:bob.ip.base.FaceEyesNorm.
Final eyes location was inspired here: https://gitlab.idiap.ch/bob/bob.bio.caffe_face/blob/master/bob/bio/caffe_face/config/preprocessor/vgg_preprocessor.py
- Parameters
- image: numpy array with color image [c, w, h] final_image_size: Image dimensions [w, h]
- Returns
- The cropped image. If there’s no face, None will be returned
-
detect_single_face
(image)[source]¶ Returns the biggest face in a COLORED image, if any.
Parameters: image (numpy.array) – numpy array with color image [c, w, h] Returns: - The face bounding box and its respective 5 landmarks (leye, reye, nose,
- mouthleft, mouthright). If there’s no face, None will be returned
-