编号:A343
大小:149M
环境:Python3.7、OpenCV4.5、dlib、Pycharm2020
简介:利用 Python 开发,借助 Dlib 库捕获摄像头中的人脸,提取人脸特征,通过计算特征值之间的欧氏距离,来和预存的人脸特征进行对比,判断是否匹配,达到人脸识别的目的;
– 完成的功能
– 新的人脸数据集和识别模型
– 做到视频识别, 实时显示人脸信息
– 可摄像头添加人脸, 且可改名
– 可通过文件夹方式批量添加人脸
– GUI化, 基本无卡顿
.. image:: introduction/main_interface.png
:align: center
.. image:: introduction/main_figure_interface.png
:align: center
关于算法:
– 基于 Residual Neural Network / 残差网络的 CNN 模型;
– This model is a ResNet network with 29 conv layers. It’s essentially a version of the ResNet-34 network from the paper Deep Residual Learning for Image Recognition by He, Zhang, Ren, and Sun with a few layers removed and the number of filters per layer reduced by half.
实现流程:
– 安装依赖库
– 进行人脸信息采集录入
– 提取所有录入人脸数据存入 “features_all.csv”
– 调用摄像头进行实时人脸识别
关于代码:
#. 树状图:
├── main_interface.py # Step0. Start First
├── get_faces_from_camera.py # Step1. Faces register
├── features_extraction_to_csv.py # Step2. Features extraction
├── face_reco_from_camera.py # Step3. Faces recognition
├── how_to_use_camera.py # Use the default camera by opencv
├── data
│ ├── data_dlib # Dlib’s model
│ │ ├── dlib_face_recognition_resnet_model_v1.dat
│ │ ├── shape_predictor_5_face_landmarks.dat
│ │ └── shape_predictor_68_face_landmarks.dat
│ ├── data_faces_from_camera # Face images captured from camera (will generate after step 1)
│ │ ├── person_1
│ │ │ ├── img_face_1.jpg
│ │ │ └── img_face_2.jpg
│ │ └── person_2
│ │ └── img_face_1.jpg
│ │ └── img_face_2.jpg
│ └── features_all.csv # CSV to save all the features of known faces (will generate after step 2)
├── introduction # Some files for readme.rst
│ ├── main_figure_interface.png
│ ├── main_interface.png
│ └── overview.png
└── requirements.txt # Some python packages needed
用到的 Dlib 相关模型函数:
#. Dlib 正向人脸检测器 (based on HOG), output:
.. code-block:: python
detector = dlib.get_frontal_face_detector()
faces = detector(img_gray, 0)
#. Dlib 人脸预测器, output:
will use shape_predictor_68_face_landmarks.dat
.. code-block:: python
# This is trained on the ibug 300-W dataset (https://ibug.doc.ic.ac.uk/resources/facial-point-annotations/)
# Also note that this model file is designed for use with dlib’s HOG face detector.
# That is, it expects the bounding boxes from the face detector to be aligned a certain way, the way dlib’s HOG face detector does it.
# It won’t work as well when used with a face detector that produces differently aligned boxes,
# such as the CNN based mmod_human_face_detector.dat face detector.
predictor = dlib.shape_predictor(“data/data_dlib/shape_predictor_68_face_landmarks.dat”)
shape = predictor(img_rd, faces[i])
#. 特征描述子 Face recognition model, the object maps human faces into 128D vectors
.. code-block:: python
face_rec = dlib.face_recognition_model_v1(“data/data_dlib/dlib_face_recognition_resnet_model_v1.dat”)
源码介绍:
#. get_face_from_camera.py:
进行 Face register / 人脸信息采集录入
* 请注意存储人脸图片时,矩形框不要超出摄像头范围,要不然无法保存到本地;
* 超出会有 “out of range” 的提醒;
#. features_extraction_to_csv.py:
从上一步存下来的图像文件中,提取人脸数据存入CSV;
* 会生成一个存储所有特征人脸数据的 “features_all.csv”;
* size: n*128 , n means n people you registered and 128 means 128D features of the face
#. face_reco_from_camera.py:
这一步将调用摄像头进行实时人脸识别; / This part will implement real-time face recognition;
* Compare the faces captured from camera with the faces you have registered which are saved in “features_all.csv”
* 将捕获到的人脸数据和之前存的人脸数据进行对比计算欧式距离, 由此判断是否是同一个人;
运行展示
配套文件
我们提供完整项目文件清单如下:
文件目录
├ 1.项目源码
├ 2.运行截图
└ 3.演示视频
2. 分享目的仅供大家学习和交流,请不要用于商业用途!
3. 如果你也有好源码或者文档,可以与我们交换,分享有积分奖励和额外收入!
4. 本站提供的源码、文档等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,默认解压密码为"www.2zcode.com",如遇到无法解压的请联系管理员!
8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载
声明:网站内的所有源码都经过我们亲自测试,均可以正常使用.
索炜达.猿创 » 基于Python+OpenCV+dlib监所卷积神经网络人脸识别系统
常见问题FAQ
- 免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 提示下载完但解压或打开不了?
- 你们有qq群吗怎么加入?