This commit is contained in:
sairate 2024-08-23 10:23:55 +08:00
parent 7dfccb5eaa
commit b3e51cd83c
11 changed files with 6 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -27,6 +27,11 @@ while photo_count < max_photos:
for face_location in face_locations:
top, right, bottom, left = face_location
# 在图像上绘制绿框
cv2.rectangle(frame, (left, top), (right, bottom), (0, 255, 0), 2)
# 提取人脸区域
face_image = frame[top:bottom, left:right]
# 保存抓拍的照片
@ -48,7 +53,6 @@ cv2.destroyAllWindows()
print(f"Captured {photo_count} images.")
def create_face_database(db_name="face_database.db"):
conn = sqlite3.connect(db_name)
c = conn.cursor()
@ -59,7 +63,6 @@ def create_face_database(db_name="face_database.db"):
conn.commit()
conn.close()
def add_face_to_database(name, image_path, db_name="face_database.db"):
conn = sqlite3.connect(db_name)
c = conn.cursor()
@ -77,7 +80,6 @@ def add_face_to_database(name, image_path, db_name="face_database.db"):
conn.commit()
conn.close()
def match_faces(captured_images, db_name="face_database.db", tolerance=0.4):
conn = sqlite3.connect(db_name)
c = conn.cursor()
@ -105,7 +107,7 @@ def match_faces(captured_images, db_name="face_database.db", tolerance=0.4):
print(f"发现匹配: {name}{image_path}")
conn.close()
return True # 一旦找到匹配,返回成功
print(f"没发现匹配: 在 {image_path}")
conn.close()
return False # 如果所有比较都没有匹配,返回失败
@ -120,4 +122,3 @@ if match_faces(captured_images):
print("至少一张匹配")
else:
print("没有匹配")