资源简介
分别在树莓派和MAC中跑人脸识别代码(分三个阶段,采集,训练,识别),识别效果还可以。
代码片段和文件信息
‘‘‘‘
Capture multiple Faces from multiple users to be stored on a Database (dataset directory)
==> Faces will be stored on a directory: dataset/ (if does not exist pls create one)
==> Each face will have a unique numeric integer ID as 1 2 3 etc
based on original code by Anirban Kar: https://github.com/thecodacus/Face-Recognition
Developed by Marcelo Rovai - MJRoBot.org @ 21Feb18
‘‘‘
import cv2
import os
cam = cv2.VideoCapture(0)
#cam.set(3 640) # set video width
#cam.set(4 480) # set video height
face_detector = cv2.CascadeClassifier(‘haarcascade_frontalface_alt2.xml‘)
color = (0 255 0)
# For each person enter one numeric face id
face_id = input(‘\n Please enter user id end press ==> ‘)
print(“\n [INFO] Initializing face capture. Look the camera and wait ...“)
# Initialize individual sampling face count
count = 0
#Start looping
while(True):
ret img = cam.read()
#img = cv2.flip(img -1) # flip video image vertically
# convert frame to grayscale
gray = cv2.cvtColor(img cv2.COLOR_BGR2GRAY)
# Using the classifier to detect the number of face matrices in the grayscale image 1.3 indicates the scaling ratio and 5 indicates the number of valid points to be detected.
# Detect frames of different sizes list of faces rectangles
faces = face_detector.detectMultiScale(gray 1.3 5)
# Loops for each faces
for (xywh) in faces:
# Specify the size of the rectangle and the thickness of the rectangle border
cv2.rectangle(img (xy) (x+wy+h) (25500) 2) # Crop the image frame into rectangle
# Increment sample face image
count += 1
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img‘count:%d‘ % (count)(x+30 y+30) font 1 (2550255)4)
# Save the captured image into the datasets folder
cv2.imwrite(“dataset/User.“ + str(face_id) + ‘.‘ + str(count) + “.jpg“ gray[y:y+hx:x+w])
# Display the video frame into the dataset folder
cv2.imshow(‘image‘ img)
# To stop taking video Press ‘ESC‘ for exiting video
k = cv2.waitKey(100) & 0xff
if k == 27:
break
# If image taken reach 100 stop taking video
elif count >= 500: # Take 30 face sample and stop video
break
# Do a bit of cleanup
print(“\n [INFO] Exiting Program and cleanup stuff“)
cam.release()
cv2.destroyAllWindows()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2202 2019-01-24 14:56 face_training.py
目录 0 2019-03-12 16:27 __MACOSX\
文件 273 2019-01-24 14:56 __MACOSX\._face_training.py
文件 540616 2019-01-08 19:27 haarcascade_frontalface_alt2.xm
文件 212 2019-01-08 19:27 __MACOSX\._haarcascade_frontalface_alt2.xm
文件 2477 2019-03-12 09:07 face_dataset.py
文件 176 2019-03-12 09:07 __MACOSX\._face_dataset.py
文件 930127 2018-02-23 11:52 haarcascade_frontalface_default.xm
目录 0 2019-01-14 20:27 trainer\
文件 6148 2019-01-14 20:17 trainer\.DS_Store
目录 0 2019-03-12 16:27 __MACOSX\trainer\
文件 120 2019-01-14 20:17 __MACOSX\trainer\._.DS_Store
文件 240860526 2019-03-11 09:34 trainer\trainer.yml
文件 2744 2019-02-15 14:17 face_recognition.py
文件 176 2019-02-15 14:17 __MACOSX\._face_recognition.py
相关资源
- LBPH算法人脸识别代码.rar
- 基于卷积神经网络的人脸识别
- python项目-face++人脸识别考勤机-pytho
- 计算机/数字图像处理专业本科毕设—
- python使用dlib对人脸识别的范例程序
- python深度学习项目:人脸识别库Face
- 人脸识别Python代码
- dlib-19.17.zip
- 人脸识别python实现源码功能丰富
- opencv_python-4.1.2+contrib-cp38-cp38-win_amd6
- 利用Python实现的BP神经网络进行人脸识
- dlib_face_recognition_resnet_model_v1.dat人脸识
- 人脸识别理论和Python实现
- face.dat.zip
- Python_Dlib_Face_Recognition.zip
- 人脸识别源代码及模型
- laview_and_python_face_recognition.zip
- python3版 40行代码的人脸识别实践
- 基于Python的人脸识别系统
- face_jiance.py
- 基于人脸识别的课堂签到管理系统.
- faceReco.py
- Python+OpenCv实现AI人脸识别身份认证系
- 人脸识别pythonLBPH
- Dlib人脸特征标定.ipynb可直接运行
- 基于Haar+Adaboost人脸识别.ipynb
- 基于PCA的人脸识别系统-python版
- 基于OpenCV 3 LBPH 人脸识别 Python代码
- 基于face_recognition和OpenCV的人脸识别程
- 利用OpenCV检测人脸python程序
评论
共有 条评论