All Projects → coneypo → Dlib_face_recognition_from_camera

coneypo / Dlib_face_recognition_from_camera

Licence: mit
Detect and recognize the faces from camera / 调用摄像头进行人脸识别,支持多张人脸同时识别

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Dlib face recognition from camera

Noiseface
Noise-Tolerant Paradigm for Training Face Recognition CNNs
Stars: ✭ 132 (-81.64%)
Mutual labels:  cnn, face-recognition
T System
the moving objects tracking system via two axis camera motion (and as optionally n joint robotic arm) for raspberry pi distributions
Stars: ✭ 17 (-97.64%)
Mutual labels:  face-recognition, dlib
Face Nn
游戏捏脸,基于神经风格迁移框架生成逼真人脸
Stars: ✭ 192 (-73.3%)
Mutual labels:  cnn, face-recognition
Face Identification With Cnn Triplet Loss
Face identification with cnn+triplet-loss written by Keras.
Stars: ✭ 45 (-93.74%)
Mutual labels:  cnn, face-recognition
Go Face
🔍 Face recognition with Go
Stars: ✭ 650 (-9.6%)
Mutual labels:  face-recognition, dlib
Deepface
Keras implementation of the renowned publication "DeepFace: Closing the Gap to Human-Level Performance in Face Verification" by Taigman et al. Pre-trained weights on VGGFace2 dataset.
Stars: ✭ 113 (-84.28%)
Mutual labels:  cnn, face-recognition
face-rec-tools
Media library face recognition tools
Stars: ✭ 14 (-98.05%)
Mutual labels:  face-recognition, dlib
Attendance Using Face
Face-recognition using Siamese network
Stars: ✭ 174 (-75.8%)
Mutual labels:  face-recognition, dlib
ofFaceRecognition
simple example face recognition with deep metric learning to dlib
Stars: ✭ 20 (-97.22%)
Mutual labels:  face-recognition, dlib
facenet-darknet-inference
Face recognition using facenet
Stars: ✭ 29 (-95.97%)
Mutual labels:  face-recognition, dlib
Facerecognition
OpenCV 3 & Keras implementation of face recognition for specific people.
Stars: ✭ 32 (-95.55%)
Mutual labels:  cnn, face-recognition
Libfaceid
libfaceid is a research framework for prototyping of face recognition solutions. It seamlessly integrates multiple detection, recognition and liveness models w/ speech synthesis and speech recognition.
Stars: ✭ 354 (-50.76%)
Mutual labels:  face-recognition, dlib
Facerecognition
Nextcloud app that implement a basic facial recognition system.
Stars: ✭ 226 (-68.57%)
Mutual labels:  face-recognition, dlib
Deepway
This project is an aid to the blind. Till date there has been no technological advancement in the way the blind navigate. So I have used deep learning particularly convolutional neural networks so that they can navigate through the streets.
Stars: ✭ 118 (-83.59%)
Mutual labels:  cnn, dlib
Face recognition py
基于OpenCV的视频人脸识别
Stars: ✭ 215 (-70.1%)
Mutual labels:  face-recognition, dlib
Face-Recognition-Attendance-System
A simple python script that recognises faces and mark attendance for the recognised faces in an excel sheet.
Stars: ✭ 57 (-92.07%)
Mutual labels:  face-recognition, dlib
Awesome Face Detection
Compare with various detectors - s3fd, dlib, ocv, ocv-dnn, mtcnn-pytorch, face_recognition
Stars: ✭ 106 (-85.26%)
Mutual labels:  face-recognition, dlib
Dlib Face Recognition Android
Android app to demo dlib face recognition
Stars: ✭ 115 (-84.01%)
Mutual labels:  face-recognition, dlib
avatar-facial-landmark-detection
A method about optimizing the facial landmark detection based on Kalman Filter, Optical Flow and Dlib
Stars: ✭ 87 (-87.9%)
Mutual labels:  face-recognition, dlib
Get Me Through
A Free, Offline, Real-Time, Open-source web-app to assist organisers of any event in allowing only authorised/invited people using Face-Recognition Technology or QR Code.
Stars: ✭ 255 (-64.53%)
Mutual labels:  face-recognition, dlib

Face recognition from camera with Dlib ######################################

Introduction


Detect and recognize single/multi-faces from camera;

调用摄像头进行人脸识别,支持多张人脸同时识别;

#. 摄像头人脸录入 / Face register

.. image:: introduction/face_register.png :align: center

请不要离摄像头过近,人脸超出摄像头范围时会有 "OUT OF RANGE" 提醒 / Please do not be too close to the camera, or you can't save faces with "OUT OF RANGE" warning;

.. image:: introduction/face_register_warning.png :align: center

#. 提取特征建立人脸数据库 / Generate database from images captured #. 利用摄像头进行人脸识别 / Face recognizer

当单张人脸 / When single-face:

.. image:: introduction/face_reco_single.png :align: center

