python人脸特征提取_Python实现检测人脸特征并打印出来

原标题:Python实现检测人脸特征并打印出来

通过python的face_recognition模块实现人脸检测功能,首先需要安装好face_recognition包:可通过pycharm直接安装,也可以用pip安装,还可以通过anaconda安装。

示例代码如下:

# -*- coding: utf-8 -*-

# 自动识别人脸特征

# filename : find_facial_features_in_picture.py

fromPIL importImage, ImageDraw

importface_recognition

# 将jpg文件加载到numpy 数组中

image = face_recognition.load_image_file( "linuxidc.com.jpg")

#查找图像中所有面部的所有面部特征

face_landmarks_list = face_recognition.face_landmarks(image)

print( "I found {} face(s) in this photograph.".format(len(face_landmarks_list)))

pil_image = Image.fromarray(image)

d = ImageDraw.Draw(pil_image)

forface_landmarks inface_landmarks_list:

#打印此图像中每个面部特征的位置

facial_features = [

'chin',

'left_eyebrow',

'right_eyebrow',

'nose_bridge',

'nose_tip',

'left_eye',

'right_eye',

'top_lip',

'bottom_lip'

]

forfacial_feature infacial_features:

print( "The {} in this face has the following points: {}".format(facial_feature, face_landmarks[facial_feature]))

#在图像中画出每个人脸特征!

forfacial_feature infacial_features:

d.line(face_landmarks[facial_feature], width= 5)

pil_image.show

更多Python相关信息见Python专题页面https://www.linuxidc.com/topicnews.aspx?tid=17

本文永久更新链接地址:

本文永久更新链接地址:https://www.linuxidc.com返回搜狐,查看更多

责任编辑:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值