Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Document and move

Manav Rathia8229f325d20
diff --git a/web/apps/photos/src/services/face/f-index.ts b/web/apps/photos/src/services/face/f-index.ts
index fa2ad69fa7..520701142d 100644
--- a/web/apps/photos/src/services/face/f-index.ts
+++ b/web/apps/photos/src/services/face/f-index.ts
@@ -461,7 +461,14 @@ const faceAlignmentUsingSimilarityTransform = (
const centerMat = simTransform.fromMean.sub(meanTranslation);
const center = new Point(centerMat.get(0, 0), centerMat.get(1, 0));
- return { affineMatrix, center, size };
+ const boundingBox = new Box({
+ x: center.x - size / 2,
+ y: center.y - size / 2,
+ width: size,
+ height: size,
+ });
+
+ return { affineMatrix, boundingBox };
};
const convertToMobileFaceNetInput = (
@@ -736,15 +743,7 @@ const extractFaceCrop = (
imageBitmap: ImageBitmap,
alignment: FaceAlignment,
): ImageBitmap => {
- const alignmentBox = new Box({
- x: alignment.center.x - alignment.size / 2,
- y: alignment.center.y - alignment.size / 2,
- width: alignment.size,
- height: alignment.size,
- });
-
- const paddedBox = roundBox(enlargeBox(alignmentBox, 1.5));
-
+ const paddedBox = roundBox(enlargeBox(alignment.boundingBox, 1.5));
const outputSize = { width: paddedBox.width, height: paddedBox.height };
const maxDimension = 256;
diff --git a/web/apps/photos/src/services/face/types.ts b/web/apps/photos/src/services/face/types.ts
index 45e26c94eb..423f6afb7b 100644
--- a/web/apps/photos/src/services/face/types.ts
+++ b/web/apps/photos/src/services/face/types.ts
@@ -8,12 +8,20 @@ export interface FaceDetection {
}
export interface FaceAlignment {
- // An affine transformation matrix (rotation, translation, scaling) to align
- // the face extracted from the image.
+ /**
+ * An affine transformation matrix (rotation, translation, scaling) to align
+ * the face extracted from the image.
+ */
affineMatrix: number[][];
- // size and center is relative to image dimentions stored at mlFileData
- size: number;
- center: Point;
+ /**
+ * The bounding box of the transformed box.
+ *
+ * The affine transformation shifts the original detection box a new,
+ * transformed, box (possibily rotated). This property is the bounding box
+ * of that transformed box. It is in the coordinate system of the original,
+ * full, image on which the detection occurred.
+ */
+ boundingBox: Box;
}
export interface Face {