Document and move
This commit is contained in:
parent
5768edb3a5
commit
a8229f325d
2 changed files with 22 additions and 15 deletions
web/apps/photos/src/services/face
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue