当前位置: 首页>>代码示例>>Python>>正文


Python face_recognition.face_landmarks方法代码示例

本文整理汇总了Python中face_recognition.face_landmarks方法的典型用法代码示例。如果您正苦于以下问题:Python face_recognition.face_landmarks方法的具体用法?Python face_recognition.face_landmarks怎么用?Python face_recognition.face_landmarks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在face_recognition的用法示例。


在下文中一共展示了face_recognition.face_landmarks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: detect_landmarks

# 需要导入模块: import face_recognition [as 别名]
# 或者: from face_recognition import face_landmarks [as 别名]
def detect_landmarks(face_img):
    landmakrs = face_recognition.face_landmarks(face_img)
    return landmakrs[0] if len(landmakrs) > 0 else None 
开发者ID:albertpumarola,项目名称:GANimation,代码行数:5,代码来源:face_utils.py

示例2: show_facial_features

# 需要导入模块: import face_recognition [as 别名]
# 或者: from face_recognition import face_landmarks [as 别名]
def show_facial_features(image_path):

    # Load the jpg file into an array
    image = face_recognition.load_image_file(image_path)

    # these are the features that will be detected and shown
    facial_features = [
        'chin',
        'left_eyebrow',
        'right_eyebrow',
        'nose_bridge',
        'nose_tip',
        'left_eye',
        'right_eye',
        'top_lip',
        'bottom_lip']

    blue = ImageColor.getcolor('blue', 'RGB')

    # Find all facial landmarks for all the faces in the image
    face_landmarks_list = face_recognition.face_landmarks(image)
    img_obj = Image.fromarray(image)

    # draw lines upon facial features
    for face_landmarks in face_landmarks_list:
        drawing = ImageDraw.Draw(img_obj)
        for facial_feature in facial_features:
            drawing.line(face_landmarks[facial_feature], width=2, fill=blue)

    # show image
    img_obj.show() 
开发者ID:PacktPublishing,项目名称:Python-for-Everyday-Life,代码行数:33,代码来源:detect_facial_features.py

示例3: main

# 需要导入模块: import face_recognition [as 别名]
# 或者: from face_recognition import face_landmarks [as 别名]
def main():
    closed_count = 0
    video_capture = cv2.VideoCapture(0)

    ret, frame = video_capture.read(0)
    # cv2.VideoCapture.release()
    small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
    rgb_small_frame = small_frame[:, :, ::-1]

    face_landmarks_list = face_recognition.face_landmarks(rgb_small_frame)
    process = True

    while True:
        ret, frame = video_capture.read(0)

        # get it into the correct format
        small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
        rgb_small_frame = small_frame[:, :, ::-1]



        # get the correct face landmarks
        
        if process:
            face_landmarks_list = face_recognition.face_landmarks(rgb_small_frame)

            # get eyes
            for face_landmark in face_landmarks_list:
                left_eye = face_landmark['left_eye']
                right_eye = face_landmark['right_eye']


                color = (255,0,0)
                thickness = 2

                cv2.rectangle(small_frame, left_eye[0], right_eye[-1], color, thickness)

                cv2.imshow('Video', small_frame)
                cv2.waitKey(1)

                ear_left = get_ear(left_eye)
                ear_right = get_ear(right_eye)

                closed = ear_left < 0.2 and ear_right < 0.2

                if (closed):
                    closed_count += 1

                else:
                    closed_count = 0

                if (closed_count >= EYES_CLOSED_SECONDS):
                    asleep = True
                    while (asleep): #continue this loop until they wake up and acknowledge music
                        print("EYES CLOSED")

                        if (kb.is_pressed('space')):
                            asleep = False
                    closed_count = 0

        process = not process 
开发者ID:ageitgey,项目名称:face_recognition,代码行数:63,代码来源:blink_detection.py


注:本文中的face_recognition.face_landmarks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。