diff --git a/src/face/facemesh.ts b/src/face/facemesh.ts index 9b2c4ef7..feba4c43 100644 --- a/src/face/facemesh.ts +++ b/src/face/facemesh.ts @@ -42,7 +42,8 @@ export async function predict(input: Tensor, config: Config): Promise [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize]); for (const key of Object.keys(coords.meshAnnotations)) face.annotations[key] = coords.meshAnnotations[key].map((index) => face.mesh[index]); // add annotations - box = util.squarifyBox({ ...util.enlargeBox(util.calculateLandmarksBoundingBox(face.mesh), (config.face.detector?.cropFactor || 1.6)), confidence: box.confidence }); // redefine box with mesh calculated one + const boxCalculated = util.calculateLandmarksBoundingBox(face.mesh); + const boxEnlarged = util.enlargeBox(boxCalculated, (config.face.detector?.cropFactor || 1.6)); + const boxSquared = util.squarifyBox(boxEnlarged); + box = { ...boxSquared, confidence: box.confidence }; // redefine box with mesh calculated one face.box = util.getClampedBox(box, input); // update detected box with box around the face mesh face.boxRaw = util.getRawBox(box, input); face.score = face.faceScore;