From 6b05be72377ce98d01cdeeeb366a27f07481b935 Mon Sep 17 00:00:00 2001 From: Mitchell Clark Date: Fri, 11 Oct 2024 08:31:39 +1000 Subject: [PATCH 1/2] wip: started double register check --- client/models/face_recognition/recognition.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/models/face_recognition/recognition.py b/client/models/face_recognition/recognition.py index 043f8a3..f3f072a 100644 --- a/client/models/face_recognition/recognition.py +++ b/client/models/face_recognition/recognition.py @@ -72,6 +72,11 @@ 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) + register_face_embeddings(user_id, face_embeddings) return Status.OK.value From 743617821dca4c993e101358826e9f3cfec4cec7 Mon Sep 17 00:00:00 2001 From: MitchellJC <81349046+MitchellJC@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:12:10 +1000 Subject: [PATCH 2/2] feat: added check for if user already registered --- client/drivers/login_system.py | 3 ++- client/models/face_recognition/recognition.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/drivers/login_system.py b/client/drivers/login_system.py index fee192f..b076ce7 100644 --- a/client/drivers/login_system.py +++ b/client/drivers/login_system.py @@ -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" diff --git a/client/models/face_recognition/recognition.py b/client/models/face_recognition/recognition.py index f3f072a..b322fbb 100644 --- a/client/models/face_recognition/recognition.py +++ b/client/models/face_recognition/recognition.py @@ -9,6 +9,7 @@ class Status(Enum): + ALREADY_REGISTERED = -4 NO_FACES = -3 TOO_MANY_FACES = -2 NO_MATCH = -1 @@ -77,6 +78,9 @@ def register_faces(user_id: int, faces: list[np.ndarray]) -> int: 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