aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx6
-rw-r--r--src/client/views/search/FaceRecognitionHandler.tsx10
2 files changed, 8 insertions, 8 deletions
diff --git a/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx b/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
index 7e47292e5..ea1c22962 100644
--- a/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
+++ b/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
@@ -102,10 +102,8 @@ export class UniqueFaceBox extends ViewBoxBaseComponent<FieldViewProps>() {
{ 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
- if (face_match) {
- FaceRecognitionHandler.UniqueFaceAddFaceImage(imgDoc, face_match, this.Document);
- }
+ // assign the face in the image that's closest to the face collection's face
+ FaceRecognitionHandler.UniqueFaceAddFaceImage(imgDoc, face_match, this.Document);
}
});
e.stopPropagation();
diff --git a/src/client/views/search/FaceRecognitionHandler.tsx b/src/client/views/search/FaceRecognitionHandler.tsx
index 0cee7184c..021802061 100644
--- a/src/client/views/search/FaceRecognitionHandler.tsx
+++ b/src/client/views/search/FaceRecognitionHandler.tsx
@@ -1,6 +1,6 @@
import * as faceapi from 'face-api.js';
import { FaceMatcher } from 'face-api.js';
-import { Doc, DocListCast } from '../../../fields/Doc';
+import { Doc, DocListCast, Opt } from '../../../fields/Doc';
import { DocData } from '../../../fields/DocSymbols';
import { List } from '../../../fields/List';
import { listSpec } from '../../../fields/Schema';
@@ -133,10 +133,12 @@ export class FaceRecognitionHandler {
* @param faceDescriptor - the face descriptor for the face in the image to add
* @param faceDoc - unique face Doc
*/
- public static UniqueFaceAddFaceImage = (img: Doc, faceDescriptor: List<number>, faceDoc: Doc) => {
+ public static UniqueFaceAddFaceImage = (img: Doc, faceDescriptor: Opt<List<number>>, faceDoc: Doc) => {
Doc.AddDocToList(faceDoc, 'face_images', img);
- Cast(faceDoc.face_descriptors, listSpec('number'), null).push(faceDescriptor as unknown as number); // items are lists of numbers, not numbers, but type system can't handle that
- Doc.AddDocToList(img[DocData], FaceRecognitionHandler.ImageDocFaceField(img), faceDoc);
+ if (faceDescriptor) {
+ Cast(faceDoc.face_descriptors, listSpec('number'), null).push(faceDescriptor as unknown as number); // items are lists of numbers, not numbers, but type system can't handle that
+ Doc.AddDocToList(img[DocData], FaceRecognitionHandler.ImageDocFaceField(img), faceDoc);
+ }
};
/**