From cf38fc81b69abb084938c8f45eaf5d94caacb3a3 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 26 Aug 2024 22:49:10 -0400
Subject: added face rectangle annotations for faces in images

---
 src/client/views/search/FaceRecognitionHandler.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'src/client/views/search/FaceRecognitionHandler.tsx')

diff --git a/src/client/views/search/FaceRecognitionHandler.tsx b/src/client/views/search/FaceRecognitionHandler.tsx
index dee0ab99b..4e500d24e 100644
--- a/src/client/views/search/FaceRecognitionHandler.tsx
+++ b/src/client/views/search/FaceRecognitionHandler.tsx
@@ -243,12 +243,17 @@ export class FaceRecognitionHandler {
                 FaceRecognitionHandler.loadImage(imgUrl).then( // load image and analyze faces
                 img => faceapi.detectAllFaces(img).withFaceLandmarks().withFaceDescriptors()
                     .then(imgDocFaceDescriptions => { // For each face detected, find a match.
+                        const annos = [] as Doc[];
+                        const scale = NumCast(imgDoc.data_nativeWidth) / img.width;
                         for (const fd of imgDocFaceDescriptions) {
                             const faceDescriptor = new List<number>(Array.from(fd.descriptor));
+                            annos.push(Docs.Create.FreeformDocument([], {backgroundColor: "#55555555", x: fd.alignedRect.box.left*scale, y: fd.alignedRect.box.top*scale, _width: fd.alignedRect.box.width*scale, _height: fd.alignedRect.box.height*scale}))
                             FaceRecognitionHandler.ImageDocAddFaceDescriptor(imgDoc, faceDescriptor); // add face descriptor to image's list of descriptors
                             const matchedUniqueFace = this.findMatchingFaceDoc(fd.descriptor) ?? this.createUniqueFaceDoc(activeDashboard);
                             FaceRecognitionHandler.UniqueFaceAddFaceImage(imgDoc, faceDescriptor, matchedUniqueFace); // add image/faceDescriptor to matched unique face
-                        } //
+                        } 
+
+                        imgDoc[DocData].data_annotations = new List<Doc>(annos);
                         return imgDocFaceDescriptions;
                     }) 
                 );
-- 
cgit v1.2.3-70-g09d2

