aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-08-22 15:36:41 -0400
committerbobzel <zzzman@gmail.com>2024-08-22 15:36:41 -0400
commitc9c5514c0607dcacaf8b84ef4a7730a815451d98 (patch)
tree6cbec7b93242d6cb70db81340ebfd618f1984ce5 /src
parentf18978c507dd4c9c0940a1ce17daa2e7000bccdd (diff)
from last
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx2
-rw-r--r--src/client/views/search/FaceRecognitionHandler.tsx52
2 files changed, 27 insertions, 27 deletions
diff --git a/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx b/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
index 46d90db86..de7c2c027 100644
--- a/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
+++ b/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
@@ -75,7 +75,7 @@ export class UniqueFaceView extends ObservableReactComponent<UniqueFaceProps> {
const match = faceMatcher.matchDescriptor(new Float32Array(Array.from(face)));
return match.distance < prev.dist ? { dist: match.distance, face_match: face } : prev;
},
- { dist: 1, face_match: new List<number>() as Opt<List<number>> }
+ { dist: 1, face_match: undefined as Opt<List<number>> }
);
// assign the face in the image that's closest to the face collection to be the face that's assigned to the collection
diff --git a/src/client/views/search/FaceRecognitionHandler.tsx b/src/client/views/search/FaceRecognitionHandler.tsx
index 9b97fdfbd..f5fc12a8d 100644
--- a/src/client/views/search/FaceRecognitionHandler.tsx
+++ b/src/client/views/search/FaceRecognitionHandler.tsx
@@ -184,6 +184,32 @@ export class FaceRecognitionHandler {
};
/**
+ * Finds the most similar matching Face Document to a face descriptor
+ * @param faceDescriptor face descriptor number list
+ * @returns face Doc
+ */
+ private findMatchingFaceDoc = (faceDescriptor: Float32Array) => {
+ if (!Doc.ActiveDashboard || FaceRecognitionHandler.UniqueFaces().length < 1) {
+ return undefined;
+ }
+
+ const faceDescriptors = FaceRecognitionHandler.UniqueFaces().map(faceDoc => {
+ const float32Array = FaceRecognitionHandler.UniqueFaceDescriptors(faceDoc).map(fd => new Float32Array(Array.from(fd)));
+ return new faceapi.LabeledFaceDescriptors(FaceRecognitionHandler.UniqueFaceLabel(faceDoc), float32Array);
+ });
+ const faceMatcher = new FaceMatcher(faceDescriptors, 0.6);
+ const match = faceMatcher.findBestMatch(faceDescriptor);
+ if (match.label !== 'unknown') {
+ for (const faceDoc of FaceRecognitionHandler.UniqueFaces()) {
+ if (FaceRecognitionHandler.UniqueFaceLabel(faceDoc) === match.label) {
+ return faceDoc;
+ }
+ }
+ }
+ return undefined;
+ };
+
+ /**
* When a document is added, this finds faces in the images and tries to
* match them to existing unique faces, otherwise new unique face(s) are created.
* @param imgDoc The document being analyzed.
@@ -214,30 +240,4 @@ export class FaceRecognitionHandler {
} // prettier-ignore
}
};
-
- /**
- * Finds the most similar matching Face Document to a face descriptor
- * @param faceDescriptor face descriptor number list
- * @returns face Doc
- */
- private findMatchingFaceDoc = (faceDescriptor: Float32Array) => {
- if (!Doc.ActiveDashboard || FaceRecognitionHandler.UniqueFaces().length < 1) {
- return undefined;
- }
-
- const faceDescriptors = FaceRecognitionHandler.UniqueFaces().map(faceDoc => {
- const float32Array = FaceRecognitionHandler.UniqueFaceDescriptors(faceDoc).map(fd => new Float32Array(Array.from(fd)));
- return new faceapi.LabeledFaceDescriptors(FaceRecognitionHandler.UniqueFaceLabel(faceDoc), float32Array);
- });
- const faceMatcher = new FaceMatcher(faceDescriptors, 0.6);
- const match = faceMatcher.findBestMatch(faceDescriptor);
- if (match.label !== 'unknown') {
- for (const faceDoc of FaceRecognitionHandler.UniqueFaces()) {
- if (FaceRecognitionHandler.UniqueFaceLabel(faceDoc) === match.label) {
- return faceDoc;
- }
- }
- }
- return undefined;
- };
}