in face_align/landmarks_detector_dlib.py [0:0]
def get_landmarks(self, img):
"""
apply dlib to get face bbox and landmarks
:param predictor:
:param detector:
:param img:
:return: bbox and landmarks (largest face)
"""
dets = self.detector(img, 1)
# print('detected face {}'.format(len(dets)))
if len(dets) == 0: # no face
return None, None
face_len = 0
landmarks = None
for _, d in enumerate(dets):
cur_bbox = [d.left(), d.top(), d.right(), d.bottom()]
# Get the landmarks/parts for the face in box d.
if face_len < (cur_bbox[3] - cur_bbox[1]):
shape = self.predictor(img, d)
landmarks = shape_to_np_dlib(shape)
face_len = cur_bbox[3] - cur_bbox[1]
return landmarks