利用 OT 对于单张人脸追踪/ Use OT to track, which can improve FPS from 1.x to 20.x:

.. image:: introduction/face_reco_single_ot.png :align: center

当多张人脸 / When multi-faces:

.. image:: introduction/face_reco_multi.png :align: center

利用 OT 来实现 / When multi-faces with OT:

.. image:: introduction/face_reco_multi_ot.png :align: center

定制显示名字, 可以写中文 / Customize names:

.. image:: introduction/face_reco_with_name.png :align: center

** 关于精度 / About accuracy:

  • When using a distance threshold of 0.6, the dlib model obtains an accuracy of 99.38% on the standard LFW face recognition benchmark.

** 关于算法 / About algorithm

  • 基于 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.

Overview


此项目中人脸识别的实现流程 (no OT, 每一帧都进行检测+识别) / The design of this repo:

.. image:: introduction/overview.png :align: center

实现流程(with OT, 初始帧进行检测+识别,后续帧检测+质心跟踪) / The design of this repo:

.. image:: introduction/overview_with_ot.png :align: center

如果利用 OT 来跟踪,可以大大提高 FPS, 因为做识别时候需要提取特征描述子的耗时很多;

Steps


#. 安装依赖库 / Install some python packages if needed

.. code-block:: bash

  pip3 install opencv-python
  pip3 install scikit-image
  pip3 install dlib

#. 下载源码 / Download zip from website or via GitHub Desktop in windows, or git clone repo in Ubuntu

.. code-block:: bash

  git clone https://github.com/coneypo/Dlib_face_recognition_from_camera

#. 进行人脸信息采集录入 / Register faces

.. code-block:: bash

  python3 get_face_from_camera.py

#. 提取所有录入人脸数据存入 "features_all.csv" / Features extraction and save into "features_all.csv"

.. code-block:: bash

  python3 features_extraction_to_csv.py

#. 调用摄像头进行实时人脸识别 / Real-time face recognition

.. code-block:: bash

  python3 face_reco_from_camera.py

#. 或者利用 OT 算法,调用摄像头进行实时人脸识别/ Real-time face recognition with OT

.. code-block:: bash

  python3 face_reco_from_camera_ot_single_person.py
  python3 face_reco_from_camera_ot_multi_people.py

About Source Code


Repo 的 tree / 树状图:

::

.
├── get_faces_from_camera.py        		# Step 1. Face register
├── features_extraction_to_csv.py   		# Step 2. Feature extraction
├── face_reco_from_camera.py        		# Step 3. Face recognizer
├── face_reco_from_camera_ot_single_person.py       # Step 3. Face recognizer with OT for single person
├── face_reco_from_camera_ot_multi_people.py        # Step 3. Face recognizer with OT for multi people
├── face_descriptor_from_camera.py  		# Face descriptor computation
├── 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_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)
├── README.rst
└── requirements.txt                		# Some python packages needed

用到的 Dlib 相关模型函数:

#. Dlib 正向人脸检测器 (based on HOG), output: <class 'dlib.dlib.rectangles'>

.. code-block:: python

  detector = dlib.get_frontal_face_detector()
  faces = detector(img_gray, 0)

#. Dlib 人脸 landmark 特征点检测器, output: <class 'dlib.dlib.full_object_detection'>, 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])

#. Dlib 特征描述子 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")

Python 源码介绍如下:

#. 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"

  • 将捕获到的人脸数据和之前存的人脸数据进行对比计算欧式距离, 由此判断是否是同一个人;

#. face_reco_from_camera_ot_single_person/multi_people.py:

区别于 face_reco_from_camera.py (对每一帧都进行检测+识别),只会对初始帧做检测+识别,对后续帧做检测+质心跟踪;

#. (optional) face_descriptor_from_camera.py

调用摄像头进行实时特征描述子计算; / Real-time face descriptor computation;

More


Tips:

#. 如果希望详细了解 dlib 的用法,请参考 Dlib 官方 Python api 的网站 / You can refer to this link for more information of how to use dlib: http://dlib.net/python/index.html

#. Windows下建议不要把代码放到 C:\, 可能会出现权限读取问题 / In windows, we will not recommend that running this repo in dir C:\

#. 代码最好不要有中文路径 / No chinese characters in your code directory

#. 人脸录入的时候先建文件夹再保存图片, 先 NS / Press N before S

#. 关于人脸识别卡顿 FPS 低问题, 原因是特征描述子提取很费时间, 光跑 face_descriptor_from_camera.py 中 face_reco_model.compute_face_descriptor 在 CPU: i7-8700K 得到的最终 FPS: 5~6 (检测在 0.03s, 特征描述子提取在 0.158s, 和已知人脸进行遍历对比在 0.003s 左右), 所以主要提取特征时候耗资源, 可以用 OT 去做追踪,而不是对每一帧都做检测+识别

可以访问我的博客获取本项目的更详细介绍,如有问题可以邮件联系我 / For more details, please refer to my blog (in chinese) or mail to me :

Thanks for your support.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].