После получения точек на лице, вы можете нарисовать его на исходном изображении, например:
def annotate_landmarks(im, landmarks):
CIRCLE_SIZE = 1
FONT_SCALE = 1
THICKNESS_S = 1
im = im.copy()
#0-16: head
for idx, point in enumerate(landmarks[0:17]):
pos = (point[0, 0], point[0, 1])
#cv2.putText(im, str(idx), pos, fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale=FONT_SCALE, color=(0, 0, 255))
cv2.circle(im, pos, CIRCLE_SIZE, color=(255, 0, 0), thickness=THICKNESS_S)
#17-21: left eye brow
#22-26: right eye brow
for idx, point in enumerate(landmarks[17:27]):
pos = (point[0, 0], point[0, 1])
#cv2.putText(im, str(idx), pos,fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,fontScale=FONT_SCALE,color=(0, 0, 255))
cv2.circle(im, pos, CIRCLE_SIZE, color=(0, 255, 0), thickness=THICKNESS_S)
#27-35: nose
for idx, point in enumerate(landmarks[27:36]):
pos = (point[0, 0], point[0, 1])
#cv2.putText(im, str(idx), pos,fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,fontScale=FONT_SCALE,color=(0, 0, 255))
cv2.circle(im, pos, CIRCLE_SIZE, color=(0, 0, 255), thickness=THICKNESS_S)
#36-41: left eye
#42-47: right eye
for idx, point in enumerate(landmarks[36:48]):
pos = (point[0, 0], point[0, 1])
#cv2.putText(im, str(idx), pos,fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,fontScale=FONT_SCALE,color=(0, 0, 255))
cv2.circle(im, pos, CIRCLE_SIZE, color=(0, 255, 255), thickness=THICKNESS_S)
#48-68: lips
for idx, point in enumerate(landmarks[48:68]):
pos = (point[0, 0], point[0, 1])
#cv2.putText(im, str(idx), pos,fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,fontScale=FONT_SCALE,color=(0, 0, 255))
cv2.circle(im, pos, CIRCLE_SIZE, color=(255, 0, 255), thickness=THICKNESS_S)
return im