我正在使用 Dlib 的 68 点人脸界标预测器,它有 68 个点标记在人脸的各个区域,如下图所示:
我已经设法从预测的地标中访问特定点,例如,我可以选择一个位于唇角的点,它是面部地标预测器中的第 48 个点,方法是从 google.colab 导入 cv2 .patches 导入 cv2_imshow
p = "path_to_shape_predictor_68_face_landmarks.dat"
img= cv2.imread('Obama.jpg')
gray=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(p)
face = detector(gray)
# Get the shape using the predictor
landmarks=predictor(gray, face)
# Defining x and y coordinates of a specific point
x=landmarks.part(48).x
y=landmarks.part(48).y
# Drawing a circle
cv2.circle(img, (x, y), 6, (0, 0, 255), -1)
cv2_imshow(img)'
它会在指定区域上绘制一个带有红色小圆圈的图像。然而; 如果我想选择一个不属于地标模型的 68 个点的点,我该如何获得它?
红色圆圈表示我使用代码访问的点,蓝色圆圈表示所需的点。