define app specific types

pull/193/head
Vladimir Mandic 2021-09-27 09:19:43 -04:00
parent d7f4bcfef9
commit 3a89251e51
56 changed files with 1403 additions and 5745 deletions

View File

@ -9,11 +9,11 @@
## Changelog ## Changelog
### **HEAD -> main** 2021/09/25 mandic00@live.com ### **HEAD -> main** 2021/09/27 mandic00@live.com
### **origin/main** 2021/09/25 mandic00@live.com
- autodetect number of bodies and hands
- upload new samples
- new samples gallery and major code folder restructure
- new release - new release
### **2.2.3** 2021/09/24 mandic00@live.com ### **2.2.3** 2021/09/24 mandic00@live.com

View File

@ -104,25 +104,25 @@ function scaleBox(keypoints3, boxScaleFact2, outputSize2) {
const maxmin = [Math.max(...coords3[0]), Math.min(...coords3[0]), Math.max(...coords3[1]), Math.min(...coords3[1])]; const maxmin = [Math.max(...coords3[0]), Math.min(...coords3[0]), Math.max(...coords3[1]), Math.min(...coords3[1])];
const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2]; const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2];
const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2; const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2;
const box6 = [ const box5 = [
Math.trunc(center[0] - diff), Math.trunc(center[0] - diff),
Math.trunc(center[1] - diff), Math.trunc(center[1] - diff),
Math.trunc(2 * diff), Math.trunc(2 * diff),
Math.trunc(2 * diff) Math.trunc(2 * diff)
]; ];
const boxRaw3 = [ const boxRaw2 = [
box6[0] / outputSize2[0], box5[0] / outputSize2[0],
box6[1] / outputSize2[1], box5[1] / outputSize2[1],
box6[2] / outputSize2[0], box5[2] / outputSize2[0],
box6[3] / outputSize2[1] box5[3] / outputSize2[1]
]; ];
const yxBox = [ const yxBox = [
boxRaw3[1], boxRaw2[1],
boxRaw3[0], boxRaw2[0],
boxRaw3[3] + boxRaw3[1], boxRaw2[3] + boxRaw2[1],
boxRaw3[2] + boxRaw3[0] boxRaw2[2] + boxRaw2[0]
]; ];
return { box: box6, boxRaw: boxRaw3, yxBox }; return { box: box5, boxRaw: boxRaw2, yxBox };
} }
// src/config.ts // src/config.ts
@ -258,50 +258,50 @@ var version9 = {
}; };
// src/blazeface/box.ts // src/blazeface/box.ts
function scaleBoxCoordinates(box6, factor) { function scaleBoxCoordinates(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
return { startPoint, endPoint }; return { startPoint, endPoint };
} }
function getBoxSize(box6) { function getBoxSize(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter(box6) { function getBoxCenter(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize(box6, image24, cropSize) { function cutBoxFromImageAndResize(box5, image24, cropSize) {
const h = image24.shape[1]; const h = image24.shape[1];
const w = image24.shape[2]; const w = image24.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return tfjs_esm_exports.image.cropAndResize(image24, boxes, [0], cropSize); return tfjs_esm_exports.image.cropAndResize(image24, boxes, [0], cropSize);
} }
function enlargeBox(box6, factor = 1.5) { function enlargeBox(box5, factor = 1.5) {
const center = getBoxCenter(box6); const center = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function squarifyBox(box6) { function squarifyBox(box5) {
const centers = getBoxCenter(box6); const centers = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)]; const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)];
const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)]; const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function calculateLandmarksBoundingBox(landmarks) { function calculateLandmarksBoundingBox(landmarks) {
const xs = landmarks.map((d) => d[0]); const xs = landmarks.map((d) => d[0]);
@ -4825,8 +4825,8 @@ var Pipeline = class {
this.skipped = 0; this.skipped = 0;
this.detectedFaces = 0; this.detectedFaces = 0;
} }
transformRawCoords(rawCoords, box6, angle, rotationMatrix) { transformRawCoords(rawCoords, box5, angle, rotationMatrix) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const boxSize = getBoxSize({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const coordsScaled = rawCoords.map((coord) => [ const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2), boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2),
boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2), boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2),
@ -4835,7 +4835,7 @@ var Pipeline = class {
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX; const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled; const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX; const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1]; const boxCenter = [...getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint }), 1];
return coordsRotated.map((coord) => [ return coordsRotated.map((coord) => [
Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])), Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])), Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])),
@ -4848,20 +4848,20 @@ var Pipeline = class {
return leftEyeZ - rightEyeZ; return leftEyeZ - rightEyeZ;
} }
getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) { getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge)); const box5 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge));
const boxSize = getBoxSize(box6); const boxSize = getBoxSize(box5);
let crop = tfjs_esm_exports.image.cropAndResize(face5, [[ let crop = tfjs_esm_exports.image.cropAndResize(face5, [[
box6.startPoint[1] / this.meshSize, box5.startPoint[1] / this.meshSize,
box6.startPoint[0] / this.meshSize, box5.startPoint[0] / this.meshSize,
box6.endPoint[1] / this.meshSize, box5.endPoint[1] / this.meshSize,
box6.endPoint[0] / this.meshSize box5.endPoint[0] / this.meshSize
]], [0], [this.irisSize, this.irisSize]); ]], [0], [this.irisSize, this.irisSize]);
if (flip && env.kernels.includes("flipleftright")) { if (flip && env.kernels.includes("flipleftright")) {
const flipped = tfjs_esm_exports.image.flipLeftRight(crop); const flipped = tfjs_esm_exports.image.flipLeftRight(crop);
tfjs_esm_exports.dispose(crop); tfjs_esm_exports.dispose(crop);
crop = flipped; crop = flipped;
} }
return { box: box6, boxSize, crop }; return { box: box5, boxSize, crop };
} }
getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) { getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) {
const eyeRawCoords = []; const eyeRawCoords = [];
@ -4891,14 +4891,14 @@ var Pipeline = class {
return [coord[0], coord[1], z]; return [coord[0], coord[1], z];
}); });
} }
correctFaceRotation(config3, box6, input) { correctFaceRotation(config3, box5, input) {
const [indexOfMouth, indexOfForehead] = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine; const [indexOfMouth, indexOfForehead] = box5.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[indexOfMouth], box6.landmarks[indexOfForehead]); const angle = computeRotation(box5.landmarks[indexOfMouth], box5.landmarks[indexOfForehead]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const faceCenter = getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]]; const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]];
const rotated = tfjs_esm_exports.image.rotateWithOffset(input, angle, 0, faceCenterNormalized); const rotated = tfjs_esm_exports.image.rotateWithOffset(input, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter); const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.boxSize, this.boxSize]);
const face5 = tfjs_esm_exports.div(cut, 255); const face5 = tfjs_esm_exports.div(cut, 255);
tfjs_esm_exports.dispose(cut); tfjs_esm_exports.dispose(cut);
tfjs_esm_exports.dispose(rotated); tfjs_esm_exports.dispose(rotated);
@ -4982,16 +4982,16 @@ var Pipeline = class {
} }
const results = []; const results = [];
const newBoxes = []; const newBoxes = [];
for (let box6 of this.storedBoxes) { for (let box5 of this.storedBoxes) {
let face5; let face5;
let angle = 0; let angle = 0;
let rotationMatrix; let rotationMatrix;
if (config3.face.detector.rotation && config3.face.mesh.enabled && env.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && env.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input);
} else { } else {
rotationMatrix = IDENTITY_MATRIX; rotationMatrix = IDENTITY_MATRIX;
const cloned = input.clone(); const cloned = input.clone();
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.boxSize, this.boxSize]);
face5 = tfjs_esm_exports.div(cut, 255); face5 = tfjs_esm_exports.div(cut, 255);
tfjs_esm_exports.dispose(cut); tfjs_esm_exports.dispose(cut);
tfjs_esm_exports.dispose(cloned); tfjs_esm_exports.dispose(cloned);
@ -4999,10 +4999,10 @@ var Pipeline = class {
if (!config3.face.mesh.enabled) { if (!config3.face.mesh.enabled) {
results.push({ results.push({
mesh: [], mesh: [],
box: box6, box: box5,
faceConfidence: null, faceConfidence: null,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: box6.confidence, confidence: box5.confidence,
image: face5 image: face5
}); });
} else if (!this.meshDetector) { } else if (!this.meshDetector) {
@ -5018,29 +5018,29 @@ var Pipeline = class {
tfjs_esm_exports.dispose(contourCoords); tfjs_esm_exports.dispose(contourCoords);
tfjs_esm_exports.dispose(coordsReshaped); tfjs_esm_exports.dispose(coordsReshaped);
if (faceConfidence < config3.face.detector.minConfidence) { if (faceConfidence < config3.face.detector.minConfidence) {
box6.confidence = faceConfidence; box5.confidence = faceConfidence;
tfjs_esm_exports.dispose(face5); tfjs_esm_exports.dispose(face5);
} else { } else {
if (config3.face.iris.enabled) if (config3.face.iris.enabled)
rawCoords = await this.augmentIris(rawCoords, face5, config3); rawCoords = await this.augmentIris(rawCoords, face5, config3);
const mesh = this.transformRawCoords(rawCoords, box6, angle, rotationMatrix); const mesh = this.transformRawCoords(rawCoords, box5, angle, rotationMatrix);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box6.confidence }; box5 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box5.confidence };
if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env.kernels.includes("rotatewithoffset")) {
tfjs_esm_exports.dispose(face5); tfjs_esm_exports.dispose(face5);
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input);
} }
results.push({ results.push({
mesh, mesh,
box: box6, box: box5,
faceConfidence, faceConfidence,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: faceConfidence, confidence: faceConfidence,
image: face5 image: face5
}); });
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence }; box5 = { ...squarifyBox(box5), confidence: box5.confidence, faceConfidence };
} }
} }
newBoxes.push(box6); newBoxes.push(box5);
} }
if (config3.face.mesh.enabled) if (config3.face.mesh.enabled)
this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence); this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence);
@ -5075,7 +5075,7 @@ async function predict(input, config3) {
Math.trunc(Math.min(input.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])), Math.trunc(Math.min(input.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1])) Math.trunc(Math.min(input.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
const boxRaw3 = prediction.box ? [ const boxRaw2 = prediction.box ? [
prediction.box.startPoint[0] / (input.shape[2] || 0), prediction.box.startPoint[0] / (input.shape[2] || 0),
prediction.box.startPoint[1] / (input.shape[1] || 0), prediction.box.startPoint[1] / (input.shape[1] || 0),
(prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0), (prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0),
@ -5087,7 +5087,7 @@ async function predict(input, config3) {
boxScore: Math.round(100 * prediction.boxConfidence) / 100, boxScore: Math.round(100 * prediction.boxConfidence) / 100,
faceScore: Math.round(100 * prediction.faceConfidence) / 100, faceScore: Math.round(100 * prediction.faceConfidence) / 100,
box: clampedBox, box: clampedBox,
boxRaw: boxRaw3, boxRaw: boxRaw2,
mesh: prediction.mesh, mesh: prediction.mesh,
meshRaw, meshRaw,
annotations: annotations3, annotations: annotations3,
@ -5181,10 +5181,10 @@ function enhance(input) {
const tensor3 = input.image || input.tensor || input; const tensor3 = input.image || input.tensor || input;
if (!(tensor3 instanceof tfjs_esm_exports.Tensor)) if (!(tensor3 instanceof tfjs_esm_exports.Tensor))
return null; return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]]; const box5 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model == null ? void 0 : model.inputs[0].shape)) if (!(model == null ? void 0 : model.inputs[0].shape))
return null; return null;
const crop = tensor3.shape.length === 3 ? tfjs_esm_exports.image.cropAndResize(tfjs_esm_exports.expandDims(tensor3, 0), box6, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]) : tfjs_esm_exports.image.cropAndResize(tensor3, box6, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]); const crop = tensor3.shape.length === 3 ? tfjs_esm_exports.image.cropAndResize(tfjs_esm_exports.expandDims(tensor3, 0), box5, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]) : tfjs_esm_exports.image.cropAndResize(tensor3, box5, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]);
const norm = tfjs_esm_exports.mul(crop, 255); const norm = tfjs_esm_exports.mul(crop, 255);
return norm; return norm;
}); });
@ -5382,8 +5382,8 @@ function scalePoses(poses2, [height, width], [inputResolutionHeight, inputResolu
score: pose.score, score: pose.score,
boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight], boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight],
box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)], box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)],
keypoints: pose.keypoints.map(({ score: score3, part, position }) => ({ keypoints: pose.keypoints.map(({ score: score2, part, position }) => ({
score: score3, score: score2,
part, part,
position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)], position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)],
positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight] positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight]
@ -5507,8 +5507,8 @@ function traverse(edgeId, sourceKeypoint, targetId, scores, offsets, displacemen
targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y }); targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y });
} }
const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width); const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width);
const score3 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId); const score2 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId);
return { position: targetKeypoint, part: partNames[targetId], score: score3 }; return { position: targetKeypoint, part: partNames[targetId], score: score2 };
} }
function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) { function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]); const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]);
@ -5539,7 +5539,7 @@ function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
} }
return keypoints3; return keypoints3;
} }
function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores) { function scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores) {
const [height, width] = scores.shape; const [height, width] = scores.shape;
let localMaximum = true; let localMaximum = true;
const yStart = Math.max(heatmapY - localMaximumRadius, 0); const yStart = Math.max(heatmapY - localMaximumRadius, 0);
@ -5548,7 +5548,7 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
const xStart = Math.max(heatmapX - localMaximumRadius, 0); const xStart = Math.max(heatmapX - localMaximumRadius, 0);
const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width); const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width);
for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) { for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) {
if (scores.get(yCurrent, xCurrent, keypointId) > score3) { if (scores.get(yCurrent, xCurrent, keypointId) > score2) {
localMaximum = false; localMaximum = false;
break; break;
} }
@ -5560,15 +5560,15 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
} }
function buildPartWithScoreQueue(minConfidence2, scores) { function buildPartWithScoreQueue(minConfidence2, scores) {
const [height, width, numKeypoints] = scores.shape; const [height, width, numKeypoints] = scores.shape;
const queue = new MaxHeap(height * width * numKeypoints, ({ score: score3 }) => score3); const queue = new MaxHeap(height * width * numKeypoints, ({ score: score2 }) => score2);
for (let heatmapY = 0; heatmapY < height; ++heatmapY) { for (let heatmapY = 0; heatmapY < height; ++heatmapY) {
for (let heatmapX = 0; heatmapX < width; ++heatmapX) { for (let heatmapX = 0; heatmapX < width; ++heatmapX) {
for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) { for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) {
const score3 = scores.get(heatmapY, heatmapX, keypointId); const score2 = scores.get(heatmapY, heatmapX, keypointId);
if (score3 < minConfidence2) if (score2 < minConfidence2)
continue; continue;
if (scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores)) if (scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores))
queue.enqueue({ score: score3, part: { heatmapY, heatmapX, id: keypointId } }); queue.enqueue({ score: score2, part: { heatmapY, heatmapX, id: keypointId } });
} }
} }
} }
@ -5584,9 +5584,9 @@ function withinRadius(poses2, { x, y }, keypointId) {
}); });
} }
function getInstanceScore(existingPoses, keypoints3) { function getInstanceScore(existingPoses, keypoints3) {
const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score3 }, keypointId) => { const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score2 }, keypointId) => {
if (!withinRadius(existingPoses, position, keypointId)) if (!withinRadius(existingPoses, position, keypointId))
result += score3; result += score2;
return result; return result;
}, 0); }, 0);
return notOverlappedKeypointScores / keypoints3.length; return notOverlappedKeypointScores / keypoints3.length;
@ -5601,10 +5601,10 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
continue; continue;
let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd); let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints3 = keypoints3.filter((a) => a.score > minConfidence2); keypoints3 = keypoints3.filter((a) => a.score > minConfidence2);
const score3 = getInstanceScore(poses2, keypoints3); const score2 = getInstanceScore(poses2, keypoints3);
const box6 = getBoundingBox(keypoints3); const box5 = getBoundingBox(keypoints3);
if (score3 > minConfidence2) if (score2 > minConfidence2)
poses2.push({ keypoints: keypoints3, box: box6, score: Math.round(100 * score3) / 100 }); poses2.push({ keypoints: keypoints3, box: box5, score: Math.round(100 * score2) / 100 });
} }
return poses2; return poses2;
} }
@ -5645,54 +5645,54 @@ async function load5(config3) {
} }
// src/handpose/box.ts // src/handpose/box.ts
function getBoxSize2(box6) { function getBoxSize2(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter2(box6) { function getBoxCenter2(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize2(box6, image24, cropSize) { function cutBoxFromImageAndResize2(box5, image24, cropSize) {
const h = image24.shape[1]; const h = image24.shape[1];
const w = image24.shape[2]; const w = image24.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return tfjs_esm_exports.image.cropAndResize(image24, boxes, [0], cropSize); return tfjs_esm_exports.image.cropAndResize(image24, boxes, [0], cropSize);
} }
function scaleBoxCoordinates2(box6, factor) { function scaleBoxCoordinates2(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => { const palmLandmarks = box5.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]]; const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord; return scaledCoord;
}); });
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence }; return { startPoint, endPoint, palmLandmarks, confidence: box5.confidence };
} }
function enlargeBox2(box6, factor = 1.5) { function enlargeBox2(box5, factor = 1.5) {
const center = getBoxCenter2(box6); const center = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
function squarifyBox2(box6) { function squarifyBox2(box5) {
const centers = getBoxCenter2(box6); const centers = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize]; const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize]; const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
// src/handpose/anchors.ts // src/handpose/anchors.ts
@ -9218,9 +9218,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedCurl, score3] of expectedCurls) { for (const [expectedCurl, score2] of expectedCurls) {
if (detectedCurl === expectedCurl) { if (detectedCurl === expectedCurl) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -9232,9 +9232,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedDirection, score3] of expectedDirections) { for (const [expectedDirection, score2] of expectedDirections) {
if (detectedDirection === expectedDirection) { if (detectedDirection === expectedDirection) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -9330,30 +9330,30 @@ async function predict5(input, config3) {
} }
} }
const keypoints3 = predictions[i].landmarks; const keypoints3 = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0]; let box5 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw3 = [0, 0, 0, 0]; let boxRaw2 = [0, 0, 0, 0];
if (keypoints3 && keypoints3.length > 0) { if (keypoints3 && keypoints3.length > 0) {
for (const pt of keypoints3) { for (const pt of keypoints3) {
if (pt[0] < box6[0]) if (pt[0] < box5[0])
box6[0] = pt[0]; box5[0] = pt[0];
if (pt[1] < box6[1]) if (pt[1] < box5[1])
box6[1] = pt[1]; box5[1] = pt[1];
if (pt[0] > box6[2]) if (pt[0] > box5[2])
box6[2] = pt[0]; box5[2] = pt[0];
if (pt[1] > box6[3]) if (pt[1] > box5[3])
box6[3] = pt[1]; box5[3] = pt[1];
} }
box6[2] -= box6[0]; box5[2] -= box5[0];
box6[3] -= box6[1]; box5[3] -= box5[1];
boxRaw3 = [box6[0] / (input.shape[2] || 0), box6[1] / (input.shape[1] || 0), box6[2] / (input.shape[2] || 0), box6[3] / (input.shape[1] || 0)]; boxRaw2 = [box5[0] / (input.shape[2] || 0), box5[1] / (input.shape[1] || 0), box5[2] / (input.shape[2] || 0), box5[3] / (input.shape[1] || 0)];
} else { } else {
box6 = predictions[i].box ? [ box5 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.max(0, predictions[i].box.topLeft[1])), Math.trunc(Math.max(0, predictions[i].box.topLeft[1])),
Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1])) Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
boxRaw3 = [ boxRaw2 = [
predictions[i].box.topLeft[0] / (input.shape[2] || 0), predictions[i].box.topLeft[0] / (input.shape[2] || 0),
predictions[i].box.topLeft[1] / (input.shape[1] || 0), predictions[i].box.topLeft[1] / (input.shape[1] || 0),
(predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0), (predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0),
@ -9367,8 +9367,8 @@ async function predict5(input, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100, boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100, fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand", label: "hand",
box: box6, box: box5,
boxRaw: boxRaw3, boxRaw: boxRaw2,
keypoints: keypoints3, keypoints: keypoints3,
annotations: annotations3, annotations: annotations3,
landmarks landmarks
@ -9698,13 +9698,13 @@ async function detectHands(input, config3) {
} else { } else {
yxBox = await boxSlice.data(); yxBox = await boxSlice.data();
} }
const boxRaw3 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]]; const boxRaw2 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]];
const box6 = [Math.trunc(boxRaw3[0] * outputSize[0]), Math.trunc(boxRaw3[1] * outputSize[1]), Math.trunc(boxRaw3[2] * outputSize[0]), Math.trunc(boxRaw3[3] * outputSize[1])]; const box5 = [Math.trunc(boxRaw2[0] * outputSize[0]), Math.trunc(boxRaw2[1] * outputSize[1]), Math.trunc(boxRaw2[2] * outputSize[0]), Math.trunc(boxRaw2[3] * outputSize[1])];
tfjs_esm_exports.dispose(boxSlice); tfjs_esm_exports.dispose(boxSlice);
const scoreSlice = tfjs_esm_exports.slice(classScores[i], res, 1); const scoreSlice = tfjs_esm_exports.slice(classScores[i], res, 1);
const score3 = (await scoreSlice.data())[0]; const score2 = (await scoreSlice.data())[0];
tfjs_esm_exports.dispose(scoreSlice); tfjs_esm_exports.dispose(scoreSlice);
const hand3 = { id: id++, score: score3, box: box6, boxRaw: boxRaw3, label: classes[i], yxBox }; const hand3 = { id: id++, score: score2, box: box5, boxRaw: boxRaw2, label: classes[i], yxBox };
hands.push(hand3); hands.push(hand3);
} }
} }
@ -9738,9 +9738,9 @@ async function detectFingers(input, h, config3) {
t.cast = tfjs_esm_exports.cast(t.crop, "float32"); t.cast = tfjs_esm_exports.cast(t.crop, "float32");
t.div = tfjs_esm_exports.div(t.cast, 255); t.div = tfjs_esm_exports.div(t.cast, 255);
[t.score, t.keypoints] = models2[1].execute(t.div); [t.score, t.keypoints] = models2[1].execute(t.div);
const score3 = Math.round(100 * (await t.score.data())[0] / 100); const score2 = Math.round(100 * (await t.score.data())[0] / 100);
if (score3 > (config3.hand.minConfidence || 0)) { if (score2 > (config3.hand.minConfidence || 0)) {
hand3.fingerScore = score3; hand3.fingerScore = score2;
t.reshaped = tfjs_esm_exports.reshape(t.keypoints, [-1, 3]); t.reshaped = tfjs_esm_exports.reshape(t.keypoints, [-1, 3]);
const rawCoords = await t.reshaped.array(); const rawCoords = await t.reshaped.array();
hand3.keypoints = rawCoords.map((coord) => [ hand3.keypoints = rawCoords.map((coord) => [
@ -9915,15 +9915,15 @@ async function predict7(image24, config3) {
} }
const x = keypoints3.map((a) => a.position[0]); const x = keypoints3.map((a) => a.position[0]);
const y = keypoints3.map((a) => a.position[1]); const y = keypoints3.map((a) => a.position[1]);
const box6 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
Math.max(...y) - Math.min(...x) Math.max(...y) - Math.min(...x)
]; ];
const boxRaw3 = [0, 0, 0, 0]; const boxRaw2 = [0, 0, 0, 0];
const score3 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); const score2 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
return [{ id: 0, score: score3, box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }]; return [{ id: 0, score: score2, box: box5, boxRaw: boxRaw2, keypoints: keypoints3 }];
} }
// src/efficientpose/efficientpose.ts // src/efficientpose/efficientpose.ts
@ -10033,9 +10033,6 @@ async function predict8(image24, config3) {
var model6; var model6;
var inputSize2 = 0; var inputSize2 = 0;
var cachedBoxes = []; var cachedBoxes = [];
var box5 = [0, 0, 0, 0];
var boxRaw2 = [0, 0, 0, 0];
var score2 = 0;
var skipped5 = Number.MAX_SAFE_INTEGER; var skipped5 = Number.MAX_SAFE_INTEGER;
var keypoints2 = []; var keypoints2 = [];
var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"]; var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"];
@ -10059,6 +10056,7 @@ async function load9(config3) {
async function parseSinglePose(res, config3, image24, inputBox) { async function parseSinglePose(res, config3, image24, inputBox) {
const kpt3 = res[0][0]; const kpt3 = res[0][0];
keypoints2.length = 0; keypoints2.length = 0;
let score2 = 0;
for (let id = 0; id < kpt3.length; id++) { for (let id = 0; id < kpt3.length; id++) {
score2 = kpt3[id][2]; score2 = kpt3[id][2];
if (score2 > config3.body.minConfidence) { if (score2 > config3.body.minConfidence) {
@ -10080,7 +10078,7 @@ async function parseSinglePose(res, config3, image24, inputBox) {
score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
const x = keypoints2.map((a) => a.position[0]); const x = keypoints2.map((a) => a.position[0]);
const y = keypoints2.map((a) => a.position[1]); const y = keypoints2.map((a) => a.position[1]);
box5 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
@ -10088,7 +10086,7 @@ async function parseSinglePose(res, config3, image24, inputBox) {
]; ];
const xRaw = keypoints2.map((a) => a.positionRaw[0]); const xRaw = keypoints2.map((a) => a.positionRaw[0]);
const yRaw = keypoints2.map((a) => a.positionRaw[1]); const yRaw = keypoints2.map((a) => a.positionRaw[1]);
boxRaw2 = [ const boxRaw2 = [
Math.min(...xRaw), Math.min(...xRaw),
Math.min(...yRaw), Math.min(...yRaw),
Math.max(...xRaw) - Math.min(...xRaw), Math.max(...xRaw) - Math.min(...xRaw),
@ -10102,7 +10100,7 @@ async function parseMultiPose(res, config3, image24, inputBox) {
const bodies = []; const bodies = [];
for (let id = 0; id < res[0].length; id++) { for (let id = 0; id < res[0].length; id++) {
const kpt3 = res[0][id]; const kpt3 = res[0][id];
score2 = Math.round(100 * kpt3[51 + 4]) / 100; const score2 = Math.round(100 * kpt3[51 + 4]) / 100;
if (score2 < config3.body.minConfidence) if (score2 < config3.body.minConfidence)
continue; continue;
keypoints2.length = 0; keypoints2.length = 0;
@ -10121,7 +10119,7 @@ async function parseMultiPose(res, config3, image24, inputBox) {
}); });
} }
} }
boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]]; const boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]];
bodies.push({ bodies.push({
id, id,
score: score2, score: score2,
@ -10297,8 +10295,8 @@ async function process3(res, inputSize4, outputShape, config3) {
const scores = await scoresT.array(); const scores = await scoresT.array();
for (let i = 0; i < scoresT.shape[0]; i++) { for (let i = 0; i < scoresT.shape[0]; i++) {
for (let j = 0; j < scoresT.shape[1]; j++) { for (let j = 0; j < scoresT.shape[1]; j++) {
const score3 = scores[i][j]; const score2 = scores[i][j];
if (score3 > config3.object.minConfidence && j !== 61) { if (score2 > config3.object.minConfidence && j !== 61) {
const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize; const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize;
const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize; const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize;
const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4)); const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4));
@ -10310,21 +10308,21 @@ async function process3(res, inputSize4, outputShape, config3) {
cx + scaleBox2 / strideSize * boxOffset[2] - x, cx + scaleBox2 / strideSize * boxOffset[2] - x,
cy + scaleBox2 / strideSize * boxOffset[3] - y cy + scaleBox2 / strideSize * boxOffset[3] - y
]; ];
let boxRaw3 = [x, y, w, h]; let boxRaw2 = [x, y, w, h];
boxRaw3 = boxRaw3.map((a) => Math.max(0, Math.min(a, 1))); boxRaw2 = boxRaw2.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [ const box5 = [
boxRaw3[0] * outputShape[0], boxRaw2[0] * outputShape[0],
boxRaw3[1] * outputShape[1], boxRaw2[1] * outputShape[1],
boxRaw3[2] * outputShape[0], boxRaw2[2] * outputShape[0],
boxRaw3[3] * outputShape[1] boxRaw2[3] * outputShape[1]
]; ];
const result = { const result = {
id: id++, id: id++,
score: Math.round(100 * score3) / 100, score: Math.round(100 * score2) / 100,
class: j + 1, class: j + 1,
label: labels[j].label, label: labels[j].label,
box: box6.map((a) => Math.trunc(a)), box: box5.map((a) => Math.trunc(a)),
boxRaw: boxRaw3 boxRaw: boxRaw2
}; };
results.push(result); results.push(result);
} }
@ -10413,26 +10411,26 @@ async function process4(res, outputShape, config3) {
tfjs_esm_exports.dispose(nmsT); tfjs_esm_exports.dispose(nmsT);
let i = 0; let i = 0;
for (const id of nms) { for (const id of nms) {
const score3 = Math.trunc(100 * detections[0][id][4]) / 100; const score2 = Math.trunc(100 * detections[0][id][4]) / 100;
const classVal = detections[0][id][5]; const classVal = detections[0][id][5];
const label = labels[classVal].label; const label = labels[classVal].label;
const [x, y] = [ const [x, y] = [
detections[0][id][0] / inputSize3, detections[0][id][0] / inputSize3,
detections[0][id][1] / inputSize3 detections[0][id][1] / inputSize3
]; ];
const boxRaw3 = [ const boxRaw2 = [
x, x,
y, y,
detections[0][id][2] / inputSize3 - x, detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y detections[0][id][3] / inputSize3 - y
]; ];
const box6 = [ const box5 = [
Math.trunc(boxRaw3[0] * outputShape[0]), Math.trunc(boxRaw2[0] * outputShape[0]),
Math.trunc(boxRaw3[1] * outputShape[1]), Math.trunc(boxRaw2[1] * outputShape[1]),
Math.trunc(boxRaw3[2] * outputShape[0]), Math.trunc(boxRaw2[2] * outputShape[0]),
Math.trunc(boxRaw3[3] * outputShape[1]) Math.trunc(boxRaw2[3] * outputShape[1])
]; ];
results.push({ id: i++, score: score3, class: classVal, label, box: box6, boxRaw: boxRaw3 }); results.push({ id: i++, score: score2, class: classVal, label, box: box5, boxRaw: boxRaw2 });
} }
return results; return results;
} }
@ -11355,7 +11353,7 @@ async function hand2(inCanvas2, result, drawOptions) {
if (localOptions.drawPoints) { if (localOptions.drawPoints) {
if (h.keypoints && h.keypoints.length > 0) { if (h.keypoints && h.keypoints.length > 0) {
for (const pt of h.keypoints) { for (const pt of h.keypoints) {
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * pt[2]}, ${127.5 - 2 * pt[2]}, 255, 0.5)` : localOptions.color; ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * (pt[2] || 0)}, ${127.5 - 2 * (pt[2] || 0)}, 255, 0.5)` : localOptions.color;
point(ctx, pt[0], pt[1], 0, localOptions); point(ctx, pt[0], pt[1], 0, localOptions);
} }
} }
@ -11506,10 +11504,10 @@ function join2(faces, bodies, hands, gestures, shape) {
} }
const x = []; const x = [];
const y = []; const y = [];
const extractXY = (box6) => { const extractXY = (box5) => {
if (box6 && box6.length === 4) { if (box5 && box5.length === 4) {
x.push(box6[0], box6[0] + box6[2]); x.push(box5[0], box5[0] + box5[2]);
y.push(box6[1], box6[1] + box6[3]); y.push(box5[1], box5[1] + box5[3]);
} }
}; };
extractXY((_k = person2.face) == null ? void 0 : _k.box); extractXY((_k = person2.face) == null ? void 0 : _k.box);
@ -11539,8 +11537,8 @@ function calc(newResult) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body)); bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else { } else {
for (let i = 0; i < newResult.body.length; i++) { for (let i = 0; i < newResult.body.length; i++) {
const box6 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor); const box5 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({ const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score, score: keypoint.score,
part: keypoint.part, part: keypoint.part,
@ -11553,18 +11551,18 @@ function calc(newResult) {
bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1] bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1]
] ]
})); }));
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }; bufferedResult.body[i] = { ...newResult.body[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3 };
} }
} }
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) { if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand)); bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else { } else {
for (let i = 0; i < newResult.hand.length; i++) { for (let i = 0; i < newResult.hand.length; i++) {
const box6 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor); const box5 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor);
if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length) if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints; bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].keypoints[j][k] + coord) / bufferedFactor)) : []; const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * (bufferedResult.hand[i].keypoints[j][k] || 1) + (coord || 0)) / bufferedFactor)) : [];
const annotations3 = {}; const annotations3 = {};
if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length) if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length)
bufferedResult.hand[i].annotations = newResult.hand[i].annotations; bufferedResult.hand[i].annotations = newResult.hand[i].annotations;
@ -11573,15 +11571,15 @@ function calc(newResult) {
annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null; annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null;
} }
} }
bufferedResult.hand[i] = { ...newResult.hand[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3, annotations: annotations3 }; bufferedResult.hand[i] = { ...newResult.hand[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3, annotations: annotations3 };
} }
} }
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) { if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face)); bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else { } else {
for (let i = 0; i < newResult.face.length; i++) { for (let i = 0; i < newResult.face.length; i++) {
const box6 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor); const box5 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor);
const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } }; const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } };
rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix; rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix;
rotation.angle = { rotation.angle = {
@ -11593,16 +11591,16 @@ function calc(newResult) {
bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor, bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor
}; };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw: boxRaw3 }; bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box5, boxRaw: boxRaw2 };
} }
} }
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) { if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object)); bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else { } else {
for (let i = 0; i < newResult.object.length; i++) { for (let i = 0; i < newResult.object.length; i++) {
const box6 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor); const box5 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor);
bufferedResult.object[i] = { ...newResult.object[i], box: box6, boxRaw: boxRaw3 }; bufferedResult.object[i] = { ...newResult.object[i], box: box5, boxRaw: boxRaw2 };
} }
} }
if (newResult.persons) { if (newResult.persons) {
@ -11611,7 +11609,7 @@ function calc(newResult) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons)); bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else { } else {
for (let i = 0; i < newPersons.length; i++) { for (let i = 0; i < newPersons.length; i++) {
bufferedResult.persons[i].box = newPersons[i].box.map((box6, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box6) / bufferedFactor); bufferedResult.persons[i].box = newPersons[i].box.map((box5, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box5) / bufferedFactor);
} }
} }
} }

