Signed-off-by: sairate <sairate@sina.cn>

This commit is contained in:
sairate 2024-08-23 10:34:56 +08:00
parent b3e51cd83c
commit b6671a6198
2 changed files with 14 additions and 35 deletions

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# 人脸识别匹配
## 1.实现步骤
- 首先初始化摄像头然后,识别人脸,并抓拍十张照片
- 如果没有可以创建数据库,如果数据库已经存在,会调用已经存在数据库
- 抓拍的十张照片一次匹配,返回结果
## 2.运行
- 直接运行scanf_face.py文件即可
- 添加人脸数据到数据库已经在scanf_face.py实现调用即可

View File

@ -1,35 +0,0 @@
import cv2
import face_recognition
import sqlite3
import numpy as np
from match_face import save_face_encoding
def add_new_face(name):
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
face_locations = face_recognition.face_locations(rgb_frame)
face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
if face_encodings:
# 假设只处理第一张检测到的人脸
encoding = face_encodings[0]
save_face_encoding(name, encoding)
print(f"Face of {name} saved!")
break
cv2.imshow('Capture New Face', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
# 示例用法
add_new_face("John Doe")