diff --git a/README.md b/README.md new file mode 100644 index 0000000..5c6e992 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# 人脸识别匹配 + +## 1.实现步骤 + +- 首先初始化摄像头然后,识别人脸,并抓拍十张照片 + +- 如果没有可以创建数据库,如果数据库已经存在,会调用已经存在数据库 + +- 抓拍的十张照片一次匹配,返回结果 + +## 2.运行 + +- 直接运行scanf_face.py文件即可 +- 添加人脸数据到数据库已经在scanf_face.py实现,调用即可 \ No newline at end of file diff --git a/add_face.py b/add_face.py deleted file mode 100644 index 6a1463f..0000000 --- a/add_face.py +++ /dev/null @@ -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")