File diff suppressed because one or more lines are too long

368
dist/human.esm.js vendored
View File

@ -100,25 +100,25 @@ function scaleBox(keypoints3, boxScaleFact2, outputSize2) {
const maxmin = [Math.max(...coords4[0]), Math.min(...coords4[0]), Math.max(...coords4[1]), Math.min(...coords4[1])]; const maxmin = [Math.max(...coords4[0]), Math.min(...coords4[0]), Math.max(...coords4[1]), Math.min(...coords4[1])];
const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2]; const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2];
const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2; const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2;
const box6 = [ const box5 = [
Math.trunc(center[0] - diff), Math.trunc(center[0] - diff),
Math.trunc(center[1] - diff), Math.trunc(center[1] - diff),
Math.trunc(2 * diff), Math.trunc(2 * diff),
Math.trunc(2 * diff) Math.trunc(2 * diff)
]; ];
const boxRaw3 = [ const boxRaw2 = [
box6[0] / outputSize2[0], box5[0] / outputSize2[0],
box6[1] / outputSize2[1], box5[1] / outputSize2[1],
box6[2] / outputSize2[0], box5[2] / outputSize2[0],
box6[3] / outputSize2[1] box5[3] / outputSize2[1]
]; ];
const yxBox = [ const yxBox = [
boxRaw3[1], boxRaw2[1],
boxRaw3[0], boxRaw2[0],
boxRaw3[3] + boxRaw3[1], boxRaw2[3] + boxRaw2[1],
boxRaw3[2] + boxRaw3[0] boxRaw2[2] + boxRaw2[0]
]; ];
return { box: box6, boxRaw: boxRaw3, yxBox }; return { box: box5, boxRaw: boxRaw2, yxBox };
} }
// src/config.ts // src/config.ts
@ -60326,50 +60326,50 @@ var version92 = {
}; };
// src/blazeface/box.ts // src/blazeface/box.ts
function scaleBoxCoordinates(box6, factor) { function scaleBoxCoordinates(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
return { startPoint, endPoint }; return { startPoint, endPoint };
} }
function getBoxSize(box6) { function getBoxSize(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter(box6) { function getBoxCenter(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize(box6, image7, cropSize) { function cutBoxFromImageAndResize(box5, image7, cropSize) {
const h = image7.shape[1]; const h = image7.shape[1];
const w = image7.shape[2]; const w = image7.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return image.cropAndResize(image7, boxes, [0], cropSize); return image.cropAndResize(image7, boxes, [0], cropSize);
} }
function enlargeBox(box6, factor = 1.5) { function enlargeBox(box5, factor = 1.5) {
const center = getBoxCenter(box6); const center = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function squarifyBox(box6) { function squarifyBox(box5) {
const centers = getBoxCenter(box6); const centers = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)]; const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)];
const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)]; const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function calculateLandmarksBoundingBox(landmarks) { function calculateLandmarksBoundingBox(landmarks) {
const xs = landmarks.map((d) => d[0]); const xs = landmarks.map((d) => d[0]);
@ -64893,8 +64893,8 @@ var Pipeline = class {
this.skipped = 0; this.skipped = 0;
this.detectedFaces = 0; this.detectedFaces = 0;
} }
transformRawCoords(rawCoords, box6, angle, rotationMatrix) { transformRawCoords(rawCoords, box5, angle, rotationMatrix) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const boxSize = getBoxSize({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const coordsScaled = rawCoords.map((coord) => [ const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2), boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2),
boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2), boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2),
@ -64903,7 +64903,7 @@ var Pipeline = class {
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX; const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled; const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX; const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1]; const boxCenter = [...getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint }), 1];
return coordsRotated.map((coord) => [ return coordsRotated.map((coord) => [
Math.round(coord[0] + dot4(boxCenter, inverseRotationMatrix[0])), Math.round(coord[0] + dot4(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot4(boxCenter, inverseRotationMatrix[1])), Math.round(coord[1] + dot4(boxCenter, inverseRotationMatrix[1])),
@ -64916,20 +64916,20 @@ var Pipeline = class {
return leftEyeZ - rightEyeZ; return leftEyeZ - rightEyeZ;
} }
getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) { getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge)); const box5 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge));
const boxSize = getBoxSize(box6); const boxSize = getBoxSize(box5);
let crop = image.cropAndResize(face5, [[ let crop = image.cropAndResize(face5, [[
box6.startPoint[1] / this.meshSize, box5.startPoint[1] / this.meshSize,
box6.startPoint[0] / this.meshSize, box5.startPoint[0] / this.meshSize,
box6.endPoint[1] / this.meshSize, box5.endPoint[1] / this.meshSize,
box6.endPoint[0] / this.meshSize box5.endPoint[0] / this.meshSize
]], [0], [this.irisSize, this.irisSize]); ]], [0], [this.irisSize, this.irisSize]);
if (flip && env2.kernels.includes("flipleftright")) { if (flip && env2.kernels.includes("flipleftright")) {
const flipped = image.flipLeftRight(crop); const flipped = image.flipLeftRight(crop);
dispose(crop); dispose(crop);
crop = flipped; crop = flipped;
} }
return { box: box6, boxSize, crop }; return { box: box5, boxSize, crop };
} }
getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) { getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) {
const eyeRawCoords = []; const eyeRawCoords = [];
@ -64959,14 +64959,14 @@ var Pipeline = class {
return [coord[0], coord[1], z]; return [coord[0], coord[1], z];
}); });
} }
correctFaceRotation(config3, box6, input2) { correctFaceRotation(config3, box5, input2) {
const [indexOfMouth, indexOfForehead] = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine; const [indexOfMouth, indexOfForehead] = box5.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[indexOfMouth], box6.landmarks[indexOfForehead]); const angle = computeRotation(box5.landmarks[indexOfMouth], box5.landmarks[indexOfForehead]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const faceCenter = getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const faceCenterNormalized = [faceCenter[0] / input2.shape[2], faceCenter[1] / input2.shape[1]]; const faceCenterNormalized = [faceCenter[0] / input2.shape[2], faceCenter[1] / input2.shape[1]];
const rotated = image.rotateWithOffset(input2, angle, 0, faceCenterNormalized); const rotated = image.rotateWithOffset(input2, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter); const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.boxSize, this.boxSize]);
const face5 = div(cut, 255); const face5 = div(cut, 255);
dispose(cut); dispose(cut);
dispose(rotated); dispose(rotated);
@ -65050,16 +65050,16 @@ var Pipeline = class {
} }
const results = []; const results = [];
const newBoxes = []; const newBoxes = [];
for (let box6 of this.storedBoxes) { for (let box5 of this.storedBoxes) {
let face5; let face5;
let angle = 0; let angle = 0;
let rotationMatrix; let rotationMatrix;
if (config3.face.detector.rotation && config3.face.mesh.enabled && env2.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && env2.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input2); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input2);
} else { } else {
rotationMatrix = IDENTITY_MATRIX; rotationMatrix = IDENTITY_MATRIX;
const cloned = input2.clone(); const cloned = input2.clone();
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.boxSize, this.boxSize]);
face5 = div(cut, 255); face5 = div(cut, 255);
dispose(cut); dispose(cut);
dispose(cloned); dispose(cloned);
@ -65067,10 +65067,10 @@ var Pipeline = class {
if (!config3.face.mesh.enabled) { if (!config3.face.mesh.enabled) {
results.push({ results.push({
mesh: [], mesh: [],
box: box6, box: box5,
faceConfidence: null, faceConfidence: null,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: box6.confidence, confidence: box5.confidence,
image: face5 image: face5
}); });
} else if (!this.meshDetector) { } else if (!this.meshDetector) {
@ -65086,29 +65086,29 @@ var Pipeline = class {
dispose(contourCoords); dispose(contourCoords);
dispose(coordsReshaped); dispose(coordsReshaped);
if (faceConfidence < config3.face.detector.minConfidence) { if (faceConfidence < config3.face.detector.minConfidence) {
box6.confidence = faceConfidence; box5.confidence = faceConfidence;
dispose(face5); dispose(face5);
} else { } else {
if (config3.face.iris.enabled) if (config3.face.iris.enabled)
rawCoords = await this.augmentIris(rawCoords, face5, config3); rawCoords = await this.augmentIris(rawCoords, face5, config3);
const mesh = this.transformRawCoords(rawCoords, box6, angle, rotationMatrix); const mesh = this.transformRawCoords(rawCoords, box5, angle, rotationMatrix);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box6.confidence }; box5 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box5.confidence };
if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env2.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env2.kernels.includes("rotatewithoffset")) {
dispose(face5); dispose(face5);
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input2); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input2);
} }
results.push({ results.push({
mesh, mesh,
box: box6, box: box5,
faceConfidence, faceConfidence,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: faceConfidence, confidence: faceConfidence,
image: face5 image: face5
}); });
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence }; box5 = { ...squarifyBox(box5), confidence: box5.confidence, faceConfidence };
} }
} }
newBoxes.push(box6); newBoxes.push(box5);
} }
if (config3.face.mesh.enabled) if (config3.face.mesh.enabled)
this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence); this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence);
@ -65143,7 +65143,7 @@ async function predict(input2, config3) {
Math.trunc(Math.min(input2.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])), Math.trunc(Math.min(input2.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])),
Math.trunc(Math.min(input2.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1])) Math.trunc(Math.min(input2.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
const boxRaw3 = prediction.box ? [ const boxRaw2 = prediction.box ? [
prediction.box.startPoint[0] / (input2.shape[2] || 0), prediction.box.startPoint[0] / (input2.shape[2] || 0),
prediction.box.startPoint[1] / (input2.shape[1] || 0), prediction.box.startPoint[1] / (input2.shape[1] || 0),
(prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input2.shape[2] || 0), (prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input2.shape[2] || 0),
@ -65155,7 +65155,7 @@ async function predict(input2, config3) {
boxScore: Math.round(100 * prediction.boxConfidence) / 100, boxScore: Math.round(100 * prediction.boxConfidence) / 100,
faceScore: Math.round(100 * prediction.faceConfidence) / 100, faceScore: Math.round(100 * prediction.faceConfidence) / 100,
box: clampedBox, box: clampedBox,
boxRaw: boxRaw3, boxRaw: boxRaw2,
mesh: prediction.mesh, mesh: prediction.mesh,
meshRaw, meshRaw,
annotations: annotations3, annotations: annotations3,
@ -65249,10 +65249,10 @@ function enhance(input2) {
const tensor2 = input2.image || input2.tensor || input2; const tensor2 = input2.image || input2.tensor || input2;
if (!(tensor2 instanceof Tensor)) if (!(tensor2 instanceof Tensor))
return null; return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]]; const box5 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model2 == null ? void 0 : model2.inputs[0].shape)) if (!(model2 == null ? void 0 : model2.inputs[0].shape))
return null; return null;
const crop = tensor2.shape.length === 3 ? image.cropAndResize(expandDims(tensor2, 0), box6, [0], [model2.inputs[0].shape[2], model2.inputs[0].shape[1]]) : image.cropAndResize(tensor2, box6, [0], [model2.inputs[0].shape[2], model2.inputs[0].shape[1]]); const crop = tensor2.shape.length === 3 ? image.cropAndResize(expandDims(tensor2, 0), box5, [0], [model2.inputs[0].shape[2], model2.inputs[0].shape[1]]) : image.cropAndResize(tensor2, box5, [0], [model2.inputs[0].shape[2], model2.inputs[0].shape[1]]);
const norm2 = mul(crop, 255); const norm2 = mul(crop, 255);
return norm2; return norm2;
}); });
@ -65450,8 +65450,8 @@ function scalePoses(poses2, [height, width], [inputResolutionHeight, inputResolu
score: pose.score, score: pose.score,
boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight], boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight],
box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)], box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)],
keypoints: pose.keypoints.map(({ score: score3, part, position }) => ({ keypoints: pose.keypoints.map(({ score: score2, part, position }) => ({
score: score3, score: score2,
part, part,
position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)], position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)],
positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight] positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight]
@ -65575,8 +65575,8 @@ function traverse(edgeId, sourceKeypoint, targetId, scores, offsets, displacemen
targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y }); targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y });
} }
const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width); const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width);
const score3 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId); const score2 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId);
return { position: targetKeypoint, part: partNames[targetId], score: score3 }; return { position: targetKeypoint, part: partNames[targetId], score: score2 };
} }
function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) { function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]); const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]);
@ -65607,7 +65607,7 @@ function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
} }
return keypoints3; return keypoints3;
} }
function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores) { function scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores) {
const [height, width] = scores.shape; const [height, width] = scores.shape;
let localMaximum = true; let localMaximum = true;
const yStart = Math.max(heatmapY - localMaximumRadius, 0); const yStart = Math.max(heatmapY - localMaximumRadius, 0);
@ -65616,7 +65616,7 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
const xStart = Math.max(heatmapX - localMaximumRadius, 0); const xStart = Math.max(heatmapX - localMaximumRadius, 0);
const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width); const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width);
for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) { for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) {
if (scores.get(yCurrent, xCurrent, keypointId) > score3) { if (scores.get(yCurrent, xCurrent, keypointId) > score2) {
localMaximum = false; localMaximum = false;
break; break;
} }
@ -65628,15 +65628,15 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
} }
function buildPartWithScoreQueue(minConfidence2, scores) { function buildPartWithScoreQueue(minConfidence2, scores) {
const [height, width, numKeypoints] = scores.shape; const [height, width, numKeypoints] = scores.shape;
const queue = new MaxHeap(height * width * numKeypoints, ({ score: score3 }) => score3); const queue = new MaxHeap(height * width * numKeypoints, ({ score: score2 }) => score2);
for (let heatmapY = 0; heatmapY < height; ++heatmapY) { for (let heatmapY = 0; heatmapY < height; ++heatmapY) {
for (let heatmapX = 0; heatmapX < width; ++heatmapX) { for (let heatmapX = 0; heatmapX < width; ++heatmapX) {
for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) { for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) {
const score3 = scores.get(heatmapY, heatmapX, keypointId); const score2 = scores.get(heatmapY, heatmapX, keypointId);
if (score3 < minConfidence2) if (score2 < minConfidence2)
continue; continue;
if (scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores)) if (scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores))
queue.enqueue({ score: score3, part: { heatmapY, heatmapX, id: keypointId } }); queue.enqueue({ score: score2, part: { heatmapY, heatmapX, id: keypointId } });
} }
} }
} }
@ -65652,9 +65652,9 @@ function withinRadius(poses2, { x, y }, keypointId) {
}); });
} }
function getInstanceScore(existingPoses, keypoints3) { function getInstanceScore(existingPoses, keypoints3) {
const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score3 }, keypointId) => { const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score2 }, keypointId) => {
if (!withinRadius(existingPoses, position, keypointId)) if (!withinRadius(existingPoses, position, keypointId))
result += score3; result += score2;
return result; return result;
}, 0); }, 0);
return notOverlappedKeypointScores / keypoints3.length; return notOverlappedKeypointScores / keypoints3.length;
@ -65669,10 +65669,10 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
continue; continue;
let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd); let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints3 = keypoints3.filter((a) => a.score > minConfidence2); keypoints3 = keypoints3.filter((a) => a.score > minConfidence2);
const score3 = getInstanceScore(poses2, keypoints3); const score2 = getInstanceScore(poses2, keypoints3);
const box6 = getBoundingBox(keypoints3); const box5 = getBoundingBox(keypoints3);
if (score3 > minConfidence2) if (score2 > minConfidence2)
poses2.push({ keypoints: keypoints3, box: box6, score: Math.round(100 * score3) / 100 }); poses2.push({ keypoints: keypoints3, box: box5, score: Math.round(100 * score2) / 100 });
} }
return poses2; return poses2;
} }
@ -65713,54 +65713,54 @@ async function load5(config3) {
} }
// src/handpose/box.ts // src/handpose/box.ts
function getBoxSize2(box6) { function getBoxSize2(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter2(box6) { function getBoxCenter2(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize2(box6, image7, cropSize) { function cutBoxFromImageAndResize2(box5, image7, cropSize) {
const h = image7.shape[1]; const h = image7.shape[1];
const w = image7.shape[2]; const w = image7.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return image.cropAndResize(image7, boxes, [0], cropSize); return image.cropAndResize(image7, boxes, [0], cropSize);
} }
function scaleBoxCoordinates2(box6, factor) { function scaleBoxCoordinates2(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => { const palmLandmarks = box5.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]]; const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord; return scaledCoord;
}); });
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence }; return { startPoint, endPoint, palmLandmarks, confidence: box5.confidence };
} }
function enlargeBox2(box6, factor = 1.5) { function enlargeBox2(box5, factor = 1.5) {
const center = getBoxCenter2(box6); const center = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
function squarifyBox2(box6) { function squarifyBox2(box5) {
const centers = getBoxCenter2(box6); const centers = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize]; const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize]; const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
// src/handpose/anchors.ts // src/handpose/anchors.ts
@ -69286,9 +69286,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedCurl, score3] of expectedCurls) { for (const [expectedCurl, score2] of expectedCurls) {
if (detectedCurl === expectedCurl) { if (detectedCurl === expectedCurl) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -69300,9 +69300,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedDirection, score3] of expectedDirections) { for (const [expectedDirection, score2] of expectedDirections) {
if (detectedDirection === expectedDirection) { if (detectedDirection === expectedDirection) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -69398,30 +69398,30 @@ async function predict5(input2, config3) {
} }
} }
const keypoints3 = predictions[i].landmarks; const keypoints3 = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0]; let box5 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw3 = [0, 0, 0, 0]; let boxRaw2 = [0, 0, 0, 0];
if (keypoints3 && keypoints3.length > 0) { if (keypoints3 && keypoints3.length > 0) {
for (const pt of keypoints3) { for (const pt of keypoints3) {
if (pt[0] < box6[0]) if (pt[0] < box5[0])
box6[0] = pt[0]; box5[0] = pt[0];
if (pt[1] < box6[1]) if (pt[1] < box5[1])
box6[1] = pt[1]; box5[1] = pt[1];
if (pt[0] > box6[2]) if (pt[0] > box5[2])
box6[2] = pt[0]; box5[2] = pt[0];
if (pt[1] > box6[3]) if (pt[1] > box5[3])
box6[3] = pt[1]; box5[3] = pt[1];
} }
box6[2] -= box6[0]; box5[2] -= box5[0];
box6[3] -= box6[1]; box5[3] -= box5[1];
boxRaw3 = [box6[0] / (input2.shape[2] || 0), box6[1] / (input2.shape[1] || 0), box6[2] / (input2.shape[2] || 0), box6[3] / (input2.shape[1] || 0)]; boxRaw2 = [box5[0] / (input2.shape[2] || 0), box5[1] / (input2.shape[1] || 0), box5[2] / (input2.shape[2] || 0), box5[3] / (input2.shape[1] || 0)];
} else { } else {
box6 = predictions[i].box ? [ box5 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.max(0, predictions[i].box.topLeft[1])), Math.trunc(Math.max(0, predictions[i].box.topLeft[1])),
Math.trunc(Math.min(input2.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.min(input2.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.min(input2.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1])) Math.trunc(Math.min(input2.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
boxRaw3 = [ boxRaw2 = [
predictions[i].box.topLeft[0] / (input2.shape[2] || 0), predictions[i].box.topLeft[0] / (input2.shape[2] || 0),
predictions[i].box.topLeft[1] / (input2.shape[1] || 0), predictions[i].box.topLeft[1] / (input2.shape[1] || 0),
(predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input2.shape[2] || 0), (predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input2.shape[2] || 0),
@ -69435,8 +69435,8 @@ async function predict5(input2, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100, boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100, fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand", label: "hand",
box: box6, box: box5,
boxRaw: boxRaw3, boxRaw: boxRaw2,
keypoints: keypoints3, keypoints: keypoints3,
annotations: annotations3, annotations: annotations3,
landmarks landmarks
@ -69766,13 +69766,13 @@ async function detectHands(input2, config3) {
} else { } else {
yxBox = await boxSlice.data(); yxBox = await boxSlice.data();
} }
const boxRaw3 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]]; const boxRaw2 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]];
const box6 = [Math.trunc(boxRaw3[0] * outputSize[0]), Math.trunc(boxRaw3[1] * outputSize[1]), Math.trunc(boxRaw3[2] * outputSize[0]), Math.trunc(boxRaw3[3] * outputSize[1])]; const box5 = [Math.trunc(boxRaw2[0] * outputSize[0]), Math.trunc(boxRaw2[1] * outputSize[1]), Math.trunc(boxRaw2[2] * outputSize[0]), Math.trunc(boxRaw2[3] * outputSize[1])];
dispose(boxSlice); dispose(boxSlice);
const scoreSlice = slice(classScores[i], res, 1); const scoreSlice = slice(classScores[i], res, 1);
const score3 = (await scoreSlice.data())[0]; const score2 = (await scoreSlice.data())[0];
dispose(scoreSlice); dispose(scoreSlice);
const hand3 = { id: id++, score: score3, box: box6, boxRaw: boxRaw3, label: classes[i], yxBox }; const hand3 = { id: id++, score: score2, box: box5, boxRaw: boxRaw2, label: classes[i], yxBox };
hands.push(hand3); hands.push(hand3);
} }
} }
@ -69806,9 +69806,9 @@ async function detectFingers(input2, h, config3) {
t.cast = cast(t.crop, "float32"); t.cast = cast(t.crop, "float32");
t.div = div(t.cast, 255); t.div = div(t.cast, 255);
[t.score, t.keypoints] = models2[1].execute(t.div); [t.score, t.keypoints] = models2[1].execute(t.div);
const score3 = Math.round(100 * (await t.score.data())[0] / 100); const score2 = Math.round(100 * (await t.score.data())[0] / 100);
if (score3 > (config3.hand.minConfidence || 0)) { if (score2 > (config3.hand.minConfidence || 0)) {
hand3.fingerScore = score3; hand3.fingerScore = score2;
t.reshaped = reshape(t.keypoints, [-1, 3]); t.reshaped = reshape(t.keypoints, [-1, 3]);
const rawCoords = await t.reshaped.array(); const rawCoords = await t.reshaped.array();
hand3.keypoints = rawCoords.map((coord) => [ hand3.keypoints = rawCoords.map((coord) => [
@ -69983,15 +69983,15 @@ async function predict7(image7, config3) {
} }
const x = keypoints3.map((a) => a.position[0]); const x = keypoints3.map((a) => a.position[0]);
const y = keypoints3.map((a) => a.position[1]); const y = keypoints3.map((a) => a.position[1]);
const box6 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
Math.max(...y) - Math.min(...x) Math.max(...y) - Math.min(...x)
]; ];
const boxRaw3 = [0, 0, 0, 0]; const boxRaw2 = [0, 0, 0, 0];
const score3 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); const score2 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
return [{ id: 0, score: score3, box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }]; return [{ id: 0, score: score2, box: box5, boxRaw: boxRaw2, keypoints: keypoints3 }];
} }
// src/efficientpose/efficientpose.ts // src/efficientpose/efficientpose.ts
@ -70101,9 +70101,6 @@ async function predict8(image7, config3) {
var model7; var model7;
var inputSize2 = 0; var inputSize2 = 0;
var cachedBoxes = []; var cachedBoxes = [];
var box5 = [0, 0, 0, 0];
var boxRaw2 = [0, 0, 0, 0];
var score2 = 0;
var skipped5 = Number.MAX_SAFE_INTEGER; var skipped5 = Number.MAX_SAFE_INTEGER;
var keypoints2 = []; var keypoints2 = [];
var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"]; var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"];
@ -70127,6 +70124,7 @@ async function load9(config3) {
async function parseSinglePose(res, config3, image7, inputBox) { async function parseSinglePose(res, config3, image7, inputBox) {
const kpt3 = res[0][0]; const kpt3 = res[0][0];
keypoints2.length = 0; keypoints2.length = 0;
let score2 = 0;
for (let id = 0; id < kpt3.length; id++) { for (let id = 0; id < kpt3.length; id++) {
score2 = kpt3[id][2]; score2 = kpt3[id][2];
if (score2 > config3.body.minConfidence) { if (score2 > config3.body.minConfidence) {
@ -70148,7 +70146,7 @@ async function parseSinglePose(res, config3, image7, inputBox) {
score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
const x = keypoints2.map((a) => a.position[0]); const x = keypoints2.map((a) => a.position[0]);
const y = keypoints2.map((a) => a.position[1]); const y = keypoints2.map((a) => a.position[1]);
box5 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
@ -70156,7 +70154,7 @@ async function parseSinglePose(res, config3, image7, inputBox) {
]; ];
const xRaw = keypoints2.map((a) => a.positionRaw[0]); const xRaw = keypoints2.map((a) => a.positionRaw[0]);
const yRaw = keypoints2.map((a) => a.positionRaw[1]); const yRaw = keypoints2.map((a) => a.positionRaw[1]);
boxRaw2 = [ const boxRaw2 = [
Math.min(...xRaw), Math.min(...xRaw),
Math.min(...yRaw), Math.min(...yRaw),
Math.max(...xRaw) - Math.min(...xRaw), Math.max(...xRaw) - Math.min(...xRaw),
@ -70170,7 +70168,7 @@ async function parseMultiPose(res, config3, image7, inputBox) {
const bodies = []; const bodies = [];
for (let id = 0; id < res[0].length; id++) { for (let id = 0; id < res[0].length; id++) {
const kpt3 = res[0][id]; const kpt3 = res[0][id];
score2 = Math.round(100 * kpt3[51 + 4]) / 100; const score2 = Math.round(100 * kpt3[51 + 4]) / 100;
if (score2 < config3.body.minConfidence) if (score2 < config3.body.minConfidence)
continue; continue;
keypoints2.length = 0; keypoints2.length = 0;
@ -70189,7 +70187,7 @@ async function parseMultiPose(res, config3, image7, inputBox) {
}); });
} }
} }
boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]]; const boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]];
bodies.push({ bodies.push({
id, id,
score: score2, score: score2,
@ -70365,8 +70363,8 @@ async function process3(res, inputSize4, outputShape, config3) {
const scores = await scoresT.array(); const scores = await scoresT.array();
for (let i = 0; i < scoresT.shape[0]; i++) { for (let i = 0; i < scoresT.shape[0]; i++) {
for (let j = 0; j < scoresT.shape[1]; j++) { for (let j = 0; j < scoresT.shape[1]; j++) {
const score3 = scores[i][j]; const score2 = scores[i][j];
if (score3 > config3.object.minConfidence && j !== 61) { if (score2 > config3.object.minConfidence && j !== 61) {
const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize; const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize;
const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize; const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize;
const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4)); const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4));
@ -70378,21 +70376,21 @@ async function process3(res, inputSize4, outputShape, config3) {
cx + scaleBox2 / strideSize * boxOffset[2] - x, cx + scaleBox2 / strideSize * boxOffset[2] - x,
cy + scaleBox2 / strideSize * boxOffset[3] - y cy + scaleBox2 / strideSize * boxOffset[3] - y
]; ];
let boxRaw3 = [x, y, w, h]; let boxRaw2 = [x, y, w, h];
boxRaw3 = boxRaw3.map((a) => Math.max(0, Math.min(a, 1))); boxRaw2 = boxRaw2.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [ const box5 = [
boxRaw3[0] * outputShape[0], boxRaw2[0] * outputShape[0],
boxRaw3[1] * outputShape[1], boxRaw2[1] * outputShape[1],
boxRaw3[2] * outputShape[0], boxRaw2[2] * outputShape[0],
boxRaw3[3] * outputShape[1] boxRaw2[3] * outputShape[1]
]; ];
const result = { const result = {
id: id++, id: id++,
score: Math.round(100 * score3) / 100, score: Math.round(100 * score2) / 100,
class: j + 1, class: j + 1,
label: labels[j].label, label: labels[j].label,
box: box6.map((a) => Math.trunc(a)), box: box5.map((a) => Math.trunc(a)),
boxRaw: boxRaw3 boxRaw: boxRaw2
}; };
results.push(result); results.push(result);
} }
@ -70481,26 +70479,26 @@ async function process4(res, outputShape, config3) {
dispose(nmsT); dispose(nmsT);
let i = 0; let i = 0;
for (const id of nms) { for (const id of nms) {
const score3 = Math.trunc(100 * detections[0][id][4]) / 100; const score2 = Math.trunc(100 * detections[0][id][4]) / 100;
const classVal = detections[0][id][5]; const classVal = detections[0][id][5];
const label = labels[classVal].label; const label = labels[classVal].label;
const [x, y] = [ const [x, y] = [
detections[0][id][0] / inputSize3, detections[0][id][0] / inputSize3,
detections[0][id][1] / inputSize3 detections[0][id][1] / inputSize3
]; ];
const boxRaw3 = [ const boxRaw2 = [
x, x,
y, y,
detections[0][id][2] / inputSize3 - x, detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y detections[0][id][3] / inputSize3 - y
]; ];
const box6 = [ const box5 = [
Math.trunc(boxRaw3[0] * outputShape[0]), Math.trunc(boxRaw2[0] * outputShape[0]),
Math.trunc(boxRaw3[1] * outputShape[1]), Math.trunc(boxRaw2[1] * outputShape[1]),
Math.trunc(boxRaw3[2] * outputShape[0]), Math.trunc(boxRaw2[2] * outputShape[0]),
Math.trunc(boxRaw3[3] * outputShape[1]) Math.trunc(boxRaw2[3] * outputShape[1])
]; ];
results.push({ id: i++, score: score3, class: classVal, label, box: box6, boxRaw: boxRaw3 }); results.push({ id: i++, score: score2, class: classVal, label, box: box5, boxRaw: boxRaw2 });
} }
return results; return results;
} }
@ -71423,7 +71421,7 @@ async function hand2(inCanvas2, result, drawOptions) {
if (localOptions.drawPoints) { if (localOptions.drawPoints) {
if (h.keypoints && h.keypoints.length > 0) { if (h.keypoints && h.keypoints.length > 0) {
for (const pt of h.keypoints) { for (const pt of h.keypoints) {
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * pt[2]}, ${127.5 - 2 * pt[2]}, 255, 0.5)` : localOptions.color; ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * (pt[2] || 0)}, ${127.5 - 2 * (pt[2] || 0)}, 255, 0.5)` : localOptions.color;
point(ctx, pt[0], pt[1], 0, localOptions); point(ctx, pt[0], pt[1], 0, localOptions);
} }
} }
@ -71574,10 +71572,10 @@ function join2(faces, bodies, hands, gestures, shape) {
} }
const x = []; const x = [];
const y = []; const y = [];
const extractXY = (box6) => { const extractXY = (box5) => {
if (box6 && box6.length === 4) { if (box5 && box5.length === 4) {
x.push(box6[0], box6[0] + box6[2]); x.push(box5[0], box5[0] + box5[2]);
y.push(box6[1], box6[1] + box6[3]); y.push(box5[1], box5[1] + box5[3]);
} }
}; };
extractXY((_k = person2.face) == null ? void 0 : _k.box); extractXY((_k = person2.face) == null ? void 0 : _k.box);
@ -71607,8 +71605,8 @@ function calc(newResult) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body)); bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else { } else {
for (let i = 0; i < newResult.body.length; i++) { for (let i = 0; i < newResult.body.length; i++) {
const box6 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor); const box5 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({ const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score, score: keypoint.score,
part: keypoint.part, part: keypoint.part,
@ -71621,18 +71619,18 @@ function calc(newResult) {
bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1] bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1]
] ]
})); }));
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }; bufferedResult.body[i] = { ...newResult.body[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3 };
} }
} }
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) { if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand)); bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else { } else {
for (let i = 0; i < newResult.hand.length; i++) { for (let i = 0; i < newResult.hand.length; i++) {
const box6 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor); const box5 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor);
if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length) if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints; bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].keypoints[j][k] + coord) / bufferedFactor)) : []; const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * (bufferedResult.hand[i].keypoints[j][k] || 1) + (coord || 0)) / bufferedFactor)) : [];
const annotations3 = {}; const annotations3 = {};
if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length) if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length)
bufferedResult.hand[i].annotations = newResult.hand[i].annotations; bufferedResult.hand[i].annotations = newResult.hand[i].annotations;
@ -71641,15 +71639,15 @@ function calc(newResult) {
annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null; annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null;
} }
} }
bufferedResult.hand[i] = { ...newResult.hand[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3, annotations: annotations3 }; bufferedResult.hand[i] = { ...newResult.hand[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3, annotations: annotations3 };
} }
} }
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) { if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face)); bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else { } else {
for (let i = 0; i < newResult.face.length; i++) { for (let i = 0; i < newResult.face.length; i++) {
const box6 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor); const box5 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor);
const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } }; const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } };
rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix; rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix;
rotation.angle = { rotation.angle = {
@ -71661,16 +71659,16 @@ function calc(newResult) {
bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor, bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor
}; };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw: boxRaw3 }; bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box5, boxRaw: boxRaw2 };
} }
} }
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) { if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object)); bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else { } else {
for (let i = 0; i < newResult.object.length; i++) { for (let i = 0; i < newResult.object.length; i++) {
const box6 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor); const box5 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor);
bufferedResult.object[i] = { ...newResult.object[i], box: box6, boxRaw: boxRaw3 }; bufferedResult.object[i] = { ...newResult.object[i], box: box5, boxRaw: boxRaw2 };
} }
} }
if (newResult.persons) { if (newResult.persons) {
@ -71679,7 +71677,7 @@ function calc(newResult) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons)); bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else { } else {
for (let i = 0; i < newPersons.length; i++) { for (let i = 0; i < newPersons.length; i++) {
bufferedResult.persons[i].box = newPersons[i].box.map((box6, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box6) / bufferedFactor); bufferedResult.persons[i].box = newPersons[i].box.map((box5, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box5) / bufferedFactor);
} }
} }
} }

