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

Commit

Permalink
Merge pull request #89 from LimaoC/mitch-register-again
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchellJC authored Oct 10, 2024
2 parents eba19a4 + 7436178 commit 53d17c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 53d17c2

Please sign in to comment.