关键词:
face_recognition 基础接口
face_recognition使用世界上最简单的人脸识别库,在Python或命令行中识别和操作人脸。
使用dlib最先进的人脸识别技术构建而成,并具有深度学习功能。 该模型在 Labeled Faces in the Wild 基准中的准确率为99.38%。
face_recognition 官方文档 :https://pypi.org/project/face_recognition/
查找图片中的面孔
# 导入face_recognition模块 import face_recognition # 查找图片中的面孔 # 将jpg文件添加到numpy数组中 image = face_recognition.load_image_file("1.jpg") # 查找图片中人脸(上下左右)的位置,图像中可能有多个人脸 # face_locations可能的值类似为 [(135,536,198,474),()] face_locations = face_recognition.face_locations(image) print(face_locations)
查找和操作图片中的面部特征
# 导入face_recognition模块 import face_recognition # 查找图片中人脸的所有面部特征(眉毛,眼睛,鼻子,上下嘴唇,面部轮廓) # 将jpg文件添加到numpy数组中 image = face_recognition.load_image_file("1.jpg") face_landmarks_list = face_recognition.face_landmarks(image) print(face_landmarks_list)
/usr/bin/python3.6 /home/wjw/PycharmProjects/face/find_nose.py [‘chin‘: [(280, 439), (282, 493), (283, 547), (290, 603), (308, 654), (340, 698), (380, 733), (427, 760), (485, 770), (544, 766), (592, 738), (634, 704), (668, 661), (689, 613), (701, 563), (712, 514), (722, 466)], ‘left_eyebrow‘: [(327, 373), (354, 340), (395, 323), (442, 324), (487, 337)], ‘right_eyebrow‘: [(560, 344), (603, 340), (647, 348), (682, 372), (698, 410)], ‘nose_bridge‘: [(519, 410), (517, 444), (515, 477), (513, 512)], ‘nose_tip‘: [(461, 548), (485, 554), (508, 561), (532, 558), (555, 556)], ‘left_eye‘: [(372, 424), (399, 420), (426, 420), (451, 429), (424, 433), (397, 432)], ‘right_eye‘: [(577, 440), (605, 437), (631, 442), (655, 451), (628, 454), (601, 449)], ‘top_lip‘: [(415, 617), (452, 600), (484, 593), (506, 600), (525, 598), (551, 610), (579, 634), (566, 630), (524, 620), (504, 619), (482, 616), (428, 616)], ‘bottom_lip‘: [(579, 634), (546, 636), (518, 636), (498, 635), (475, 632), (447, 626), (415, 617), (428, 616), (479, 605), (500, 610), (520, 610), (566, 630)]] Process finished with exit code 0
美图
寻找面部特征对于许多重要的东西非常有用,比如美图。
from PIL import Image, ImageDraw import face_recognition # 将图片文件添加到numpy数组中 image = face_recognition.load_image_file("1.jpg") # 查找图像中的所有面部特征 face_landmarks_list = face_recognition.face_landmarks(image) for face_landmarks in face_landmarks_list: pil_image = Image.fromarray(image) d = ImageDraw.Draw(pil_image, ‘RGBA‘) # 美化眉毛 d.polygon(face_landmarks[‘left_eyebrow‘], fill=(68, 54, 39, 128)) d.polygon(face_landmarks[‘right_eyebrow‘], fill=(68, 54, 39, 128)) d.line(face_landmarks[‘left_eyebrow‘], fill=(68, 54, 39, 150), width=5) d.line(face_landmarks[‘right_eyebrow‘], fill=(68, 54, 39, 150), width=5) # 嘴唇光泽 d.polygon(face_landmarks[‘top_lip‘], fill=(150, 0, 0, 128)) d.polygon(face_landmarks[‘bottom_lip‘], fill=(150, 0, 0, 128)) d.line(face_landmarks[‘top_lip‘], fill=(150, 0, 0, 64), width=8) d.line(face_landmarks[‘bottom_lip‘], fill=(150, 0, 0, 64), width=8) # 闪耀的眼睛 d.polygon(face_landmarks[‘left_eye‘], fill=(255, 255, 255, 30)) d.polygon(face_landmarks[‘right_eye‘], fill=(255, 255, 255, 30)) # 涂一些眼线 d.line(face_landmarks[‘left_eye‘] + [face_landmarks[‘left_eye‘][0]], fill=(0, 0, 0, 110), width=6) d.line(face_landmarks[‘right_eye‘] + [face_landmarks[‘right_eye‘][0]], fill=(0, 0, 0, 110), width=6) # 显示图片 pil_image.show()
(丑了哈?没关系,技术重要!!)
识别图片中的面孔
# 导入face_recognition模块 import face_recognition # 识别图像中出现的人脸 # 获取每个图像文件中每个面部的面部编码 known_image = face_recognition.load_image_file("zhangjie.jpg") unknown_image = face_recognition.load_image_file("uknow.jpg") # 由于每个图像中可能有多个人脸,所以返回一个编码列表。 # 但是事先知道每个图像只有一个人脸,每个图像中的第一个编码,取索引0。 biden_encoding = face_recognition.face_encodings(known_image)[0] unknown_encoding = face_recognition.face_encodings(unknown_image)[0] # 获取比较结果 result = face_recognition.compare_faces([biden_encoding],unknown_encoding) print(result)
一个很强大的人脸识别库face_recognition(代码片段)
官方网址:https://github.com/ageitgey/face_recognition 在图片中查找面孔:importface_recognitionimage=face_recognition.load_image_file("your_file.jpg")face_locations=face_recognition.f 查看详情
一个很强大的人脸识别库face_recognition(代码片段)
官方网址:https://github.com/ageitgey/face_recognition 在图片中查找面孔:importface_recognitionimage=face_recognition.load_image_file("your_file.jpg")face_locations=face_recognition.f 查看详情
face_recognition模块方法集合(代码片段)
face_recognitionAPI以下描述了face_recognition人脸识别库的一些API参数、用法、返回值函数batch_face_locationsbatch_face_locations(images,number_of_times_to_upsample=1,batch_size=128)使用cnn人脸检测器返回一个包含人脸特征的二维数组,如果使用 查看详情
人脸识别----face_recognition安装与应用(附代码)(代码片段)
face_recognition号称是世界上最简单的基于python的人脸识别库,是在大名鼎鼎的深度学习框架dlib上做的整合,dlib模型在LFW(LabeledFacesintheWild)能有99.38的准确率。另外face_recognition提供了相应的命令行工具,可以通过命令... 查看详情
face_recognition人脸识别报错(代码片段)
[[email protected]examples]#pythonfacerec_from_video_file.pyRuntimeError:modulecompiledagainstAPIversion0xabutthisversionofnumpyis0x7Traceback(mostrecentcalllast):File"facerec_from_video_file.py" 查看详情
face_recognition实现人脸相似度比较(代码片段)
face_recognitionface_recognition是github上一个非常有名气的人脸识别开源工具包,我们可以通过以下指令安装到python环境内$pipinstallface_recognition加载人脸图片image=face_recognition.load_image_file(src)获取图片人脸定位[(top,right,bottom,left)] 查看详情
python使用python-opencv进行face_recognition(代码片段)
mac下安装face_recognition(代码片段)
安装依赖库:1、安装cmake(是一个跨平台的安装工具)brewinstallcmake2、安装boost、boost-python(C++的程序库)brewinstallboostbrewinstallboost-python--with-python2.73、编译dlibgitclonehttps://github.com/davisking/dlib.gitcddlibmkdirbuildc 查看详情
linux下配置face_recognition(代码片段)
1、如linux下已有python2.7,但需要更新一下python2.7至python2.xsudoadd-apt-repositoryppa:fkrull/deadsnakes-python2.7sudoapt-getupdatesudoapt-getupgrade2、部署步骤安装Boost,Boost.Pythonsudoapt-getinstallbuild-essentialcmakes 查看详情
人工智能之基于face_recognition的人脸检测与识别(代码片段)
...其实没那么复杂。我基本上是基于https://github.com/ageitgey/face_recognition上的资料和源码做一些尝试和试验。首先,需要配置我们的python环境,我悬着的python27(比较稳定),具体过程不多说了。然后,需要安装这次的主角face_recognition... 查看详情
python3安装dlib库和face_recognition库(代码片段)
安装dlib库(不安装这个库的话,face_recognition库无法安装)安装cmake从官网下载https://cmake.org/download/installer直接安装,或者zip,自行解压配置。百度网盘地址:链接:https://pan.baidu.com/s/1J6Hm8MENAg-Hs6mJ7YVY2w提取码:exft配置完毕后,打开... 查看详情
人脸识别face_recognition库的使用(代码片段)
目录1.load_image_file加载图像2.face_locations定位图中所有人脸(1)在原图像中框出人脸(2)剪切出人脸3.face_landmarks识别人脸关键点1.load_image_file加载图像输出图像是RGB格式(opencv中是BGR格式)图像类型是ndarray... 查看详情
ai识别照片是谁,人脸识别face_recognition开源项目安装使用|机器学习(代码片段)
...用总结前言最近碰到了照片识别的场景,正好使用了face_recognition项目,给大家分享分享。face_recognition项目能做的很多,人脸检测功能也是有的,是一个比较成熟的项目。该项目的github地址:github仓库本文主要... 查看详情
face_recognition库实现人脸识别demo(代码片段)
...出名字和图像。 主要方法:demo:#1、加载库importface_recognitionimportcv2importnumpyasnp#2、加载图片fei=cv2.imrea 查看详情
face_recognition库实现人脸识别demo(代码片段)
...出名字和图像。 主要方法:demo:#1、加载库importface_recognitionimportcv2importnumpyasnp#2、加载图片fei=cv2.imrea 查看详情
利用face_recognition,dlib与opencv调用摄像头进行人脸识别(代码片段)
用已经搭建好 face_recognition,dlib环境来进行人脸识别未搭建好环境请参考:https://www.cnblogs.com/guihua-pingting/p/12201077.html使用OpenCV调用摄像头importface_recognitionimportcv2video_capture=cv2.VideoCapture(0)#VideoCapture打开摄像头,0为笔记本内置... 查看详情
接口测试基础(代码片段)
接口测试概述要进行接口测试,我们肯定要了解什么是接口?什么是接口测试?为什么要进行接口测试?HTTP协议等等知识。什么是接口是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例... 查看详情
java基础——接口(代码片段)
如果类要遵从某个接口,那么就履行这项服务。接口不是类,这是两个不同的概念。接口是类的需求的描述接口的特性:接口不能实例化,但是可以声明一个接口变量用于存储接口实现类的对象。可以使用instanceof... 查看详情