2022-06-09 12:47:52 索煒達電子 1235
文件編號:A343
文件大?。?/strong>149M
開發(fā)環(huán)境:Python3.7、OpenCV4.5、dlib、Pycharm2020
猿創(chuàng)承諾:該項目親測正常運行,需遠程調(diào)試部署需另外收費,確保正常使用,不能正常使用全額退款。
簡要概述:利用 Python 開發(fā),借助 Dlib 庫捕獲攝像頭中的人臉,提取人臉特征,通過計算特征值之間的歐氏距離,來和預(yù)存的人臉特征進行對比,判斷是否匹配,達到人臉識別的目的;
- 完成的功能
- 新的人臉數(shù)據(jù)集和識別模型
- 做到視頻識別, 實時顯示人臉信息
- 可攝像頭添加人臉, 且可改名
- 可通過文件夾方式批量添加人臉
- GUI化, 基本無卡頓
.. image:: introduction/main_interface.png
:align: center
.. image:: introduction/main_figure_interface.png
:align: center
關(guān)于算法:
- 基于 Residual Neural Network / 殘差網(wǎng)絡(luò)的 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.
實現(xiàn)流程:
- 安裝依賴庫
- 進行人臉信息采集錄入
- 提取所有錄入人臉數(shù)據(jù)存入 "features_all.csv"
- 調(diào)用攝像頭進行實時人臉識別
關(guān)于代碼:
#. 樹狀圖:
├── 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 相關(guān)模型函數(shù):
#. Dlib 正向人臉檢測器 (based on HOG), output: <class 'dlib.dlib.rectangles'>
.. code-block:: python
detector = dlib.get_frontal_face_detector()
faces = detector(img_gray, 0)
#. Dlib 人臉預(yù)測器, 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])
#. 特征描述子 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:
從上一步存下來的圖像文件中,提取人臉數(shù)據(jù)存入CSV;
* 會生成一個存儲所有特征人臉數(shù)據(jù)的 "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:
這一步將調(diào)用攝像頭進行實時人臉識別; / 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"
* 將捕獲到的人臉數(shù)據(jù)和之前存的人臉數(shù)據(jù)進行對比計算歐式距離, 由此判斷是否是同一個人;
按需寫作:
演示視頻:
點擊查看:系統(tǒng)演示視頻
運行效果:
遠程協(xié)助:
溫馨提示:索煒達.猿創(chuàng)官方提供收費遠程協(xié)助,確保您項目運行成功。
點擊查看:遠程協(xié)助相關(guān)事項
我們提供完整項目文件清單如下:
文件目錄
├ 1.項目源碼
├ 2.運行截圖
└ 3.演示視頻