Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Added check for if face is already registered. #89

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/drivers/login_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
from models.pose_detection.frame_capturer import RaspCapturer

NUM_FACES = 5
QUIT = -4
QUIT = -6
RESET = -5
BAD_STATUS_MESSAGES = {
Status.NO_FACES.value: "No face detected please",
Status.TOO_MANY_FACES.value: "Too many faces detected",
Status.NO_MATCH.value: "Could not match face",
Status.ALREADY_REGISTERED.value: "Face already registered",
}
QUIT_INSTRUCTIONS = "Right button to quit"

Expand Down
9 changes: 9 additions & 0 deletions client/models/face_recognition/recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


class Status(Enum):
ALREADY_REGISTERED = -4
NO_FACES = -3
TOO_MANY_FACES = -2
NO_MATCH = -1
Expand Down Expand Up @@ -72,6 +73,14 @@ def register_faces(user_id: int, faces: list[np.ndarray]) -> int:
if not all(matches):
return Status.TOO_MANY_FACES.value

# Ensure user is not already registered
for _, other_user_embeddings in iter_face_embeddings():
for embedding in face_embeddings:
matches = face_recognition.compare_faces(other_user_embeddings, embedding)

if any(matches):
return Status.ALREADY_REGISTERED.value

register_face_embeddings(user_id, face_embeddings)

return Status.OK.value