File diff suppressed because one or more lines are too long

556
dist/human.js vendored

File diff suppressed because one or more lines are too long

368
dist/human.node-gpu.js vendored
View File

@ -147,25 +147,25 @@ function scaleBox(keypoints3, boxScaleFact2, outputSize2) {
const maxmin = [Math.max(...coords3[0]), Math.min(...coords3[0]), Math.max(...coords3[1]), Math.min(...coords3[1])]; const maxmin = [Math.max(...coords3[0]), Math.min(...coords3[0]), Math.max(...coords3[1]), Math.min(...coords3[1])];
const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2]; const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2];
const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2; const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2;
const box6 = [ const box5 = [
Math.trunc(center[0] - diff), Math.trunc(center[0] - diff),
Math.trunc(center[1] - diff), Math.trunc(center[1] - diff),
Math.trunc(2 * diff), Math.trunc(2 * diff),
Math.trunc(2 * diff) Math.trunc(2 * diff)
]; ];
const boxRaw3 = [ const boxRaw2 = [
box6[0] / outputSize2[0], box5[0] / outputSize2[0],
box6[1] / outputSize2[1], box5[1] / outputSize2[1],
box6[2] / outputSize2[0], box5[2] / outputSize2[0],
box6[3] / outputSize2[1] box5[3] / outputSize2[1]
]; ];
const yxBox = [ const yxBox = [
boxRaw3[1], boxRaw2[1],
boxRaw3[0], boxRaw2[0],
boxRaw3[3] + boxRaw3[1], boxRaw2[3] + boxRaw2[1],
boxRaw3[2] + boxRaw3[0] boxRaw2[2] + boxRaw2[0]
]; ];
return { box: box6, boxRaw: boxRaw3, yxBox }; return { box: box5, boxRaw: boxRaw2, yxBox };
} }
// src/config.ts // src/config.ts
@ -281,50 +281,50 @@ var tf2 = __toModule(require_tfjs_esm());
// src/blazeface/box.ts // src/blazeface/box.ts
var tf = __toModule(require_tfjs_esm()); var tf = __toModule(require_tfjs_esm());
function scaleBoxCoordinates(box6, factor) { function scaleBoxCoordinates(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
return { startPoint, endPoint }; return { startPoint, endPoint };
} }
function getBoxSize(box6) { function getBoxSize(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter(box6) { function getBoxCenter(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize(box6, image24, cropSize) { function cutBoxFromImageAndResize(box5, image24, cropSize) {
const h = image24.shape[1]; const h = image24.shape[1];
const w = image24.shape[2]; const w = image24.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return tf.image.cropAndResize(image24, boxes, [0], cropSize); return tf.image.cropAndResize(image24, boxes, [0], cropSize);
} }
function enlargeBox(box6, factor = 1.5) { function enlargeBox(box5, factor = 1.5) {
const center = getBoxCenter(box6); const center = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function squarifyBox(box6) { function squarifyBox(box5) {
const centers = getBoxCenter(box6); const centers = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)]; const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)];
const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)]; const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function calculateLandmarksBoundingBox(landmarks) { function calculateLandmarksBoundingBox(landmarks) {
const xs = landmarks.map((d) => d[0]); const xs = landmarks.map((d) => d[0]);
@ -4857,8 +4857,8 @@ var Pipeline = class {
this.skipped = 0; this.skipped = 0;
this.detectedFaces = 0; this.detectedFaces = 0;
} }
transformRawCoords(rawCoords, box6, angle, rotationMatrix) { transformRawCoords(rawCoords, box5, angle, rotationMatrix) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const boxSize = getBoxSize({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const coordsScaled = rawCoords.map((coord) => [ const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2), boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2),
boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2), boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2),
@ -4867,7 +4867,7 @@ var Pipeline = class {
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX; const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled; const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX; const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1]; const boxCenter = [...getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint }), 1];
return coordsRotated.map((coord) => [ return coordsRotated.map((coord) => [
Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])), Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])), Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])),
@ -4880,20 +4880,20 @@ var Pipeline = class {
return leftEyeZ - rightEyeZ; return leftEyeZ - rightEyeZ;
} }
getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) { getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge)); const box5 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge));
const boxSize = getBoxSize(box6); const boxSize = getBoxSize(box5);
let crop = tf5.image.cropAndResize(face5, [[ let crop = tf5.image.cropAndResize(face5, [[
box6.startPoint[1] / this.meshSize, box5.startPoint[1] / this.meshSize,
box6.startPoint[0] / this.meshSize, box5.startPoint[0] / this.meshSize,
box6.endPoint[1] / this.meshSize, box5.endPoint[1] / this.meshSize,
box6.endPoint[0] / this.meshSize box5.endPoint[0] / this.meshSize
]], [0], [this.irisSize, this.irisSize]); ]], [0], [this.irisSize, this.irisSize]);
if (flip && env.kernels.includes("flipleftright")) { if (flip && env.kernels.includes("flipleftright")) {
const flipped = tf5.image.flipLeftRight(crop); const flipped = tf5.image.flipLeftRight(crop);
tf5.dispose(crop); tf5.dispose(crop);
crop = flipped; crop = flipped;
} }
return { box: box6, boxSize, crop }; return { box: box5, boxSize, crop };
} }
getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) { getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) {
const eyeRawCoords = []; const eyeRawCoords = [];
@ -4923,14 +4923,14 @@ var Pipeline = class {
return [coord[0], coord[1], z]; return [coord[0], coord[1], z];
}); });
} }
correctFaceRotation(config3, box6, input) { correctFaceRotation(config3, box5, input) {
const [indexOfMouth, indexOfForehead] = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine; const [indexOfMouth, indexOfForehead] = box5.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[indexOfMouth], box6.landmarks[indexOfForehead]); const angle = computeRotation(box5.landmarks[indexOfMouth], box5.landmarks[indexOfForehead]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const faceCenter = getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]]; const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]];
const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized); const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter); const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.boxSize, this.boxSize]);
const face5 = tf5.div(cut, 255); const face5 = tf5.div(cut, 255);
tf5.dispose(cut); tf5.dispose(cut);
tf5.dispose(rotated); tf5.dispose(rotated);
@ -5014,16 +5014,16 @@ var Pipeline = class {
} }
const results = []; const results = [];
const newBoxes = []; const newBoxes = [];
for (let box6 of this.storedBoxes) { for (let box5 of this.storedBoxes) {
let face5; let face5;
let angle = 0; let angle = 0;
let rotationMatrix; let rotationMatrix;
if (config3.face.detector.rotation && config3.face.mesh.enabled && env.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && env.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input);
} else { } else {
rotationMatrix = IDENTITY_MATRIX; rotationMatrix = IDENTITY_MATRIX;
const cloned = input.clone(); const cloned = input.clone();
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.boxSize, this.boxSize]);
face5 = tf5.div(cut, 255); face5 = tf5.div(cut, 255);
tf5.dispose(cut); tf5.dispose(cut);
tf5.dispose(cloned); tf5.dispose(cloned);
@ -5031,10 +5031,10 @@ var Pipeline = class {
if (!config3.face.mesh.enabled) { if (!config3.face.mesh.enabled) {
results.push({ results.push({
mesh: [], mesh: [],
box: box6, box: box5,
faceConfidence: null, faceConfidence: null,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: box6.confidence, confidence: box5.confidence,
image: face5 image: face5
}); });
} else if (!this.meshDetector) { } else if (!this.meshDetector) {
@ -5050,29 +5050,29 @@ var Pipeline = class {
tf5.dispose(contourCoords); tf5.dispose(contourCoords);
tf5.dispose(coordsReshaped); tf5.dispose(coordsReshaped);
if (faceConfidence < config3.face.detector.minConfidence) { if (faceConfidence < config3.face.detector.minConfidence) {
box6.confidence = faceConfidence; box5.confidence = faceConfidence;
tf5.dispose(face5); tf5.dispose(face5);
} else { } else {
if (config3.face.iris.enabled) if (config3.face.iris.enabled)
rawCoords = await this.augmentIris(rawCoords, face5, config3); rawCoords = await this.augmentIris(rawCoords, face5, config3);
const mesh = this.transformRawCoords(rawCoords, box6, angle, rotationMatrix); const mesh = this.transformRawCoords(rawCoords, box5, angle, rotationMatrix);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box6.confidence }; box5 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box5.confidence };
if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env.kernels.includes("rotatewithoffset")) {
tf5.dispose(face5); tf5.dispose(face5);
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input);
} }
results.push({ results.push({
mesh, mesh,
box: box6, box: box5,
faceConfidence, faceConfidence,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: faceConfidence, confidence: faceConfidence,
image: face5 image: face5
}); });
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence }; box5 = { ...squarifyBox(box5), confidence: box5.confidence, faceConfidence };
} }
} }
newBoxes.push(box6); newBoxes.push(box5);
} }
if (config3.face.mesh.enabled) if (config3.face.mesh.enabled)
this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence); this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence);
@ -5107,7 +5107,7 @@ async function predict(input, config3) {
Math.trunc(Math.min(input.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])), Math.trunc(Math.min(input.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1])) Math.trunc(Math.min(input.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
const boxRaw3 = prediction.box ? [ const boxRaw2 = prediction.box ? [
prediction.box.startPoint[0] / (input.shape[2] || 0), prediction.box.startPoint[0] / (input.shape[2] || 0),
prediction.box.startPoint[1] / (input.shape[1] || 0), prediction.box.startPoint[1] / (input.shape[1] || 0),
(prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0), (prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0),
@ -5119,7 +5119,7 @@ async function predict(input, config3) {
boxScore: Math.round(100 * prediction.boxConfidence) / 100, boxScore: Math.round(100 * prediction.boxConfidence) / 100,
faceScore: Math.round(100 * prediction.faceConfidence) / 100, faceScore: Math.round(100 * prediction.faceConfidence) / 100,
box: clampedBox, box: clampedBox,
boxRaw: boxRaw3, boxRaw: boxRaw2,
mesh: prediction.mesh, mesh: prediction.mesh,
meshRaw, meshRaw,
annotations: annotations3, annotations: annotations3,
@ -5214,10 +5214,10 @@ function enhance(input) {
const tensor3 = input.image || input.tensor || input; const tensor3 = input.image || input.tensor || input;
if (!(tensor3 instanceof tf7.Tensor)) if (!(tensor3 instanceof tf7.Tensor))
return null; return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]]; const box5 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model == null ? void 0 : model.inputs[0].shape)) if (!(model == null ? void 0 : model.inputs[0].shape))
return null; return null;
const crop = tensor3.shape.length === 3 ? tf7.image.cropAndResize(tf7.expandDims(tensor3, 0), box6, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]) : tf7.image.cropAndResize(tensor3, box6, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]); const crop = tensor3.shape.length === 3 ? tf7.image.cropAndResize(tf7.expandDims(tensor3, 0), box5, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]) : tf7.image.cropAndResize(tensor3, box5, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]);
const norm = tf7.mul(crop, 255); const norm = tf7.mul(crop, 255);
return norm; return norm;
}); });
@ -5419,8 +5419,8 @@ function scalePoses(poses2, [height, width], [inputResolutionHeight, inputResolu
score: pose.score, score: pose.score,
boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight], boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight],
box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)], box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)],
keypoints: pose.keypoints.map(({ score: score3, part, position }) => ({ keypoints: pose.keypoints.map(({ score: score2, part, position }) => ({
score: score3, score: score2,
part, part,
position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)], position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)],
positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight] positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight]
@ -5544,8 +5544,8 @@ function traverse(edgeId, sourceKeypoint, targetId, scores, offsets, displacemen
targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y }); targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y });
} }
const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width); const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width);
const score3 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId); const score2 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId);
return { position: targetKeypoint, part: partNames[targetId], score: score3 }; return { position: targetKeypoint, part: partNames[targetId], score: score2 };
} }
function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) { function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]); const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]);
@ -5576,7 +5576,7 @@ function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
} }
return keypoints3; return keypoints3;
} }
function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores) { function scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores) {
const [height, width] = scores.shape; const [height, width] = scores.shape;
let localMaximum = true; let localMaximum = true;
const yStart = Math.max(heatmapY - localMaximumRadius, 0); const yStart = Math.max(heatmapY - localMaximumRadius, 0);
@ -5585,7 +5585,7 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
const xStart = Math.max(heatmapX - localMaximumRadius, 0); const xStart = Math.max(heatmapX - localMaximumRadius, 0);
const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width); const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width);
for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) { for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) {
if (scores.get(yCurrent, xCurrent, keypointId) > score3) { if (scores.get(yCurrent, xCurrent, keypointId) > score2) {
localMaximum = false; localMaximum = false;
break; break;
} }
@ -5597,15 +5597,15 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
} }
function buildPartWithScoreQueue(minConfidence2, scores) { function buildPartWithScoreQueue(minConfidence2, scores) {
const [height, width, numKeypoints] = scores.shape; const [height, width, numKeypoints] = scores.shape;
const queue = new MaxHeap(height * width * numKeypoints, ({ score: score3 }) => score3); const queue = new MaxHeap(height * width * numKeypoints, ({ score: score2 }) => score2);
for (let heatmapY = 0; heatmapY < height; ++heatmapY) { for (let heatmapY = 0; heatmapY < height; ++heatmapY) {
for (let heatmapX = 0; heatmapX < width; ++heatmapX) { for (let heatmapX = 0; heatmapX < width; ++heatmapX) {
for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) { for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) {
const score3 = scores.get(heatmapY, heatmapX, keypointId); const score2 = scores.get(heatmapY, heatmapX, keypointId);
if (score3 < minConfidence2) if (score2 < minConfidence2)
continue; continue;
if (scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores)) if (scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores))
queue.enqueue({ score: score3, part: { heatmapY, heatmapX, id: keypointId } }); queue.enqueue({ score: score2, part: { heatmapY, heatmapX, id: keypointId } });
} }
} }
} }
@ -5621,9 +5621,9 @@ function withinRadius(poses2, { x, y }, keypointId) {
}); });
} }
function getInstanceScore(existingPoses, keypoints3) { function getInstanceScore(existingPoses, keypoints3) {
const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score3 }, keypointId) => { const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score2 }, keypointId) => {
if (!withinRadius(existingPoses, position, keypointId)) if (!withinRadius(existingPoses, position, keypointId))
result += score3; result += score2;
return result; return result;
}, 0); }, 0);
return notOverlappedKeypointScores / keypoints3.length; return notOverlappedKeypointScores / keypoints3.length;
@ -5638,10 +5638,10 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
continue; continue;
let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd); let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints3 = keypoints3.filter((a) => a.score > minConfidence2); keypoints3 = keypoints3.filter((a) => a.score > minConfidence2);
const score3 = getInstanceScore(poses2, keypoints3); const score2 = getInstanceScore(poses2, keypoints3);
const box6 = getBoundingBox(keypoints3); const box5 = getBoundingBox(keypoints3);
if (score3 > minConfidence2) if (score2 > minConfidence2)
poses2.push({ keypoints: keypoints3, box: box6, score: Math.round(100 * score3) / 100 }); poses2.push({ keypoints: keypoints3, box: box5, score: Math.round(100 * score2) / 100 });
} }
return poses2; return poses2;
} }
@ -5689,54 +5689,54 @@ var tf11 = __toModule(require_tfjs_esm());
// src/handpose/box.ts // src/handpose/box.ts
var tf10 = __toModule(require_tfjs_esm()); var tf10 = __toModule(require_tfjs_esm());
function getBoxSize2(box6) { function getBoxSize2(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter2(box6) { function getBoxCenter2(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize2(box6, image24, cropSize) { function cutBoxFromImageAndResize2(box5, image24, cropSize) {
const h = image24.shape[1]; const h = image24.shape[1];
const w = image24.shape[2]; const w = image24.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return tf10.image.cropAndResize(image24, boxes, [0], cropSize); return tf10.image.cropAndResize(image24, boxes, [0], cropSize);
} }
function scaleBoxCoordinates2(box6, factor) { function scaleBoxCoordinates2(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => { const palmLandmarks = box5.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]]; const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord; return scaledCoord;
}); });
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence }; return { startPoint, endPoint, palmLandmarks, confidence: box5.confidence };
} }
function enlargeBox2(box6, factor = 1.5) { function enlargeBox2(box5, factor = 1.5) {
const center = getBoxCenter2(box6); const center = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
function squarifyBox2(box6) { function squarifyBox2(box5) {
const centers = getBoxCenter2(box6); const centers = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize]; const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize]; const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
// src/handpose/anchors.ts // src/handpose/anchors.ts
@ -9265,9 +9265,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedCurl, score3] of expectedCurls) { for (const [expectedCurl, score2] of expectedCurls) {
if (detectedCurl === expectedCurl) { if (detectedCurl === expectedCurl) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -9279,9 +9279,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedDirection, score3] of expectedDirections) { for (const [expectedDirection, score2] of expectedDirections) {
if (detectedDirection === expectedDirection) { if (detectedDirection === expectedDirection) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -9377,30 +9377,30 @@ async function predict5(input, config3) {
} }
} }
const keypoints3 = predictions[i].landmarks; const keypoints3 = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0]; let box5 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw3 = [0, 0, 0, 0]; let boxRaw2 = [0, 0, 0, 0];
if (keypoints3 && keypoints3.length > 0) { if (keypoints3 && keypoints3.length > 0) {
for (const pt of keypoints3) { for (const pt of keypoints3) {
if (pt[0] < box6[0]) if (pt[0] < box5[0])
box6[0] = pt[0]; box5[0] = pt[0];
if (pt[1] < box6[1]) if (pt[1] < box5[1])
box6[1] = pt[1]; box5[1] = pt[1];
if (pt[0] > box6[2]) if (pt[0] > box5[2])
box6[2] = pt[0]; box5[2] = pt[0];
if (pt[1] > box6[3]) if (pt[1] > box5[3])
box6[3] = pt[1]; box5[3] = pt[1];
} }
box6[2] -= box6[0]; box5[2] -= box5[0];
box6[3] -= box6[1]; box5[3] -= box5[1];
boxRaw3 = [box6[0] / (input.shape[2] || 0), box6[1] / (input.shape[1] || 0), box6[2] / (input.shape[2] || 0), box6[3] / (input.shape[1] || 0)]; boxRaw2 = [box5[0] / (input.shape[2] || 0), box5[1] / (input.shape[1] || 0), box5[2] / (input.shape[2] || 0), box5[3] / (input.shape[1] || 0)];
} else { } else {
box6 = predictions[i].box ? [ box5 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.max(0, predictions[i].box.topLeft[1])), Math.trunc(Math.max(0, predictions[i].box.topLeft[1])),
Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1])) Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
boxRaw3 = [ boxRaw2 = [
predictions[i].box.topLeft[0] / (input.shape[2] || 0), predictions[i].box.topLeft[0] / (input.shape[2] || 0),
predictions[i].box.topLeft[1] / (input.shape[1] || 0), predictions[i].box.topLeft[1] / (input.shape[1] || 0),
(predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0), (predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0),
@ -9414,8 +9414,8 @@ async function predict5(input, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100, boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100, fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand", label: "hand",
box: box6, box: box5,
boxRaw: boxRaw3, boxRaw: boxRaw2,
keypoints: keypoints3, keypoints: keypoints3,
annotations: annotations3, annotations: annotations3,
landmarks landmarks
@ -9750,13 +9750,13 @@ async function detectHands(input, config3) {
} else { } else {
yxBox = await boxSlice.data(); yxBox = await boxSlice.data();
} }
const boxRaw3 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]]; const boxRaw2 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]];
const box6 = [Math.trunc(boxRaw3[0] * outputSize[0]), Math.trunc(boxRaw3[1] * outputSize[1]), Math.trunc(boxRaw3[2] * outputSize[0]), Math.trunc(boxRaw3[3] * outputSize[1])]; const box5 = [Math.trunc(boxRaw2[0] * outputSize[0]), Math.trunc(boxRaw2[1] * outputSize[1]), Math.trunc(boxRaw2[2] * outputSize[0]), Math.trunc(boxRaw2[3] * outputSize[1])];
tf16.dispose(boxSlice); tf16.dispose(boxSlice);
const scoreSlice = tf16.slice(classScores[i], res, 1); const scoreSlice = tf16.slice(classScores[i], res, 1);
const score3 = (await scoreSlice.data())[0]; const score2 = (await scoreSlice.data())[0];
tf16.dispose(scoreSlice); tf16.dispose(scoreSlice);
const hand3 = { id: id++, score: score3, box: box6, boxRaw: boxRaw3, label: classes[i], yxBox }; const hand3 = { id: id++, score: score2, box: box5, boxRaw: boxRaw2, label: classes[i], yxBox };
hands.push(hand3); hands.push(hand3);
} }
} }
@ -9790,9 +9790,9 @@ async function detectFingers(input, h, config3) {
t.cast = tf16.cast(t.crop, "float32"); t.cast = tf16.cast(t.crop, "float32");
t.div = tf16.div(t.cast, 255); t.div = tf16.div(t.cast, 255);
[t.score, t.keypoints] = models2[1].execute(t.div); [t.score, t.keypoints] = models2[1].execute(t.div);
const score3 = Math.round(100 * (await t.score.data())[0] / 100); const score2 = Math.round(100 * (await t.score.data())[0] / 100);
if (score3 > (config3.hand.minConfidence || 0)) { if (score2 > (config3.hand.minConfidence || 0)) {
hand3.fingerScore = score3; hand3.fingerScore = score2;
t.reshaped = tf16.reshape(t.keypoints, [-1, 3]); t.reshaped = tf16.reshape(t.keypoints, [-1, 3]);
const rawCoords = await t.reshaped.array(); const rawCoords = await t.reshaped.array();
hand3.keypoints = rawCoords.map((coord) => [ hand3.keypoints = rawCoords.map((coord) => [
@ -9970,15 +9970,15 @@ async function predict7(image24, config3) {
} }
const x = keypoints3.map((a) => a.position[0]); const x = keypoints3.map((a) => a.position[0]);
const y = keypoints3.map((a) => a.position[1]); const y = keypoints3.map((a) => a.position[1]);
const box6 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
Math.max(...y) - Math.min(...x) Math.max(...y) - Math.min(...x)
]; ];
const boxRaw3 = [0, 0, 0, 0]; const boxRaw2 = [0, 0, 0, 0];
const score3 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); const score2 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
return [{ id: 0, score: score3, box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }]; return [{ id: 0, score: score2, box: box5, boxRaw: boxRaw2, keypoints: keypoints3 }];
} }
// src/efficientpose/efficientpose.ts // src/efficientpose/efficientpose.ts
@ -10090,9 +10090,6 @@ var tf19 = __toModule(require_tfjs_esm());
var model6; var model6;
var inputSize2 = 0; var inputSize2 = 0;
var cachedBoxes = []; var cachedBoxes = [];
var box5 = [0, 0, 0, 0];
var boxRaw2 = [0, 0, 0, 0];
var score2 = 0;
var skipped5 = Number.MAX_SAFE_INTEGER; var skipped5 = Number.MAX_SAFE_INTEGER;
var keypoints2 = []; var keypoints2 = [];
var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"]; var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"];
@ -10116,6 +10113,7 @@ async function load9(config3) {
async function parseSinglePose(res, config3, image24, inputBox) { async function parseSinglePose(res, config3, image24, inputBox) {
const kpt3 = res[0][0]; const kpt3 = res[0][0];
keypoints2.length = 0; keypoints2.length = 0;
let score2 = 0;
for (let id = 0; id < kpt3.length; id++) { for (let id = 0; id < kpt3.length; id++) {
score2 = kpt3[id][2]; score2 = kpt3[id][2];
if (score2 > config3.body.minConfidence) { if (score2 > config3.body.minConfidence) {
@ -10137,7 +10135,7 @@ async function parseSinglePose(res, config3, image24, inputBox) {
score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
const x = keypoints2.map((a) => a.position[0]); const x = keypoints2.map((a) => a.position[0]);
const y = keypoints2.map((a) => a.position[1]); const y = keypoints2.map((a) => a.position[1]);
box5 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
@ -10145,7 +10143,7 @@ async function parseSinglePose(res, config3, image24, inputBox) {
]; ];
const xRaw = keypoints2.map((a) => a.positionRaw[0]); const xRaw = keypoints2.map((a) => a.positionRaw[0]);
const yRaw = keypoints2.map((a) => a.positionRaw[1]); const yRaw = keypoints2.map((a) => a.positionRaw[1]);
boxRaw2 = [ const boxRaw2 = [
Math.min(...xRaw), Math.min(...xRaw),
Math.min(...yRaw), Math.min(...yRaw),
Math.max(...xRaw) - Math.min(...xRaw), Math.max(...xRaw) - Math.min(...xRaw),
@ -10159,7 +10157,7 @@ async function parseMultiPose(res, config3, image24, inputBox) {
const bodies = []; const bodies = [];
for (let id = 0; id < res[0].length; id++) { for (let id = 0; id < res[0].length; id++) {
const kpt3 = res[0][id]; const kpt3 = res[0][id];
score2 = Math.round(100 * kpt3[51 + 4]) / 100; const score2 = Math.round(100 * kpt3[51 + 4]) / 100;
if (score2 < config3.body.minConfidence) if (score2 < config3.body.minConfidence)
continue; continue;
keypoints2.length = 0; keypoints2.length = 0;
@ -10178,7 +10176,7 @@ async function parseMultiPose(res, config3, image24, inputBox) {
}); });
} }
} }
boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]]; const boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]];
bodies.push({ bodies.push({
id, id,
score: score2, score: score2,
@ -10357,8 +10355,8 @@ async function process3(res, inputSize4, outputShape, config3) {
const scores = await scoresT.array(); const scores = await scoresT.array();
for (let i = 0; i < scoresT.shape[0]; i++) { for (let i = 0; i < scoresT.shape[0]; i++) {
for (let j = 0; j < scoresT.shape[1]; j++) { for (let j = 0; j < scoresT.shape[1]; j++) {
const score3 = scores[i][j]; const score2 = scores[i][j];
if (score3 > config3.object.minConfidence && j !== 61) { if (score2 > config3.object.minConfidence && j !== 61) {
const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize; const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize;
const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize; const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize;
const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4)); const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4));
@ -10370,21 +10368,21 @@ async function process3(res, inputSize4, outputShape, config3) {
cx + scaleBox2 / strideSize * boxOffset[2] - x, cx + scaleBox2 / strideSize * boxOffset[2] - x,
cy + scaleBox2 / strideSize * boxOffset[3] - y cy + scaleBox2 / strideSize * boxOffset[3] - y
]; ];
let boxRaw3 = [x, y, w, h]; let boxRaw2 = [x, y, w, h];
boxRaw3 = boxRaw3.map((a) => Math.max(0, Math.min(a, 1))); boxRaw2 = boxRaw2.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [ const box5 = [
boxRaw3[0] * outputShape[0], boxRaw2[0] * outputShape[0],
boxRaw3[1] * outputShape[1], boxRaw2[1] * outputShape[1],
boxRaw3[2] * outputShape[0], boxRaw2[2] * outputShape[0],
boxRaw3[3] * outputShape[1] boxRaw2[3] * outputShape[1]
]; ];
const result = { const result = {
id: id++, id: id++,
score: Math.round(100 * score3) / 100, score: Math.round(100 * score2) / 100,
class: j + 1, class: j + 1,
label: labels[j].label, label: labels[j].label,
box: box6.map((a) => Math.trunc(a)), box: box5.map((a) => Math.trunc(a)),
boxRaw: boxRaw3 boxRaw: boxRaw2
}; };
results.push(result); results.push(result);
} }
@ -10474,26 +10472,26 @@ async function process4(res, outputShape, config3) {
tf21.dispose(nmsT); tf21.dispose(nmsT);
let i = 0; let i = 0;
for (const id of nms) { for (const id of nms) {
const score3 = Math.trunc(100 * detections[0][id][4]) / 100; const score2 = Math.trunc(100 * detections[0][id][4]) / 100;
const classVal = detections[0][id][5]; const classVal = detections[0][id][5];
const label = labels[classVal].label; const label = labels[classVal].label;
const [x, y] = [ const [x, y] = [
detections[0][id][0] / inputSize3, detections[0][id][0] / inputSize3,
detections[0][id][1] / inputSize3 detections[0][id][1] / inputSize3
]; ];
const boxRaw3 = [ const boxRaw2 = [
x, x,
y, y,
detections[0][id][2] / inputSize3 - x, detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y detections[0][id][3] / inputSize3 - y
]; ];
const box6 = [ const box5 = [
Math.trunc(boxRaw3[0] * outputShape[0]), Math.trunc(boxRaw2[0] * outputShape[0]),
Math.trunc(boxRaw3[1] * outputShape[1]), Math.trunc(boxRaw2[1] * outputShape[1]),
Math.trunc(boxRaw3[2] * outputShape[0]), Math.trunc(boxRaw2[2] * outputShape[0]),
Math.trunc(boxRaw3[3] * outputShape[1]) Math.trunc(boxRaw2[3] * outputShape[1])
]; ];
results.push({ id: i++, score: score3, class: classVal, label, box: box6, boxRaw: boxRaw3 }); results.push({ id: i++, score: score2, class: classVal, label, box: box5, boxRaw: boxRaw2 });
} }
return results; return results;
} }
@ -11419,7 +11417,7 @@ async function hand2(inCanvas2, result, drawOptions) {
if (localOptions.drawPoints) { if (localOptions.drawPoints) {
if (h.keypoints && h.keypoints.length > 0) { if (h.keypoints && h.keypoints.length > 0) {
for (const pt of h.keypoints) { for (const pt of h.keypoints) {
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * pt[2]}, ${127.5 - 2 * pt[2]}, 255, 0.5)` : localOptions.color; ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * (pt[2] || 0)}, ${127.5 - 2 * (pt[2] || 0)}, 255, 0.5)` : localOptions.color;
point(ctx, pt[0], pt[1], 0, localOptions); point(ctx, pt[0], pt[1], 0, localOptions);
} }
} }
@ -11570,10 +11568,10 @@ function join2(faces, bodies, hands, gestures, shape) {
} }
const x = []; const x = [];
const y = []; const y = [];
const extractXY = (box6) => { const extractXY = (box5) => {
if (box6 && box6.length === 4) { if (box5 && box5.length === 4) {
x.push(box6[0], box6[0] + box6[2]); x.push(box5[0], box5[0] + box5[2]);
y.push(box6[1], box6[1] + box6[3]); y.push(box5[1], box5[1] + box5[3]);
} }
}; };
extractXY((_k = person2.face) == null ? void 0 : _k.box); extractXY((_k = person2.face) == null ? void 0 : _k.box);
@ -11603,8 +11601,8 @@ function calc(newResult) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body)); bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else { } else {
for (let i = 0; i < newResult.body.length; i++) { for (let i = 0; i < newResult.body.length; i++) {
const box6 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor); const box5 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({ const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score, score: keypoint.score,
part: keypoint.part, part: keypoint.part,
@ -11617,18 +11615,18 @@ function calc(newResult) {
bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1] bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1]
] ]
})); }));
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }; bufferedResult.body[i] = { ...newResult.body[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3 };
} }
} }
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) { if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand)); bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else { } else {
for (let i = 0; i < newResult.hand.length; i++) { for (let i = 0; i < newResult.hand.length; i++) {
const box6 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor); const box5 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor);
if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length) if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints; bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].keypoints[j][k] + coord) / bufferedFactor)) : []; const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * (bufferedResult.hand[i].keypoints[j][k] || 1) + (coord || 0)) / bufferedFactor)) : [];
const annotations3 = {}; const annotations3 = {};
if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length) if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length)
bufferedResult.hand[i].annotations = newResult.hand[i].annotations; bufferedResult.hand[i].annotations = newResult.hand[i].annotations;
@ -11637,15 +11635,15 @@ function calc(newResult) {
annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null; annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null;
} }
} }
bufferedResult.hand[i] = { ...newResult.hand[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3, annotations: annotations3 }; bufferedResult.hand[i] = { ...newResult.hand[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3, annotations: annotations3 };
} }
} }
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) { if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face)); bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else { } else {
for (let i = 0; i < newResult.face.length; i++) { for (let i = 0; i < newResult.face.length; i++) {
const box6 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor); const box5 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor);
const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } }; const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } };
rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix; rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix;
rotation.angle = { rotation.angle = {
@ -11657,16 +11655,16 @@ function calc(newResult) {
bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor, bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor
}; };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw: boxRaw3 }; bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box5, boxRaw: boxRaw2 };
} }
} }
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) { if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object)); bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else { } else {
for (let i = 0; i < newResult.object.length; i++) { for (let i = 0; i < newResult.object.length; i++) {
const box6 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor); const box5 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor);
bufferedResult.object[i] = { ...newResult.object[i], box: box6, boxRaw: boxRaw3 }; bufferedResult.object[i] = { ...newResult.object[i], box: box5, boxRaw: boxRaw2 };
} }
} }
if (newResult.persons) { if (newResult.persons) {
@ -11675,7 +11673,7 @@ function calc(newResult) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons)); bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else { } else {
for (let i = 0; i < newPersons.length; i++) { for (let i = 0; i < newPersons.length; i++) {
bufferedResult.persons[i].box = newPersons[i].box.map((box6, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box6) / bufferedFactor); bufferedResult.persons[i].box = newPersons[i].box.map((box5, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box5) / bufferedFactor);
} }
} }
} }

