xMin, yMin to x, y in the remote format

This commit is contained in:
Manav Rathi 2024-05-21 15:51:55 +05:30
parent 2d5894c5d6
commit 94cc26aead
No known key found for this signature in database
2 changed files with 14 additions and 28 deletions

View file

@ -239,8 +239,8 @@ const filterExtractDetectionsFromYOLOOutput = (
const yCenter = rows[i + 1];
const width = rows[i + 2];
const height = rows[i + 3];
const xMin = xCenter - width / 2.0; // topLeft
const yMin = yCenter - height / 2.0; // topLeft
const x = xCenter - width / 2.0; // topLeft
const y = yCenter - height / 2.0; // topLeft
const leftEyeX = rows[i + 5];
const leftEyeY = rows[i + 6];
@ -253,12 +253,7 @@ const filterExtractDetectionsFromYOLOOutput = (
const rightMouthX = rows[i + 13];
const rightMouthY = rows[i + 14];
const box = {
x: xMin,
y: yMin,
width: width,
height: height,
};
const box = { x, y, width, height };
const probability = score as number;
const landmarks = [
{ x: leftEyeX, y: leftEyeY },
@ -387,18 +382,14 @@ const intersectionOverUnion = (a: FaceDetection, b: FaceDetection): number => {
const makeFaceID = (
fileID: number,
detection: FaceDetection,
imageDims: Dimensions,
{ box }: FaceDetection,
image: Dimensions,
) => {
const part = (v: number) => clamp(v, 0.0, 0.999999).toFixed(5).substring(2);
const xMin = part(detection.box.x / imageDims.width);
const yMin = part(detection.box.y / imageDims.height);
const xMax = part(
(detection.box.x + detection.box.width) / imageDims.width,
);
const yMax = part(
(detection.box.y + detection.box.height) / imageDims.height,
);
const xMin = part(box.x / image.width);
const yMin = part(box.y / image.height);
const xMax = part((box.x + box.width) / image.width);
const yMax = part((box.y + box.height) / image.height);
return [`${fileID}`, xMin, yMin, xMax, yMax].join("_");
};

View file

@ -102,19 +102,14 @@ class ServerDetection {
}
class ServerFaceBox {
public xMin: number;
public yMin: number;
public x: number;
public y: number;
public width: number;
public height: number;
public constructor(
xMin: number,
yMin: number,
width: number,
height: number,
) {
this.xMin = xMin;
this.yMin = yMin;
public constructor(x: number, y: number, width: number, height: number) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}