如何在 face_recognition 库中使用 face_landmarks

How to use face_landmarks in face_recognition library

face_recognition 图书馆有 face_recognition.face_landmarks() 这个 returns 列表中的许多词典,每个词典都包含 top_lips right_eye 等地标和许多元组。谁能解释一下这些元组是什么,以及我如何使用它们?

[{'chin': [(294, 215), (295, 230), (297, 244), (300, 258), (304, 271), (312, 282), (321, 291), (332, 299), (345, 301), (358, 299), (368, 292), (376, 282), (384, 272), (390, 259), (393, 245), (396, 230), (397, 214)], 'left_eyebrow': [(306, 200), (313, 195), (322, 194), (331, 195), (339, 199)], 'right_eyebrow': [(357, 197), (365, 193), (374, 192), (383, 193), (389, 200)], 'nose_bridge': [(348, 211), (348, 221), (348, 231), (348, 242)], 'nose_tip': [(337, 248), (343, 250), (348, 251), (353, 250), (358, 248)], 'left_eye': [(316, 213), (322, 210), (329, 210), (335, 214), (329, 215), (322, 215)], 'right_eye': [(361, 214), (366, 209), (373, 209), (378, 212), (374, 215), (367, 215)], 'top_lip': [(329, 267), (335, 262), (343, 260), (348, 262), (354, 261), (360, 263), (366, 268), (363, 269), (353, 266), (348, 266), (343, 265), (332, 267)], 'bottom_lip': [(366, 268), (360, 276), (354, 279), (347, 279), (342, 278), (335, 274), (329, 267), (332, 267), (342, 271), (348, 272), (353, 272), (363, 269)]}]

你可以查一下this

但是是图片上地标的坐标

假设您有获取地标的代码: 在评论中纠正我。

results = face_recognition.face_landmarks()
import cv2

image = cv2.imread('path/to/image.jpg') 
for k, v in result:
    for (x, y) in v:
        cv2.circle(image, (x, y), 1, (0, 0, 255), -1)

您可能更愿意了解该坐标的含义:

别忘了从 0 而不是 1 开始。 this Whosebug answer 也可能有用。