简体   繁体   中英

How to use face_landmarks in face_recognition library

The face_recognition library has face_recognition.face_landmarks() this returns many dictionaries in a list, and each dictionary contains landmarks like top_lips right_eye etc. and many tuples. Can anyone explain what these tuples are, and how I could use them?

[{'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)]}]

You could look up this

but they are the coordinates of the land mark on the picture.

Lets say you have code that gets the landmarks: Correct me in the comments.

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)

You may prefer to see what that coordinates mean: 在此处输入图像描述

Don't forget to start from 0 instead of 1. Also this StackOverflow answer could be useful too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM