From 33b09585311672f9c14569252157e2bee721c284 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 21 Oct 2024 10:59:28 -0600 Subject: [PATCH] Crop frame to face box --- frigate/embeddings/maintainer.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frigate/embeddings/maintainer.py b/frigate/embeddings/maintainer.py index 1262d6fa5..dee78fd0a 100644 --- a/frigate/embeddings/maintainer.py +++ b/frigate/embeddings/maintainer.py @@ -288,7 +288,21 @@ class EmbeddingMaintainer(threading.Thread): if not face: return - # TODO crop frame to face box + face_box = face.get("box") + + if not face_box: + return + + face_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420) + face_frame = face_frame[face_box[1] : face_box[3], face_box[0] : face_box[2]] + + # if face_frame is not None: + # cv2.imwrite( + # "/media/frigate/face_crop.webp", + # face_frame, + # [int(cv2.IMWRITE_WEBP_QUALITY), 60], + # ) + # TODO run embedding on face box # TODO compare embedding to faces in embeddings DB to fine cosine similarity # TODO check against threshold and min score to see if best face qualifies