Face Trigger - Process package¶
Contains code for performing face detection, landmark detection and face alignment.
Submodules¶
face_trigger.process.post_process module¶
Module for performing Face detection, Face Alignment and Landmark Detection
-
class
face_trigger.process.post_process.
FaceAlign
(left_eye_offset=(0.35, 0.35), final_width=256, final_height=None)¶ Align a face by performing affine transformations. Inspired from ‘Face Alignment with OpenCV and Python’ https://www.pyimagesearch.com/2017/05/22/face-alignment-with-opencv-and-python/
-
align
(img, landmarks)¶ Align the given image according to given face landmarks - 1. Eyes are aligned on a horizontal axis 2. Face is scaled to keep eye centers on the same offset location w.r.t the face 3. Face is centered on the center of mass of the eyes.
Parameters: img (numpy.ndarray) – rgb or gray-scale image/frame Landmarks: the x,y-coordinates of the facial landmarks Returns: aligned image of final dimensions Return type: numpy.ndarray
-
-
class
face_trigger.process.post_process.
FaceDetector
(face_area_threshold=0.25)¶ HOG-based frontal face detector class.
-
detect
(gray_frame)¶ Detect faces in the frame. If multiple faces are detected, only the largest face is taken into consideration.
Parameters: gray_frame (numpy.ndarray) – grayscale image that might include a face Returns: bounding box coordinates signifying the location of the face Return type: dlib.rectangle
-
detect_unbounded
(gray_frame)¶ Detect all faces in the frame
Parameters: gray_frame (numpy.ndarray) – grayscale image that might faces Returns: bounding box coordinates signifying the location of the faces Return type: list of dlib.rectangle
-
-
class
face_trigger.process.post_process.
LandmarkDetector
(predictor_path=None)¶ A landmark detector that annotates face bounding boxes with 5 landmarks
-
predict
(bounding_box, grayImg)¶ Provides an array of tuples for facial landmarks, predicted within a bounding box
Parameters: - bounding_box (dlib.rectangle) – bounding box coordinates in dlib format
- grayImg (numpy.ndarray) – grayscale image
Returns: 5-tuple
Return type: dlib.full_object_detection
-