View File

@ -148,25 +148,25 @@ function scaleBox(keypoints3, boxScaleFact2, outputSize2) {
const maxmin = [Math.max(...coords3[0]), Math.min(...coords3[0]), Math.max(...coords3[1]), Math.min(...coords3[1])]; const maxmin = [Math.max(...coords3[0]), Math.min(...coords3[0]), Math.max(...coords3[1]), Math.min(...coords3[1])];
const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2]; const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2];
const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2; const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2;
const box6 = [ const box5 = [
Math.trunc(center[0] - diff), Math.trunc(center[0] - diff),
Math.trunc(center[1] - diff), Math.trunc(center[1] - diff),
Math.trunc(2 * diff), Math.trunc(2 * diff),
Math.trunc(2 * diff) Math.trunc(2 * diff)
]; ];
const boxRaw3 = [ const boxRaw2 = [
box6[0] / outputSize2[0], box5[0] / outputSize2[0],
box6[1] / outputSize2[1], box5[1] / outputSize2[1],
box6[2] / outputSize2[0], box5[2] / outputSize2[0],
box6[3] / outputSize2[1] box5[3] / outputSize2[1]
]; ];
const yxBox = [ const yxBox = [
boxRaw3[1], boxRaw2[1],
boxRaw3[0], boxRaw2[0],
boxRaw3[3] + boxRaw3[1], boxRaw2[3] + boxRaw2[1],
boxRaw3[2] + boxRaw3[0] boxRaw2[2] + boxRaw2[0]
]; ];
return { box: box6, boxRaw: boxRaw3, yxBox }; return { box: box5, boxRaw: boxRaw2, yxBox };
} }
// src/config.ts // src/config.ts
@ -282,50 +282,50 @@ var tf2 = __toModule(require_tfjs_esm());
// src/blazeface/box.ts // src/blazeface/box.ts
var tf = __toModule(require_tfjs_esm()); var tf = __toModule(require_tfjs_esm());
function scaleBoxCoordinates(box6, factor) { function scaleBoxCoordinates(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
return { startPoint, endPoint }; return { startPoint, endPoint };
} }
function getBoxSize(box6) { function getBoxSize(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter(box6) { function getBoxCenter(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize(box6, image24, cropSize) { function cutBoxFromImageAndResize(box5, image24, cropSize) {
const h = image24.shape[1]; const h = image24.shape[1];
const w = image24.shape[2]; const w = image24.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return tf.image.cropAndResize(image24, boxes, [0], cropSize); return tf.image.cropAndResize(image24, boxes, [0], cropSize);
} }
function enlargeBox(box6, factor = 1.5) { function enlargeBox(box5, factor = 1.5) {
const center = getBoxCenter(box6); const center = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function squarifyBox(box6) { function squarifyBox(box5) {
const centers = getBoxCenter(box6); const centers = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)]; const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)];
const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)]; const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function calculateLandmarksBoundingBox(landmarks) { function calculateLandmarksBoundingBox(landmarks) {
const xs = landmarks.map((d) => d[0]); const xs = landmarks.map((d) => d[0]);
@ -4858,8 +4858,8 @@ var Pipeline = class {
this.skipped = 0; this.skipped = 0;
this.detectedFaces = 0; this.detectedFaces = 0;
} }
transformRawCoords(rawCoords, box6, angle, rotationMatrix) { transformRawCoords(rawCoords, box5, angle, rotationMatrix) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const boxSize = getBoxSize({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const coordsScaled = rawCoords.map((coord) => [ const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2), boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2),
boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2), boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2),
@ -4868,7 +4868,7 @@ var Pipeline = class {
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX; const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled; const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX; const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1]; const boxCenter = [...getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint }), 1];
return coordsRotated.map((coord) => [ return coordsRotated.map((coord) => [
Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])), Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])), Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])),
@ -4881,20 +4881,20 @@ var Pipeline = class {
return leftEyeZ - rightEyeZ; return leftEyeZ - rightEyeZ;
} }
getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) { getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge)); const box5 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge));
const boxSize = getBoxSize(box6); const boxSize = getBoxSize(box5);
let crop = tf5.image.cropAndResize(face5, [[ let crop = tf5.image.cropAndResize(face5, [[
box6.startPoint[1] / this.meshSize, box5.startPoint[1] / this.meshSize,
box6.startPoint[0] / this.meshSize, box5.startPoint[0] / this.meshSize,
box6.endPoint[1] / this.meshSize, box5.endPoint[1] / this.meshSize,
box6.endPoint[0] / this.meshSize box5.endPoint[0] / this.meshSize
]], [0], [this.irisSize, this.irisSize]); ]], [0], [this.irisSize, this.irisSize]);
if (flip && env.kernels.includes("flipleftright")) { if (flip && env.kernels.includes("flipleftright")) {
const flipped = tf5.image.flipLeftRight(crop); const flipped = tf5.image.flipLeftRight(crop);
tf5.dispose(crop); tf5.dispose(crop);
crop = flipped; crop = flipped;
} }
return { box: box6, boxSize, crop }; return { box: box5, boxSize, crop };
} }
getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) { getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) {
const eyeRawCoords = []; const eyeRawCoords = [];
@ -4924,14 +4924,14 @@ var Pipeline = class {
return [coord[0], coord[1], z]; return [coord[0], coord[1], z];
}); });
} }
correctFaceRotation(config3, box6, input) { correctFaceRotation(config3, box5, input) {
const [indexOfMouth, indexOfForehead] = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine; const [indexOfMouth, indexOfForehead] = box5.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[indexOfMouth], box6.landmarks[indexOfForehead]); const angle = computeRotation(box5.landmarks[indexOfMouth], box5.landmarks[indexOfForehead]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const faceCenter = getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]]; const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]];
const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized); const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter); const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.boxSize, this.boxSize]);
const face5 = tf5.div(cut, 255); const face5 = tf5.div(cut, 255);
tf5.dispose(cut); tf5.dispose(cut);
tf5.dispose(rotated); tf5.dispose(rotated);
@ -5015,16 +5015,16 @@ var Pipeline = class {
} }
const results = []; const results = [];
const newBoxes = []; const newBoxes = [];
for (let box6 of this.storedBoxes) { for (let box5 of this.storedBoxes) {
let face5; let face5;
let angle = 0; let angle = 0;
let rotationMatrix; let rotationMatrix;
if (config3.face.detector.rotation && config3.face.mesh.enabled && env.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && env.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input);
} else { } else {
rotationMatrix = IDENTITY_MATRIX; rotationMatrix = IDENTITY_MATRIX;
const cloned = input.clone(); const cloned = input.clone();
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.boxSize, this.boxSize]);
face5 = tf5.div(cut, 255); face5 = tf5.div(cut, 255);
tf5.dispose(cut); tf5.dispose(cut);
tf5.dispose(cloned); tf5.dispose(cloned);
@ -5032,10 +5032,10 @@ var Pipeline = class {
if (!config3.face.mesh.enabled) { if (!config3.face.mesh.enabled) {
results.push({ results.push({
mesh: [], mesh: [],
box: box6, box: box5,
faceConfidence: null, faceConfidence: null,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: box6.confidence, confidence: box5.confidence,
image: face5 image: face5
}); });
} else if (!this.meshDetector) { } else if (!this.meshDetector) {
@ -5051,29 +5051,29 @@ var Pipeline = class {
tf5.dispose(contourCoords); tf5.dispose(contourCoords);
tf5.dispose(coordsReshaped); tf5.dispose(coordsReshaped);
if (faceConfidence < config3.face.detector.minConfidence) { if (faceConfidence < config3.face.detector.minConfidence) {
box6.confidence = faceConfidence; box5.confidence = faceConfidence;
tf5.dispose(face5); tf5.dispose(face5);
} else { } else {
if (config3.face.iris.enabled) if (config3.face.iris.enabled)
rawCoords = await this.augmentIris(rawCoords, face5, config3); rawCoords = await this.augmentIris(rawCoords, face5, config3);
const mesh = this.transformRawCoords(rawCoords, box6, angle, rotationMatrix); const mesh = this.transformRawCoords(rawCoords, box5, angle, rotationMatrix);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box6.confidence }; box5 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box5.confidence };
if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env.kernels.includes("rotatewithoffset")) {
tf5.dispose(face5); tf5.dispose(face5);
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input);
} }
results.push({ results.push({
mesh, mesh,
box: box6, box: box5,
faceConfidence, faceConfidence,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: faceConfidence, confidence: faceConfidence,
image: face5 image: face5
}); });
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence }; box5 = { ...squarifyBox(box5), confidence: box5.confidence, faceConfidence };
} }
} }
newBoxes.push(box6); newBoxes.push(box5);
} }
if (config3.face.mesh.enabled) if (config3.face.mesh.enabled)
this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence); this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence);
@ -5108,7 +5108,7 @@ async function predict(input, config3) {
Math.trunc(Math.min(input.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])), Math.trunc(Math.min(input.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1])) Math.trunc(Math.min(input.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
const boxRaw3 = prediction.box ? [ const boxRaw2 = prediction.box ? [
prediction.box.startPoint[0] / (input.shape[2] || 0), prediction.box.startPoint[0] / (input.shape[2] || 0),
prediction.box.startPoint[1] / (input.shape[1] || 0), prediction.box.startPoint[1] / (input.shape[1] || 0),
(prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0), (prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0),
@ -5120,7 +5120,7 @@ async function predict(input, config3) {
boxScore: Math.round(100 * prediction.boxConfidence) / 100, boxScore: Math.round(100 * prediction.boxConfidence) / 100,
faceScore: Math.round(100 * prediction.faceConfidence) / 100, faceScore: Math.round(100 * prediction.faceConfidence) / 100,
box: clampedBox, box: clampedBox,
boxRaw: boxRaw3, boxRaw: boxRaw2,
mesh: prediction.mesh, mesh: prediction.mesh,
meshRaw, meshRaw,
annotations: annotations3, annotations: annotations3,
@ -5215,10 +5215,10 @@ function enhance(input) {
const tensor3 = input.image || input.tensor || input; const tensor3 = input.image || input.tensor || input;
if (!(tensor3 instanceof tf7.Tensor)) if (!(tensor3 instanceof tf7.Tensor))
return null; return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]]; const box5 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model == null ? void 0 : model.inputs[0].shape)) if (!(model == null ? void 0 : model.inputs[0].shape))
return null; return null;
const crop = tensor3.shape.length === 3 ? tf7.image.cropAndResize(tf7.expandDims(tensor3, 0), box6, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]) : tf7.image.cropAndResize(tensor3, box6, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]); const crop = tensor3.shape.length === 3 ? tf7.image.cropAndResize(tf7.expandDims(tensor3, 0), box5, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]) : tf7.image.cropAndResize(tensor3, box5, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]);
const norm = tf7.mul(crop, 255); const norm = tf7.mul(crop, 255);
return norm; return norm;
}); });
@ -5420,8 +5420,8 @@ function scalePoses(poses2, [height, width], [inputResolutionHeight, inputResolu
score: pose.score, score: pose.score,
boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight], boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight],
box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)], box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)],
keypoints: pose.keypoints.map(({ score: score3, part, position }) => ({ keypoints: pose.keypoints.map(({ score: score2, part, position }) => ({
score: score3, score: score2,
part, part,
position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)], position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)],
positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight] positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight]
@ -5545,8 +5545,8 @@ function traverse(edgeId, sourceKeypoint, targetId, scores, offsets, displacemen
targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y }); targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y });
} }
const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width); const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width);
const score3 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId); const score2 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId);
return { position: targetKeypoint, part: partNames[targetId], score: score3 }; return { position: targetKeypoint, part: partNames[targetId], score: score2 };
} }
function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) { function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]); const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]);
@ -5577,7 +5577,7 @@ function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
} }
return keypoints3; return keypoints3;
} }
function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores) { function scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores) {
const [height, width] = scores.shape; const [height, width] = scores.shape;
let localMaximum = true; let localMaximum = true;
const yStart = Math.max(heatmapY - localMaximumRadius, 0); const yStart = Math.max(heatmapY - localMaximumRadius, 0);
@ -5586,7 +5586,7 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
const xStart = Math.max(heatmapX - localMaximumRadius, 0); const xStart = Math.max(heatmapX - localMaximumRadius, 0);
const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width); const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width);
for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) { for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) {
if (scores.get(yCurrent, xCurrent, keypointId) > score3) { if (scores.get(yCurrent, xCurrent, keypointId) > score2) {
localMaximum = false; localMaximum = false;
break; break;
} }
@ -5598,15 +5598,15 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
} }
function buildPartWithScoreQueue(minConfidence2, scores) { function buildPartWithScoreQueue(minConfidence2, scores) {
const [height, width, numKeypoints] = scores.shape; const [height, width, numKeypoints] = scores.shape;
const queue = new MaxHeap(height * width * numKeypoints, ({ score: score3 }) => score3); const queue = new MaxHeap(height * width * numKeypoints, ({ score: score2 }) => score2);
for (let heatmapY = 0; heatmapY < height; ++heatmapY) { for (let heatmapY = 0; heatmapY < height; ++heatmapY) {
for (let heatmapX = 0; heatmapX < width; ++heatmapX) { for (let heatmapX = 0; heatmapX < width; ++heatmapX) {
for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) { for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) {
const score3 = scores.get(heatmapY, heatmapX, keypointId); const score2 = scores.get(heatmapY, heatmapX, keypointId);
if (score3 < minConfidence2) if (score2 < minConfidence2)
continue; continue;
if (scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores)) if (scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores))
queue.enqueue({ score: score3, part: { heatmapY, heatmapX, id: keypointId } }); queue.enqueue({ score: score2, part: { heatmapY, heatmapX, id: keypointId } });
} }
} }
} }
@ -5622,9 +5622,9 @@ function withinRadius(poses2, { x, y }, keypointId) {
}); });
} }
function getInstanceScore(existingPoses, keypoints3) { function getInstanceScore(existingPoses, keypoints3) {
const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score3 }, keypointId) => { const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score2 }, keypointId) => {
if (!withinRadius(existingPoses, position, keypointId)) if (!withinRadius(existingPoses, position, keypointId))
result += score3; result += score2;
return result; return result;
}, 0); }, 0);
return notOverlappedKeypointScores / keypoints3.length; return notOverlappedKeypointScores / keypoints3.length;
@ -5639,10 +5639,10 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
continue; continue;
let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd); let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints3 = keypoints3.filter((a) => a.score > minConfidence2); keypoints3 = keypoints3.filter((a) => a.score > minConfidence2);
const score3 = getInstanceScore(poses2, keypoints3); const score2 = getInstanceScore(poses2, keypoints3);
const box6 = getBoundingBox(keypoints3); const box5 = getBoundingBox(keypoints3);
if (score3 > minConfidence2) if (score2 > minConfidence2)
poses2.push({ keypoints: keypoints3, box: box6, score: Math.round(100 * score3) / 100 }); poses2.push({ keypoints: keypoints3, box: box5, score: Math.round(100 * score2) / 100 });
} }
return poses2; return poses2;
} }
@ -5690,54 +5690,54 @@ var tf11 = __toModule(require_tfjs_esm());
// src/handpose/box.ts // src/handpose/box.ts
var tf10 = __toModule(require_tfjs_esm()); var tf10 = __toModule(require_tfjs_esm());
function getBoxSize2(box6) { function getBoxSize2(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter2(box6) { function getBoxCenter2(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize2(box6, image24, cropSize) { function cutBoxFromImageAndResize2(box5, image24, cropSize) {
const h = image24.shape[1]; const h = image24.shape[1];
const w = image24.shape[2]; const w = image24.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return tf10.image.cropAndResize(image24, boxes, [0], cropSize); return tf10.image.cropAndResize(image24, boxes, [0], cropSize);
} }
function scaleBoxCoordinates2(box6, factor) { function scaleBoxCoordinates2(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => { const palmLandmarks = box5.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]]; const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord; return scaledCoord;
}); });
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence }; return { startPoint, endPoint, palmLandmarks, confidence: box5.confidence };
} }
function enlargeBox2(box6, factor = 1.5) { function enlargeBox2(box5, factor = 1.5) {
const center = getBoxCenter2(box6); const center = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
function squarifyBox2(box6) { function squarifyBox2(box5) {
const centers = getBoxCenter2(box6); const centers = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize]; const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize]; const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
// src/handpose/anchors.ts // src/handpose/anchors.ts
@ -9266,9 +9266,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedCurl, score3] of expectedCurls) { for (const [expectedCurl, score2] of expectedCurls) {
if (detectedCurl === expectedCurl) { if (detectedCurl === expectedCurl) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -9280,9 +9280,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedDirection, score3] of expectedDirections) { for (const [expectedDirection, score2] of expectedDirections) {
if (detectedDirection === expectedDirection) { if (detectedDirection === expectedDirection) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -9378,30 +9378,30 @@ async function predict5(input, config3) {
} }
} }
const keypoints3 = predictions[i].landmarks; const keypoints3 = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0]; let box5 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw3 = [0, 0, 0, 0]; let boxRaw2 = [0, 0, 0, 0];
if (keypoints3 && keypoints3.length > 0) { if (keypoints3 && keypoints3.length > 0) {
for (const pt of keypoints3) { for (const pt of keypoints3) {
if (pt[0] < box6[0]) if (pt[0] < box5[0])
box6[0] = pt[0]; box5[0] = pt[0];
if (pt[1] < box6[1]) if (pt[1] < box5[1])
box6[1] = pt[1]; box5[1] = pt[1];
if (pt[0] > box6[2]) if (pt[0] > box5[2])
box6[2] = pt[0]; box5[2] = pt[0];
if (pt[1] > box6[3]) if (pt[1] > box5[3])
box6[3] = pt[1]; box5[3] = pt[1];
} }
box6[2] -= box6[0]; box5[2] -= box5[0];
box6[3] -= box6[1]; box5[3] -= box5[1];
boxRaw3 = [box6[0] / (input.shape[2] || 0), box6[1] / (input.shape[1] || 0), box6[2] / (input.shape[2] || 0), box6[3] / (input.shape[1] || 0)]; boxRaw2 = [box5[0] / (input.shape[2] || 0), box5[1] / (input.shape[1] || 0), box5[2] / (input.shape[2] || 0), box5[3] / (input.shape[1] || 0)];
} else { } else {
box6 = predictions[i].box ? [ box5 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.max(0, predictions[i].box.topLeft[1])), Math.trunc(Math.max(0, predictions[i].box.topLeft[1])),
Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1])) Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
boxRaw3 = [ boxRaw2 = [
predictions[i].box.topLeft[0] / (input.shape[2] || 0), predictions[i].box.topLeft[0] / (input.shape[2] || 0),
predictions[i].box.topLeft[1] / (input.shape[1] || 0), predictions[i].box.topLeft[1] / (input.shape[1] || 0),
(predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0), (predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0),
@ -9415,8 +9415,8 @@ async function predict5(input, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100, boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100, fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand", label: "hand",
box: box6, box: box5,
boxRaw: boxRaw3, boxRaw: boxRaw2,
keypoints: keypoints3, keypoints: keypoints3,
annotations: annotations3, annotations: annotations3,
landmarks landmarks
@ -9751,13 +9751,13 @@ async function detectHands(input, config3) {
} else { } else {
yxBox = await boxSlice.data(); yxBox = await boxSlice.data();
} }
const boxRaw3 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]]; const boxRaw2 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]];
const box6 = [Math.trunc(boxRaw3[0] * outputSize[0]), Math.trunc(boxRaw3[1] * outputSize[1]), Math.trunc(boxRaw3[2] * outputSize[0]), Math.trunc(boxRaw3[3] * outputSize[1])]; const box5 = [Math.trunc(boxRaw2[0] * outputSize[0]), Math.trunc(boxRaw2[1] * outputSize[1]), Math.trunc(boxRaw2[2] * outputSize[0]), Math.trunc(boxRaw2[3] * outputSize[1])];
tf16.dispose(boxSlice); tf16.dispose(boxSlice);
const scoreSlice = tf16.slice(classScores[i], res, 1); const scoreSlice = tf16.slice(classScores[i], res, 1);
const score3 = (await scoreSlice.data())[0]; const score2 = (await scoreSlice.data())[0];
tf16.dispose(scoreSlice); tf16.dispose(scoreSlice);
const hand3 = { id: id++, score: score3, box: box6, boxRaw: boxRaw3, label: classes[i], yxBox }; const hand3 = { id: id++, score: score2, box: box5, boxRaw: boxRaw2, label: classes[i], yxBox };
hands.push(hand3); hands.push(hand3);
} }
} }
@ -9791,9 +9791,9 @@ async function detectFingers(input, h, config3) {
t.cast = tf16.cast(t.crop, "float32"); t.cast = tf16.cast(t.crop, "float32");
t.div = tf16.div(t.cast, 255); t.div = tf16.div(t.cast, 255);
[t.score, t.keypoints] = models2[1].execute(t.div); [t.score, t.keypoints] = models2[1].execute(t.div);
const score3 = Math.round(100 * (await t.score.data())[0] / 100); const score2 = Math.round(100 * (await t.score.data())[0] / 100);
if (score3 > (config3.hand.minConfidence || 0)) { if (score2 > (config3.hand.minConfidence || 0)) {
hand3.fingerScore = score3; hand3.fingerScore = score2;
t.reshaped = tf16.reshape(t.keypoints, [-1, 3]); t.reshaped = tf16.reshape(t.keypoints, [-1, 3]);
const rawCoords = await t.reshaped.array(); const rawCoords = await t.reshaped.array();
hand3.keypoints = rawCoords.map((coord) => [ hand3.keypoints = rawCoords.map((coord) => [
@ -9971,15 +9971,15 @@ async function predict7(image24, config3) {
} }
const x = keypoints3.map((a) => a.position[0]); const x = keypoints3.map((a) => a.position[0]);
const y = keypoints3.map((a) => a.position[1]); const y = keypoints3.map((a) => a.position[1]);
const box6 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
Math.max(...y) - Math.min(...x) Math.max(...y) - Math.min(...x)
]; ];
const boxRaw3 = [0, 0, 0, 0]; const boxRaw2 = [0, 0, 0, 0];
const score3 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); const score2 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
return [{ id: 0, score: score3, box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }]; return [{ id: 0, score: score2, box: box5, boxRaw: boxRaw2, keypoints: keypoints3 }];
} }
// src/efficientpose/efficientpose.ts // src/efficientpose/efficientpose.ts
@ -10091,9 +10091,6 @@ var tf19 = __toModule(require_tfjs_esm());
var model6; var model6;
var inputSize2 = 0; var inputSize2 = 0;
var cachedBoxes = []; var cachedBoxes = [];
var box5 = [0, 0, 0, 0];
var boxRaw2 = [0, 0, 0, 0];
var score2 = 0;
var skipped5 = Number.MAX_SAFE_INTEGER; var skipped5 = Number.MAX_SAFE_INTEGER;
var keypoints2 = []; var keypoints2 = [];
var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"]; var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"];
@ -10117,6 +10114,7 @@ async function load9(config3) {
async function parseSinglePose(res, config3, image24, inputBox) { async function parseSinglePose(res, config3, image24, inputBox) {
const kpt3 = res[0][0]; const kpt3 = res[0][0];
keypoints2.length = 0; keypoints2.length = 0;
let score2 = 0;
for (let id = 0; id < kpt3.length; id++) { for (let id = 0; id < kpt3.length; id++) {
score2 = kpt3[id][2]; score2 = kpt3[id][2];
if (score2 > config3.body.minConfidence) { if (score2 > config3.body.minConfidence) {
@ -10138,7 +10136,7 @@ async function parseSinglePose(res, config3, image24, inputBox) {
score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
const x = keypoints2.map((a) => a.position[0]); const x = keypoints2.map((a) => a.position[0]);
const y = keypoints2.map((a) => a.position[1]); const y = keypoints2.map((a) => a.position[1]);
box5 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
@ -10146,7 +10144,7 @@ async function parseSinglePose(res, config3, image24, inputBox) {
]; ];
const xRaw = keypoints2.map((a) => a.positionRaw[0]); const xRaw = keypoints2.map((a) => a.positionRaw[0]);
const yRaw = keypoints2.map((a) => a.positionRaw[1]); const yRaw = keypoints2.map((a) => a.positionRaw[1]);
boxRaw2 = [ const boxRaw2 = [
Math.min(...xRaw), Math.min(...xRaw),
Math.min(...yRaw), Math.min(...yRaw),
Math.max(...xRaw) - Math.min(...xRaw), Math.max(...xRaw) - Math.min(...xRaw),
@ -10160,7 +10158,7 @@ async function parseMultiPose(res, config3, image24, inputBox) {
const bodies = []; const bodies = [];
for (let id = 0; id < res[0].length; id++) { for (let id = 0; id < res[0].length; id++) {
const kpt3 = res[0][id]; const kpt3 = res[0][id];
score2 = Math.round(100 * kpt3[51 + 4]) / 100; const score2 = Math.round(100 * kpt3[51 + 4]) / 100;
if (score2 < config3.body.minConfidence) if (score2 < config3.body.minConfidence)
continue; continue;
keypoints2.length = 0; keypoints2.length = 0;
@ -10179,7 +10177,7 @@ async function parseMultiPose(res, config3, image24, inputBox) {
}); });
} }
} }
boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]]; const boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]];
bodies.push({ bodies.push({
id, id,
score: score2, score: score2,
@ -10358,8 +10356,8 @@ async function process3(res, inputSize4, outputShape, config3) {
const scores = await scoresT.array(); const scores = await scoresT.array();
for (let i = 0; i < scoresT.shape[0]; i++) { for (let i = 0; i < scoresT.shape[0]; i++) {
for (let j = 0; j < scoresT.shape[1]; j++) { for (let j = 0; j < scoresT.shape[1]; j++) {
const score3 = scores[i][j]; const score2 = scores[i][j];
if (score3 > config3.object.minConfidence && j !== 61) { if (score2 > config3.object.minConfidence && j !== 61) {
const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize; const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize;
const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize; const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize;
const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4)); const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4));
@ -10371,21 +10369,21 @@ async function process3(res, inputSize4, outputShape, config3) {
cx + scaleBox2 / strideSize * boxOffset[2] - x, cx + scaleBox2 / strideSize * boxOffset[2] - x,
cy + scaleBox2 / strideSize * boxOffset[3] - y cy + scaleBox2 / strideSize * boxOffset[3] - y
]; ];
let boxRaw3 = [x, y, w, h]; let boxRaw2 = [x, y, w, h];
boxRaw3 = boxRaw3.map((a) => Math.max(0, Math.min(a, 1))); boxRaw2 = boxRaw2.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [ const box5 = [
boxRaw3[0] * outputShape[0], boxRaw2[0] * outputShape[0],
boxRaw3[1] * outputShape[1], boxRaw2[1] * outputShape[1],
boxRaw3[2] * outputShape[0], boxRaw2[2] * outputShape[0],
boxRaw3[3] * outputShape[1] boxRaw2[3] * outputShape[1]
]; ];
const result = { const result = {
id: id++, id: id++,
score: Math.round(100 * score3) / 100, score: Math.round(100 * score2) / 100,
class: j + 1, class: j + 1,
label: labels[j].label, label: labels[j].label,
box: box6.map((a) => Math.trunc(a)), box: box5.map((a) => Math.trunc(a)),
boxRaw: boxRaw3 boxRaw: boxRaw2
}; };
results.push(result); results.push(result);
} }
@ -10475,26 +10473,26 @@ async function process4(res, outputShape, config3) {
tf21.dispose(nmsT); tf21.dispose(nmsT);
let i = 0; let i = 0;
for (const id of nms) { for (const id of nms) {
const score3 = Math.trunc(100 * detections[0][id][4]) / 100; const score2 = Math.trunc(100 * detections[0][id][4]) / 100;
const classVal = detections[0][id][5]; const classVal = detections[0][id][5];
const label = labels[classVal].label; const label = labels[classVal].label;
const [x, y] = [ const [x, y] = [
detections[0][id][0] / inputSize3, detections[0][id][0] / inputSize3,
detections[0][id][1] / inputSize3 detections[0][id][1] / inputSize3
]; ];
const boxRaw3 = [ const boxRaw2 = [
x, x,
y, y,
detections[0][id][2] / inputSize3 - x, detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y detections[0][id][3] / inputSize3 - y
]; ];
const box6 = [ const box5 = [
Math.trunc(boxRaw3[0] * outputShape[0]), Math.trunc(boxRaw2[0] * outputShape[0]),
Math.trunc(boxRaw3[1] * outputShape[1]), Math.trunc(boxRaw2[1] * outputShape[1]),
Math.trunc(boxRaw3[2] * outputShape[0]), Math.trunc(boxRaw2[2] * outputShape[0]),
Math.trunc(boxRaw3[3] * outputShape[1]) Math.trunc(boxRaw2[3] * outputShape[1])
]; ];
results.push({ id: i++, score: score3, class: classVal, label, box: box6, boxRaw: boxRaw3 }); results.push({ id: i++, score: score2, class: classVal, label, box: box5, boxRaw: boxRaw2 });
} }
return results; return results;
} }
@ -11420,7 +11418,7 @@ async function hand2(inCanvas2, result, drawOptions) {
if (localOptions.drawPoints) { if (localOptions.drawPoints) {
if (h.keypoints && h.keypoints.length > 0) { if (h.keypoints && h.keypoints.length > 0) {
for (const pt of h.keypoints) { for (const pt of h.keypoints) {
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * pt[2]}, ${127.5 - 2 * pt[2]}, 255, 0.5)` : localOptions.color; ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * (pt[2] || 0)}, ${127.5 - 2 * (pt[2] || 0)}, 255, 0.5)` : localOptions.color;
point(ctx, pt[0], pt[1], 0, localOptions); point(ctx, pt[0], pt[1], 0, localOptions);
} }
} }
@ -11571,10 +11569,10 @@ function join2(faces, bodies, hands, gestures, shape) {
} }
const x = []; const x = [];
const y = []; const y = [];
const extractXY = (box6) => { const extractXY = (box5) => {
if (box6 && box6.length === 4) { if (box5 && box5.length === 4) {
x.push(box6[0], box6[0] + box6[2]); x.push(box5[0], box5[0] + box5[2]);
y.push(box6[1], box6[1] + box6[3]); y.push(box5[1], box5[1] + box5[3]);
} }
}; };
extractXY((_k = person2.face) == null ? void 0 : _k.box); extractXY((_k = person2.face) == null ? void 0 : _k.box);
@ -11604,8 +11602,8 @@ function calc(newResult) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body)); bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else { } else {
for (let i = 0; i < newResult.body.length; i++) { for (let i = 0; i < newResult.body.length; i++) {
const box6 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor); const box5 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({ const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score, score: keypoint.score,
part: keypoint.part, part: keypoint.part,
@ -11618,18 +11616,18 @@ function calc(newResult) {
bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1] bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1]
] ]
})); }));
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }; bufferedResult.body[i] = { ...newResult.body[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3 };
} }
} }
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) { if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand)); bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else { } else {
for (let i = 0; i < newResult.hand.length; i++) { for (let i = 0; i < newResult.hand.length; i++) {
const box6 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor); const box5 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor);
if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length) if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints; bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].keypoints[j][k] + coord) / bufferedFactor)) : []; const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * (bufferedResult.hand[i].keypoints[j][k] || 1) + (coord || 0)) / bufferedFactor)) : [];
const annotations3 = {}; const annotations3 = {};
if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length) if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length)
bufferedResult.hand[i].annotations = newResult.hand[i].annotations; bufferedResult.hand[i].annotations = newResult.hand[i].annotations;
@ -11638,15 +11636,15 @@ function calc(newResult) {
annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null; annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null;
} }
} }
bufferedResult.hand[i] = { ...newResult.hand[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3, annotations: annotations3 }; bufferedResult.hand[i] = { ...newResult.hand[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3, annotations: annotations3 };
} }
} }
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) { if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face)); bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else { } else {
for (let i = 0; i < newResult.face.length; i++) { for (let i = 0; i < newResult.face.length; i++) {
const box6 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor); const box5 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor);
const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } }; const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } };
rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix; rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix;
rotation.angle = { rotation.angle = {
@ -11658,16 +11656,16 @@ function calc(newResult) {
bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor, bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor
}; };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw: boxRaw3 }; bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box5, boxRaw: boxRaw2 };
} }
} }
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) { if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object)); bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else { } else {
for (let i = 0; i < newResult.object.length; i++) { for (let i = 0; i < newResult.object.length; i++) {
const box6 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor); const box5 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor);
bufferedResult.object[i] = { ...newResult.object[i], box: box6, boxRaw: boxRaw3 }; bufferedResult.object[i] = { ...newResult.object[i], box: box5, boxRaw: boxRaw2 };
} }
} }
if (newResult.persons) { if (newResult.persons) {
@ -11676,7 +11674,7 @@ function calc(newResult) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons)); bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else { } else {
for (let i = 0; i < newPersons.length; i++) { for (let i = 0; i < newPersons.length; i++) {
bufferedResult.persons[i].box = newPersons[i].box.map((box6, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box6) / bufferedFactor); bufferedResult.persons[i].box = newPersons[i].box.map((box5, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box5) / bufferedFactor);
} }
} }
} }

