def get_landmarks(self, img):
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
rects = self.detector(img, 0)
if len(rects) > 1:
print 'TooManyFaces'
if len(rects) == 0:
raise ValueError('Error: NoFaces!!')
landmarks = np.matrix([[p.x, p.y]
for p in self.predictor(img, rects[0]).parts()])
for group in self.MOUTH_POINTS:
hull = cv2.convexHull(landmarks[group])
return hull
评论列表
文章目录