当前位置:网站首页>人脸检测和识别--face recognition包
人脸检测和识别--face recognition包
2022-08-03 05:41:00 【茫茫人海一粒沙】
环境准备
pip install cmake
pip install dlib==19.8.1
pip install face_recognition
pip install opencv-python人脸检测
代码
提取图片中人脸的位置
import face_recognition
image = face_recognition.load_image_file("your_file.jpg")
face_locations = face_recognition.face_locations(image)结果
[(297, 810, 759, 348)]
完整代码
import face_recognition
import cv2
from matplotlib import pyplot as plt
image = cv2.imread("test1.jpeg")
# image = face_recognition.load_image_file("test1.jpeg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image_orign = image.copy()
face_locations = face_recognition.face_locations(image)
for (top, right, bottom, left) in face_locations:
image = cv2.rectangle(image, (left, top), (right, bottom), (0, 0, 255), 2)
plt.subplot(1, 2, 1)
plt.imshow(image_orign)
plt.subplot(1, 2, 2)
plt.imshow(image)
plt.show()
人脸中具体部分的位置
import face_recognition
image = face_recognition.load_image_file("your_file.jpg")
face_landmarks_list = face_recognition.face_landmarks(image)结果
[{'chin': [(299, 533), (316, 592), (337, 648), (367, 696), (410, 733), (463, 758), (520, 778), (574, 790), (618, 785), (649, 763), (668, 725), (688, 686), (707, 644), (719, 599), (725, 551), (723, 502), (713, 454)], 'left_eyebrow': [(375, 465), (405, 431), (450, 409), (501, 403), (549, 414)], 'right_eyebrow': [(590, 411), (618, 390), (648, 380), (679, 383), (700, 401)], 'nose_bridge': [(574, 471), (585, 504), (596, 537), (608, 571)], 'nose_tip': [(568, 613), (587, 614), (606, 615), (620, 606), (633, 594)], 'left_eye': [(429, 503), (453, 483), (482, 478), (510, 495), (485, 504), (456, 508)], 'right_eye': [(612, 476), (629, 450), (654, 443), (675, 454), (661, 468), (636, 474)], 'top_lip': [(540, 694), (571, 668), (595, 650), (612, 651), (624, 642), (643, 647), (658, 661), (647, 662), (626, 660), (614, 665), (598, 669), (555, 689)], 'bottom_lip': [(658, 661), (649, 680), (636, 694), (622, 701), (604, 705), (577, 705), (540, 694), (555, 689), (601, 675), (617, 672), (630, 666), (647, 662)]}]人脸识别
代码
那你要识别的人脸照片与检测出来的照片做一个对比,如果自信度高,就是你要找的人脸
import face_recognition
known_image = face_recognition.load_image_file("me.jpg")
unknown_image = face_recognition.load_image_file("unknown.jpg")
biden_encoding = face_recognition.face_encodings(known_image)[0]
unknown_encoding = face_recognition.face_encodings(unknown_image)[0]
results = face_recognition.compare_faces([biden_encoding], unknown_encoding)总结
人脸检测没有MTCNN好,人脸的小的时候就检测不出来了。或者模糊的时候也检测不出来。
下图可以看出第三个人的脸没检测出来,这种例子很多,你们可以试一试。

参考资料
边栏推荐
- SQL——左连接(Left join)、右连接(Right join)、内连接(Inner join)
- El - table column filter functions, control columns show and hide (effect and easy to implement full marks)
- FiBiNet torch reproduction
- 2021年PHP-Laravel面试题问卷题 答案记录
- 保姆级讲解Transformer
- postman配置中文
- El - tree set using setCheckedNodessetCheckedKeys default check nodes, and a new check through setChecked specified node
- Nacos单机模式的安装与启动
- 你真的了解volatile关键字吗?
- Charles capture shows
solution
猜你喜欢

Shell脚本--信号发送与捕捉

2021新版idea过滤无用文件.idea .iml

hashSet解析

UniApp 自定义条件编译详细使用流程

RADIUS计费认证如何配置?这篇文章一步一步教你完成

SQL——左连接(Left join)、右连接(Right join)、内连接(Inner join)

Composer require 报错 Installation failed, reverting ./composer.json and ./composer.lock to their ...

MySQL的触发器

CISP-PTE真题演示

el-table实现列筛选功能,控制列的显示和隐藏(实现简单,效果满分)
随机推荐
AR路由器如何配置Portal认证(二层网络)
linux安装mysql
UniApp 获取当前页面标题(navigationBarTitleText)
Chrome configuration samesite=none method
Shell脚本--信号发送与捕捉
你真的了解volatile关键字吗?
mysql 数据去重的三种方式[实战]
502 bad gateway原因、解决方法
ES6中 async 函数、await表达式 的基本用法
AutoInt网络详解及pytorch复现
解决plt.imshow()不显示图片cv2.imshw()不显示图片
MySQL 日期时间类型精确到毫秒
cookie和session区别
Nacos与Eureka的区别
链表之打基础--基本操作(必会)
Example of embedding code for continuous features
Spark 的架构与作业提交流程
MySQL的Replace用法详解
【RT_Thread学习笔记】---以太网LAN8720A Lwip ping 通网络
el-table获取读取数据表中某一行的数据属性