368
dist/human.node.js vendored
View File

@ -147,25 +147,25 @@ function scaleBox(keypoints3, boxScaleFact2, outputSize2) {
const maxmin = [Math.max(...coords3[0]), Math.min(...coords3[0]), Math.max(...coords3[1]), Math.min(...coords3[1])]; const maxmin = [Math.max(...coords3[0]), Math.min(...coords3[0]), Math.max(...coords3[1]), Math.min(...coords3[1])];
const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2]; const center = [(maxmin[0] + maxmin[1]) / 2, (maxmin[2] + maxmin[3]) / 2];
const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2; const diff = Math.max(center[0] - maxmin[1], center[1] - maxmin[3], -center[0] + maxmin[0], -center[1] + maxmin[2]) * boxScaleFact2;
const box6 = [ const box5 = [
Math.trunc(center[0] - diff), Math.trunc(center[0] - diff),
Math.trunc(center[1] - diff), Math.trunc(center[1] - diff),
Math.trunc(2 * diff), Math.trunc(2 * diff),
Math.trunc(2 * diff) Math.trunc(2 * diff)
]; ];
const boxRaw3 = [ const boxRaw2 = [
box6[0] / outputSize2[0], box5[0] / outputSize2[0],
box6[1] / outputSize2[1], box5[1] / outputSize2[1],
box6[2] / outputSize2[0], box5[2] / outputSize2[0],
box6[3] / outputSize2[1] box5[3] / outputSize2[1]
]; ];
const yxBox = [ const yxBox = [
boxRaw3[1], boxRaw2[1],
boxRaw3[0], boxRaw2[0],
boxRaw3[3] + boxRaw3[1], boxRaw2[3] + boxRaw2[1],
boxRaw3[2] + boxRaw3[0] boxRaw2[2] + boxRaw2[0]
]; ];
return { box: box6, boxRaw: boxRaw3, yxBox }; return { box: box5, boxRaw: boxRaw2, yxBox };
} }
// src/config.ts // src/config.ts
@ -281,50 +281,50 @@ var tf2 = __toModule(require_tfjs_esm());
// src/blazeface/box.ts // src/blazeface/box.ts
var tf = __toModule(require_tfjs_esm()); var tf = __toModule(require_tfjs_esm());
function scaleBoxCoordinates(box6, factor) { function scaleBoxCoordinates(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
return { startPoint, endPoint }; return { startPoint, endPoint };
} }
function getBoxSize(box6) { function getBoxSize(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter(box6) { function getBoxCenter(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize(box6, image24, cropSize) { function cutBoxFromImageAndResize(box5, image24, cropSize) {
const h = image24.shape[1]; const h = image24.shape[1];
const w = image24.shape[2]; const w = image24.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return tf.image.cropAndResize(image24, boxes, [0], cropSize); return tf.image.cropAndResize(image24, boxes, [0], cropSize);
} }
function enlargeBox(box6, factor = 1.5) { function enlargeBox(box5, factor = 1.5) {
const center = getBoxCenter(box6); const center = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function squarifyBox(box6) { function squarifyBox(box5) {
const centers = getBoxCenter(box6); const centers = getBoxCenter(box5);
const size = getBoxSize(box6); const size = getBoxSize(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)]; const startPoint = [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)];
const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)]; const endPoint = [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)];
return { startPoint, endPoint, landmarks: box6.landmarks }; return { startPoint, endPoint, landmarks: box5.landmarks };
} }
function calculateLandmarksBoundingBox(landmarks) { function calculateLandmarksBoundingBox(landmarks) {
const xs = landmarks.map((d) => d[0]); const xs = landmarks.map((d) => d[0]);
@ -4857,8 +4857,8 @@ var Pipeline = class {
this.skipped = 0; this.skipped = 0;
this.detectedFaces = 0; this.detectedFaces = 0;
} }
transformRawCoords(rawCoords, box6, angle, rotationMatrix) { transformRawCoords(rawCoords, box5, angle, rotationMatrix) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const boxSize = getBoxSize({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const coordsScaled = rawCoords.map((coord) => [ const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2), boxSize[0] / this.meshSize * (coord[0] - this.meshSize / 2),
boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2), boxSize[1] / this.meshSize * (coord[1] - this.meshSize / 2),
@ -4867,7 +4867,7 @@ var Pipeline = class {
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX; const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled; const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX; const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1]; const boxCenter = [...getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint }), 1];
return coordsRotated.map((coord) => [ return coordsRotated.map((coord) => [
Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])), Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])), Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])),
@ -4880,20 +4880,20 @@ var Pipeline = class {
return leftEyeZ - rightEyeZ; return leftEyeZ - rightEyeZ;
} }
getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) { getEyeBox(rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false) {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge)); const box5 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), this.irisEnlarge));
const boxSize = getBoxSize(box6); const boxSize = getBoxSize(box5);
let crop = tf5.image.cropAndResize(face5, [[ let crop = tf5.image.cropAndResize(face5, [[
box6.startPoint[1] / this.meshSize, box5.startPoint[1] / this.meshSize,
box6.startPoint[0] / this.meshSize, box5.startPoint[0] / this.meshSize,
box6.endPoint[1] / this.meshSize, box5.endPoint[1] / this.meshSize,
box6.endPoint[0] / this.meshSize box5.endPoint[0] / this.meshSize
]], [0], [this.irisSize, this.irisSize]); ]], [0], [this.irisSize, this.irisSize]);
if (flip && env.kernels.includes("flipleftright")) { if (flip && env.kernels.includes("flipleftright")) {
const flipped = tf5.image.flipLeftRight(crop); const flipped = tf5.image.flipLeftRight(crop);
tf5.dispose(crop); tf5.dispose(crop);
crop = flipped; crop = flipped;
} }
return { box: box6, boxSize, crop }; return { box: box5, boxSize, crop };
} }
getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) { getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) {
const eyeRawCoords = []; const eyeRawCoords = [];
@ -4923,14 +4923,14 @@ var Pipeline = class {
return [coord[0], coord[1], z]; return [coord[0], coord[1], z];
}); });
} }
correctFaceRotation(config3, box6, input) { correctFaceRotation(config3, box5, input) {
const [indexOfMouth, indexOfForehead] = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine; const [indexOfMouth, indexOfForehead] = box5.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[indexOfMouth], box6.landmarks[indexOfForehead]); const angle = computeRotation(box5.landmarks[indexOfMouth], box5.landmarks[indexOfForehead]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }); const faceCenter = getBoxCenter({ startPoint: box5.startPoint, endPoint: box5.endPoint });
const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]]; const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]];
const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized); const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter); const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, rotated, [this.boxSize, this.boxSize]);
const face5 = tf5.div(cut, 255); const face5 = tf5.div(cut, 255);
tf5.dispose(cut); tf5.dispose(cut);
tf5.dispose(rotated); tf5.dispose(rotated);
@ -5014,16 +5014,16 @@ var Pipeline = class {
} }
const results = []; const results = [];
const newBoxes = []; const newBoxes = [];
for (let box6 of this.storedBoxes) { for (let box5 of this.storedBoxes) {
let face5; let face5;
let angle = 0; let angle = 0;
let rotationMatrix; let rotationMatrix;
if (config3.face.detector.rotation && config3.face.mesh.enabled && env.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && env.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input);
} else { } else {
rotationMatrix = IDENTITY_MATRIX; rotationMatrix = IDENTITY_MATRIX;
const cloned = input.clone(); const cloned = input.clone();
const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, cloned, [this.boxSize, this.boxSize]); const cut = config3.face.mesh.enabled ? cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.meshSize, this.meshSize]) : cutBoxFromImageAndResize({ startPoint: box5.startPoint, endPoint: box5.endPoint }, cloned, [this.boxSize, this.boxSize]);
face5 = tf5.div(cut, 255); face5 = tf5.div(cut, 255);
tf5.dispose(cut); tf5.dispose(cut);
tf5.dispose(cloned); tf5.dispose(cloned);
@ -5031,10 +5031,10 @@ var Pipeline = class {
if (!config3.face.mesh.enabled) { if (!config3.face.mesh.enabled) {
results.push({ results.push({
mesh: [], mesh: [],
box: box6, box: box5,
faceConfidence: null, faceConfidence: null,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: box6.confidence, confidence: box5.confidence,
image: face5 image: face5
}); });
} else if (!this.meshDetector) { } else if (!this.meshDetector) {
@ -5050,29 +5050,29 @@ var Pipeline = class {
tf5.dispose(contourCoords); tf5.dispose(contourCoords);
tf5.dispose(coordsReshaped); tf5.dispose(coordsReshaped);
if (faceConfidence < config3.face.detector.minConfidence) { if (faceConfidence < config3.face.detector.minConfidence) {
box6.confidence = faceConfidence; box5.confidence = faceConfidence;
tf5.dispose(face5); tf5.dispose(face5);
} else { } else {
if (config3.face.iris.enabled) if (config3.face.iris.enabled)
rawCoords = await this.augmentIris(rawCoords, face5, config3); rawCoords = await this.augmentIris(rawCoords, face5, config3);
const mesh = this.transformRawCoords(rawCoords, box6, angle, rotationMatrix); const mesh = this.transformRawCoords(rawCoords, box5, angle, rotationMatrix);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box6.confidence }; box5 = { ...enlargeBox(calculateLandmarksBoundingBox(mesh), 1.5), confidence: box5.confidence };
if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env.kernels.includes("rotatewithoffset")) { if (config3.face.detector.rotation && config3.face.mesh.enabled && config3.face.description.enabled && env.kernels.includes("rotatewithoffset")) {
tf5.dispose(face5); tf5.dispose(face5);
[angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box6, input); [angle, rotationMatrix, face5] = this.correctFaceRotation(config3, box5, input);
} }
results.push({ results.push({
mesh, mesh,
box: box6, box: box5,
faceConfidence, faceConfidence,
boxConfidence: box6.confidence, boxConfidence: box5.confidence,
confidence: faceConfidence, confidence: faceConfidence,
image: face5 image: face5
}); });
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence }; box5 = { ...squarifyBox(box5), confidence: box5.confidence, faceConfidence };
} }
} }
newBoxes.push(box6); newBoxes.push(box5);
} }
if (config3.face.mesh.enabled) if (config3.face.mesh.enabled)
this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence); this.storedBoxes = newBoxes.filter((a) => a.confidence > config3.face.detector.minConfidence);
@ -5107,7 +5107,7 @@ async function predict(input, config3) {
Math.trunc(Math.min(input.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])), Math.trunc(Math.min(input.shape[2] || 0, prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1])) Math.trunc(Math.min(input.shape[1] || 0, prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
const boxRaw3 = prediction.box ? [ const boxRaw2 = prediction.box ? [
prediction.box.startPoint[0] / (input.shape[2] || 0), prediction.box.startPoint[0] / (input.shape[2] || 0),
prediction.box.startPoint[1] / (input.shape[1] || 0), prediction.box.startPoint[1] / (input.shape[1] || 0),
(prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0), (prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0),
@ -5119,7 +5119,7 @@ async function predict(input, config3) {
boxScore: Math.round(100 * prediction.boxConfidence) / 100, boxScore: Math.round(100 * prediction.boxConfidence) / 100,
faceScore: Math.round(100 * prediction.faceConfidence) / 100, faceScore: Math.round(100 * prediction.faceConfidence) / 100,
box: clampedBox, box: clampedBox,
boxRaw: boxRaw3, boxRaw: boxRaw2,
mesh: prediction.mesh, mesh: prediction.mesh,
meshRaw, meshRaw,
annotations: annotations3, annotations: annotations3,
@ -5214,10 +5214,10 @@ function enhance(input) {
const tensor3 = input.image || input.tensor || input; const tensor3 = input.image || input.tensor || input;
if (!(tensor3 instanceof tf7.Tensor)) if (!(tensor3 instanceof tf7.Tensor))
return null; return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]]; const box5 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model == null ? void 0 : model.inputs[0].shape)) if (!(model == null ? void 0 : model.inputs[0].shape))
return null; return null;
const crop = tensor3.shape.length === 3 ? tf7.image.cropAndResize(tf7.expandDims(tensor3, 0), box6, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]) : tf7.image.cropAndResize(tensor3, box6, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]); const crop = tensor3.shape.length === 3 ? tf7.image.cropAndResize(tf7.expandDims(tensor3, 0), box5, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]) : tf7.image.cropAndResize(tensor3, box5, [0], [model.inputs[0].shape[2], model.inputs[0].shape[1]]);
const norm = tf7.mul(crop, 255); const norm = tf7.mul(crop, 255);
return norm; return norm;
}); });
@ -5419,8 +5419,8 @@ function scalePoses(poses2, [height, width], [inputResolutionHeight, inputResolu
score: pose.score, score: pose.score,
boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight], boxRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight],
box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)], box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)],
keypoints: pose.keypoints.map(({ score: score3, part, position }) => ({ keypoints: pose.keypoints.map(({ score: score2, part, position }) => ({
score: score3, score: score2,
part, part,
position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)], position: [Math.trunc(position.x * scaleX), Math.trunc(position.y * scaleY)],
positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight] positionRaw: [position.x / inputResolutionHeight, position.y / inputResolutionHeight]
@ -5544,8 +5544,8 @@ function traverse(edgeId, sourceKeypoint, targetId, scores, offsets, displacemen
targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y }); targetKeypoint = addVectors({ x: targetKeypointIndices.x * outputStride, y: targetKeypointIndices.y * outputStride }, { x: offsetPoint.x, y: offsetPoint.y });
} }
const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width); const targetKeyPointIndices = getStridedIndexNearPoint(targetKeypoint, height, width);
const score3 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId); const score2 = scores.get(targetKeyPointIndices.y, targetKeyPointIndices.x, targetId);
return { position: targetKeypoint, part: partNames[targetId], score: score3 }; return { position: targetKeypoint, part: partNames[targetId], score: score2 };
} }
function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) { function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]); const tuples = poseChain.map(([parentJoinName, childJoinName]) => [partIds[parentJoinName], partIds[childJoinName]]);
@ -5576,7 +5576,7 @@ function decodePose(root, scores, offsets, displacementsFwd, displacementsBwd) {
} }
return keypoints3; return keypoints3;
} }
function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores) { function scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores) {
const [height, width] = scores.shape; const [height, width] = scores.shape;
let localMaximum = true; let localMaximum = true;
const yStart = Math.max(heatmapY - localMaximumRadius, 0); const yStart = Math.max(heatmapY - localMaximumRadius, 0);
@ -5585,7 +5585,7 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
const xStart = Math.max(heatmapX - localMaximumRadius, 0); const xStart = Math.max(heatmapX - localMaximumRadius, 0);
const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width); const xEnd = Math.min(heatmapX + localMaximumRadius + 1, width);
for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) { for (let xCurrent = xStart; xCurrent < xEnd; ++xCurrent) {
if (scores.get(yCurrent, xCurrent, keypointId) > score3) { if (scores.get(yCurrent, xCurrent, keypointId) > score2) {
localMaximum = false; localMaximum = false;
break; break;
} }
@ -5597,15 +5597,15 @@ function scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, sco
} }
function buildPartWithScoreQueue(minConfidence2, scores) { function buildPartWithScoreQueue(minConfidence2, scores) {
const [height, width, numKeypoints] = scores.shape; const [height, width, numKeypoints] = scores.shape;
const queue = new MaxHeap(height * width * numKeypoints, ({ score: score3 }) => score3); const queue = new MaxHeap(height * width * numKeypoints, ({ score: score2 }) => score2);
for (let heatmapY = 0; heatmapY < height; ++heatmapY) { for (let heatmapY = 0; heatmapY < height; ++heatmapY) {
for (let heatmapX = 0; heatmapX < width; ++heatmapX) { for (let heatmapX = 0; heatmapX < width; ++heatmapX) {
for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) { for (let keypointId = 0; keypointId < numKeypoints; ++keypointId) {
const score3 = scores.get(heatmapY, heatmapX, keypointId); const score2 = scores.get(heatmapY, heatmapX, keypointId);
if (score3 < minConfidence2) if (score2 < minConfidence2)
continue; continue;
if (scoreIsMaximumInLocalWindow(keypointId, score3, heatmapY, heatmapX, scores)) if (scoreIsMaximumInLocalWindow(keypointId, score2, heatmapY, heatmapX, scores))
queue.enqueue({ score: score3, part: { heatmapY, heatmapX, id: keypointId } }); queue.enqueue({ score: score2, part: { heatmapY, heatmapX, id: keypointId } });
} }
} }
} }
@ -5621,9 +5621,9 @@ function withinRadius(poses2, { x, y }, keypointId) {
}); });
} }
function getInstanceScore(existingPoses, keypoints3) { function getInstanceScore(existingPoses, keypoints3) {
const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score3 }, keypointId) => { const notOverlappedKeypointScores = keypoints3.reduce((result, { position, score: score2 }, keypointId) => {
if (!withinRadius(existingPoses, position, keypointId)) if (!withinRadius(existingPoses, position, keypointId))
result += score3; result += score2;
return result; return result;
}, 0); }, 0);
return notOverlappedKeypointScores / keypoints3.length; return notOverlappedKeypointScores / keypoints3.length;
@ -5638,10 +5638,10 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
continue; continue;
let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd); let keypoints3 = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints3 = keypoints3.filter((a) => a.score > minConfidence2); keypoints3 = keypoints3.filter((a) => a.score > minConfidence2);
const score3 = getInstanceScore(poses2, keypoints3); const score2 = getInstanceScore(poses2, keypoints3);
const box6 = getBoundingBox(keypoints3); const box5 = getBoundingBox(keypoints3);
if (score3 > minConfidence2) if (score2 > minConfidence2)
poses2.push({ keypoints: keypoints3, box: box6, score: Math.round(100 * score3) / 100 }); poses2.push({ keypoints: keypoints3, box: box5, score: Math.round(100 * score2) / 100 });
} }
return poses2; return poses2;
} }
@ -5689,54 +5689,54 @@ var tf11 = __toModule(require_tfjs_esm());
// src/handpose/box.ts // src/handpose/box.ts
var tf10 = __toModule(require_tfjs_esm()); var tf10 = __toModule(require_tfjs_esm());
function getBoxSize2(box6) { function getBoxSize2(box5) {
return [ return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box5.endPoint[0] - box5.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1]) Math.abs(box5.endPoint[1] - box5.startPoint[1])
]; ];
} }
function getBoxCenter2(box6) { function getBoxCenter2(box5) {
return [ return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box5.startPoint[0] + (box5.endPoint[0] - box5.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2 box5.startPoint[1] + (box5.endPoint[1] - box5.startPoint[1]) / 2
]; ];
} }
function cutBoxFromImageAndResize2(box6, image24, cropSize) { function cutBoxFromImageAndResize2(box5, image24, cropSize) {
const h = image24.shape[1]; const h = image24.shape[1];
const w = image24.shape[2]; const w = image24.shape[2];
const boxes = [[ const boxes = [[
box6.startPoint[1] / h, box5.startPoint[1] / h,
box6.startPoint[0] / w, box5.startPoint[0] / w,
box6.endPoint[1] / h, box5.endPoint[1] / h,
box6.endPoint[0] / w box5.endPoint[0] / w
]]; ]];
return tf10.image.cropAndResize(image24, boxes, [0], cropSize); return tf10.image.cropAndResize(image24, boxes, [0], cropSize);
} }
function scaleBoxCoordinates2(box6, factor) { function scaleBoxCoordinates2(box5, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]]; const startPoint = [box5.startPoint[0] * factor[0], box5.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]]; const endPoint = [box5.endPoint[0] * factor[0], box5.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => { const palmLandmarks = box5.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]]; const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord; return scaledCoord;
}); });
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence }; return { startPoint, endPoint, palmLandmarks, confidence: box5.confidence };
} }
function enlargeBox2(box6, factor = 1.5) { function enlargeBox2(box5, factor = 1.5) {
const center = getBoxCenter2(box6); const center = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2]; const newHalfSize = [factor * size[0] / 2, factor * size[1] / 2];
const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]]; const startPoint = [center[0] - newHalfSize[0], center[1] - newHalfSize[1]];
const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]]; const endPoint = [center[0] + newHalfSize[0], center[1] + newHalfSize[1]];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
function squarifyBox2(box6) { function squarifyBox2(box5) {
const centers = getBoxCenter2(box6); const centers = getBoxCenter2(box5);
const size = getBoxSize2(box6); const size = getBoxSize2(box5);
const maxEdge = Math.max(...size); const maxEdge = Math.max(...size);
const halfSize = maxEdge / 2; const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize]; const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize]; const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks }; return { startPoint, endPoint, palmLandmarks: box5.palmLandmarks };
} }
// src/handpose/anchors.ts // src/handpose/anchors.ts
@ -9265,9 +9265,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedCurl, score3] of expectedCurls) { for (const [expectedCurl, score2] of expectedCurls) {
if (detectedCurl === expectedCurl) { if (detectedCurl === expectedCurl) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -9279,9 +9279,9 @@ var Gesture = class {
confidence += this.weightsRelative[fingerIdx]; confidence += this.weightsRelative[fingerIdx];
continue; continue;
} }
for (const [expectedDirection, score3] of expectedDirections) { for (const [expectedDirection, score2] of expectedDirections) {
if (detectedDirection === expectedDirection) { if (detectedDirection === expectedDirection) {
confidence += score3 * this.weightsRelative[fingerIdx]; confidence += score2 * this.weightsRelative[fingerIdx];
break; break;
} }
} }
@ -9377,30 +9377,30 @@ async function predict5(input, config3) {
} }
} }
const keypoints3 = predictions[i].landmarks; const keypoints3 = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0]; let box5 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw3 = [0, 0, 0, 0]; let boxRaw2 = [0, 0, 0, 0];
if (keypoints3 && keypoints3.length > 0) { if (keypoints3 && keypoints3.length > 0) {
for (const pt of keypoints3) { for (const pt of keypoints3) {
if (pt[0] < box6[0]) if (pt[0] < box5[0])
box6[0] = pt[0]; box5[0] = pt[0];
if (pt[1] < box6[1]) if (pt[1] < box5[1])
box6[1] = pt[1]; box5[1] = pt[1];
if (pt[0] > box6[2]) if (pt[0] > box5[2])
box6[2] = pt[0]; box5[2] = pt[0];
if (pt[1] > box6[3]) if (pt[1] > box5[3])
box6[3] = pt[1]; box5[3] = pt[1];
} }
box6[2] -= box6[0]; box5[2] -= box5[0];
box6[3] -= box6[1]; box5[3] -= box5[1];
boxRaw3 = [box6[0] / (input.shape[2] || 0), box6[1] / (input.shape[1] || 0), box6[2] / (input.shape[2] || 0), box6[3] / (input.shape[1] || 0)]; boxRaw2 = [box5[0] / (input.shape[2] || 0), box5[1] / (input.shape[1] || 0), box5[2] / (input.shape[2] || 0), box5[3] / (input.shape[1] || 0)];
} else { } else {
box6 = predictions[i].box ? [ box5 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.max(0, predictions[i].box.topLeft[1])), Math.trunc(Math.max(0, predictions[i].box.topLeft[1])),
Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])), Math.trunc(Math.min(input.shape[2] || 0, predictions[i].box.bottomRight[0]) - Math.max(0, predictions[i].box.topLeft[0])),
Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1])) Math.trunc(Math.min(input.shape[1] || 0, predictions[i].box.bottomRight[1]) - Math.max(0, predictions[i].box.topLeft[1]))
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
boxRaw3 = [ boxRaw2 = [
predictions[i].box.topLeft[0] / (input.shape[2] || 0), predictions[i].box.topLeft[0] / (input.shape[2] || 0),
predictions[i].box.topLeft[1] / (input.shape[1] || 0), predictions[i].box.topLeft[1] / (input.shape[1] || 0),
(predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0), (predictions[i].box.bottomRight[0] - predictions[i].box.topLeft[0]) / (input.shape[2] || 0),
@ -9414,8 +9414,8 @@ async function predict5(input, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100, boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100, fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand", label: "hand",
box: box6, box: box5,
boxRaw: boxRaw3, boxRaw: boxRaw2,
keypoints: keypoints3, keypoints: keypoints3,
annotations: annotations3, annotations: annotations3,
landmarks landmarks
@ -9750,13 +9750,13 @@ async function detectHands(input, config3) {
} else { } else {
yxBox = await boxSlice.data(); yxBox = await boxSlice.data();
} }
const boxRaw3 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]]; const boxRaw2 = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]];
const box6 = [Math.trunc(boxRaw3[0] * outputSize[0]), Math.trunc(boxRaw3[1] * outputSize[1]), Math.trunc(boxRaw3[2] * outputSize[0]), Math.trunc(boxRaw3[3] * outputSize[1])]; const box5 = [Math.trunc(boxRaw2[0] * outputSize[0]), Math.trunc(boxRaw2[1] * outputSize[1]), Math.trunc(boxRaw2[2] * outputSize[0]), Math.trunc(boxRaw2[3] * outputSize[1])];
tf16.dispose(boxSlice); tf16.dispose(boxSlice);
const scoreSlice = tf16.slice(classScores[i], res, 1); const scoreSlice = tf16.slice(classScores[i], res, 1);
const score3 = (await scoreSlice.data())[0]; const score2 = (await scoreSlice.data())[0];
tf16.dispose(scoreSlice); tf16.dispose(scoreSlice);
const hand3 = { id: id++, score: score3, box: box6, boxRaw: boxRaw3, label: classes[i], yxBox }; const hand3 = { id: id++, score: score2, box: box5, boxRaw: boxRaw2, label: classes[i], yxBox };
hands.push(hand3); hands.push(hand3);
} }
} }
@ -9790,9 +9790,9 @@ async function detectFingers(input, h, config3) {
t.cast = tf16.cast(t.crop, "float32"); t.cast = tf16.cast(t.crop, "float32");
t.div = tf16.div(t.cast, 255); t.div = tf16.div(t.cast, 255);
[t.score, t.keypoints] = models2[1].execute(t.div); [t.score, t.keypoints] = models2[1].execute(t.div);
const score3 = Math.round(100 * (await t.score.data())[0] / 100); const score2 = Math.round(100 * (await t.score.data())[0] / 100);
if (score3 > (config3.hand.minConfidence || 0)) { if (score2 > (config3.hand.minConfidence || 0)) {
hand3.fingerScore = score3; hand3.fingerScore = score2;
t.reshaped = tf16.reshape(t.keypoints, [-1, 3]); t.reshaped = tf16.reshape(t.keypoints, [-1, 3]);
const rawCoords = await t.reshaped.array(); const rawCoords = await t.reshaped.array();
hand3.keypoints = rawCoords.map((coord) => [ hand3.keypoints = rawCoords.map((coord) => [
@ -9970,15 +9970,15 @@ async function predict7(image24, config3) {
} }
const x = keypoints3.map((a) => a.position[0]); const x = keypoints3.map((a) => a.position[0]);
const y = keypoints3.map((a) => a.position[1]); const y = keypoints3.map((a) => a.position[1]);
const box6 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
Math.max(...y) - Math.min(...x) Math.max(...y) - Math.min(...x)
]; ];
const boxRaw3 = [0, 0, 0, 0]; const boxRaw2 = [0, 0, 0, 0];
const score3 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); const score2 = keypoints3.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
return [{ id: 0, score: score3, box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }]; return [{ id: 0, score: score2, box: box5, boxRaw: boxRaw2, keypoints: keypoints3 }];
} }
// src/efficientpose/efficientpose.ts // src/efficientpose/efficientpose.ts
@ -10090,9 +10090,6 @@ var tf19 = __toModule(require_tfjs_esm());
var model6; var model6;
var inputSize2 = 0; var inputSize2 = 0;
var cachedBoxes = []; var cachedBoxes = [];
var box5 = [0, 0, 0, 0];
var boxRaw2 = [0, 0, 0, 0];
var score2 = 0;
var skipped5 = Number.MAX_SAFE_INTEGER; var skipped5 = Number.MAX_SAFE_INTEGER;
var keypoints2 = []; var keypoints2 = [];
var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"]; var bodyParts2 = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"];
@ -10116,6 +10113,7 @@ async function load9(config3) {
async function parseSinglePose(res, config3, image24, inputBox) { async function parseSinglePose(res, config3, image24, inputBox) {
const kpt3 = res[0][0]; const kpt3 = res[0][0];
keypoints2.length = 0; keypoints2.length = 0;
let score2 = 0;
for (let id = 0; id < kpt3.length; id++) { for (let id = 0; id < kpt3.length; id++) {
score2 = kpt3[id][2]; score2 = kpt3[id][2];
if (score2 > config3.body.minConfidence) { if (score2 > config3.body.minConfidence) {
@ -10137,7 +10135,7 @@ async function parseSinglePose(res, config3, image24, inputBox) {
score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0); score2 = keypoints2.reduce((prev, curr) => curr.score > prev ? curr.score : prev, 0);
const x = keypoints2.map((a) => a.position[0]); const x = keypoints2.map((a) => a.position[0]);
const y = keypoints2.map((a) => a.position[1]); const y = keypoints2.map((a) => a.position[1]);
box5 = [ const box5 = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
@ -10145,7 +10143,7 @@ async function parseSinglePose(res, config3, image24, inputBox) {
]; ];
const xRaw = keypoints2.map((a) => a.positionRaw[0]); const xRaw = keypoints2.map((a) => a.positionRaw[0]);
const yRaw = keypoints2.map((a) => a.positionRaw[1]); const yRaw = keypoints2.map((a) => a.positionRaw[1]);
boxRaw2 = [ const boxRaw2 = [
Math.min(...xRaw), Math.min(...xRaw),
Math.min(...yRaw), Math.min(...yRaw),
Math.max(...xRaw) - Math.min(...xRaw), Math.max(...xRaw) - Math.min(...xRaw),
@ -10159,7 +10157,7 @@ async function parseMultiPose(res, config3, image24, inputBox) {
const bodies = []; const bodies = [];
for (let id = 0; id < res[0].length; id++) { for (let id = 0; id < res[0].length; id++) {
const kpt3 = res[0][id]; const kpt3 = res[0][id];
score2 = Math.round(100 * kpt3[51 + 4]) / 100; const score2 = Math.round(100 * kpt3[51 + 4]) / 100;
if (score2 < config3.body.minConfidence) if (score2 < config3.body.minConfidence)
continue; continue;
keypoints2.length = 0; keypoints2.length = 0;
@ -10178,7 +10176,7 @@ async function parseMultiPose(res, config3, image24, inputBox) {
}); });
} }
} }
boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]]; const boxRaw2 = [kpt3[51 + 1], kpt3[51 + 0], kpt3[51 + 3] - kpt3[51 + 1], kpt3[51 + 2] - kpt3[51 + 0]];
bodies.push({ bodies.push({
id, id,
score: score2, score: score2,
@ -10357,8 +10355,8 @@ async function process3(res, inputSize4, outputShape, config3) {
const scores = await scoresT.array(); const scores = await scoresT.array();
for (let i = 0; i < scoresT.shape[0]; i++) { for (let i = 0; i < scoresT.shape[0]; i++) {
for (let j = 0; j < scoresT.shape[1]; j++) { for (let j = 0; j < scoresT.shape[1]; j++) {
const score3 = scores[i][j]; const score2 = scores[i][j];
if (score3 > config3.object.minConfidence && j !== 61) { if (score2 > config3.object.minConfidence && j !== 61) {
const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize; const cx = (0.5 + Math.trunc(i % baseSize)) / baseSize;
const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize; const cy = (0.5 + Math.trunc(i / baseSize)) / baseSize;
const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4)); const boxOffset = boxIdx[i].map((a) => a * (baseSize / strideSize / inputSize4));
@ -10370,21 +10368,21 @@ async function process3(res, inputSize4, outputShape, config3) {
cx + scaleBox2 / strideSize * boxOffset[2] - x, cx + scaleBox2 / strideSize * boxOffset[2] - x,
cy + scaleBox2 / strideSize * boxOffset[3] - y cy + scaleBox2 / strideSize * boxOffset[3] - y
]; ];
let boxRaw3 = [x, y, w, h]; let boxRaw2 = [x, y, w, h];
boxRaw3 = boxRaw3.map((a) => Math.max(0, Math.min(a, 1))); boxRaw2 = boxRaw2.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [ const box5 = [
boxRaw3[0] * outputShape[0], boxRaw2[0] * outputShape[0],
boxRaw3[1] * outputShape[1], boxRaw2[1] * outputShape[1],
boxRaw3[2] * outputShape[0], boxRaw2[2] * outputShape[0],
boxRaw3[3] * outputShape[1] boxRaw2[3] * outputShape[1]
]; ];
const result = { const result = {
id: id++, id: id++,
score: Math.round(100 * score3) / 100, score: Math.round(100 * score2) / 100,
class: j + 1, class: j + 1,
label: labels[j].label, label: labels[j].label,
box: box6.map((a) => Math.trunc(a)), box: box5.map((a) => Math.trunc(a)),
boxRaw: boxRaw3 boxRaw: boxRaw2
}; };
results.push(result); results.push(result);
} }
@ -10474,26 +10472,26 @@ async function process4(res, outputShape, config3) {
tf21.dispose(nmsT); tf21.dispose(nmsT);
let i = 0; let i = 0;
for (const id of nms) { for (const id of nms) {
const score3 = Math.trunc(100 * detections[0][id][4]) / 100; const score2 = Math.trunc(100 * detections[0][id][4]) / 100;
const classVal = detections[0][id][5]; const classVal = detections[0][id][5];
const label = labels[classVal].label; const label = labels[classVal].label;
const [x, y] = [ const [x, y] = [
detections[0][id][0] / inputSize3, detections[0][id][0] / inputSize3,
detections[0][id][1] / inputSize3 detections[0][id][1] / inputSize3
]; ];
const boxRaw3 = [ const boxRaw2 = [
x, x,
y, y,
detections[0][id][2] / inputSize3 - x, detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y detections[0][id][3] / inputSize3 - y
]; ];
const box6 = [ const box5 = [
Math.trunc(boxRaw3[0] * outputShape[0]), Math.trunc(boxRaw2[0] * outputShape[0]),
Math.trunc(boxRaw3[1] * outputShape[1]), Math.trunc(boxRaw2[1] * outputShape[1]),
Math.trunc(boxRaw3[2] * outputShape[0]), Math.trunc(boxRaw2[2] * outputShape[0]),
Math.trunc(boxRaw3[3] * outputShape[1]) Math.trunc(boxRaw2[3] * outputShape[1])
]; ];
results.push({ id: i++, score: score3, class: classVal, label, box: box6, boxRaw: boxRaw3 }); results.push({ id: i++, score: score2, class: classVal, label, box: box5, boxRaw: boxRaw2 });
} }
return results; return results;
} }
@ -11419,7 +11417,7 @@ async function hand2(inCanvas2, result, drawOptions) {
if (localOptions.drawPoints) { if (localOptions.drawPoints) {
if (h.keypoints && h.keypoints.length > 0) { if (h.keypoints && h.keypoints.length > 0) {
for (const pt of h.keypoints) { for (const pt of h.keypoints) {
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * pt[2]}, ${127.5 - 2 * pt[2]}, 255, 0.5)` : localOptions.color; ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * (pt[2] || 0)}, ${127.5 - 2 * (pt[2] || 0)}, 255, 0.5)` : localOptions.color;
point(ctx, pt[0], pt[1], 0, localOptions); point(ctx, pt[0], pt[1], 0, localOptions);
} }
} }
@ -11570,10 +11568,10 @@ function join2(faces, bodies, hands, gestures, shape) {
} }
const x = []; const x = [];
const y = []; const y = [];
const extractXY = (box6) => { const extractXY = (box5) => {
if (box6 && box6.length === 4) { if (box5 && box5.length === 4) {
x.push(box6[0], box6[0] + box6[2]); x.push(box5[0], box5[0] + box5[2]);
y.push(box6[1], box6[1] + box6[3]); y.push(box5[1], box5[1] + box5[3]);
} }
}; };
extractXY((_k = person2.face) == null ? void 0 : _k.box); extractXY((_k = person2.face) == null ? void 0 : _k.box);
@ -11603,8 +11601,8 @@ function calc(newResult) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body)); bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else { } else {
for (let i = 0; i < newResult.body.length; i++) { for (let i = 0; i < newResult.body.length; i++) {
const box6 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor); const box5 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({ const keypoints3 = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score, score: keypoint.score,
part: keypoint.part, part: keypoint.part,
@ -11617,18 +11615,18 @@ function calc(newResult) {
bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1] bufferedResult.body[i].keypoints[j] ? ((bufferedFactor - 1) * bufferedResult.body[i].keypoints[j].positionRaw[1] + keypoint.positionRaw[1]) / bufferedFactor : keypoint.position[1]
] ]
})); }));
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3 }; bufferedResult.body[i] = { ...newResult.body[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3 };
} }
} }
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) { if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand)); bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else { } else {
for (let i = 0; i < newResult.hand.length; i++) { for (let i = 0; i < newResult.hand.length; i++) {
const box6 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor); const box5 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.hand[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor);
if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length) if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints; bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].keypoints[j][k] + coord) / bufferedFactor)) : []; const keypoints3 = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints.map((landmark, j) => landmark.map((coord, k) => ((bufferedFactor - 1) * (bufferedResult.hand[i].keypoints[j][k] || 1) + (coord || 0)) / bufferedFactor)) : [];
const annotations3 = {}; const annotations3 = {};
if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length) if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length)
bufferedResult.hand[i].annotations = newResult.hand[i].annotations; bufferedResult.hand[i].annotations = newResult.hand[i].annotations;
@ -11637,15 +11635,15 @@ function calc(newResult) {
annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null; annotations3[key] = newResult.hand[i].annotations[key] && newResult.hand[i].annotations[key][0] ? newResult.hand[i].annotations[key].map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)) : null;
} }
} }
bufferedResult.hand[i] = { ...newResult.hand[i], box: box6, boxRaw: boxRaw3, keypoints: keypoints3, annotations: annotations3 }; bufferedResult.hand[i] = { ...newResult.hand[i], box: box5, boxRaw: boxRaw2, keypoints: keypoints3, annotations: annotations3 };
} }
} }
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) { if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face)); bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else { } else {
for (let i = 0; i < newResult.face.length; i++) { for (let i = 0; i < newResult.face.length; i++) {
const box6 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor); const box5 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.face[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor);
const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } }; const rotation = { matrix: [0, 0, 0, 0, 0, 0, 0, 0, 0], angle: { roll: 0, yaw: 0, pitch: 0 }, gaze: { bearing: 0, strength: 0 } };
rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix; rotation.matrix = (_a = newResult.face[i].rotation) == null ? void 0 : _a.matrix;
rotation.angle = { rotation.angle = {
@ -11657,16 +11655,16 @@ function calc(newResult) {
bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor, bearing: ((bufferedFactor - 1) * (((_o = (_n = bufferedResult.face[i].rotation) == null ? void 0 : _n.gaze) == null ? void 0 : _o.bearing) || 0) + (((_q = (_p = newResult.face[i].rotation) == null ? void 0 : _p.gaze) == null ? void 0 : _q.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor strength: ((bufferedFactor - 1) * (((_s = (_r = bufferedResult.face[i].rotation) == null ? void 0 : _r.gaze) == null ? void 0 : _s.strength) || 0) + (((_u = (_t = newResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.strength) || 0)) / bufferedFactor
}; };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw: boxRaw3 }; bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box5, boxRaw: boxRaw2 };
} }
} }
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) { if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object)); bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else { } else {
for (let i = 0; i < newResult.object.length; i++) { for (let i = 0; i < newResult.object.length; i++) {
const box6 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor); const box5 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw3 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor); const boxRaw2 = newResult.object[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor);
bufferedResult.object[i] = { ...newResult.object[i], box: box6, boxRaw: boxRaw3 }; bufferedResult.object[i] = { ...newResult.object[i], box: box5, boxRaw: boxRaw2 };
} }
} }
if (newResult.persons) { if (newResult.persons) {
@ -11675,7 +11673,7 @@ function calc(newResult) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons)); bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else { } else {
for (let i = 0; i < newPersons.length; i++) { for (let i = 0; i < newPersons.length; i++) {
bufferedResult.persons[i].box = newPersons[i].box.map((box6, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box6) / bufferedFactor); bufferedResult.persons[i].box = newPersons[i].box.map((box5, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box5) / bufferedFactor);
} }
} }
} }

