【发布时间】:2021-07-25 11:01:18
【问题描述】:
我正在使用 Dlib 的 68 点人脸界标预测器,它有 68 个点标记在人脸的各个区域,如下图所示:
我已经设法从预测的地标中访问特定点,例如,我可以通过以下方式选择唇角处的点,该点是面部地标预测器中的第 48 个点 ' 导入简历2 导入 dlib 从 google.colab.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 个点的点,我该如何获得它?
红色圆圈表示我使用代码访问的点,蓝色圆圈表示所需的点。
【问题讨论】:
-
定义要检测的点。你的意思是像你用鼠标点击一个点,你需要得到那个点的坐标吗?
-
我需要从给定的面部图像中提取面部的一部分,因此我需要指定用于提取特定区域的掩蔽函数的坐标。
-
试试 google face-mesh google.github.io/mediapipe/solutions/face_mesh.html,它提供了 468 个面部关键点。
标签: python opencv image-processing dlib facial-landmark-alignment