View File

@ -13,7 +13,7 @@ import * as blazeface from './blazeface';
import * as facepipeline from './facepipeline'; import * as facepipeline from './facepipeline';
import * as coords from './coords'; import * as coords from './coords';
import type { GraphModel, Tensor } from '../tfjs/types'; import type { GraphModel, Tensor } from '../tfjs/types';
import type { FaceResult } from '../result'; import type { FaceResult, Box } from '../result';
import type { Config } from '../config'; import type { Config } from '../config';
import { env } from '../env'; import { env } from '../env';
@ -35,13 +35,13 @@ export async function predict(input: Tensor, config: Config): Promise<FaceResult
if (prediction.mesh && prediction.mesh.length > 0) { if (prediction.mesh && prediction.mesh.length > 0) {
for (const key of Object.keys(coords.MESH_ANNOTATIONS)) annotations[key] = coords.MESH_ANNOTATIONS[key].map((index) => prediction.mesh[index]); for (const key of Object.keys(coords.MESH_ANNOTATIONS)) annotations[key] = coords.MESH_ANNOTATIONS[key].map((index) => prediction.mesh[index]);
} }
const clampedBox: [number, number, number, number] = prediction.box ? [ const clampedBox: Box = prediction.box ? [
Math.trunc(Math.max(0, prediction.box.startPoint[0])), Math.trunc(Math.max(0, prediction.box.startPoint[0])),
Math.trunc(Math.max(0, prediction.box.startPoint[1])), Math.trunc(Math.max(0, prediction.box.startPoint[1])),
Math.trunc(Math.min((input.shape[2] || 0), prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])), Math.trunc(Math.min((input.shape[2] || 0), prediction.box.endPoint[0]) - Math.max(0, prediction.box.startPoint[0])),
Math.trunc(Math.min((input.shape[1] || 0), prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1])), Math.trunc(Math.min((input.shape[1] || 0), prediction.box.endPoint[1]) - Math.max(0, prediction.box.startPoint[1])),
] : [0, 0, 0, 0]; ] : [0, 0, 0, 0];
const boxRaw: [number, number, number, number] = prediction.box ? [ const boxRaw: Box = prediction.box ? [
prediction.box.startPoint[0] / (input.shape[2] || 0), prediction.box.startPoint[0] / (input.shape[2] || 0),
prediction.box.startPoint[1] / (input.shape[1] || 0), prediction.box.startPoint[1] / (input.shape[1] || 0),
(prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0), (prediction.box.endPoint[0] - prediction.box.startPoint[0]) / (input.shape[2] || 0),

View File

@ -11,6 +11,7 @@ import type { Tensor, GraphModel } from '../tfjs/types';
import type { BlazeFaceModel } from './blazeface'; import type { BlazeFaceModel } from './blazeface';
import { env } from '../env'; import { env } from '../env';
import { log } from '../util'; import { log } from '../util';
import type { Point } from '../result';
const leftOutline = coords.MESH_ANNOTATIONS['leftEyeLower0']; const leftOutline = coords.MESH_ANNOTATIONS['leftEyeLower0'];
const rightOutline = coords.MESH_ANNOTATIONS['rightEyeLower0']; const rightOutline = coords.MESH_ANNOTATIONS['rightEyeLower0'];
@ -131,7 +132,7 @@ export class Pipeline {
// Given a cropped image of an eye, returns the coordinates of the contours surrounding the eye and the iris. // Given a cropped image of an eye, returns the coordinates of the contours surrounding the eye and the iris.
getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) { getEyeCoords(eyeData, eyeBox, eyeBoxSize, flip = false) {
const eyeRawCoords: Array<[number, number, number]> = []; const eyeRawCoords: Array<Point> = [];
for (let i = 0; i < irisLandmarks.numCoordinates; i++) { for (let i = 0; i < irisLandmarks.numCoordinates; i++) {
const x = eyeData[i * 3]; const x = eyeData[i * 3];
const y = eyeData[i * 3 + 1]; const y = eyeData[i * 3 + 1];

View File

@ -8,7 +8,7 @@ import { log, join } from '../util';
import * as tf from '../../dist/tfjs.esm.js'; import * as tf from '../../dist/tfjs.esm.js';
import * as annotations from './annotations'; import * as annotations from './annotations';
import type { Tensor, GraphModel } from '../tfjs/types'; import type { Tensor, GraphModel } from '../tfjs/types';
import type { BodyResult } from '../result'; import type { BodyResult, Box, Point } from '../result';
import type { Config } from '../config'; import type { Config } from '../config';
import { env } from '../env'; import { env } from '../env';
@ -38,7 +38,7 @@ export async function predict(image: Tensor, config: Config): Promise<BodyResult
const points = await findT?.data() || []; // order of output tensors may change between models, full has 195 and upper has 155 items const points = await findT?.data() || []; // order of output tensors may change between models, full has 195 and upper has 155 items
resT.forEach((t) => tf.dispose(t)); resT.forEach((t) => tf.dispose(t));
tf.dispose(normalize); tf.dispose(normalize);
const keypoints: Array<{ id, part, position: [number, number, number], positionRaw: [number, number, number], score, presence }> = []; const keypoints: Array<{ id, part, position: Point, positionRaw: Point, score, presence }> = [];
const labels = points?.length === 195 ? annotations.full : annotations.upper; // full model has 39 keypoints, upper has 31 keypoints const labels = points?.length === 195 ? annotations.full : annotations.upper; // full model has 39 keypoints, upper has 31 keypoints
const depth = 5; // each points has x,y,z,visibility,presence const depth = 5; // each points has x,y,z,visibility,presence
for (let i = 0; i < points.length / depth; i++) { for (let i = 0; i < points.length / depth; i++) {
@ -61,13 +61,13 @@ export async function predict(image: Tensor, config: Config): Promise<BodyResult
} }
const x = keypoints.map((a) => a.position[0]); const x = keypoints.map((a) => a.position[0]);
const y = keypoints.map((a) => a.position[1]); const y = keypoints.map((a) => a.position[1]);
const box: [number, number, number, number] = [ const box: Box = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
Math.max(...y) - Math.min(...x), Math.max(...y) - Math.min(...x),
]; ];
const boxRaw: [number, number, number, number] = [0, 0, 0, 0]; // not yet implemented const boxRaw: Box = [0, 0, 0, 0]; // not yet implemented
const score = keypoints.reduce((prev, curr) => (curr.score > prev ? curr.score : prev), 0); const score = keypoints.reduce((prev, curr) => (curr.score > prev ? curr.score : prev), 0);
return [{ id: 0, score, box, boxRaw, keypoints }]; return [{ id: 0, score, box, boxRaw, keypoints }];
} }

View File

@ -400,7 +400,7 @@ export async function hand(inCanvas: HTMLCanvasElement | OffscreenCanvas, result
if (localOptions.drawPoints) { if (localOptions.drawPoints) {
if (h.keypoints && h.keypoints.length > 0) { if (h.keypoints && h.keypoints.length > 0) {
for (const pt of h.keypoints) { for (const pt of h.keypoints) {
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + (2 * pt[2])}, ${127.5 - (2 * pt[2])}, 255, 0.5)` : localOptions.color; ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + (2 * (pt[2] || 0))}, ${127.5 - (2 * (pt[2] || 0))}, 255, 0.5)` : localOptions.color;
point(ctx, pt[0], pt[1], 0, localOptions); point(ctx, pt[0], pt[1], 0, localOptions);
} }
} }

View File

@ -6,7 +6,7 @@
import { log, join } from '../util'; import { log, join } from '../util';
import * as tf from '../../dist/tfjs.esm.js'; import * as tf from '../../dist/tfjs.esm.js';
import type { BodyResult } from '../result'; import type { BodyResult, Box } from '../result';
import type { GraphModel, Tensor } from '../tfjs/types'; import type { GraphModel, Tensor } from '../tfjs/types';
import type { Config } from '../config'; import type { Config } from '../config';
import { env } from '../env'; import { env } from '../env';
@ -16,8 +16,8 @@ let model: GraphModel | null;
type Keypoints = { score: number, part: string, position: [number, number], positionRaw: [number, number] }; type Keypoints = { score: number, part: string, position: [number, number], positionRaw: [number, number] };
const keypoints: Array<Keypoints> = []; const keypoints: Array<Keypoints> = [];
let box: [number, number, number, number] = [0, 0, 0, 0]; let box: Box = [0, 0, 0, 0];
let boxRaw: [number, number, number, number] = [0, 0, 0, 0]; let boxRaw: Box = [0, 0, 0, 0];
let score = 0; let score = 0;
let skipped = Number.MAX_SAFE_INTEGER; let skipped = Number.MAX_SAFE_INTEGER;

View File

@ -9,7 +9,7 @@ import * as tf from '../../dist/tfjs.esm.js';
import * as handdetector from './handdetector'; import * as handdetector from './handdetector';
import * as handpipeline from './handpipeline'; import * as handpipeline from './handpipeline';
import * as fingerPose from '../fingerpose/fingerpose'; import * as fingerPose from '../fingerpose/fingerpose';
import type { HandResult } from '../result'; import type { HandResult, Box, Point } from '../result';
import type { Tensor, GraphModel } from '../tfjs/types'; import type { Tensor, GraphModel } from '../tfjs/types';
import type { Config } from '../config'; import type { Config } from '../config';
import { env } from '../env'; import { env } from '../env';
@ -39,10 +39,10 @@ export async function predict(input: Tensor, config: Config): Promise<HandResult
} }
} }
const keypoints = predictions[i].landmarks as unknown as Array<[number, number, number]>; const keypoints = predictions[i].landmarks as unknown as Array<Point>;
let box: [number, number, number, number] = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0]; // maximums so conditionals work let box: Box = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0]; // maximums so conditionals work
let boxRaw: [number, number, number, number] = [0, 0, 0, 0]; let boxRaw: Box = [0, 0, 0, 0];
if (keypoints && keypoints.length > 0) { // if we have landmarks, calculate box based on landmarks if (keypoints && keypoints.length > 0) { // if we have landmarks, calculate box based on landmarks
for (const pt of keypoints) { for (const pt of keypoints) {
if (pt[0] < box[0]) box[0] = pt[0]; if (pt[0] < box[0]) box[0] = pt[0];

View File

@ -8,7 +8,7 @@
import { log, join, scaleBox } from '../util'; import { log, join, scaleBox } from '../util';
import * as tf from '../../dist/tfjs.esm.js'; import * as tf from '../../dist/tfjs.esm.js';
import type { HandResult } from '../result'; import type { HandResult, Box } from '../result';
import type { GraphModel, Tensor } from '../tfjs/types'; import type { GraphModel, Tensor } from '../tfjs/types';
import type { Config } from '../config'; import type { Config } from '../config';
import { env } from '../env'; import { env } from '../env';
@ -29,10 +29,10 @@ let outputSize: [number, number] = [0, 0];
type HandDetectResult = { type HandDetectResult = {
id: number, id: number,
score: number, score: number,
box: [number, number, number, number], box: Box,
boxRaw: [number, number, number, number], boxRaw: Box,
label: string, label: string,
yxBox: [number, number, number, number], yxBox: Box,
} }
const cache: { const cache: {
@ -111,17 +111,17 @@ async function detectHands(input: Tensor, config: Config): Promise<HandDetectRes
tf.dispose(t.nms); tf.dispose(t.nms);
for (const res of Array.from(nms)) { // generates results for each class for (const res of Array.from(nms)) { // generates results for each class
const boxSlice = tf.slice(t.boxes, res, 1); const boxSlice = tf.slice(t.boxes, res, 1);
let yxBox: [number, number, number, number] = [0, 0, 0, 0]; let yxBox: Box = [0, 0, 0, 0];
if (config.hand.landmarks) { // scale box if (config.hand.landmarks) { // scale box
const detectedBox: [number, number, number, number] = await boxSlice.data(); const detectedBox: Box = await boxSlice.data();
const boxCenter: [number, number] = [(detectedBox[0] + detectedBox[2]) / 2, (detectedBox[1] + detectedBox[3]) / 2]; const boxCenter: [number, number] = [(detectedBox[0] + detectedBox[2]) / 2, (detectedBox[1] + detectedBox[3]) / 2];
const boxDiff: [number, number, number, number] = [+boxCenter[0] - detectedBox[0], +boxCenter[1] - detectedBox[1], -boxCenter[0] + detectedBox[2], -boxCenter[1] + detectedBox[3]]; const boxDiff: Box = [+boxCenter[0] - detectedBox[0], +boxCenter[1] - detectedBox[1], -boxCenter[0] + detectedBox[2], -boxCenter[1] + detectedBox[3]];
yxBox = [boxCenter[0] - boxScaleFact * boxDiff[0], boxCenter[1] - boxScaleFact * boxDiff[1], boxCenter[0] + boxScaleFact * boxDiff[2], boxCenter[1] + boxScaleFact * boxDiff[3]]; yxBox = [boxCenter[0] - boxScaleFact * boxDiff[0], boxCenter[1] - boxScaleFact * boxDiff[1], boxCenter[0] + boxScaleFact * boxDiff[2], boxCenter[1] + boxScaleFact * boxDiff[3]];
} else { // use box as-is } else { // use box as-is
yxBox = await boxSlice.data(); yxBox = await boxSlice.data();
} }
const boxRaw: [number, number, number, number] = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]]; const boxRaw: Box = [yxBox[1], yxBox[0], yxBox[3] - yxBox[1], yxBox[2] - yxBox[0]];
const box: [number, number, number, number] = [Math.trunc(boxRaw[0] * outputSize[0]), Math.trunc(boxRaw[1] * outputSize[1]), Math.trunc(boxRaw[2] * outputSize[0]), Math.trunc(boxRaw[3] * outputSize[1])]; const box: Box = [Math.trunc(boxRaw[0] * outputSize[0]), Math.trunc(boxRaw[1] * outputSize[1]), Math.trunc(boxRaw[2] * outputSize[0]), Math.trunc(boxRaw[3] * outputSize[1])];
tf.dispose(boxSlice); tf.dispose(boxSlice);
const scoreSlice = tf.slice(classScores[i], res, 1); const scoreSlice = tf.slice(classScores[i], res, 1);
const score = (await scoreSlice.data())[0]; const score = (await scoreSlice.data())[0];

View File

@ -37,6 +37,7 @@ export * from './config';
export * from './result'; export * from './result';
export type { DrawOptions } from './draw'; export type { DrawOptions } from './draw';
export { env, Env } from './env'; export { env, Env } from './env';
export { Box, Point } from './result';
export { Models } from './models'; export { Models } from './models';
/** Defines all possible input types for **Human** detection /** Defines all possible input types for **Human** detection

View File

@ -2,7 +2,7 @@
* Results interpolation for smoothening of video detection results inbetween detected frames * Results interpolation for smoothening of video detection results inbetween detected frames
*/ */
import type { Result, FaceResult, BodyResult, HandResult, ObjectResult, GestureResult, PersonResult } from './result'; import type { Result, FaceResult, BodyResult, HandResult, ObjectResult, GestureResult, PersonResult, Box, Point } from './result';
const bufferedResult: Result = { face: [], body: [], hand: [], gesture: [], object: [], persons: [], performance: {}, timestamp: 0 }; const bufferedResult: Result = { face: [], body: [], hand: [], gesture: [], object: [], persons: [], performance: {}, timestamp: 0 };
@ -30,9 +30,9 @@ export function calc(newResult: Result): Result {
} else { } else {
for (let i = 0; i < newResult.body.length; i++) { for (let i = 0; i < newResult.body.length; i++) {
const box = newResult.body[i].box // update box const box = newResult.body[i].box // update box
.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor) as [number, number, number, number]; .map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor) as Box;
const boxRaw = newResult.body[i].boxRaw // update boxRaw const boxRaw = newResult.body[i].boxRaw // update boxRaw
.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor) as [number, number, number, number]; .map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor) as Box;
const keypoints = (newResult.body[i].keypoints // update keypoints const keypoints = (newResult.body[i].keypoints // update keypoints
.map((keypoint, j) => ({ .map((keypoint, j) => ({
score: keypoint.score, score: keypoint.score,
@ -56,13 +56,13 @@ export function calc(newResult: Result): Result {
} else { } else {
for (let i = 0; i < newResult.hand.length; i++) { for (let i = 0; i < newResult.hand.length; i++) {
const box = (newResult.hand[i].box// update box const box = (newResult.hand[i].box// update box
.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor)) as [number, number, number, number]; .map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor)) as Box;
const boxRaw = (newResult.hand[i].boxRaw // update boxRaw const boxRaw = (newResult.hand[i].boxRaw // update boxRaw
.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor)) as [number, number, number, number]; .map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor)) as Box;
if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length) bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints; // reset keypoints as previous frame did not have them if (bufferedResult.hand[i].keypoints.length !== newResult.hand[i].keypoints.length) bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints; // reset keypoints as previous frame did not have them
const keypoints = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints // update landmarks const keypoints = newResult.hand[i].keypoints && newResult.hand[i].keypoints.length > 0 ? newResult.hand[i].keypoints // update landmarks
.map((landmark, j) => landmark .map((landmark, j) => landmark
.map((coord, k) => (((bufferedFactor - 1) * bufferedResult.hand[i].keypoints[j][k] + coord) / bufferedFactor)) as [number, number, number]) .map((coord, k) => (((bufferedFactor - 1) * (bufferedResult.hand[i].keypoints[j][k] || 1) + (coord || 0)) / bufferedFactor)) as Point)
: []; : [];
const annotations = {}; const annotations = {};
if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length) bufferedResult.hand[i].annotations = newResult.hand[i].annotations; // reset annotations as previous frame did not have them if (Object.keys(bufferedResult.hand[i].annotations).length !== Object.keys(newResult.hand[i].annotations).length) bufferedResult.hand[i].annotations = newResult.hand[i].annotations; // reset annotations as previous frame did not have them
@ -83,9 +83,9 @@ export function calc(newResult: Result): Result {
} else { } else {
for (let i = 0; i < newResult.face.length; i++) { for (let i = 0; i < newResult.face.length; i++) {
const box = (newResult.face[i].box // update box const box = (newResult.face[i].box // update box
.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor)) as [number, number, number, number]; .map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor)) as Box;
const boxRaw = (newResult.face[i].boxRaw // update boxRaw const boxRaw = (newResult.face[i].boxRaw // update boxRaw
.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor)) as [number, number, number, number]; .map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].boxRaw[j] + b) / bufferedFactor)) as Box;
const rotation: { const rotation: {
matrix: [number, number, number, number, number, number, number, number, number], matrix: [number, number, number, number, number, number, number, number, number],
angle: { roll: number, yaw: number, pitch: number }, angle: { roll: number, yaw: number, pitch: number },
@ -112,9 +112,9 @@ export function calc(newResult: Result): Result {
} else { } else {
for (let i = 0; i < newResult.object.length; i++) { for (let i = 0; i < newResult.object.length; i++) {
const box = (newResult.object[i].box // update box const box = (newResult.object[i].box // update box
.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor)) as [number, number, number, number]; .map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor)) as Box;
const boxRaw = (newResult.object[i].boxRaw // update boxRaw const boxRaw = (newResult.object[i].boxRaw // update boxRaw
.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor)) as [number, number, number, number]; .map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].boxRaw[j] + b) / bufferedFactor)) as Box;
bufferedResult.object[i] = { ...newResult.object[i], box, boxRaw }; // shallow clone plus updated values bufferedResult.object[i] = { ...newResult.object[i], box, boxRaw }; // shallow clone plus updated values
} }
} }
@ -127,7 +127,7 @@ export function calc(newResult: Result): Result {
} else { } else {
for (let i = 0; i < newPersons.length; i++) { // update person box, we don't update the rest as it's updated as reference anyhow for (let i = 0; i < newPersons.length; i++) { // update person box, we don't update the rest as it's updated as reference anyhow
bufferedResult.persons[i].box = (newPersons[i].box bufferedResult.persons[i].box = (newPersons[i].box
.map((box, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box) / bufferedFactor)) as [number, number, number, number]; .map((box, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box) / bufferedFactor)) as Box;
} }
} }
} }

View File

@ -6,7 +6,7 @@
import { log, join, scaleBox } from '../util'; import { log, join, scaleBox } from '../util';
import * as tf from '../../dist/tfjs.esm.js'; import * as tf from '../../dist/tfjs.esm.js';
import type { BodyResult } from '../result'; import type { BodyResult, Box } from '../result';
import type { GraphModel, Tensor } from '../tfjs/types'; import type { GraphModel, Tensor } from '../tfjs/types';
import type { Config } from '../config'; import type { Config } from '../config';
import { fakeOps } from '../tfjs/backend'; import { fakeOps } from '../tfjs/backend';
@ -14,14 +14,11 @@ import { env } from '../env';
let model: GraphModel | null; let model: GraphModel | null;
let inputSize = 0; let inputSize = 0;
const cachedBoxes: Array<[number, number, number, number]> = []; const cachedBoxes: Array<Box> = [];
type Keypoints = { score: number, part: string, position: [number, number], positionRaw: [number, number] }; type Keypoints = { score: number, part: string, position: [number, number], positionRaw: [number, number] };
type Body = { id: number, score: number, box: [number, number, number, number], boxRaw: [number, number, number, number], keypoints: Array<Keypoints> } type Body = { id: number, score: number, box: Box, boxRaw: Box, keypoints: Array<Keypoints> }
let box: [number, number, number, number] = [0, 0, 0, 0];
let boxRaw: [number, number, number, number] = [0, 0, 0, 0];
let score = 0;
let skipped = Number.MAX_SAFE_INTEGER; let skipped = Number.MAX_SAFE_INTEGER;
const keypoints: Array<Keypoints> = []; const keypoints: Array<Keypoints> = [];
@ -43,6 +40,7 @@ export async function load(config: Config): Promise<GraphModel> {
async function parseSinglePose(res, config, image, inputBox) { async function parseSinglePose(res, config, image, inputBox) {
const kpt = res[0][0]; const kpt = res[0][0];
keypoints.length = 0; keypoints.length = 0;
let score = 0;
for (let id = 0; id < kpt.length; id++) { for (let id = 0; id < kpt.length; id++) {
score = kpt[id][2]; score = kpt[id][2];
if (score > config.body.minConfidence) { if (score > config.body.minConfidence) {
@ -64,7 +62,7 @@ async function parseSinglePose(res, config, image, inputBox) {
score = keypoints.reduce((prev, curr) => (curr.score > prev ? curr.score : prev), 0); score = keypoints.reduce((prev, curr) => (curr.score > prev ? curr.score : prev), 0);
const x = keypoints.map((a) => a.position[0]); const x = keypoints.map((a) => a.position[0]);
const y = keypoints.map((a) => a.position[1]); const y = keypoints.map((a) => a.position[1]);
box = [ const box: Box = [
Math.min(...x), Math.min(...x),
Math.min(...y), Math.min(...y),
Math.max(...x) - Math.min(...x), Math.max(...x) - Math.min(...x),
@ -72,7 +70,7 @@ async function parseSinglePose(res, config, image, inputBox) {
]; ];
const xRaw = keypoints.map((a) => a.positionRaw[0]); const xRaw = keypoints.map((a) => a.positionRaw[0]);
const yRaw = keypoints.map((a) => a.positionRaw[1]); const yRaw = keypoints.map((a) => a.positionRaw[1]);
boxRaw = [ const boxRaw: Box = [
Math.min(...xRaw), Math.min(...xRaw),
Math.min(...yRaw), Math.min(...yRaw),
Math.max(...xRaw) - Math.min(...xRaw), Math.max(...xRaw) - Math.min(...xRaw),
@ -87,7 +85,7 @@ async function parseMultiPose(res, config, image, inputBox) {
const bodies: Array<Body> = []; const bodies: Array<Body> = [];
for (let id = 0; id < res[0].length; id++) { for (let id = 0; id < res[0].length; id++) {
const kpt = res[0][id]; const kpt = res[0][id];
score = Math.round(100 * kpt[51 + 4]) / 100; const score = Math.round(100 * kpt[51 + 4]) / 100;
// eslint-disable-next-line no-continue // eslint-disable-next-line no-continue
if (score < config.body.minConfidence) continue; if (score < config.body.minConfidence) continue;
keypoints.length = 0; keypoints.length = 0;
@ -106,7 +104,7 @@ async function parseMultiPose(res, config, image, inputBox) {
}); });
} }
} }
boxRaw = [kpt[51 + 1], kpt[51 + 0], kpt[51 + 3] - kpt[51 + 1], kpt[51 + 2] - kpt[51 + 0]]; const boxRaw: Box = [kpt[51 + 1], kpt[51 + 0], kpt[51 + 3] - kpt[51 + 1], kpt[51 + 2] - kpt[51 + 0]];
bodies.push({ bodies.push({
id, id,
score, score,

View File

@ -7,7 +7,7 @@
import { log, join } from '../util'; import { log, join } from '../util';
import * as tf from '../../dist/tfjs.esm.js'; import * as tf from '../../dist/tfjs.esm.js';
import { labels } from './labels'; import { labels } from './labels';
import type { ObjectResult } from '../result'; import type { ObjectResult, Box } from '../result';
import type { GraphModel, Tensor } from '../tfjs/types'; import type { GraphModel, Tensor } from '../tfjs/types';
import type { Config } from '../config'; import type { Config } from '../config';
import { env } from '../env'; import { env } from '../env';
@ -60,18 +60,18 @@ async function process(res: Tensor | null, outputShape, config: Config) {
detections[0][id][0] / inputSize, detections[0][id][0] / inputSize,
detections[0][id][1] / inputSize, detections[0][id][1] / inputSize,
]; ];
const boxRaw = [ const boxRaw: Box = [
x, x,
y, y,
detections[0][id][2] / inputSize - x, detections[0][id][2] / inputSize - x,
detections[0][id][3] / inputSize - y, detections[0][id][3] / inputSize - y,
] as [number, number, number, number]; ];
const box = [ const box: Box = [
Math.trunc(boxRaw[0] * outputShape[0]), Math.trunc(boxRaw[0] * outputShape[0]),
Math.trunc(boxRaw[1] * outputShape[1]), Math.trunc(boxRaw[1] * outputShape[1]),
Math.trunc(boxRaw[2] * outputShape[0]), Math.trunc(boxRaw[2] * outputShape[0]),
Math.trunc(boxRaw[3] * outputShape[1]), Math.trunc(boxRaw[3] * outputShape[1]),
] as [number, number, number, number]; ];
results.push({ id: i++, score, class: classVal, label, box, boxRaw }); results.push({ id: i++, score, class: classVal, label, box, boxRaw });
} }
return results; return results;

View File

@ -7,7 +7,7 @@
import { log, join } from '../util'; import { log, join } from '../util';
import * as tf from '../../dist/tfjs.esm.js'; import * as tf from '../../dist/tfjs.esm.js';
import { labels } from './labels'; import { labels } from './labels';
import type { ObjectResult } from '../result'; import type { ObjectResult, Box } from '../result';
import type { GraphModel, Tensor } from '../tfjs/types'; import type { GraphModel, Tensor } from '../tfjs/types';
import type { Config } from '../config'; import type { Config } from '../config';
import { env } from '../env'; import { env } from '../env';
@ -58,8 +58,8 @@ async function process(res, inputSize, outputShape, config) {
cx + (scaleBox / strideSize * boxOffset[2]) - x, cx + (scaleBox / strideSize * boxOffset[2]) - x,
cy + (scaleBox / strideSize * boxOffset[3]) - y, cy + (scaleBox / strideSize * boxOffset[3]) - y,
]; ];
let boxRaw = [x, y, w, h]; // results normalized to range 0..1 let boxRaw: Box = [x, y, w, h]; // results normalized to range 0..1
boxRaw = boxRaw.map((a) => Math.max(0, Math.min(a, 1))); // fix out-of-bounds coords boxRaw = boxRaw.map((a) => Math.max(0, Math.min(a, 1))) as Box; // fix out-of-bounds coords
const box = [ // results normalized to input image pixels const box = [ // results normalized to input image pixels
boxRaw[0] * outputShape[0], boxRaw[0] * outputShape[0],
boxRaw[1] * outputShape[1], boxRaw[1] * outputShape[1],
@ -74,8 +74,8 @@ async function process(res, inputSize, outputShape, config) {
label: labels[j].label, label: labels[j].label,
// center: [Math.trunc(outputShape[0] * cx), Math.trunc(outputShape[1] * cy)], // center: [Math.trunc(outputShape[0] * cx), Math.trunc(outputShape[1] * cy)],
// centerRaw: [cx, cy], // centerRaw: [cx, cy],
box: (box.map((a) => Math.trunc(a))) as [number, number, number, number], box: box.map((a) => Math.trunc(a)) as Box,
boxRaw: boxRaw as [number, number, number, number], boxRaw,
}; };
results.push(result); results.push(result);
} }

View File

@ -2,7 +2,7 @@
* Analyze detection Results and sort&combine them into per-person view * Analyze detection Results and sort&combine them into per-person view
*/ */
import type { FaceResult, BodyResult, HandResult, GestureResult, PersonResult } from './result'; import type { FaceResult, BodyResult, HandResult, GestureResult, PersonResult, Box } from './result';
export function join(faces: Array<FaceResult>, bodies: Array<BodyResult>, hands: Array<HandResult>, gestures: Array<GestureResult>, shape: Array<number> | undefined): Array<PersonResult> { export function join(faces: Array<FaceResult>, bodies: Array<BodyResult>, hands: Array<HandResult>, gestures: Array<GestureResult>, shape: Array<number> | undefined): Array<PersonResult> {
let id = 0; let id = 0;
@ -44,7 +44,7 @@ export function join(faces: Array<FaceResult>, bodies: Array<BodyResult>, hands:
// create new overarching box from all boxes beloning to person // create new overarching box from all boxes beloning to person
const x: number[] = []; const x: number[] = [];
const y: number[] = []; const y: number[] = [];
const extractXY = (box: [number, number, number, number] | undefined) => { // extract all [x, y] coordinates from boxes [x, y, width, height] const extractXY = (box: Box | undefined) => { // extract all [x, y] coordinates from boxes [x, y, width, height]
if (box && box.length === 4) { if (box && box.length === 4) {
x.push(box[0], box[0] + box[2]); x.push(box[0], box[0] + box[2]);
y.push(box[1], box[1] + box[3]); y.push(box[1], box[1] + box[3]);

View File

@ -5,6 +5,7 @@
import * as utils from './utils'; import * as utils from './utils';
import * as kpt from './keypoints'; import * as kpt from './keypoints';
import type { Box } from '../result';
const localMaximumRadius = 1; const localMaximumRadius = 1;
const outputStride = 16; const outputStride = 16;
@ -125,7 +126,7 @@ function getInstanceScore(existingPoses, keypoints) {
} }
export function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected, minConfidence) { export function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected, minConfidence) {
const poses: Array<{ keypoints, box: [number, number, number, number], score: number }> = []; const poses: Array<{ keypoints, box: Box, score: number }> = [];
const queue = buildPartWithScoreQueue(minConfidence, scores); const queue = buildPartWithScoreQueue(minConfidence, scores);
// Generate at most maxDetected object instances per image in decreasing root part score order. // Generate at most maxDetected object instances per image in decreasing root part score order.
while (poses.length < maxDetected && !queue.empty()) { while (poses.length < maxDetected && !queue.empty()) {

View File

@ -5,6 +5,9 @@
import type { Tensor } from './tfjs/types'; import type { Tensor } from './tfjs/types';
import type { FaceGesture, BodyGesture, HandGesture, IrisGesture } from './gesture/gesture'; import type { FaceGesture, BodyGesture, HandGesture, IrisGesture } from './gesture/gesture';
export type Box = [number, number, number, number];
export type Point = [number, number, number?];
/** Face results /** Face results
* Combined results of face detector, face mesh, age, gender, emotion, embedding, iris models * Combined results of face detector, face mesh, age, gender, emotion, embedding, iris models
* Some values may be null if specific model is not enabled * Some values may be null if specific model is not enabled
@ -37,11 +40,11 @@ export interface FaceResult {
score: number, score: number,
boxScore: number, boxScore: number,
faceScore: number, faceScore: number,
box: [number, number, number, number], box: Box,
boxRaw: [number, number, number, number], boxRaw: Box,
mesh: Array<[number, number, number]> mesh: Array<Point>
meshRaw: Array<[number, number, number]> meshRaw: Array<Point>
annotations: Record<string, Array<[number, number, number]>>, annotations: Record<string, Point[]>,
age?: number, age?: number,
gender?: string, gender?: string,
genderScore?: number, genderScore?: number,
@ -72,12 +75,12 @@ export interface FaceResult {
export interface BodyResult { export interface BodyResult {
id: number, id: number,
score: number, score: number,
box: [number, number, number, number], box: Box,
boxRaw: [number, number, number, number], boxRaw: Box,
keypoints: Array<{ keypoints: Array<{
part: string, part: string,
position: [number, number, number?], position: Point,
positionRaw: [number, number, number?], positionRaw: Point,
score: number, score: number,
presence?: number, presence?: number,
}> }>
@ -99,13 +102,13 @@ export interface HandResult {
score: number, score: number,
boxScore: number, boxScore: number,
fingerScore: number, fingerScore: number,
box: [number, number, number, number], box: Box,
boxRaw: [number, number, number, number], boxRaw: Box,
keypoints: Array<[number, number, number]>, keypoints: Array<Point>,
label: string, label: string,
annotations: Record< annotations: Record<
'index' | 'middle' | 'pinky' | 'ring' | 'thumb' | 'palm', 'index' | 'middle' | 'pinky' | 'ring' | 'thumb' | 'palm',
Array<[number, number, number]> Array<Point>
>, >,
landmarks: Record< landmarks: Record<
'index' | 'middle' | 'pinky' | 'ring' | 'thumb', 'index' | 'middle' | 'pinky' | 'ring' | 'thumb',
@ -130,8 +133,8 @@ export interface ObjectResult {
score: number, score: number,
class: number, class: number,
label: string, label: string,
box: [number, number, number, number], box: Box,
boxRaw: [number, number, number, number], boxRaw: Box,
} }
/** Gesture results /** Gesture results
@ -166,8 +169,8 @@ export interface PersonResult {
body: BodyResult | null, body: BodyResult | null,
hands: { left: HandResult | null, right: HandResult | null }, hands: { left: HandResult | null, right: HandResult | null },
gestures: Array<GestureResult>, gestures: Array<GestureResult>,
box: [number, number, number, number], box: Box,
boxRaw?: [number, number, number, number], boxRaw?: Box,
} }
/** /**

View File

@ -2,6 +2,8 @@
* Simple helper functions used accross codebase * Simple helper functions used accross codebase
*/ */
import type { Box } from './result';
// helper function: join two paths // helper function: join two paths
export function join(folder: string, file: string): string { export function join(folder: string, file: string): string {
const separator = folder.endsWith('/') ? '' : '/'; const separator = folder.endsWith('/') ? '' : '/';
@ -81,18 +83,18 @@ export function scaleBox(keypoints, boxScaleFact, outputSize) {
Math.trunc(center[1] - diff), Math.trunc(center[1] - diff),
Math.trunc(2 * diff), Math.trunc(2 * diff),
Math.trunc(2 * diff), Math.trunc(2 * diff),
] as [number, number, number, number]; ] as Box;
const boxRaw = [ // work backwards const boxRaw = [ // work backwards
box[0] / outputSize[0], box[0] / outputSize[0],
box[1] / outputSize[1], box[1] / outputSize[1],
box[2] / outputSize[0], box[2] / outputSize[0],
box[3] / outputSize[1], box[3] / outputSize[1],
] as [number, number, number, number]; ] as Box;
const yxBox = [ // work backwards const yxBox = [ // work backwards
boxRaw[1], boxRaw[1],
boxRaw[0], boxRaw[0],
boxRaw[3] + boxRaw[1], boxRaw[3] + boxRaw[1],
boxRaw[2] + boxRaw[0], boxRaw[2] + boxRaw[0],
] as [number, number, number, number]; ] as Box;
return { box, boxRaw, yxBox }; return { box, boxRaw, yxBox };
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -8,16 +8,16 @@
</ul> </ul>
</div><dl class="tsd-comment-tags"><dt>param userConfig:</dt><dd><p><a href="../interfaces/Config.html">Config</a></p> </div><dl class="tsd-comment-tags"><dt>param userConfig:</dt><dd><p><a href="../interfaces/Config.html">Config</a></p>
</dd><dt>returns</dt><dd><p>instance</p> </dd><dt>returns</dt><dd><p>instance</p>
</dd></dl></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">Human</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="Human.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#config" class="tsd-kind-icon">config</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#draw" class="tsd-kind-icon">draw</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#env" class="tsd-kind-icon">env</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#events" class="tsd-kind-icon">events</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#faceTriangulation" class="tsd-kind-icon">face<wbr/>Triangulation</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#faceUVMap" class="tsd-kind-icon">faceUVMap</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#gl" class="tsd-kind-icon">gl</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#performance" class="tsd-kind-icon">performance</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#process" class="tsd-kind-icon">process</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#result" class="tsd-kind-icon">result</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#state" class="tsd-kind-icon">state</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#version" class="tsd-kind-icon">version</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#detect" class="tsd-kind-icon">detect</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#enhance" class="tsd-kind-icon">enhance</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#image" class="tsd-kind-icon">image</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#init" class="tsd-kind-icon">init</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#load" class="tsd-kind-icon">load</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#match" class="tsd-kind-icon">match</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#next" class="tsd-kind-icon">next</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#reset" class="tsd-kind-icon">reset</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#segmentation" class="tsd-kind-icon">segmentation</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#similarity" class="tsd-kind-icon">similarity</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#validate" class="tsd-kind-icon">validate</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#warmup" class="tsd-kind-icon">warmup</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</h2><section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class"><a name="constructor" class="tsd-anchor"></a><h3>constructor</h3><ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">new <wbr/>Human<span class="tsd-signature-symbol">(</span>userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Human.html" class="tsd-signature-type" data-tsd-kind="Class">Human</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L160">human.ts:160</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </dd></dl></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">Human</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="Human.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#config" class="tsd-kind-icon">config</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#draw" class="tsd-kind-icon">draw</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#env" class="tsd-kind-icon">env</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#events" class="tsd-kind-icon">events</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#faceTriangulation" class="tsd-kind-icon">face<wbr/>Triangulation</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#faceUVMap" class="tsd-kind-icon">faceUVMap</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#gl" class="tsd-kind-icon">gl</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#performance" class="tsd-kind-icon">performance</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#process" class="tsd-kind-icon">process</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#result" class="tsd-kind-icon">result</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#state" class="tsd-kind-icon">state</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Human.html#version" class="tsd-kind-icon">version</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#detect" class="tsd-kind-icon">detect</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#enhance" class="tsd-kind-icon">enhance</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#image" class="tsd-kind-icon">image</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#init" class="tsd-kind-icon">init</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#load" class="tsd-kind-icon">load</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#match" class="tsd-kind-icon">match</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#next" class="tsd-kind-icon">next</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#reset" class="tsd-kind-icon">reset</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#segmentation" class="tsd-kind-icon">segmentation</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#similarity" class="tsd-kind-icon">similarity</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#validate" class="tsd-kind-icon">validate</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#warmup" class="tsd-kind-icon">warmup</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</h2><section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class"><a name="constructor" class="tsd-anchor"></a><h3>constructor</h3><ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">new <wbr/>Human<span class="tsd-signature-symbol">(</span>userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Human.html" class="tsd-signature-type" data-tsd-kind="Class">Human</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L161">human.ts:161</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Constructor for <strong>Human</strong> library that is futher used for all operations</p> <p>Constructor for <strong>Human</strong> library that is futher used for all operations</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> userConfig: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="Human.html" class="tsd-signature-type" data-tsd-kind="Class">Human</a></h4><div><p>instance: <a href="Human.html">Human</a></p> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> userConfig: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="Human.html" class="tsd-signature-type" data-tsd-kind="Class">Human</a></h4><div><p>instance: <a href="Human.html">Human</a></p>
</div></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="config" class="tsd-anchor"></a><h3>config</h3><div class="tsd-signature tsd-kind-icon">config<span class="tsd-signature-symbol">:</span> <a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L86">human.ts:86</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="config" class="tsd-anchor"></a><h3>config</h3><div class="tsd-signature tsd-kind-icon">config<span class="tsd-signature-symbol">:</span> <a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L87">human.ts:87</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Current configuration</p> <p>Current configuration</p>
<ul> <ul>
<li>Definition: <a href="../interfaces/Config.html">Config</a></li> <li>Definition: <a href="../interfaces/Config.html">Config</a></li>
<li>Defaults: <a href="https://github.com/vladmandic/human/blob/main/src/config.ts#L292">config</a></li> <li>Defaults: <a href="https://github.com/vladmandic/human/blob/main/src/config.ts#L292">config</a></li>
</ul> </ul>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="draw" class="tsd-anchor"></a><h3>draw</h3><div class="tsd-signature tsd-kind-icon">draw<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>all<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>body<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>face<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>gesture<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>hand<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>object<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>options<span class="tsd-signature-symbol">: </span><a href="../interfaces/DrawOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">DrawOptions</a><span class="tsd-signature-symbol">; </span>person<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> }</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L122">human.ts:122</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="draw" class="tsd-anchor"></a><h3>draw</h3><div class="tsd-signature tsd-kind-icon">draw<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>all<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>body<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>face<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>gesture<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>hand<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>object<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span>options<span class="tsd-signature-symbol">: </span><a href="../interfaces/DrawOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">DrawOptions</a><span class="tsd-signature-symbol">; </span>person<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> }</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L123">human.ts:123</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Draw helper classes that can draw detected objects on canvas using specified draw</p> <p>Draw helper classes that can draw detected objects on canvas using specified draw</p>
<ul> <ul>
<li>options: <a href="../interfaces/DrawOptions.html">DrawOptions</a> global settings for all draw operations, can be overriden for each draw method</li> <li>options: <a href="../interfaces/DrawOptions.html">DrawOptions</a> global settings for all draw operations, can be overriden for each draw method</li>
@ -27,9 +27,9 @@
<li>canvas: draw processed canvas which is a processed copy of the input</li> <li>canvas: draw processed canvas which is a processed copy of the input</li>
<li>all: meta-function that performs: canvas, face, body, hand</li> <li>all: meta-function that performs: canvas, face, body, hand</li>
</ul> </ul>
</div></div><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter"><h5>all<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>body<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>face<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>gesture<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>hand<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>object<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>options<span class="tsd-signature-symbol">: </span><a href="../interfaces/DrawOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">DrawOptions</a></h5></li><li class="tsd-parameter"><h5>person<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li></ul></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="env" class="tsd-anchor"></a><h3>env</h3><div class="tsd-signature tsd-kind-icon">env<span class="tsd-signature-symbol">:</span> <a href="../index.html#Env" class="tsd-signature-type" data-tsd-kind="Type alias">Env</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L112">human.ts:112</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter"><h5>all<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>body<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>face<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>gesture<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>hand<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>object<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li><li class="tsd-parameter"><h5>options<span class="tsd-signature-symbol">: </span><a href="../interfaces/DrawOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">DrawOptions</a></h5></li><li class="tsd-parameter"><h5>person<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></h5></li></ul></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="env" class="tsd-anchor"></a><h3>env</h3><div class="tsd-signature tsd-kind-icon">env<span class="tsd-signature-symbol">:</span> <a href="../index.html#Env" class="tsd-signature-type" data-tsd-kind="Type alias">Env</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L113">human.ts:113</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Object containing environment information used for diagnostics</p> <p>Object containing environment information used for diagnostics</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="events" class="tsd-anchor"></a><h3>events</h3><div class="tsd-signature tsd-kind-icon">events<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">EventTarget</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L140">human.ts:140</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="events" class="tsd-anchor"></a><h3>events</h3><div class="tsd-signature tsd-kind-icon">events<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">EventTarget</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L141">human.ts:141</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Container for events dispatched by Human</p> <p>Container for events dispatched by Human</p>
</div><div><p>Possible events:</p> </div><div><p>Possible events:</p>
<ul> <ul>
@ -40,31 +40,31 @@
<li><code>warmup</code>: triggered when warmup is complete</li> <li><code>warmup</code>: triggered when warmup is complete</li>
<li><code>error</code>: triggered on some errors</li> <li><code>error</code>: triggered on some errors</li>
</ul> </ul>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="faceTriangulation" class="tsd-anchor"></a><h3>face<wbr/>Triangulation</h3><div class="tsd-signature tsd-kind-icon">face<wbr/>Triangulation<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L142">human.ts:142</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="faceTriangulation" class="tsd-anchor"></a><h3>face<wbr/>Triangulation</h3><div class="tsd-signature tsd-kind-icon">face<wbr/>Triangulation<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L143">human.ts:143</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Reference face triangualtion array of 468 points, used for triangle references between points</p> <p>Reference face triangualtion array of 468 points, used for triangle references between points</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="faceUVMap" class="tsd-anchor"></a><h3>faceUVMap</h3><div class="tsd-signature tsd-kind-icon">faceUVMap<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L144">human.ts:144</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="faceUVMap" class="tsd-anchor"></a><h3>faceUVMap</h3><div class="tsd-signature tsd-kind-icon">faceUVMap<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L145">human.ts:145</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Refernce UV map of 468 values, used for 3D mapping of the face mesh</p> <p>Refernce UV map of 468 values, used for 3D mapping of the face mesh</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="gl" class="tsd-anchor"></a><h3>gl</h3><div class="tsd-signature tsd-kind-icon">gl<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L151">human.ts:151</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="gl" class="tsd-anchor"></a><h3>gl</h3><div class="tsd-signature tsd-kind-icon">gl<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L152">human.ts:152</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>WebGL debug info</p> <p>WebGL debug info</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="performance" class="tsd-anchor"></a><h3>performance</h3><div class="tsd-signature tsd-kind-icon">performance<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L146">human.ts:146</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="performance" class="tsd-anchor"></a><h3>performance</h3><div class="tsd-signature tsd-kind-icon">performance<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L147">human.ts:147</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Performance object that contains values for all recently performed operations</p> <p>Performance object that contains values for all recently performed operations</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="process" class="tsd-anchor"></a><h3>process</h3><div class="tsd-signature tsd-kind-icon">process<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> }</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L101">human.ts:101</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="process" class="tsd-anchor"></a><h3>process</h3><div class="tsd-signature tsd-kind-icon">process<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> }</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L102">human.ts:102</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>currenty processed image tensor and canvas</p> <p>currenty processed image tensor and canvas</p>
</div></div><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter"><h5>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span></h5></li><li class="tsd-parameter"><h5>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="result" class="tsd-anchor"></a><h3>result</h3><div class="tsd-signature tsd-kind-icon">result<span class="tsd-signature-symbol">:</span> <a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L92">human.ts:92</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter"><h5>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span></h5></li><li class="tsd-parameter"><h5>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="result" class="tsd-anchor"></a><h3>result</h3><div class="tsd-signature tsd-kind-icon">result<span class="tsd-signature-symbol">:</span> <a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L93">human.ts:93</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Last known result of detect run</p> <p>Last known result of detect run</p>
<ul> <ul>
<li>Can be accessed anytime after initial detection</li> <li>Can be accessed anytime after initial detection</li>
<li>Definition: <a href="../interfaces/Result.html">Result</a></li> <li>Definition: <a href="../interfaces/Result.html">Result</a></li>
</ul> </ul>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="state" class="tsd-anchor"></a><h3>state</h3><div class="tsd-signature tsd-kind-icon">state<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L98">human.ts:98</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="state" class="tsd-anchor"></a><h3>state</h3><div class="tsd-signature tsd-kind-icon">state<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L99">human.ts:99</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Current state of Human library</p> <p>Current state of Human library</p>
<ul> <ul>
<li>Can be polled to determine operations that are currently executed</li> <li>Can be polled to determine operations that are currently executed</li>
<li>Progresses through: &#39;config&#39;, &#39;check&#39;, &#39;backend&#39;, &#39;load&#39;, &#39;run:<model>&#39;, &#39;idle&#39;</li> <li>Progresses through: &#39;config&#39;, &#39;check&#39;, &#39;backend&#39;, &#39;load&#39;, &#39;run:<model>&#39;, &#39;idle&#39;</li>
</ul> </ul>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="version" class="tsd-anchor"></a><h3>version</h3><div class="tsd-signature tsd-kind-icon">version<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L80">human.ts:80</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a name="version" class="tsd-anchor"></a><h3>version</h3><div class="tsd-signature tsd-kind-icon">version<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L81">human.ts:81</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Current version of Human library in <em>semver</em> format</p> <p>Current version of Human library in <em>semver</em> format</p>
</div></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="detect" class="tsd-anchor"></a><h3>detect</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">detect<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a>, userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../index.html#Error" class="tsd-signature-type" data-tsd-kind="Type alias">Error</a><span class="tsd-signature-symbol"> | </span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L387">human.ts:387</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="detect" class="tsd-anchor"></a><h3>detect</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">detect<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a>, userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../index.html#Error" class="tsd-signature-type" data-tsd-kind="Type alias">Error</a><span class="tsd-signature-symbol"> | </span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L388">human.ts:388</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Main detection method</p> <p>Main detection method</p>
<ul> <ul>
<li>Analyze configuration: <a href="../interfaces/Config.html">Config</a></li> <li>Analyze configuration: <a href="../interfaces/Config.html">Config</a></li>
@ -73,12 +73,12 @@
<li>Process and return result: <a href="../interfaces/Result.html">Result</a></li> <li>Process and return result: <a href="../interfaces/Result.html">Result</a></li>
</ul> </ul>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> userConfig: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../index.html#Error" class="tsd-signature-type" data-tsd-kind="Type alias">Error</a><span class="tsd-signature-symbol"> | </span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>result: <a href="../interfaces/Result.html">Result</a></p> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> userConfig: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../index.html#Error" class="tsd-signature-type" data-tsd-kind="Type alias">Error</a><span class="tsd-signature-symbol"> | </span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>result: <a href="../interfaces/Result.html">Result</a></p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="enhance" class="tsd-anchor"></a><h3>enhance</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">enhance<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L287">human.ts:287</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="enhance" class="tsd-anchor"></a><h3>enhance</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">enhance<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L288">human.ts:288</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Enhance method performs additional enhacements to face image previously detected for futher processing</p> <p>Enhance method performs additional enhacements to face image previously detected for futher processing</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>Tensor</p> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>Tensor</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="image" class="tsd-anchor"></a><h3>image</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">image<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">{ </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> }</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L247">human.ts:247</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="image" class="tsd-anchor"></a><h3>image</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">image<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">{ </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> }</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L248">human.ts:248</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Process input as return canvas and tensor</p> <p>Process input as return canvas and tensor</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">{ </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> }</span></h4><div></div><ul class="tsd-parameters"><li class="tsd-parameter"><h5>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span></h5></li><li class="tsd-parameter"><h5>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="init" class="tsd-anchor"></a><h3>init</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">init<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L310">human.ts:310</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">{ </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> }</span></h4><div></div><ul class="tsd-parameters"><li class="tsd-parameter"><h5>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span></h5></li><li class="tsd-parameter"><h5>tensor<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Rank</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="init" class="tsd-anchor"></a><h3>init</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">init<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L311">human.ts:311</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Explicit backend initialization</p> <p>Explicit backend initialization</p>
<ul> <ul>
<li>Normally done implicitly during initial load phase</li> <li>Normally done implicitly during initial load phase</li>
@ -86,22 +86,22 @@
<li>Use when changing backend during runtime</li> <li>Use when changing backend during runtime</li>
</ul> </ul>
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>Promise<void></p> </div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>Promise<void></p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="load" class="tsd-anchor"></a><h3>load</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">load<span class="tsd-signature-symbol">(</span>userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L322">human.ts:322</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="load" class="tsd-anchor"></a><h3>load</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">load<span class="tsd-signature-symbol">(</span>userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L323">human.ts:323</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Load method preloads all configured models on-demand</p> <p>Load method preloads all configured models on-demand</p>
<ul> <ul>
<li>Not explicitly required as any required model is load implicitly on it&#39;s first run</li> <li>Not explicitly required as any required model is load implicitly on it&#39;s first run</li>
</ul> </ul>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> userConfig: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>Promise<void></p> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> userConfig: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>Promise<void></p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="match" class="tsd-anchor"></a><h3>match</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">match<span class="tsd-signature-symbol">(</span>faceEmbedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span>, db<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">{ </span>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">[]</span>, threshold<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">{ </span>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>similarity<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L299">human.ts:299</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="match" class="tsd-anchor"></a><h3>match</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">match<span class="tsd-signature-symbol">(</span>faceEmbedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span>, db<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">{ </span>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">[]</span>, threshold<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">{ </span>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>similarity<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L300">human.ts:300</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Math method find best match between provided face descriptor and predefined database of known descriptors</p> <p>Math method find best match between provided face descriptor and predefined database of known descriptors</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>faceEmbedding: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li><li><h5>db: <span class="tsd-signature-symbol">{ </span>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">[]</span></h5></li><li><h5>threshold: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> = 0</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">{ </span>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>similarity<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></h4><div><p>best match</p> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>faceEmbedding: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li><li><h5>db: <span class="tsd-signature-symbol">{ </span>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">[]</span></h5></li><li><h5>threshold: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> = 0</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">{ </span>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>similarity<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></h4><div><p>best match</p>
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li><li class="tsd-parameter"><h5>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5></li><li class="tsd-parameter"><h5>similarity<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></h5></li><li class="tsd-parameter"><h5>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5></li></ul></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="next" class="tsd-anchor"></a><h3>next</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">next<span class="tsd-signature-symbol">(</span>result<span class="tsd-signature-symbol">?: </span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L363">human.ts:363</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div><ul class="tsd-parameters"><li class="tsd-parameter"><h5>embedding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li><li class="tsd-parameter"><h5>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5></li><li class="tsd-parameter"><h5>similarity<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></h5></li><li class="tsd-parameter"><h5>source<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5></li></ul></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="next" class="tsd-anchor"></a><h3>next</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">next<span class="tsd-signature-symbol">(</span>result<span class="tsd-signature-symbol">?: </span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L364">human.ts:364</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Runs interpolation using last known result and returns smoothened result <p>Runs interpolation using last known result and returns smoothened result
Interpolation is based on time since last known result so can be called independently</p> Interpolation is based on time since last known result so can be called independently</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>result: <a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol"> = ...</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a></h4><div><p>result: <a href="../interfaces/Result.html">Result</a></p> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>result: <a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol"> = ...</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a></h4><div><p>result: <a href="../interfaces/Result.html">Result</a></p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="reset" class="tsd-anchor"></a><h3>reset</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">reset<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L231">human.ts:231</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="reset" class="tsd-anchor"></a><h3>reset</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">reset<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L232">human.ts:232</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Reset configuration to default values</p> <p>Reset configuration to default values</p>
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="segmentation" class="tsd-anchor"></a><h3>segmentation</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">segmentation<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a>, background<span class="tsd-signature-symbol">?: </span><a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-symbol">{ </span>alpha<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L277">human.ts:277</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="segmentation" class="tsd-anchor"></a><h3>segmentation</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">segmentation<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a>, background<span class="tsd-signature-symbol">?: </span><a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-symbol">{ </span>alpha<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L278">human.ts:278</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Segmentation method takes any input and returns processed canvas with body segmentation</p> <p>Segmentation method takes any input and returns processed canvas with body segmentation</p>
<ul> <ul>
<li>Optional parameter background is used to fill the background with specific input</li> <li>Optional parameter background is used to fill the background with specific input</li>
@ -113,16 +113,16 @@ Interpolation is based on time since last known result so can be called independ
<li><code>canvas</code> as canvas which is input image filtered with segementation data and optionally merged with background image. canvas alpha values are set to segmentation values for easy merging</li> <li><code>canvas</code> as canvas which is input image filtered with segementation data and optionally merged with background image. canvas alpha values are set to segmentation values for easy merging</li>
<li><code>alpha</code> as grayscale canvas that represents segmentation alpha values</li> <li><code>alpha</code> as grayscale canvas that represents segmentation alpha values</li>
</ul> </ul>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> background: <a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-symbol">{ </span>alpha<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></h4><div></div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="similarity" class="tsd-anchor"></a><h3>similarity</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">similarity<span class="tsd-signature-symbol">(</span>embedding1<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span>, embedding2<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L260">human.ts:260</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> background: <a href="../index.html#Input" class="tsd-signature-type" data-tsd-kind="Type alias">Input</a></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-symbol">{ </span>alpha<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span><span class="tsd-signature-symbol">; </span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></h4><div></div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="similarity" class="tsd-anchor"></a><h3>similarity</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">similarity<span class="tsd-signature-symbol">(</span>embedding1<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span>, embedding2<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L261">human.ts:261</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Simmilarity method calculates simmilarity between two provided face descriptors (face embeddings)</p> <p>Simmilarity method calculates simmilarity between two provided face descriptors (face embeddings)</p>
<ul> <ul>
<li>Calculation is based on normalized Minkowski distance between two descriptors</li> <li>Calculation is based on normalized Minkowski distance between two descriptors</li>
<li>Default is Euclidean distance which is Minkowski distance of 2nd order</li> <li>Default is Euclidean distance which is Minkowski distance of 2nd order</li>
</ul> </ul>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>embedding1: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li><li><h5>embedding2: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><div><p>similarity: number</p> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>embedding1: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li><li><h5>embedding2: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><div><p>similarity: number</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="validate" class="tsd-anchor"></a><h3>validate</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">validate<span class="tsd-signature-symbol">(</span>userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">{ </span>expected<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>reason<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>where<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">[]</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L238">human.ts:238</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="validate" class="tsd-anchor"></a><h3>validate</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">validate<span class="tsd-signature-symbol">(</span>userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">{ </span>expected<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>reason<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>where<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">[]</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L239">human.ts:239</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Validate current configuration schema</p> <p>Validate current configuration schema</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> userConfig: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">{ </span>expected<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>reason<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>where<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">[]</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="warmup" class="tsd-anchor"></a><h3>warmup</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">warmup<span class="tsd-signature-symbol">(</span>userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">{ </span>error<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L373">human.ts:373</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> userConfig: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">{ </span>expected<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>reason<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>where<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">[]</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="warmup" class="tsd-anchor"></a><h3>warmup</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">warmup<span class="tsd-signature-symbol">(</span>userConfig<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Config.html" class="tsd-signature-type" data-tsd-kind="Interface">Config</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/Result.html" class="tsd-signature-type" data-tsd-kind="Interface">Result</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">{ </span>error<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L374">human.ts:374</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Warmup method pre-initializes all configured models for faster inference</p> <p>Warmup method pre-initializes all configured models for faster inference</p>
<ul> <ul>
<li>can take significant time on startup</li> <li>can take significant time on startup</li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,22 +1,22 @@
<!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Result | @vladmandic/human - v2.2.3</title><meta name="description" content="Documentation for @vladmandic/human - v2.2.3"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@vladmandic/human - v2.2.3</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../index.html">@vladmandic/human - v2.2.3</a></li><li><a href="Result.html">Result</a></li></ul><h1>Interface Result</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead"> <!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Result | @vladmandic/human - v2.2.3</title><meta name="description" content="Documentation for @vladmandic/human - v2.2.3"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@vladmandic/human - v2.2.3</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../index.html">@vladmandic/human - v2.2.3</a></li><li><a href="Result.html">Result</a></li></ul><h1>Interface Result</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>Result interface definition for <strong>Human</strong> library</p> <p>Result interface definition for <strong>Human</strong> library</p>
</div><div><p>Contains all possible detection results</p> </div><div><p>Contains all possible detection results</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">Result</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#body" class="tsd-kind-icon">body</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#canvas" class="tsd-kind-icon">canvas</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#face" class="tsd-kind-icon">face</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#gesture" class="tsd-kind-icon">gesture</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#hand" class="tsd-kind-icon">hand</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#object" class="tsd-kind-icon">object</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#performance" class="tsd-kind-icon">performance</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#persons" class="tsd-kind-icon">persons</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#timestamp" class="tsd-kind-icon">timestamp</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="body" class="tsd-anchor"></a><h3>body</h3><div class="tsd-signature tsd-kind-icon">body<span class="tsd-signature-symbol">:</span> <a href="BodyResult.html" class="tsd-signature-type" data-tsd-kind="Interface">BodyResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L182">result.ts:182</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">Result</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#body" class="tsd-kind-icon">body</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#canvas" class="tsd-kind-icon">canvas</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#face" class="tsd-kind-icon">face</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#gesture" class="tsd-kind-icon">gesture</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#hand" class="tsd-kind-icon">hand</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#object" class="tsd-kind-icon">object</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#performance" class="tsd-kind-icon">performance</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#persons" class="tsd-kind-icon">persons</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#timestamp" class="tsd-kind-icon">timestamp</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="body" class="tsd-anchor"></a><h3>body</h3><div class="tsd-signature tsd-kind-icon">body<span class="tsd-signature-symbol">:</span> <a href="BodyResult.html" class="tsd-signature-type" data-tsd-kind="Interface">BodyResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L185">result.ts:185</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="BodyResult.html">BodyResult</a>: detection &amp; analysis results</p> <p><a href="BodyResult.html">BodyResult</a>: detection &amp; analysis results</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="canvas" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> canvas</h3><div class="tsd-signature tsd-kind-icon">canvas<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L192">result.ts:192</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="canvas" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> canvas</h3><div class="tsd-signature tsd-kind-icon">canvas<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L195">result.ts:195</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>optional processed canvas that can be used to draw input on screen</p> <p>optional processed canvas that can be used to draw input on screen</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="face" class="tsd-anchor"></a><h3>face</h3><div class="tsd-signature tsd-kind-icon">face<span class="tsd-signature-symbol">:</span> <a href="FaceResult.html" class="tsd-signature-type" data-tsd-kind="Interface">FaceResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L180">result.ts:180</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="face" class="tsd-anchor"></a><h3>face</h3><div class="tsd-signature tsd-kind-icon">face<span class="tsd-signature-symbol">:</span> <a href="FaceResult.html" class="tsd-signature-type" data-tsd-kind="Interface">FaceResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L183">result.ts:183</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="FaceResult.html">FaceResult</a>: detection &amp; analysis results</p> <p><a href="FaceResult.html">FaceResult</a>: detection &amp; analysis results</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="gesture" class="tsd-anchor"></a><h3>gesture</h3><div class="tsd-signature tsd-kind-icon">gesture<span class="tsd-signature-symbol">:</span> <a href="../index.html#GestureResult" class="tsd-signature-type" data-tsd-kind="Type alias">GestureResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L186">result.ts:186</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="gesture" class="tsd-anchor"></a><h3>gesture</h3><div class="tsd-signature tsd-kind-icon">gesture<span class="tsd-signature-symbol">:</span> <a href="../index.html#GestureResult" class="tsd-signature-type" data-tsd-kind="Type alias">GestureResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L189">result.ts:189</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="../index.html#GestureResult">GestureResult</a>: detection &amp; analysis results</p> <p><a href="../index.html#GestureResult">GestureResult</a>: detection &amp; analysis results</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="hand" class="tsd-anchor"></a><h3>hand</h3><div class="tsd-signature tsd-kind-icon">hand<span class="tsd-signature-symbol">:</span> <a href="HandResult.html" class="tsd-signature-type" data-tsd-kind="Interface">HandResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L184">result.ts:184</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="hand" class="tsd-anchor"></a><h3>hand</h3><div class="tsd-signature tsd-kind-icon">hand<span class="tsd-signature-symbol">:</span> <a href="HandResult.html" class="tsd-signature-type" data-tsd-kind="Interface">HandResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L187">result.ts:187</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="HandResult.html">HandResult</a>: detection &amp; analysis results</p> <p><a href="HandResult.html">HandResult</a>: detection &amp; analysis results</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="object" class="tsd-anchor"></a><h3>object</h3><div class="tsd-signature tsd-kind-icon">object<span class="tsd-signature-symbol">:</span> <a href="ObjectResult.html" class="tsd-signature-type" data-tsd-kind="Interface">ObjectResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L188">result.ts:188</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="object" class="tsd-anchor"></a><h3>object</h3><div class="tsd-signature tsd-kind-icon">object<span class="tsd-signature-symbol">:</span> <a href="ObjectResult.html" class="tsd-signature-type" data-tsd-kind="Interface">ObjectResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L191">result.ts:191</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="ObjectResult.html">ObjectResult</a>: detection &amp; analysis results</p> <p><a href="ObjectResult.html">ObjectResult</a>: detection &amp; analysis results</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="performance" class="tsd-anchor"></a><h3>performance</h3><div class="tsd-signature tsd-kind-icon">performance<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L190">result.ts:190</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="performance" class="tsd-anchor"></a><h3>performance</h3><div class="tsd-signature tsd-kind-icon">performance<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L193">result.ts:193</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>global performance object with timing values for each operation</p> <p>global performance object with timing values for each operation</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="persons" class="tsd-anchor"></a><h3>persons</h3><div class="tsd-signature tsd-kind-icon">persons<span class="tsd-signature-symbol">:</span> <a href="PersonResult.html" class="tsd-signature-type" data-tsd-kind="Interface">PersonResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L196">result.ts:196</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="persons" class="tsd-anchor"></a><h3>persons</h3><div class="tsd-signature tsd-kind-icon">persons<span class="tsd-signature-symbol">:</span> <a href="PersonResult.html" class="tsd-signature-type" data-tsd-kind="Interface">PersonResult</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L199">result.ts:199</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>getter property that returns unified persons object</p> <p>getter property that returns unified persons object</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="timestamp" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagReadonly">Readonly</span> timestamp</h3><div class="tsd-signature tsd-kind-icon">timestamp<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L194">result.ts:194</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="timestamp" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagReadonly">Readonly</span> timestamp</h3><div class="tsd-signature tsd-kind-icon">timestamp<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/result.ts#L197">result.ts:197</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>timestamp of detection representing the milliseconds elapsed since the UNIX epoch</p> <p>timestamp of detection representing the milliseconds elapsed since the UNIX epoch</p>
</div></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../index.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface"><a href="Result.html" class="tsd-kind-icon">Result</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#body" class="tsd-kind-icon">body</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#canvas" class="tsd-kind-icon">canvas</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#face" class="tsd-kind-icon">face</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#gesture" class="tsd-kind-icon">gesture</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#hand" class="tsd-kind-icon">hand</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#object" class="tsd-kind-icon">object</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#performance" class="tsd-kind-icon">performance</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#persons" class="tsd-kind-icon">persons</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#timestamp" class="tsd-kind-icon">timestamp</a></li></ul></li></ul></nav></div></div></div><footer class=""><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="overlay"></div><script src="../assets/main.js"></script></body></html> </div></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../index.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface"><a href="Result.html" class="tsd-kind-icon">Result</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#body" class="tsd-kind-icon">body</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#canvas" class="tsd-kind-icon">canvas</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#face" class="tsd-kind-icon">face</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#gesture" class="tsd-kind-icon">gesture</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#hand" class="tsd-kind-icon">hand</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#object" class="tsd-kind-icon">object</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#performance" class="tsd-kind-icon">performance</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#persons" class="tsd-kind-icon">persons</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="Result.html#timestamp" class="tsd-kind-icon">timestamp</a></li></ul></li></ul></nav></div></div></div><footer class=""><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="overlay"></div><script src="../assets/main.js"></script></body></html>

View File

@ -1 +1 @@
{"version":3,"file":"facemesh.d.ts","sourceRoot":"","sources":["../../../src/blazeface/facemesh.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAMxC,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAyClF;AAED,wBAAsB,IAAI,CAAC,MAAM,KAAA,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAuBrG;AAED,eAAO,MAAM,aAAa,UAAgB,CAAC;AAC3C,eAAO,MAAM,KAAK,YAAe,CAAC"} {"version":3,"file":"facemesh.d.ts","sourceRoot":"","sources":["../../../src/blazeface/facemesh.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAMxC,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAyClF;AAED,wBAAsB,IAAI,CAAC,MAAM,KAAA,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAuBrG;AAED,eAAO,MAAM,aAAa,UAAgB,CAAC;AAC3C,eAAO,MAAM,KAAK,YAAe,CAAC"}

View File

@ -4,6 +4,7 @@
*/ */
import type { GraphModel } from '../tfjs/types'; import type { GraphModel } from '../tfjs/types';
import type { BlazeFaceModel } from './blazeface'; import type { BlazeFaceModel } from './blazeface';
import type { Point } from '../result';
export declare class Pipeline { export declare class Pipeline {
storedBoxes: Array<{ storedBoxes: Array<{
startPoint: number[]; startPoint: number[];
@ -34,8 +35,8 @@ export declare class Pipeline {
crop: any; crop: any;
}; };
getEyeCoords(eyeData: any, eyeBox: any, eyeBoxSize: any, flip?: boolean): { getEyeCoords(eyeData: any, eyeBox: any, eyeBoxSize: any, flip?: boolean): {
rawCoords: [number, number, number][]; rawCoords: Point[];
iris: [number, number, number][]; iris: Point[];
}; };
getAdjustedIrisCoords(rawCoords: any, irisCoords: any, direction: any): any; getAdjustedIrisCoords(rawCoords: any, irisCoords: any, direction: any): any;
correctFaceRotation(config: any, box: any, input: any): any[]; correctFaceRotation(config: any, box: any, input: any): any[];

View File

@ -1 +1 @@
{"version":3,"file":"facepipeline.d.ts","sourceRoot":"","sources":["../../../src/blazeface/facepipeline.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAU,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAqDlD,qBAAa,QAAQ;IACnB,WAAW,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC,CAAC;IACpJ,mBAAmB,EAAE,cAAc,CAAC;IACpC,YAAY,EAAE,UAAU,CAAC;IACzB,SAAS,EAAE,UAAU,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;gBAEV,mBAAmB,KAAA,EAAE,YAAY,KAAA,EAAE,SAAS,KAAA;IAcxD,kBAAkB,CAAC,SAAS,KAAA,EAAE,GAAG,KAAA,EAAE,KAAK,KAAA,EAAE,cAAc,KAAA;IAmBxD,gCAAgC,CAAC,SAAS,KAAA;IAO1C,SAAS,CAAC,SAAS,KAAA,EAAE,IAAI,KAAA,EAAE,mBAAmB,KAAA,EAAE,mBAAmB,KAAA,EAAE,IAAI,UAAQ;;;;;;;;;IAiBjF,YAAY,CAAC,OAAO,KAAA,EAAE,MAAM,KAAA,EAAE,UAAU,KAAA,EAAE,IAAI,UAAQ;;;;IAgBtD,qBAAqB,CAAC,SAAS,KAAA,EAAE,UAAU,KAAA,EAAE,SAAS,KAAA;IAgBtD,mBAAmB,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA,EAAE,KAAK,KAAA;IAgBhC,WAAW,CAAC,SAAS,KAAA,EAAE,IAAI,KAAA,EAAE,MAAM,KAAA;IAmCnC,OAAO,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA;;;;;;;;CAiI5B"} {"version":3,"file":"facepipeline.d.ts","sourceRoot":"","sources":["../../../src/blazeface/facepipeline.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAU,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAmDvC,qBAAa,QAAQ;IACnB,WAAW,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC,CAAC;IACpJ,mBAAmB,EAAE,cAAc,CAAC;IACpC,YAAY,EAAE,UAAU,CAAC;IACzB,SAAS,EAAE,UAAU,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;gBAEV,mBAAmB,KAAA,EAAE,YAAY,KAAA,EAAE,SAAS,KAAA;IAcxD,kBAAkB,CAAC,SAAS,KAAA,EAAE,GAAG,KAAA,EAAE,KAAK,KAAA,EAAE,cAAc,KAAA;IAmBxD,gCAAgC,CAAC,SAAS,KAAA;IAO1C,SAAS,CAAC,SAAS,KAAA,EAAE,IAAI,KAAA,EAAE,mBAAmB,KAAA,EAAE,mBAAmB,KAAA,EAAE,IAAI,UAAQ;;;;;;;;;IAiBjF,YAAY,CAAC,OAAO,KAAA,EAAE,MAAM,KAAA,EAAE,UAAU,KAAA,EAAE,IAAI,UAAQ;;;;IAgBtD,qBAAqB,CAAC,SAAS,KAAA,EAAE,UAAU,KAAA,EAAE,SAAS,KAAA;IAgBtD,mBAAmB,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA,EAAE,KAAK,KAAA;IAgBhC,WAAW,CAAC,SAAS,KAAA,EAAE,IAAI,KAAA,EAAE,MAAM,KAAA;IAmCnC,OAAO,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA;;;;;;;;CAiI5B"}

View File

@ -1 +1 @@
{"version":3,"file":"blazepose.d.ts","sourceRoot":"","sources":["../../../src/blazepose/blazepose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKxC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAU9D;AAED,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA4ClF"} {"version":3,"file":"blazepose.d.ts","sourceRoot":"","sources":["../../../src/blazepose/blazepose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKxC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAU9D;AAED,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA4ClF"}

View File

@ -1 +1 @@
{"version":3,"file":"efficientpose.d.ts","sourceRoot":"","sources":["../../../src/efficientpose/efficientpose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAexC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAQ9D;AAmBD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAkElF"} {"version":3,"file":"efficientpose.d.ts","sourceRoot":"","sources":["../../../src/efficientpose/efficientpose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAexC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAQ9D;AAmBD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAkElF"}

View File

@ -1 +1 @@
{"version":3,"file":"handpose.d.ts","sourceRoot":"","sources":["../../../src/handpose/handpose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAgBxC,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAuDlF;AAED,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAuB1F"} {"version":3,"file":"handpose.d.ts","sourceRoot":"","sources":["../../../src/handpose/handpose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAgBxC,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAuDlF;AAED,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAuB1F"}

View File

@ -1 +1 @@
{"version":3,"file":"handtrack.d.ts","sourceRoot":"","sources":["../../../src/handtrack/handtrack.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAoDxC,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAepE;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAWtE;AAED,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAI1F;AAsHD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAsBlF"} {"version":3,"file":"handtrack.d.ts","sourceRoot":"","sources":["../../../src/handtrack/handtrack.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA4CxC,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAepE;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAWtE;AAED,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAI1F;AAgGD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAmBlF"}

View File

@ -13,6 +13,7 @@ export * from './config';
export * from './result'; export * from './result';
export type { DrawOptions } from './draw'; export type { DrawOptions } from './draw';
export { env, Env } from './env'; export { env, Env } from './env';
export { Box, Point } from './result';
export { Models } from './models'; export { Models } from './models';
/** Defines all possible input types for **Human** detection /** Defines all possible input types for **Human** detection
* @typedef Input Type * @typedef Input Type

View File

@ -1 +1 @@
{"version":3,"file":"human.d.ts","sourceRoot":"","sources":["../../src/human.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,MAAM,EAAY,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAiF,MAAM,UAAU,CAAC;AACtH,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAgBjD,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAK7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAG1C,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,oBAAY,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAEpJ;;;;;;;GAOG;AACH,oBAAY,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEjF;;GAEG;AACH,oBAAY,KAAK,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;GAEG;AACH,oBAAY,UAAU,GAAG,OAAO,EAAE,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,qBAAa,KAAK;;IAChB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;MAGE;IACF,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd,iDAAiD;IACjD,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,CAAA;KAAE,CAAC;IAEvF;;;;;OAKG;IACH,EAAE,EAAE,UAAU,CAAC;IAEf,qEAAqE;IACrE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;IAEb;;;;;;;OAOG;IACH,IAAI,EAAE;QAAE,MAAM,MAAC;QAAC,IAAI,MAAC;QAAC,IAAI,MAAC;QAAC,IAAI,MAAC;QAAC,OAAO,MAAC;QAAC,MAAM,MAAC;QAAC,MAAM,MAAC;QAAC,GAAG,MAAC;QAAC,OAAO,EAAE,WAAW,CAAA;KAAE,CAAC;IAEvF;;;MAGE;IACF,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IAEtB;;;;;;;;;OASG;IACH,MAAM,EAAE,WAAW,CAAC;IACpB,oGAAoG;IACpG,iBAAiB,EAAE,OAAO,QAAQ,CAAC,aAAa,CAAC;IACjD,0EAA0E;IAC1E,SAAS,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC;IACjC,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIpC,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAG5B;;;;;OAKG;gBACS,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;IA8CxC,cAAc;IACd,OAAO,WAAY,MAAM,EAAE,UAO1B;IAgBD,4CAA4C;IAC5C,KAAK;IAML,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;;;;;IAIrC;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,KAAK;;;;IAIlB;;;;;;;MAOE;IAEF,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;IAIxE;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI,CAAA;KAAE,CAAC;IAIxL;;;;OAIG;IAEH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIrC;;;;;;OAMG;IAEH,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,EAAE,SAAS,SAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE;IAI/L;;;;;;OAMG;IACG,IAAI;IAMV;;;;;MAKE;IACI,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;IAgCvC,cAAc;IACd,IAAI,UAAW,MAAM,aAAkD;IAEvE;;;;;OAKG;IACH,IAAI,CAAC,MAAM,GAAE,MAAoB;IAIjC;;;;;MAKE;IACI,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG;QAAE,KAAK,MAAA;KAAE,CAAC;IAIvE;;;;;;;;;MASE;IACI,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;CAkKlF;AAED,oCAAoC;AACpC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,CAAC"} {"version":3,"file":"human.d.ts","sourceRoot":"","sources":["../../src/human.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,MAAM,EAAY,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAiF,MAAM,UAAU,CAAC;AACtH,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAgBjD,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAK7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAG1C,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,oBAAY,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAEpJ;;;;;;;GAOG;AACH,oBAAY,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEjF;;GAEG;AACH,oBAAY,KAAK,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;GAEG;AACH,oBAAY,UAAU,GAAG,OAAO,EAAE,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,qBAAa,KAAK;;IAChB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;MAGE;IACF,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd,iDAAiD;IACjD,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,CAAA;KAAE,CAAC;IAEvF;;;;;OAKG;IACH,EAAE,EAAE,UAAU,CAAC;IAEf,qEAAqE;IACrE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;IAEb;;;;;;;OAOG;IACH,IAAI,EAAE;QAAE,MAAM,MAAC;QAAC,IAAI,MAAC;QAAC,IAAI,MAAC;QAAC,IAAI,MAAC;QAAC,OAAO,MAAC;QAAC,MAAM,MAAC;QAAC,MAAM,MAAC;QAAC,GAAG,MAAC;QAAC,OAAO,EAAE,WAAW,CAAA;KAAE,CAAC;IAEvF;;;MAGE;IACF,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IAEtB;;;;;;;;;OASG;IACH,MAAM,EAAE,WAAW,CAAC;IACpB,oGAAoG;IACpG,iBAAiB,EAAE,OAAO,QAAQ,CAAC,aAAa,CAAC;IACjD,0EAA0E;IAC1E,SAAS,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC;IACjC,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIpC,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAG5B;;;;;OAKG;gBACS,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;IA8CxC,cAAc;IACd,OAAO,WAAY,MAAM,EAAE,UAO1B;IAgBD,4CAA4C;IAC5C,KAAK;IAML,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;;;;;IAIrC;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,KAAK;;;;IAIlB;;;;;;;MAOE;IAEF,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;IAIxE;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI,CAAA;KAAE,CAAC;IAIxL;;;;OAIG;IAEH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIrC;;;;;;OAMG;IAEH,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,EAAE,SAAS,SAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE;IAI/L;;;;;;OAMG;IACG,IAAI;IAMV;;;;;MAKE;IACI,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;IAgCvC,cAAc;IACd,IAAI,UAAW,MAAM,aAAkD;IAEvE;;;;;OAKG;IACH,IAAI,CAAC,MAAM,GAAE,MAAoB;IAIjC;;;;;MAKE;IACI,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG;QAAE,KAAK,MAAA;KAAE,CAAC;IAIvE;;;;;;;;;MASE;IACI,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;CAkKlF;AAED,oCAAoC;AACpC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,CAAC"}

View File

@ -1 +1 @@
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/interpolate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiF,MAAM,UAAU,CAAC;AAItH,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAmI9C"} {"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/interpolate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAA6F,MAAM,UAAU,CAAC;AAIlI,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAmI9C"}

View File

@ -7,5 +7,5 @@ import type { BodyResult } from '../result';
import type { GraphModel, Tensor } from '../tfjs/types'; import type { GraphModel, Tensor } from '../tfjs/types';
import type { Config } from '../config'; import type { Config } from '../config';
export declare function load(config: Config): Promise<GraphModel>; export declare function load(config: Config): Promise<GraphModel>;
export declare function predict(image: Tensor, config: Config): Promise<BodyResult[]>; export declare function predict(input: Tensor, config: Config): Promise<BodyResult[]>;
//# sourceMappingURL=movenet.d.ts.map //# sourceMappingURL=movenet.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"movenet.d.ts","sourceRoot":"","sources":["../../../src/movenet/movenet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAiBxC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAS9D;AAgFD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA6BlF"} {"version":3,"file":"movenet.d.ts","sourceRoot":"","sources":["../../../src/movenet/movenet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAgBxC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAW9D;AAsFD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA2ClF"}

View File

@ -1 +1 @@
{"version":3,"file":"centernet.d.ts","sourceRoot":"","sources":["../../../src/object/centernet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AASxC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAW9D;AAgDD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAkBpF"} {"version":3,"file":"centernet.d.ts","sourceRoot":"","sources":["../../../src/object/centernet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAO,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AASxC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAW9D;AAgDD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAkBpF"}

View File

@ -1 +1 @@
{"version":3,"file":"nanodet.d.ts","sourceRoot":"","sources":["../../../src/object/nanodet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AASxC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAU9D;AA6ED,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAuBpF"} {"version":3,"file":"nanodet.d.ts","sourceRoot":"","sources":["../../../src/object/nanodet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAO,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AASxC,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAU9D;AA6ED,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAuBpF"}

View File

@ -1 +1 @@
{"version":3,"file":"persons.d.ts","sourceRoot":"","sources":["../../src/persons.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhG,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,CA4DzL"} {"version":3,"file":"persons.d.ts","sourceRoot":"","sources":["../../src/persons.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAO,MAAM,UAAU,CAAC;AAErG,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,CA4DzL"}

View File

@ -3,11 +3,12 @@
* See `posenet.ts` for entry point * See `posenet.ts` for entry point
*/ */
import * as utils from './utils'; import * as utils from './utils';
import type { Box } from '../result';
export declare function decodePose(root: any, scores: any, offsets: any, displacementsFwd: any, displacementsBwd: any): any[]; export declare function decodePose(root: any, scores: any, offsets: any, displacementsFwd: any, displacementsBwd: any): any[];
export declare function buildPartWithScoreQueue(minConfidence: any, scores: any): utils.MaxHeap; export declare function buildPartWithScoreQueue(minConfidence: any, scores: any): utils.MaxHeap;
export declare function decode(offsets: any, scores: any, displacementsFwd: any, displacementsBwd: any, maxDetected: any, minConfidence: any): { export declare function decode(offsets: any, scores: any, displacementsFwd: any, displacementsBwd: any, maxDetected: any, minConfidence: any): {
keypoints: any; keypoints: any;
box: [number, number, number, number]; box: Box;
score: number; score: number;
}[]; }[];
//# sourceMappingURL=poses.d.ts.map //# sourceMappingURL=poses.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"poses.d.ts","sourceRoot":"","sources":["../../../src/posenet/poses.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAoCjC,wBAAgB,UAAU,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,OAAO,KAAA,EAAE,gBAAgB,KAAA,EAAE,gBAAgB,KAAA,SA+BnF;AAqBD,wBAAgB,uBAAuB,CAAC,aAAa,KAAA,EAAE,MAAM,KAAA,iBAe5D;AAkBD,wBAAgB,MAAM,CAAC,OAAO,KAAA,EAAE,MAAM,KAAA,EAAE,gBAAgB,KAAA,EAAE,gBAAgB,KAAA,EAAE,WAAW,KAAA,EAAE,aAAa,KAAA;;SAC/D,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;WAAS,MAAM;IAmBrF"} {"version":3,"file":"poses.d.ts","sourceRoot":"","sources":["../../../src/posenet/poses.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAmCrC,wBAAgB,UAAU,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,OAAO,KAAA,EAAE,gBAAgB,KAAA,EAAE,gBAAgB,KAAA,SA+BnF;AAqBD,wBAAgB,uBAAuB,CAAC,aAAa,KAAA,EAAE,MAAM,KAAA,iBAe5D;AAkBD,wBAAgB,MAAM,CAAC,OAAO,KAAA,EAAE,MAAM,KAAA,EAAE,gBAAgB,KAAA,EAAE,gBAAgB,KAAA,EAAE,WAAW,KAAA,EAAE,aAAa,KAAA;;;WACnD,MAAM;IAmBxD"}

36
types/src/result.d.ts vendored
View File

@ -3,6 +3,8 @@
*/ */
import type { Tensor } from './tfjs/types'; import type { Tensor } from './tfjs/types';
import type { FaceGesture, BodyGesture, HandGesture, IrisGesture } from './gesture/gesture'; import type { FaceGesture, BodyGesture, HandGesture, IrisGesture } from './gesture/gesture';
export declare type Box = [number, number, number, number];
export declare type Point = [number, number, number?];
/** Face results /** Face results
* Combined results of face detector, face mesh, age, gender, emotion, embedding, iris models * Combined results of face detector, face mesh, age, gender, emotion, embedding, iris models
* Some values may be null if specific model is not enabled * Some values may be null if specific model is not enabled
@ -35,11 +37,11 @@ export interface FaceResult {
score: number; score: number;
boxScore: number; boxScore: number;
faceScore: number; faceScore: number;
box: [number, number, number, number]; box: Box;
boxRaw: [number, number, number, number]; boxRaw: Box;
mesh: Array<[number, number, number]>; mesh: Array<Point>;
meshRaw: Array<[number, number, number]>; meshRaw: Array<Point>;
annotations: Record<string, Array<[number, number, number]>>; annotations: Record<string, Point[]>;
age?: number; age?: number;
gender?: string; gender?: string;
genderScore?: number; genderScore?: number;
@ -79,12 +81,12 @@ export interface FaceResult {
export interface BodyResult { export interface BodyResult {
id: number; id: number;
score: number; score: number;
box: [number, number, number, number]; box: Box;
boxRaw: [number, number, number, number]; boxRaw: Box;
keypoints: Array<{ keypoints: Array<{
part: string; part: string;
position: [number, number, number?]; position: Point;
positionRaw: [number, number, number?]; positionRaw: Point;
score: number; score: number;
presence?: number; presence?: number;
}>; }>;
@ -105,11 +107,11 @@ export interface HandResult {
score: number; score: number;
boxScore: number; boxScore: number;
fingerScore: number; fingerScore: number;
box: [number, number, number, number]; box: Box;
boxRaw: [number, number, number, number]; boxRaw: Box;
keypoints: Array<[number, number, number]>; keypoints: Array<Point>;
label: string; label: string;
annotations: Record<'index' | 'middle' | 'pinky' | 'ring' | 'thumb' | 'palm', Array<[number, number, number]>>; annotations: Record<'index' | 'middle' | 'pinky' | 'ring' | 'thumb' | 'palm', Array<Point>>;
landmarks: Record<'index' | 'middle' | 'pinky' | 'ring' | 'thumb', { landmarks: Record<'index' | 'middle' | 'pinky' | 'ring' | 'thumb', {
curl: 'none' | 'half' | 'full'; curl: 'none' | 'half' | 'full';
direction: 'verticalUp' | 'verticalDown' | 'horizontalLeft' | 'horizontalRight' | 'diagonalUpRight' | 'diagonalUpLeft' | 'diagonalDownRight' | 'diagonalDownLeft'; direction: 'verticalUp' | 'verticalDown' | 'horizontalLeft' | 'horizontalRight' | 'diagonalUpRight' | 'diagonalUpLeft' | 'diagonalDownRight' | 'diagonalDownLeft';
@ -132,8 +134,8 @@ export interface ObjectResult {
score: number; score: number;
class: number; class: number;
label: string; label: string;
box: [number, number, number, number]; box: Box;
boxRaw: [number, number, number, number]; boxRaw: Box;
} }
/** Gesture results /** Gesture results
* @typedef Gesture Type * @typedef Gesture Type
@ -177,8 +179,8 @@ export interface PersonResult {
right: HandResult | null; right: HandResult | null;
}; };
gestures: Array<GestureResult>; gestures: Array<GestureResult>;
box: [number, number, number, number]; box: Box;
boxRaw?: [number, number, number, number]; boxRaw?: Box;
} }
/** /**
* Result interface definition for **Human** library * Result interface definition for **Human** library

View File

@ -1 +1 @@
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/result.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACrC,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACxC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QACpD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACjF,IAAI,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7C,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,SAAS,EAAE,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACpC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACvC,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAA;CACH;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,SAAS,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CACjB,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EACxD,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAChC,CAAC;IACF,SAAS,EAAE,MAAM,CACf,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,EAC/C;QAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;QAAC,SAAS,EAAE,YAAY,GAAG,cAAc,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,kBAAkB,CAAA;KAAE,CACtM,CAAC;CACH;AAED;;;;;;;;;;;EAWE;AACF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED;;;;;;;GAOG;AACH,oBAAY,aAAa,GACvB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GACtC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAA;AAE5C;;;;;;;;;;;EAWE;AACF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;KAAE,CAAC;IAC7D,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC/B,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,uDAAuD;IACvD,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACxB,uDAAuD;IACvD,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACxB,uDAAuD;IACvD,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACxB,0DAA0D;IAC1D,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9B,yDAAyD;IACzD,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;IAC3B,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,yEAAyE;IACzE,MAAM,CAAC,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAChE,wFAAwF;IACxF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,2DAA2D;IAC3D,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAC9B"} {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/result.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5F,oBAAY,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACnD,oBAAY,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAClB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QACpD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACjF,IAAI,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7C,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,GAAG,CAAC;IACZ,SAAS,EAAE,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,KAAK,CAAC;QAChB,WAAW,EAAE,KAAK,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAA;CACH;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,GAAG,CAAC;IACZ,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CACjB,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EACxD,KAAK,CAAC,KAAK,CAAC,CACb,CAAC;IACF,SAAS,EAAE,MAAM,CACf,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,EAC/C;QAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;QAAC,SAAS,EAAE,YAAY,GAAG,cAAc,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,kBAAkB,CAAA;KAAE,CACtM,CAAC;CACH;AAED;;;;;;;;;;;EAWE;AACF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,GAAG,CAAC;CACb;AAED;;;;;;;GAOG;AACH,oBAAY,aAAa,GACvB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GACtC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAA;AAE5C;;;;;;;;;;;EAWE;AACF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;KAAE,CAAC;IAC7D,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC/B,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,uDAAuD;IACvD,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACxB,uDAAuD;IACvD,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACxB,uDAAuD;IACvD,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACxB,0DAA0D;IAC1D,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9B,yDAAyD;IACzD,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;IAC3B,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,yEAAyE;IACzE,MAAM,CAAC,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAChE,wFAAwF;IACxF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,2DAA2D;IAC3D,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAC9B"}

6
types/src/util.d.ts vendored
View File

@ -1,6 +1,7 @@
/** /**
* Simple helper functions used accross codebase * Simple helper functions used accross codebase
*/ */
import type { Box } from './result';
export declare function join(folder: string, file: string): string; export declare function join(folder: string, file: string): string;
export declare function log(...msg: any[]): void; export declare function log(...msg: any[]): void;
export declare const now: () => number; export declare const now: () => number;
@ -16,4 +17,9 @@ export declare function validate(defaults: any, config: any, parent?: string, ms
export declare function mergeDeep(...objects: any[]): any; export declare function mergeDeep(...objects: any[]): any;
export declare const minmax: (data: Array<number>) => number[]; export declare const minmax: (data: Array<number>) => number[];
export declare function wait(time: any): Promise<void>; export declare function wait(time: any): Promise<void>;
export declare function scaleBox(keypoints: any, boxScaleFact: any, outputSize: any): {
box: Box;
boxRaw: Box;
yxBox: Box;
};
//# sourceMappingURL=util.d.ts.map //# sourceMappingURL=util.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMzD;AAGD,wBAAgB,GAAG,CAAC,GAAG,GAAG,OAAA,GAAG,IAAI,CAKhC;AAGD,eAAO,MAAM,GAAG,cAGf,CAAC;AAGF,wBAAgB,QAAQ,CAAC,QAAQ,KAAA,EAAE,MAAM,KAAA,EAAE,MAAM,SAAW,EAAE,IAAI,GAAE,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAM;YAAhD,MAAM;WAAS,MAAM;eAAa,MAAM;IAc3H;AAGD,wBAAgB,SAAS,CAAC,GAAG,OAAO,OAAA,OAYnC;AAGD,eAAO,MAAM,MAAM,SAAU,MAAM,MAAM,CAAC,aAIpC,CAAC;AAGP,wBAAsB,IAAI,CAAC,IAAI,KAAA,iBAG9B"} {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMzD;AAGD,wBAAgB,GAAG,CAAC,GAAG,GAAG,OAAA,GAAG,IAAI,CAKhC;AAGD,eAAO,MAAM,GAAG,cAGf,CAAC;AAGF,wBAAgB,QAAQ,CAAC,QAAQ,KAAA,EAAE,MAAM,KAAA,EAAE,MAAM,SAAW,EAAE,IAAI,GAAE,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAM;YAAhD,MAAM;WAAS,MAAM;eAAa,MAAM;IAc3H;AAGD,wBAAgB,SAAS,CAAC,GAAG,OAAO,OAAA,OAYnC;AAGD,eAAO,MAAM,MAAM,SAAU,MAAM,MAAM,CAAC,aAIpC,CAAC;AAGP,wBAAsB,IAAI,CAAC,IAAI,KAAA,iBAG9B;AAGD,wBAAgB,QAAQ,CAAC,SAAS,KAAA,EAAE,YAAY,KAAA,EAAE,UAAU,KAAA;;;;EAwB3D"}