update handtrack boxes and refactor handpose

pull/233/head
Vladimir Mandic 2021-10-20 09:10:57 -04:00
parent 90d5f32126
commit 9e73648f3d
38 changed files with 1336 additions and 1332 deletions

View File

@ -9,11 +9,12 @@
## Changelog
### **HEAD -> main** 2021/10/19 mandic00@live.com
### **2.3.5** 2021/10/19 mandic00@live.com
### **origin/main** 2021/10/19 snaggadhagga@gmail.com
- removed direct usage of performance.now
### **2.3.4** 2021/10/19 mandic00@live.com

View File

@ -4584,41 +4584,41 @@ var UV7 = VTX7.map((x) => UV468[x]);
// src/face/facemeshutil.ts
var createBox = (startEndTensor) => ({ startPoint: tfjs_esm_exports.slice(startEndTensor, [0, 0], [-1, 2]), endPoint: tfjs_esm_exports.slice(startEndTensor, [0, 2], [-1, 2]) });
var getBoxSize = (box6) => [Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box6.endPoint[1] - box6.startPoint[1])];
var getBoxCenter = (box6) => [box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2];
var getClampedBox = (box6, input) => box6 ? [
Math.trunc(Math.max(0, box6.startPoint[0])),
Math.trunc(Math.max(0, box6.startPoint[1])),
Math.trunc(Math.min(input.shape[2] || 0, box6.endPoint[0]) - Math.max(0, box6.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, box6.endPoint[1]) - Math.max(0, box6.startPoint[1]))
var getBoxSize = (box4) => [Math.abs(box4.endPoint[0] - box4.startPoint[0]), Math.abs(box4.endPoint[1] - box4.startPoint[1])];
var getBoxCenter = (box4) => [box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2, box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2];
var getClampedBox = (box4, input) => box4 ? [
Math.trunc(Math.max(0, box4.startPoint[0])),
Math.trunc(Math.max(0, box4.startPoint[1])),
Math.trunc(Math.min(input.shape[2] || 0, box4.endPoint[0]) - Math.max(0, box4.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, box4.endPoint[1]) - Math.max(0, box4.startPoint[1]))
] : [0, 0, 0, 0];
var getRawBox = (box6, input) => box6 ? [
box6.startPoint[0] / (input.shape[2] || 0),
box6.startPoint[1] / (input.shape[1] || 0),
(box6.endPoint[0] - box6.startPoint[0]) / (input.shape[2] || 0),
(box6.endPoint[1] - box6.startPoint[1]) / (input.shape[1] || 0)
var getRawBox = (box4, input) => box4 ? [
box4.startPoint[0] / (input.shape[2] || 0),
box4.startPoint[1] / (input.shape[1] || 0),
(box4.endPoint[0] - box4.startPoint[0]) / (input.shape[2] || 0),
(box4.endPoint[1] - box4.startPoint[1]) / (input.shape[1] || 0)
] : [0, 0, 0, 0];
var scaleBoxCoordinates = (box6, factor) => {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
var scaleBoxCoordinates = (box4, factor) => {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
return { startPoint, endPoint };
};
var cutBoxFromImageAndResize = (box6, image25, cropSize) => {
var cutBoxFromImageAndResize = (box4, image25, cropSize) => {
const h = image25.shape[1];
const w = image25.shape[2];
return tfjs_esm_exports.image.cropAndResize(image25, [[box6.startPoint[1] / h, box6.startPoint[0] / w, box6.endPoint[1] / h, box6.endPoint[0] / w]], [0], cropSize);
return tfjs_esm_exports.image.cropAndResize(image25, [[box4.startPoint[1] / h, box4.startPoint[0] / w, box4.endPoint[1] / h, box4.endPoint[0] / w]], [0], cropSize);
};
var enlargeBox = (box6, factor = 1.5) => {
const center = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var enlargeBox = (box4, factor = 1.5) => {
const center = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box6.landmarks };
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box4.landmarks };
};
var squarifyBox = (box6) => {
const centers = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var squarifyBox = (box4) => {
const centers = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = Math.max(...size2) / 2;
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box6.landmarks };
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box4.landmarks };
};
var calculateLandmarksBoundingBox = (landmarks) => {
const xs = landmarks.map((d) => d[0]);
@ -4686,8 +4686,8 @@ function generateAnchors(inputSize8) {
}
return anchors4;
}
function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / inputSize8 * (coord[0] - inputSize8 / 2),
boxSize[1] / inputSize8 * (coord[1] - inputSize8 / 2),
@ -4696,21 +4696,21 @@ function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8)
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1];
const boxCenter = [...getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint }), 1];
return coordsRotated.map((coord) => [
Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])),
Math.round(coord[2] || 0)
]);
}
function correctFaceRotation(box6, input, inputSize8) {
const symmetryLine = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[symmetryLine[0]], box6.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function correctFaceRotation(box4, input, inputSize8) {
const symmetryLine = box4.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box4.landmarks[symmetryLine[0]], box4.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]];
const rotated = tfjs_esm_exports.image.rotateWithOffset(input, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [inputSize8, inputSize8]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, rotated, [inputSize8, inputSize8]);
const face5 = tfjs_esm_exports.div(cut, 255);
tfjs_esm_exports.dispose(cut);
tfjs_esm_exports.dispose(rotated);
@ -5137,13 +5137,13 @@ async function process3(res, outputShape, config3) {
detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y
];
const box6 = [
const box4 = [
Math.trunc(boxRaw[0] * outputShape[0]),
Math.trunc(boxRaw[1] * outputShape[1]),
Math.trunc(boxRaw[2] * outputShape[0]),
Math.trunc(boxRaw[3] * outputShape[1])
];
results.push({ id: i++, score, class: classVal, label, box: box6, boxRaw });
results.push({ id: i++, score, class: classVal, label, box: box4, boxRaw });
}
return results;
}
@ -5428,20 +5428,20 @@ var getLeftToRightEyeDepthDifference = (rawCoords) => {
return leftEyeZ - rightEyeZ;
};
var getEyeBox = (rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false, meshSize) => {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box6);
const box4 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box4);
let crop2 = tfjs_esm_exports.image.cropAndResize(face5, [[
box6.startPoint[1] / meshSize,
box6.startPoint[0] / meshSize,
box6.endPoint[1] / meshSize,
box6.endPoint[0] / meshSize
box4.startPoint[1] / meshSize,
box4.startPoint[0] / meshSize,
box4.endPoint[1] / meshSize,
box4.endPoint[0] / meshSize
]], [0], [inputSize4, inputSize4]);
if (flip && env2.kernels.includes("flipleftright")) {
const flipped = tfjs_esm_exports.image.flipLeftRight(crop2);
tfjs_esm_exports.dispose(crop2);
crop2 = flipped;
}
return { box: box6, boxSize, crop: crop2 };
return { box: box4, boxSize, crop: crop2 };
};
var getEyeCoords = (eyeData, eyeBox, eyeBoxSize, flip = false) => {
const eyeRawCoords = [];
@ -5536,7 +5536,7 @@ async function predict6(input, config3) {
const faces = [];
const newBoxes = [];
let id = 0;
for (let box6 of boxCache) {
for (let box4 of boxCache) {
let angle = 0;
let rotationMatrix;
const face5 = {
@ -5551,21 +5551,21 @@ async function predict6(input, config3) {
annotations: {}
};
if (((_d = config3.face.detector) == null ? void 0 : _d.rotation) && ((_e = config3.face.mesh) == null ? void 0 : _e.enabled) && env2.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input, inputSize5);
} else {
rotationMatrix = IDENTITY_MATRIX;
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, input, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, input, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
face5.tensor = tfjs_esm_exports.div(cut, 255);
tfjs_esm_exports.dispose(cut);
}
face5.boxScore = Math.round(100 * box6.confidence) / 100;
face5.boxScore = Math.round(100 * box4.confidence) / 100;
if (!((_g = config3.face.mesh) == null ? void 0 : _g.enabled)) {
face5.box = getClampedBox(box6, input);
face5.boxRaw = getRawBox(box6, input);
face5.score = Math.round(100 * box6.confidence || 0) / 100;
face5.mesh = box6.landmarks.map((pt) => [
(box6.startPoint[0] + box6.endPoint[0]) / 2 + (box6.endPoint[0] + box6.startPoint[0]) * pt[0] / size(),
(box6.startPoint[1] + box6.endPoint[1]) / 2 + (box6.endPoint[1] + box6.startPoint[1]) * pt[1] / size()
face5.box = getClampedBox(box4, input);
face5.boxRaw = getRawBox(box4, input);
face5.score = Math.round(100 * box4.confidence || 0) / 100;
face5.mesh = box4.landmarks.map((pt) => [
(box4.startPoint[0] + box4.endPoint[0]) / 2 + (box4.endPoint[0] + box4.startPoint[0]) * pt[0] / size(),
(box4.startPoint[1] + box4.endPoint[1]) / 2 + (box4.endPoint[1] + box4.startPoint[1]) * pt[1] / size()
]);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize5]);
for (const key of Object.keys(blazeFaceLandmarks))
@ -5583,28 +5583,28 @@ async function predict6(input, config3) {
tfjs_esm_exports.dispose(contourCoords);
tfjs_esm_exports.dispose(coordsReshaped);
if (faceConfidence < (((_h = config3.face.detector) == null ? void 0 : _h.minConfidence) || 1)) {
box6.confidence = faceConfidence;
box4.confidence = faceConfidence;
} else {
if ((_i = config3.face.iris) == null ? void 0 : _i.enabled)
rawCoords = await augmentIris(rawCoords, face5.tensor, config3, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize5);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize5]);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box6.confidence };
box4 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box4.confidence };
for (const key of Object.keys(meshAnnotations))
face5.annotations[key] = meshAnnotations[key].map((index) => face5.mesh[index]);
if (((_j = config3.face.detector) == null ? void 0 : _j.rotation) && config3.face.mesh.enabled && ((_k = config3.face.description) == null ? void 0 : _k.enabled) && env2.kernels.includes("rotatewithoffset")) {
tfjs_esm_exports.dispose(face5.tensor);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input, inputSize5);
}
face5.box = getClampedBox(box6, input);
face5.boxRaw = getRawBox(box6, input);
face5.score = Math.round(100 * faceConfidence || 100 * box6.confidence || 0) / 100;
face5.box = getClampedBox(box4, input);
face5.boxRaw = getRawBox(box4, input);
face5.score = Math.round(100 * faceConfidence || 100 * box4.confidence || 0) / 100;
face5.faceScore = Math.round(100 * faceConfidence) / 100;
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence };
box4 = { ...squarifyBox(box4), confidence: box4.confidence, faceConfidence };
}
}
faces.push(face5);
newBoxes.push(box6);
newBoxes.push(box4);
}
if ((_l = config3.face.mesh) == null ? void 0 : _l.enabled)
boxCache = newBoxes.filter((a) => {
@ -5659,10 +5659,10 @@ function enhance(input) {
const tensor3 = input.image || input.tensor || input;
if (!(tensor3 instanceof tfjs_esm_exports.Tensor))
return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]];
const box4 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model9 == null ? void 0 : model9.inputs[0].shape))
return null;
const crop2 = tensor3.shape.length === 3 ? tfjs_esm_exports.image.cropAndResize(tfjs_esm_exports.expandDims(tensor3, 0), box6, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]) : tfjs_esm_exports.image.cropAndResize(tensor3, box6, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]);
const crop2 = tensor3.shape.length === 3 ? tfjs_esm_exports.image.cropAndResize(tfjs_esm_exports.expandDims(tensor3, 0), box4, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]) : tfjs_esm_exports.image.cropAndResize(tensor3, box4, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]);
const norm = tfjs_esm_exports.mul(crop2, 255);
return norm;
});
@ -5713,58 +5713,119 @@ async function predict7(image25, config3, idx, count2) {
});
}
// src/handpose/box.ts
function getBoxSize2(box6) {
// src/hand/handposeutil.ts
function getBoxSize2(box4) {
return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1])
Math.abs(box4.endPoint[0] - box4.startPoint[0]),
Math.abs(box4.endPoint[1] - box4.startPoint[1])
];
}
function getBoxCenter2(box6) {
function getBoxCenter2(box4) {
return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2
box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2,
box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2
];
}
function cutBoxFromImageAndResize2(box6, image25, cropSize) {
function cutBoxFromImageAndResize2(box4, image25, cropSize) {
const h = image25.shape[1];
const w = image25.shape[2];
const boxes = [[
box6.startPoint[1] / h,
box6.startPoint[0] / w,
box6.endPoint[1] / h,
box6.endPoint[0] / w
box4.startPoint[1] / h,
box4.startPoint[0] / w,
box4.endPoint[1] / h,
box4.endPoint[0] / w
]];
return tfjs_esm_exports.image.cropAndResize(image25, boxes, [0], cropSize);
}
function scaleBoxCoordinates2(box6, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => {
function scaleBoxCoordinates2(box4, factor) {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
const palmLandmarks = box4.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord;
});
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence };
return { startPoint, endPoint, palmLandmarks, confidence: box4.confidence };
}
function enlargeBox2(box6, factor = 1.5) {
const center = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function enlargeBox2(box4, factor = 1.5) {
const center = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const newHalfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
const startPoint = [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: box4.palmLandmarks };
}
function squarifyBox2(box6) {
const centers = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function squarifyBox2(box4) {
const centers = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const maxEdge = Math.max(...size2);
const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks };
return { startPoint, endPoint, palmLandmarks: box4.palmLandmarks };
}
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot2(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot2(rotationComponent[0], translationComponent),
-dot2(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot2(homogeneousCoordinate, rotationMatrix[0]),
dot2(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/anchors.ts
// src/hand/handposeanchors.ts
var anchors2 = [
{ x: 0.015625, y: 0.015625 },
{ x: 0.015625, y: 0.015625 },
@ -8712,7 +8773,7 @@ var anchors2 = [
{ x: 0.9375, y: 0.9375 }
];
// src/handpose/handdetector.ts
// src/hand/handposedetector.ts
var HandDetector = class {
constructor(model14) {
__publicField(this, "model");
@ -8787,70 +8848,7 @@ var HandDetector = class {
}
};
// src/handpose/util.ts
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot2(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot2(rotationComponent[0], translationComponent),
-dot2(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot2(homogeneousCoordinate, rotationMatrix[0]),
dot2(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/handpipeline.ts
// src/hand/handposepipeline.ts
var palmBoxEnlargeFactor = 5;
var handBoxEnlargeFactor = 1.65;
var palmLandmarkIds = [0, 5, 9, 13, 17, 1, 2];
@ -9370,7 +9368,7 @@ function match(keypoints) {
return poses;
}
// src/handpose/handpose.ts
// src/hand/handpose.ts
var meshAnnotations2 = {
thumb: [1, 2, 3, 4],
index: [5, 6, 7, 8],
@ -9395,24 +9393,24 @@ async function predict8(input, config3) {
}
}
const keypoints = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let box4 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw = [0, 0, 0, 0];
if (keypoints && keypoints.length > 0) {
for (const pt of keypoints) {
if (pt[0] < box6[0])
box6[0] = pt[0];
if (pt[1] < box6[1])
box6[1] = pt[1];
if (pt[0] > box6[2])
box6[2] = pt[0];
if (pt[1] > box6[3])
box6[3] = pt[1];
if (pt[0] < box4[0])
box4[0] = pt[0];
if (pt[1] < box4[1])
box4[1] = pt[1];
if (pt[0] > box4[2])
box4[2] = pt[0];
if (pt[1] > box4[3])
box4[3] = pt[1];
}
box6[2] -= box6[0];
box6[3] -= box6[1];
boxRaw = [box6[0] / (input.shape[2] || 0), box6[1] / (input.shape[1] || 0), box6[2] / (input.shape[2] || 0), box6[3] / (input.shape[1] || 0)];
box4[2] -= box4[0];
box4[3] -= box4[1];
boxRaw = [box4[0] / (input.shape[2] || 0), box4[1] / (input.shape[1] || 0), box4[2] / (input.shape[2] || 0), box4[3] / (input.shape[1] || 0)];
} else {
box6 = predictions[i].box ? [
box4 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
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])),
@ -9432,7 +9430,7 @@ async function predict8(input, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand",
box: box6,
box: box4,
boxRaw,
keypoints,
annotations: annotations2,
@ -9478,9 +9476,9 @@ function calc(keypoints, outputSize2 = [1, 1]) {
const coords8 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
const min = [Math.min(...coords8[0]), Math.min(...coords8[1])];
const max3 = [Math.max(...coords8[0]), Math.max(...coords8[1])];
const box6 = [min[0], min[1], max3[0] - min[0], max3[1] - min[1]];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [min[0], min[1], max3[0] - min[0], max3[1] - min[1]];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function square(keypoints, outputSize2 = [1, 1]) {
const coords8 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
@ -9488,22 +9486,22 @@ function square(keypoints, outputSize2 = [1, 1]) {
const max3 = [Math.max(...coords8[0]), Math.max(...coords8[1])];
const center = [(min[0] + max3[0]) / 2, (min[1] + max3[1]) / 2];
const dist = Math.max(center[0] - min[0], center[1] - min[1], -center[0] + max3[0], -center[1] + max3[1]);
const box6 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function scale(box6, scaleFact) {
const dist = [box6[2] * scaleFact, box6[3] * scaleFact];
function scale(box4, scaleFact) {
const dist = [box4[2] * scaleFact, box4[3] * scaleFact];
const newBox = [
box6[0] - (dist[0] - box6[2]) / 2,
box6[1] - (dist[1] - box6[3]) / 2,
box4[0] - (dist[0] - box4[2]) / 2,
box4[1] - (dist[1] - box4[3]) / 2,
dist[0],
dist[1]
];
return newBox;
}
function crop(box6) {
const yxBox = [Math.max(0, box6[1]), Math.max(0, box6[0]), Math.min(1, box6[3] + box6[1]), Math.min(1, box6[2] + box6[0])];
function crop(box4) {
const yxBox = [Math.max(0, box4[1]), Math.max(0, box4[0]), Math.min(1, box4[3] + box4[1]), Math.min(1, box4[2] + box4[0])];
return yxBox;
}
@ -9682,6 +9680,11 @@ async function predict9(input, config3) {
}
}
}
for (let i = 0; i < cache3.hands.length; i++) {
const bbox = calc(cache3.hands[i].keypoints, outputSize);
cache3.hands[i].box = bbox.box;
cache3.hands[i].boxRaw = bbox.boxRaw;
}
resolve(cache3.hands);
});
}
@ -10025,7 +10028,7 @@ async function process4(res, inputSize8, outputShape, config3) {
];
let boxRaw = [x, y, w, h];
boxRaw = boxRaw.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [
const box4 = [
boxRaw[0] * outputShape[0],
boxRaw[1] * outputShape[1],
boxRaw[2] * outputShape[0],
@ -10036,7 +10039,7 @@ async function process4(res, inputSize8, outputShape, config3) {
score: Math.round(100 * score) / 100,
class: j + 1,
label: labels[j].label,
box: box6.map((a) => Math.trunc(a)),
box: box4.map((a) => Math.trunc(a)),
boxRaw
};
results.push(result);
@ -10384,9 +10387,9 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
let keypoints = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints = keypoints.filter((a) => a.score > minConfidence2);
const score = getInstanceScore(poses, keypoints);
const box6 = getBoundingBox(keypoints);
const box4 = getBoundingBox(keypoints);
if (score > minConfidence2)
poses.push({ keypoints, box: box6, score: Math.round(100 * score) / 100 });
poses.push({ keypoints, box: box4, score: Math.round(100 * score) / 100 });
}
return poses;
}
@ -11620,7 +11623,7 @@ function calc2(newResult, config3) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else {
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 box4 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score,
@ -11652,14 +11655,14 @@ function calc2(newResult, config3) {
}
annotations2[name] = pt;
}
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw, keypoints, annotations: annotations2 };
bufferedResult.body[i] = { ...newResult.body[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else {
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 box4 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw = 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)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
@ -11673,14 +11676,14 @@ function calc2(newResult, config3) {
annotations2[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, keypoints, annotations: annotations2 };
bufferedResult.hand[i] = { ...newResult.hand[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else {
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 box4 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 } };
rotation.matrix = (_g = newResult.face[i].rotation) == null ? void 0 : _g.matrix;
@ -11693,16 +11696,16 @@ function calc2(newResult, config3) {
bearing: ((bufferedFactor - 1) * (((_u = (_t = bufferedResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.bearing) || 0) + (((_w = (_v = newResult.face[i].rotation) == null ? void 0 : _v.gaze) == null ? void 0 : _w.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_y = (_x = bufferedResult.face[i].rotation) == null ? void 0 : _x.gaze) == null ? void 0 : _y.strength) || 0) + (((_A = (_z = newResult.face[i].rotation) == null ? void 0 : _z.gaze) == null ? void 0 : _A.strength) || 0)) / bufferedFactor
};
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box4, boxRaw };
}
}
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else {
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 box4 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 };
bufferedResult.object[i] = { ...newResult.object[i], box: box4, boxRaw };
}
}
if (newResult.persons) {
@ -11711,7 +11714,7 @@ function calc2(newResult, config3) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else {
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((box4, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box4) / bufferedFactor);
}
}
}
@ -11794,10 +11797,10 @@ function join2(faces, bodies, hands, gestures, shape) {
}
const x = [];
const y = [];
const extractXY = (box6) => {
if (box6 && box6.length === 4) {
x.push(box6[0], box6[0] + box6[2]);
y.push(box6[1], box6[1] + box6[3]);
const extractXY = (box4) => {
if (box4 && box4.length === 4) {
x.push(box4[0], box4[0] + box4[2]);
y.push(box4[1], box4[1] + box4[3]);
}
};
extractXY((_k = person2.face) == null ? void 0 : _k.box);

File diff suppressed because one or more lines are too long

399
dist/human.esm.js vendored
View File

@ -72073,41 +72073,41 @@ var UV7 = VTX7.map((x) => UV468[x]);
// src/face/facemeshutil.ts
var createBox = (startEndTensor) => ({ startPoint: slice(startEndTensor, [0, 0], [-1, 2]), endPoint: slice(startEndTensor, [0, 2], [-1, 2]) });
var getBoxSize = (box6) => [Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box6.endPoint[1] - box6.startPoint[1])];
var getBoxCenter = (box6) => [box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2];
var getClampedBox = (box6, input2) => box6 ? [
Math.trunc(Math.max(0, box6.startPoint[0])),
Math.trunc(Math.max(0, box6.startPoint[1])),
Math.trunc(Math.min(input2.shape[2] || 0, box6.endPoint[0]) - Math.max(0, box6.startPoint[0])),
Math.trunc(Math.min(input2.shape[1] || 0, box6.endPoint[1]) - Math.max(0, box6.startPoint[1]))
var getBoxSize = (box4) => [Math.abs(box4.endPoint[0] - box4.startPoint[0]), Math.abs(box4.endPoint[1] - box4.startPoint[1])];
var getBoxCenter = (box4) => [box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2, box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2];
var getClampedBox = (box4, input2) => box4 ? [
Math.trunc(Math.max(0, box4.startPoint[0])),
Math.trunc(Math.max(0, box4.startPoint[1])),
Math.trunc(Math.min(input2.shape[2] || 0, box4.endPoint[0]) - Math.max(0, box4.startPoint[0])),
Math.trunc(Math.min(input2.shape[1] || 0, box4.endPoint[1]) - Math.max(0, box4.startPoint[1]))
] : [0, 0, 0, 0];
var getRawBox = (box6, input2) => box6 ? [
box6.startPoint[0] / (input2.shape[2] || 0),
box6.startPoint[1] / (input2.shape[1] || 0),
(box6.endPoint[0] - box6.startPoint[0]) / (input2.shape[2] || 0),
(box6.endPoint[1] - box6.startPoint[1]) / (input2.shape[1] || 0)
var getRawBox = (box4, input2) => box4 ? [
box4.startPoint[0] / (input2.shape[2] || 0),
box4.startPoint[1] / (input2.shape[1] || 0),
(box4.endPoint[0] - box4.startPoint[0]) / (input2.shape[2] || 0),
(box4.endPoint[1] - box4.startPoint[1]) / (input2.shape[1] || 0)
] : [0, 0, 0, 0];
var scaleBoxCoordinates = (box6, factor) => {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
var scaleBoxCoordinates = (box4, factor) => {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
return { startPoint, endPoint };
};
var cutBoxFromImageAndResize = (box6, image7, cropSize) => {
var cutBoxFromImageAndResize = (box4, image7, cropSize) => {
const h = image7.shape[1];
const w = image7.shape[2];
return image.cropAndResize(image7, [[box6.startPoint[1] / h, box6.startPoint[0] / w, box6.endPoint[1] / h, box6.endPoint[0] / w]], [0], cropSize);
return image.cropAndResize(image7, [[box4.startPoint[1] / h, box4.startPoint[0] / w, box4.endPoint[1] / h, box4.endPoint[0] / w]], [0], cropSize);
};
var enlargeBox = (box6, factor = 1.5) => {
const center = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var enlargeBox = (box4, factor = 1.5) => {
const center = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box6.landmarks };
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box4.landmarks };
};
var squarifyBox = (box6) => {
const centers = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var squarifyBox = (box4) => {
const centers = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = Math.max(...size2) / 2;
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box6.landmarks };
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box4.landmarks };
};
var calculateLandmarksBoundingBox = (landmarks) => {
const xs = landmarks.map((d) => d[0]);
@ -72175,8 +72175,8 @@ function generateAnchors(inputSize8) {
}
return anchors4;
}
function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / inputSize8 * (coord[0] - inputSize8 / 2),
boxSize[1] / inputSize8 * (coord[1] - inputSize8 / 2),
@ -72185,21 +72185,21 @@ function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8)
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1];
const boxCenter = [...getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint }), 1];
return coordsRotated.map((coord) => [
Math.round(coord[0] + dot4(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot4(boxCenter, inverseRotationMatrix[1])),
Math.round(coord[2] || 0)
]);
}
function correctFaceRotation(box6, input2, inputSize8) {
const symmetryLine = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[symmetryLine[0]], box6.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function correctFaceRotation(box4, input2, inputSize8) {
const symmetryLine = box4.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box4.landmarks[symmetryLine[0]], box4.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const faceCenterNormalized = [faceCenter[0] / input2.shape[2], faceCenter[1] / input2.shape[1]];
const rotated = image.rotateWithOffset(input2, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [inputSize8, inputSize8]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, rotated, [inputSize8, inputSize8]);
const face5 = div(cut, 255);
dispose(cut);
dispose(rotated);
@ -72626,13 +72626,13 @@ async function process3(res, outputShape, config3) {
detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y
];
const box6 = [
const box4 = [
Math.trunc(boxRaw[0] * outputShape[0]),
Math.trunc(boxRaw[1] * outputShape[1]),
Math.trunc(boxRaw[2] * outputShape[0]),
Math.trunc(boxRaw[3] * outputShape[1])
];
results.push({ id: i++, score, class: classVal, label, box: box6, boxRaw });
results.push({ id: i++, score, class: classVal, label, box: box4, boxRaw });
}
return results;
}
@ -72917,20 +72917,20 @@ var getLeftToRightEyeDepthDifference = (rawCoords) => {
return leftEyeZ - rightEyeZ;
};
var getEyeBox = (rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false, meshSize) => {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box6);
const box4 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box4);
let crop2 = image.cropAndResize(face5, [[
box6.startPoint[1] / meshSize,
box6.startPoint[0] / meshSize,
box6.endPoint[1] / meshSize,
box6.endPoint[0] / meshSize
box4.startPoint[1] / meshSize,
box4.startPoint[0] / meshSize,
box4.endPoint[1] / meshSize,
box4.endPoint[0] / meshSize
]], [0], [inputSize4, inputSize4]);
if (flip && env2.kernels.includes("flipleftright")) {
const flipped = image.flipLeftRight(crop2);
dispose(crop2);
crop2 = flipped;
}
return { box: box6, boxSize, crop: crop2 };
return { box: box4, boxSize, crop: crop2 };
};
var getEyeCoords = (eyeData, eyeBox, eyeBoxSize, flip = false) => {
const eyeRawCoords = [];
@ -73025,7 +73025,7 @@ async function predict6(input2, config3) {
const faces = [];
const newBoxes = [];
let id = 0;
for (let box6 of boxCache) {
for (let box4 of boxCache) {
let angle = 0;
let rotationMatrix;
const face5 = {
@ -73040,21 +73040,21 @@ async function predict6(input2, config3) {
annotations: {}
};
if (((_d = config3.face.detector) == null ? void 0 : _d.rotation) && ((_e = config3.face.mesh) == null ? void 0 : _e.enabled) && env2.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input2, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input2, inputSize5);
} else {
rotationMatrix = IDENTITY_MATRIX;
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, input2, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, input2, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
face5.tensor = div(cut, 255);
dispose(cut);
}
face5.boxScore = Math.round(100 * box6.confidence) / 100;
face5.boxScore = Math.round(100 * box4.confidence) / 100;
if (!((_g = config3.face.mesh) == null ? void 0 : _g.enabled)) {
face5.box = getClampedBox(box6, input2);
face5.boxRaw = getRawBox(box6, input2);
face5.score = Math.round(100 * box6.confidence || 0) / 100;
face5.mesh = box6.landmarks.map((pt) => [
(box6.startPoint[0] + box6.endPoint[0]) / 2 + (box6.endPoint[0] + box6.startPoint[0]) * pt[0] / size(),
(box6.startPoint[1] + box6.endPoint[1]) / 2 + (box6.endPoint[1] + box6.startPoint[1]) * pt[1] / size()
face5.box = getClampedBox(box4, input2);
face5.boxRaw = getRawBox(box4, input2);
face5.score = Math.round(100 * box4.confidence || 0) / 100;
face5.mesh = box4.landmarks.map((pt) => [
(box4.startPoint[0] + box4.endPoint[0]) / 2 + (box4.endPoint[0] + box4.startPoint[0]) * pt[0] / size(),
(box4.startPoint[1] + box4.endPoint[1]) / 2 + (box4.endPoint[1] + box4.startPoint[1]) * pt[1] / size()
]);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input2.shape[2] || 0), pt[1] / (input2.shape[1] || 0), (pt[2] || 0) / inputSize5]);
for (const key of Object.keys(blazeFaceLandmarks))
@ -73072,28 +73072,28 @@ async function predict6(input2, config3) {
dispose(contourCoords);
dispose(coordsReshaped);
if (faceConfidence < (((_h = config3.face.detector) == null ? void 0 : _h.minConfidence) || 1)) {
box6.confidence = faceConfidence;
box4.confidence = faceConfidence;
} else {
if ((_i = config3.face.iris) == null ? void 0 : _i.enabled)
rawCoords = await augmentIris(rawCoords, face5.tensor, config3, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize5);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input2.shape[2] || 0), pt[1] / (input2.shape[1] || 0), (pt[2] || 0) / inputSize5]);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box6.confidence };
box4 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box4.confidence };
for (const key of Object.keys(meshAnnotations))
face5.annotations[key] = meshAnnotations[key].map((index) => face5.mesh[index]);
if (((_j = config3.face.detector) == null ? void 0 : _j.rotation) && config3.face.mesh.enabled && ((_k = config3.face.description) == null ? void 0 : _k.enabled) && env2.kernels.includes("rotatewithoffset")) {
dispose(face5.tensor);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input2, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input2, inputSize5);
}
face5.box = getClampedBox(box6, input2);
face5.boxRaw = getRawBox(box6, input2);
face5.score = Math.round(100 * faceConfidence || 100 * box6.confidence || 0) / 100;
face5.box = getClampedBox(box4, input2);
face5.boxRaw = getRawBox(box4, input2);
face5.score = Math.round(100 * faceConfidence || 100 * box4.confidence || 0) / 100;
face5.faceScore = Math.round(100 * faceConfidence) / 100;
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence };
box4 = { ...squarifyBox(box4), confidence: box4.confidence, faceConfidence };
}
}
faces.push(face5);
newBoxes.push(box6);
newBoxes.push(box4);
}
if ((_l = config3.face.mesh) == null ? void 0 : _l.enabled)
boxCache = newBoxes.filter((a) => {
@ -73148,10 +73148,10 @@ function enhance(input2) {
const tensor2 = input2.image || input2.tensor || input2;
if (!(tensor2 instanceof Tensor))
return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]];
const box4 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model10 == null ? void 0 : model10.inputs[0].shape))
return null;
const crop2 = tensor2.shape.length === 3 ? image.cropAndResize(expandDims(tensor2, 0), box6, [0], [model10.inputs[0].shape[2], model10.inputs[0].shape[1]]) : image.cropAndResize(tensor2, box6, [0], [model10.inputs[0].shape[2], model10.inputs[0].shape[1]]);
const crop2 = tensor2.shape.length === 3 ? image.cropAndResize(expandDims(tensor2, 0), box4, [0], [model10.inputs[0].shape[2], model10.inputs[0].shape[1]]) : image.cropAndResize(tensor2, box4, [0], [model10.inputs[0].shape[2], model10.inputs[0].shape[1]]);
const norm2 = mul(crop2, 255);
return norm2;
});
@ -73202,58 +73202,119 @@ async function predict7(image7, config3, idx, count3) {
});
}
// src/handpose/box.ts
function getBoxSize2(box6) {
// src/hand/handposeutil.ts
function getBoxSize2(box4) {
return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1])
Math.abs(box4.endPoint[0] - box4.startPoint[0]),
Math.abs(box4.endPoint[1] - box4.startPoint[1])
];
}
function getBoxCenter2(box6) {
function getBoxCenter2(box4) {
return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2
box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2,
box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2
];
}
function cutBoxFromImageAndResize2(box6, image7, cropSize) {
function cutBoxFromImageAndResize2(box4, image7, cropSize) {
const h = image7.shape[1];
const w = image7.shape[2];
const boxes = [[
box6.startPoint[1] / h,
box6.startPoint[0] / w,
box6.endPoint[1] / h,
box6.endPoint[0] / w
box4.startPoint[1] / h,
box4.startPoint[0] / w,
box4.endPoint[1] / h,
box4.endPoint[0] / w
]];
return image.cropAndResize(image7, boxes, [0], cropSize);
}
function scaleBoxCoordinates2(box6, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => {
function scaleBoxCoordinates2(box4, factor) {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
const palmLandmarks = box4.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord;
});
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence };
return { startPoint, endPoint, palmLandmarks, confidence: box4.confidence };
}
function enlargeBox2(box6, factor = 1.5) {
const center = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function enlargeBox2(box4, factor = 1.5) {
const center = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const newHalfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
const startPoint = [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: box4.palmLandmarks };
}
function squarifyBox2(box6) {
const centers = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function squarifyBox2(box4) {
const centers = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const maxEdge = Math.max(...size2);
const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks };
return { startPoint, endPoint, palmLandmarks: box4.palmLandmarks };
}
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot5(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot5(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot5(rotationComponent[0], translationComponent),
-dot5(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot5(homogeneousCoordinate, rotationMatrix[0]),
dot5(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/anchors.ts
// src/hand/handposeanchors.ts
var anchors2 = [
{ x: 0.015625, y: 0.015625 },
{ x: 0.015625, y: 0.015625 },
@ -76201,7 +76262,7 @@ var anchors2 = [
{ x: 0.9375, y: 0.9375 }
];
// src/handpose/handdetector.ts
// src/hand/handposedetector.ts
var HandDetector = class {
constructor(model15) {
__publicField(this, "model");
@ -76276,70 +76337,7 @@ var HandDetector = class {
}
};
// src/handpose/util.ts
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot5(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot5(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot5(rotationComponent[0], translationComponent),
-dot5(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot5(homogeneousCoordinate, rotationMatrix[0]),
dot5(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/handpipeline.ts
// src/hand/handposepipeline.ts
var palmBoxEnlargeFactor = 5;
var handBoxEnlargeFactor = 1.65;
var palmLandmarkIds = [0, 5, 9, 13, 17, 1, 2];
@ -76859,7 +76857,7 @@ function match(keypoints) {
return poses;
}
// src/handpose/handpose.ts
// src/hand/handpose.ts
var meshAnnotations2 = {
thumb: [1, 2, 3, 4],
index: [5, 6, 7, 8],
@ -76884,24 +76882,24 @@ async function predict8(input2, config3) {
}
}
const keypoints = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let box4 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw = [0, 0, 0, 0];
if (keypoints && keypoints.length > 0) {
for (const pt of keypoints) {
if (pt[0] < box6[0])
box6[0] = pt[0];
if (pt[1] < box6[1])
box6[1] = pt[1];
if (pt[0] > box6[2])
box6[2] = pt[0];
if (pt[1] > box6[3])
box6[3] = pt[1];
if (pt[0] < box4[0])
box4[0] = pt[0];
if (pt[1] < box4[1])
box4[1] = pt[1];
if (pt[0] > box4[2])
box4[2] = pt[0];
if (pt[1] > box4[3])
box4[3] = pt[1];
}
box6[2] -= box6[0];
box6[3] -= box6[1];
boxRaw = [box6[0] / (input2.shape[2] || 0), box6[1] / (input2.shape[1] || 0), box6[2] / (input2.shape[2] || 0), box6[3] / (input2.shape[1] || 0)];
box4[2] -= box4[0];
box4[3] -= box4[1];
boxRaw = [box4[0] / (input2.shape[2] || 0), box4[1] / (input2.shape[1] || 0), box4[2] / (input2.shape[2] || 0), box4[3] / (input2.shape[1] || 0)];
} else {
box6 = predictions[i].box ? [
box4 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
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])),
@ -76921,7 +76919,7 @@ async function predict8(input2, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand",
box: box6,
box: box4,
boxRaw,
keypoints,
annotations: annotations2,
@ -76967,9 +76965,9 @@ function calc(keypoints, outputSize2 = [1, 1]) {
const coords10 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
const min7 = [Math.min(...coords10[0]), Math.min(...coords10[1])];
const max7 = [Math.max(...coords10[0]), Math.max(...coords10[1])];
const box6 = [min7[0], min7[1], max7[0] - min7[0], max7[1] - min7[1]];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [min7[0], min7[1], max7[0] - min7[0], max7[1] - min7[1]];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function square4(keypoints, outputSize2 = [1, 1]) {
const coords10 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
@ -76977,22 +76975,22 @@ function square4(keypoints, outputSize2 = [1, 1]) {
const max7 = [Math.max(...coords10[0]), Math.max(...coords10[1])];
const center = [(min7[0] + max7[0]) / 2, (min7[1] + max7[1]) / 2];
const dist = Math.max(center[0] - min7[0], center[1] - min7[1], -center[0] + max7[0], -center[1] + max7[1]);
const box6 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function scale2(box6, scaleFact) {
const dist = [box6[2] * scaleFact, box6[3] * scaleFact];
function scale2(box4, scaleFact) {
const dist = [box4[2] * scaleFact, box4[3] * scaleFact];
const newBox = [
box6[0] - (dist[0] - box6[2]) / 2,
box6[1] - (dist[1] - box6[3]) / 2,
box4[0] - (dist[0] - box4[2]) / 2,
box4[1] - (dist[1] - box4[3]) / 2,
dist[0],
dist[1]
];
return newBox;
}
function crop(box6) {
const yxBox = [Math.max(0, box6[1]), Math.max(0, box6[0]), Math.min(1, box6[3] + box6[1]), Math.min(1, box6[2] + box6[0])];
function crop(box4) {
const yxBox = [Math.max(0, box4[1]), Math.max(0, box4[0]), Math.min(1, box4[3] + box4[1]), Math.min(1, box4[2] + box4[0])];
return yxBox;
}
@ -77171,6 +77169,11 @@ async function predict9(input2, config3) {
}
}
}
for (let i = 0; i < cache3.hands.length; i++) {
const bbox = calc(cache3.hands[i].keypoints, outputSize);
cache3.hands[i].box = bbox.box;
cache3.hands[i].boxRaw = bbox.boxRaw;
}
resolve(cache3.hands);
});
}
@ -77514,7 +77517,7 @@ async function process4(res, inputSize8, outputShape, config3) {
];
let boxRaw = [x, y, w, h];
boxRaw = boxRaw.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [
const box4 = [
boxRaw[0] * outputShape[0],
boxRaw[1] * outputShape[1],
boxRaw[2] * outputShape[0],
@ -77525,7 +77528,7 @@ async function process4(res, inputSize8, outputShape, config3) {
score: Math.round(100 * score) / 100,
class: j + 1,
label: labels[j].label,
box: box6.map((a) => Math.trunc(a)),
box: box4.map((a) => Math.trunc(a)),
boxRaw
};
results.push(result);
@ -77873,9 +77876,9 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
let keypoints = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints = keypoints.filter((a) => a.score > minConfidence2);
const score = getInstanceScore(poses, keypoints);
const box6 = getBoundingBox(keypoints);
const box4 = getBoundingBox(keypoints);
if (score > minConfidence2)
poses.push({ keypoints, box: box6, score: Math.round(100 * score) / 100 });
poses.push({ keypoints, box: box4, score: Math.round(100 * score) / 100 });
}
return poses;
}
@ -79109,7 +79112,7 @@ function calc2(newResult, config3) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else {
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 box4 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score,
@ -79141,14 +79144,14 @@ function calc2(newResult, config3) {
}
annotations2[name] = pt;
}
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw, keypoints, annotations: annotations2 };
bufferedResult.body[i] = { ...newResult.body[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else {
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 box4 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw = 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)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
@ -79162,14 +79165,14 @@ function calc2(newResult, config3) {
annotations2[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, keypoints, annotations: annotations2 };
bufferedResult.hand[i] = { ...newResult.hand[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else {
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 box4 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 } };
rotation.matrix = (_g = newResult.face[i].rotation) == null ? void 0 : _g.matrix;
@ -79182,16 +79185,16 @@ function calc2(newResult, config3) {
bearing: ((bufferedFactor - 1) * (((_u = (_t = bufferedResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.bearing) || 0) + (((_w = (_v = newResult.face[i].rotation) == null ? void 0 : _v.gaze) == null ? void 0 : _w.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_y = (_x = bufferedResult.face[i].rotation) == null ? void 0 : _x.gaze) == null ? void 0 : _y.strength) || 0) + (((_A = (_z = newResult.face[i].rotation) == null ? void 0 : _z.gaze) == null ? void 0 : _A.strength) || 0)) / bufferedFactor
};
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box4, boxRaw };
}
}
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else {
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 box4 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 };
bufferedResult.object[i] = { ...newResult.object[i], box: box4, boxRaw };
}
}
if (newResult.persons) {
@ -79200,7 +79203,7 @@ function calc2(newResult, config3) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else {
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((box4, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box4) / bufferedFactor);
}
}
}
@ -79283,10 +79286,10 @@ function join2(faces, bodies, hands, gestures, shape) {
}
const x = [];
const y = [];
const extractXY = (box6) => {
if (box6 && box6.length === 4) {
x.push(box6[0], box6[0] + box6[2]);
y.push(box6[1], box6[1] + box6[3]);
const extractXY = (box4) => {
if (box4 && box4.length === 4) {
x.push(box4[0], box4[0] + box4[2]);
y.push(box4[1], box4[1] + box4[3]);
}
};
extractXY((_k = person2.face) == null ? void 0 : _k.box);

File diff suppressed because one or more lines are too long

356
dist/human.js vendored

File diff suppressed because one or more lines are too long

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

@ -4613,41 +4613,41 @@ var UV7 = VTX7.map((x) => UV468[x]);
// src/face/facemeshutil.ts
var createBox = (startEndTensor) => ({ startPoint: tf5.slice(startEndTensor, [0, 0], [-1, 2]), endPoint: tf5.slice(startEndTensor, [0, 2], [-1, 2]) });
var getBoxSize = (box6) => [Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box6.endPoint[1] - box6.startPoint[1])];
var getBoxCenter = (box6) => [box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2];
var getClampedBox = (box6, input) => box6 ? [
Math.trunc(Math.max(0, box6.startPoint[0])),
Math.trunc(Math.max(0, box6.startPoint[1])),
Math.trunc(Math.min(input.shape[2] || 0, box6.endPoint[0]) - Math.max(0, box6.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, box6.endPoint[1]) - Math.max(0, box6.startPoint[1]))
var getBoxSize = (box4) => [Math.abs(box4.endPoint[0] - box4.startPoint[0]), Math.abs(box4.endPoint[1] - box4.startPoint[1])];
var getBoxCenter = (box4) => [box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2, box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2];
var getClampedBox = (box4, input) => box4 ? [
Math.trunc(Math.max(0, box4.startPoint[0])),
Math.trunc(Math.max(0, box4.startPoint[1])),
Math.trunc(Math.min(input.shape[2] || 0, box4.endPoint[0]) - Math.max(0, box4.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, box4.endPoint[1]) - Math.max(0, box4.startPoint[1]))
] : [0, 0, 0, 0];
var getRawBox = (box6, input) => box6 ? [
box6.startPoint[0] / (input.shape[2] || 0),
box6.startPoint[1] / (input.shape[1] || 0),
(box6.endPoint[0] - box6.startPoint[0]) / (input.shape[2] || 0),
(box6.endPoint[1] - box6.startPoint[1]) / (input.shape[1] || 0)
var getRawBox = (box4, input) => box4 ? [
box4.startPoint[0] / (input.shape[2] || 0),
box4.startPoint[1] / (input.shape[1] || 0),
(box4.endPoint[0] - box4.startPoint[0]) / (input.shape[2] || 0),
(box4.endPoint[1] - box4.startPoint[1]) / (input.shape[1] || 0)
] : [0, 0, 0, 0];
var scaleBoxCoordinates = (box6, factor) => {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
var scaleBoxCoordinates = (box4, factor) => {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
return { startPoint, endPoint };
};
var cutBoxFromImageAndResize = (box6, image25, cropSize) => {
var cutBoxFromImageAndResize = (box4, image25, cropSize) => {
const h = image25.shape[1];
const w = image25.shape[2];
return tf5.image.cropAndResize(image25, [[box6.startPoint[1] / h, box6.startPoint[0] / w, box6.endPoint[1] / h, box6.endPoint[0] / w]], [0], cropSize);
return tf5.image.cropAndResize(image25, [[box4.startPoint[1] / h, box4.startPoint[0] / w, box4.endPoint[1] / h, box4.endPoint[0] / w]], [0], cropSize);
};
var enlargeBox = (box6, factor = 1.5) => {
const center = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var enlargeBox = (box4, factor = 1.5) => {
const center = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box6.landmarks };
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box4.landmarks };
};
var squarifyBox = (box6) => {
const centers = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var squarifyBox = (box4) => {
const centers = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = Math.max(...size2) / 2;
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box6.landmarks };
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box4.landmarks };
};
var calculateLandmarksBoundingBox = (landmarks) => {
const xs = landmarks.map((d) => d[0]);
@ -4715,8 +4715,8 @@ function generateAnchors(inputSize8) {
}
return anchors4;
}
function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / inputSize8 * (coord[0] - inputSize8 / 2),
boxSize[1] / inputSize8 * (coord[1] - inputSize8 / 2),
@ -4725,21 +4725,21 @@ function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8)
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1];
const boxCenter = [...getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint }), 1];
return coordsRotated.map((coord) => [
Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])),
Math.round(coord[2] || 0)
]);
}
function correctFaceRotation(box6, input, inputSize8) {
const symmetryLine = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[symmetryLine[0]], box6.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function correctFaceRotation(box4, input, inputSize8) {
const symmetryLine = box4.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box4.landmarks[symmetryLine[0]], box4.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]];
const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [inputSize8, inputSize8]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, rotated, [inputSize8, inputSize8]);
const face5 = tf5.div(cut, 255);
tf5.dispose(cut);
tf5.dispose(rotated);
@ -5172,13 +5172,13 @@ async function process3(res, outputShape, config3) {
detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y
];
const box6 = [
const box4 = [
Math.trunc(boxRaw[0] * outputShape[0]),
Math.trunc(boxRaw[1] * outputShape[1]),
Math.trunc(boxRaw[2] * outputShape[0]),
Math.trunc(boxRaw[3] * outputShape[1])
];
results.push({ id: i++, score, class: classVal, label, box: box6, boxRaw });
results.push({ id: i++, score, class: classVal, label, box: box4, boxRaw });
}
return results;
}
@ -5471,20 +5471,20 @@ var getLeftToRightEyeDepthDifference = (rawCoords) => {
return leftEyeZ - rightEyeZ;
};
var getEyeBox = (rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false, meshSize) => {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box6);
const box4 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box4);
let crop2 = tf11.image.cropAndResize(face5, [[
box6.startPoint[1] / meshSize,
box6.startPoint[0] / meshSize,
box6.endPoint[1] / meshSize,
box6.endPoint[0] / meshSize
box4.startPoint[1] / meshSize,
box4.startPoint[0] / meshSize,
box4.endPoint[1] / meshSize,
box4.endPoint[0] / meshSize
]], [0], [inputSize4, inputSize4]);
if (flip && env2.kernels.includes("flipleftright")) {
const flipped = tf11.image.flipLeftRight(crop2);
tf11.dispose(crop2);
crop2 = flipped;
}
return { box: box6, boxSize, crop: crop2 };
return { box: box4, boxSize, crop: crop2 };
};
var getEyeCoords = (eyeData, eyeBox, eyeBoxSize, flip = false) => {
const eyeRawCoords = [];
@ -5579,7 +5579,7 @@ async function predict6(input, config3) {
const faces = [];
const newBoxes = [];
let id = 0;
for (let box6 of boxCache) {
for (let box4 of boxCache) {
let angle = 0;
let rotationMatrix;
const face5 = {
@ -5594,21 +5594,21 @@ async function predict6(input, config3) {
annotations: {}
};
if (((_d = config3.face.detector) == null ? void 0 : _d.rotation) && ((_e = config3.face.mesh) == null ? void 0 : _e.enabled) && env2.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input, inputSize5);
} else {
rotationMatrix = IDENTITY_MATRIX;
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, input, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, input, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
face5.tensor = tf12.div(cut, 255);
tf12.dispose(cut);
}
face5.boxScore = Math.round(100 * box6.confidence) / 100;
face5.boxScore = Math.round(100 * box4.confidence) / 100;
if (!((_g = config3.face.mesh) == null ? void 0 : _g.enabled)) {
face5.box = getClampedBox(box6, input);
face5.boxRaw = getRawBox(box6, input);
face5.score = Math.round(100 * box6.confidence || 0) / 100;
face5.mesh = box6.landmarks.map((pt) => [
(box6.startPoint[0] + box6.endPoint[0]) / 2 + (box6.endPoint[0] + box6.startPoint[0]) * pt[0] / size(),
(box6.startPoint[1] + box6.endPoint[1]) / 2 + (box6.endPoint[1] + box6.startPoint[1]) * pt[1] / size()
face5.box = getClampedBox(box4, input);
face5.boxRaw = getRawBox(box4, input);
face5.score = Math.round(100 * box4.confidence || 0) / 100;
face5.mesh = box4.landmarks.map((pt) => [
(box4.startPoint[0] + box4.endPoint[0]) / 2 + (box4.endPoint[0] + box4.startPoint[0]) * pt[0] / size(),
(box4.startPoint[1] + box4.endPoint[1]) / 2 + (box4.endPoint[1] + box4.startPoint[1]) * pt[1] / size()
]);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize5]);
for (const key of Object.keys(blazeFaceLandmarks))
@ -5626,28 +5626,28 @@ async function predict6(input, config3) {
tf12.dispose(contourCoords);
tf12.dispose(coordsReshaped);
if (faceConfidence < (((_h = config3.face.detector) == null ? void 0 : _h.minConfidence) || 1)) {
box6.confidence = faceConfidence;
box4.confidence = faceConfidence;
} else {
if ((_i = config3.face.iris) == null ? void 0 : _i.enabled)
rawCoords = await augmentIris(rawCoords, face5.tensor, config3, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize5);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize5]);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box6.confidence };
box4 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box4.confidence };
for (const key of Object.keys(meshAnnotations))
face5.annotations[key] = meshAnnotations[key].map((index) => face5.mesh[index]);
if (((_j = config3.face.detector) == null ? void 0 : _j.rotation) && config3.face.mesh.enabled && ((_k = config3.face.description) == null ? void 0 : _k.enabled) && env2.kernels.includes("rotatewithoffset")) {
tf12.dispose(face5.tensor);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input, inputSize5);
}
face5.box = getClampedBox(box6, input);
face5.boxRaw = getRawBox(box6, input);
face5.score = Math.round(100 * faceConfidence || 100 * box6.confidence || 0) / 100;
face5.box = getClampedBox(box4, input);
face5.boxRaw = getRawBox(box4, input);
face5.score = Math.round(100 * faceConfidence || 100 * box4.confidence || 0) / 100;
face5.faceScore = Math.round(100 * faceConfidence) / 100;
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence };
box4 = { ...squarifyBox(box4), confidence: box4.confidence, faceConfidence };
}
}
faces.push(face5);
newBoxes.push(box6);
newBoxes.push(box4);
}
if ((_l = config3.face.mesh) == null ? void 0 : _l.enabled)
boxCache = newBoxes.filter((a) => {
@ -5703,10 +5703,10 @@ function enhance(input) {
const tensor3 = input.image || input.tensor || input;
if (!(tensor3 instanceof tf13.Tensor))
return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]];
const box4 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model9 == null ? void 0 : model9.inputs[0].shape))
return null;
const crop2 = tensor3.shape.length === 3 ? tf13.image.cropAndResize(tf13.expandDims(tensor3, 0), box6, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]) : tf13.image.cropAndResize(tensor3, box6, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]);
const crop2 = tensor3.shape.length === 3 ? tf13.image.cropAndResize(tf13.expandDims(tensor3, 0), box4, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]) : tf13.image.cropAndResize(tensor3, box4, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]);
const norm = tf13.mul(crop2, 255);
return norm;
});
@ -5757,65 +5757,126 @@ async function predict7(image25, config3, idx, count2) {
});
}
// src/handpose/handpose.ts
// src/hand/handpose.ts
var tf17 = __toModule(require_tfjs_esm());
// src/handpose/handdetector.ts
// src/hand/handposedetector.ts
var tf15 = __toModule(require_tfjs_esm());
// src/handpose/box.ts
// src/hand/handposeutil.ts
var tf14 = __toModule(require_tfjs_esm());
function getBoxSize2(box6) {
function getBoxSize2(box4) {
return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1])
Math.abs(box4.endPoint[0] - box4.startPoint[0]),
Math.abs(box4.endPoint[1] - box4.startPoint[1])
];
}
function getBoxCenter2(box6) {
function getBoxCenter2(box4) {
return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2
box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2,
box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2
];
}
function cutBoxFromImageAndResize2(box6, image25, cropSize) {
function cutBoxFromImageAndResize2(box4, image25, cropSize) {
const h = image25.shape[1];
const w = image25.shape[2];
const boxes = [[
box6.startPoint[1] / h,
box6.startPoint[0] / w,
box6.endPoint[1] / h,
box6.endPoint[0] / w
box4.startPoint[1] / h,
box4.startPoint[0] / w,
box4.endPoint[1] / h,
box4.endPoint[0] / w
]];
return tf14.image.cropAndResize(image25, boxes, [0], cropSize);
}
function scaleBoxCoordinates2(box6, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => {
function scaleBoxCoordinates2(box4, factor) {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
const palmLandmarks = box4.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord;
});
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence };
return { startPoint, endPoint, palmLandmarks, confidence: box4.confidence };
}
function enlargeBox2(box6, factor = 1.5) {
const center = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function enlargeBox2(box4, factor = 1.5) {
const center = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const newHalfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
const startPoint = [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: box4.palmLandmarks };
}
function squarifyBox2(box6) {
const centers = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function squarifyBox2(box4) {
const centers = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const maxEdge = Math.max(...size2);
const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks };
return { startPoint, endPoint, palmLandmarks: box4.palmLandmarks };
}
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot2(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot2(rotationComponent[0], translationComponent),
-dot2(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot2(homogeneousCoordinate, rotationMatrix[0]),
dot2(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/anchors.ts
// src/hand/handposeanchors.ts
var anchors2 = [
{ x: 0.015625, y: 0.015625 },
{ x: 0.015625, y: 0.015625 },
@ -8763,7 +8824,7 @@ var anchors2 = [
{ x: 0.9375, y: 0.9375 }
];
// src/handpose/handdetector.ts
// src/hand/handposedetector.ts
var HandDetector = class {
constructor(model14) {
__publicField(this, "model");
@ -8838,73 +8899,8 @@ var HandDetector = class {
}
};
// src/handpose/handpipeline.ts
// src/hand/handposepipeline.ts
var tf16 = __toModule(require_tfjs_esm());
// src/handpose/util.ts
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot2(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot2(rotationComponent[0], translationComponent),
-dot2(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot2(homogeneousCoordinate, rotationMatrix[0]),
dot2(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/handpipeline.ts
var palmBoxEnlargeFactor = 5;
var handBoxEnlargeFactor = 1.65;
var palmLandmarkIds = [0, 5, 9, 13, 17, 1, 2];
@ -9424,7 +9420,7 @@ function match(keypoints) {
return poses;
}
// src/handpose/handpose.ts
// src/hand/handpose.ts
var meshAnnotations2 = {
thumb: [1, 2, 3, 4],
index: [5, 6, 7, 8],
@ -9449,24 +9445,24 @@ async function predict8(input, config3) {
}
}
const keypoints = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let box4 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw = [0, 0, 0, 0];
if (keypoints && keypoints.length > 0) {
for (const pt of keypoints) {
if (pt[0] < box6[0])
box6[0] = pt[0];
if (pt[1] < box6[1])
box6[1] = pt[1];
if (pt[0] > box6[2])
box6[2] = pt[0];
if (pt[1] > box6[3])
box6[3] = pt[1];
if (pt[0] < box4[0])
box4[0] = pt[0];
if (pt[1] < box4[1])
box4[1] = pt[1];
if (pt[0] > box4[2])
box4[2] = pt[0];
if (pt[1] > box4[3])
box4[3] = pt[1];
}
box6[2] -= box6[0];
box6[3] -= box6[1];
boxRaw = [box6[0] / (input.shape[2] || 0), box6[1] / (input.shape[1] || 0), box6[2] / (input.shape[2] || 0), box6[3] / (input.shape[1] || 0)];
box4[2] -= box4[0];
box4[3] -= box4[1];
boxRaw = [box4[0] / (input.shape[2] || 0), box4[1] / (input.shape[1] || 0), box4[2] / (input.shape[2] || 0), box4[3] / (input.shape[1] || 0)];
} else {
box6 = predictions[i].box ? [
box4 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
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])),
@ -9486,7 +9482,7 @@ async function predict8(input, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand",
box: box6,
box: box4,
boxRaw,
keypoints,
annotations: annotations2,
@ -9532,9 +9528,9 @@ function calc(keypoints, outputSize2 = [1, 1]) {
const coords8 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
const min = [Math.min(...coords8[0]), Math.min(...coords8[1])];
const max3 = [Math.max(...coords8[0]), Math.max(...coords8[1])];
const box6 = [min[0], min[1], max3[0] - min[0], max3[1] - min[1]];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [min[0], min[1], max3[0] - min[0], max3[1] - min[1]];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function square(keypoints, outputSize2 = [1, 1]) {
const coords8 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
@ -9542,22 +9538,22 @@ function square(keypoints, outputSize2 = [1, 1]) {
const max3 = [Math.max(...coords8[0]), Math.max(...coords8[1])];
const center = [(min[0] + max3[0]) / 2, (min[1] + max3[1]) / 2];
const dist = Math.max(center[0] - min[0], center[1] - min[1], -center[0] + max3[0], -center[1] + max3[1]);
const box6 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function scale(box6, scaleFact) {
const dist = [box6[2] * scaleFact, box6[3] * scaleFact];
function scale(box4, scaleFact) {
const dist = [box4[2] * scaleFact, box4[3] * scaleFact];
const newBox = [
box6[0] - (dist[0] - box6[2]) / 2,
box6[1] - (dist[1] - box6[3]) / 2,
box4[0] - (dist[0] - box4[2]) / 2,
box4[1] - (dist[1] - box4[3]) / 2,
dist[0],
dist[1]
];
return newBox;
}
function crop(box6) {
const yxBox = [Math.max(0, box6[1]), Math.max(0, box6[0]), Math.min(1, box6[3] + box6[1]), Math.min(1, box6[2] + box6[0])];
function crop(box4) {
const yxBox = [Math.max(0, box4[1]), Math.max(0, box4[0]), Math.min(1, box4[3] + box4[1]), Math.min(1, box4[2] + box4[0])];
return yxBox;
}
@ -9737,6 +9733,11 @@ async function predict9(input, config3) {
}
}
}
for (let i = 0; i < cache3.hands.length; i++) {
const bbox = calc(cache3.hands[i].keypoints, outputSize);
cache3.hands[i].box = bbox.box;
cache3.hands[i].boxRaw = bbox.boxRaw;
}
resolve(cache3.hands);
});
}
@ -10085,7 +10086,7 @@ async function process4(res, inputSize8, outputShape, config3) {
];
let boxRaw = [x, y, w, h];
boxRaw = boxRaw.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [
const box4 = [
boxRaw[0] * outputShape[0],
boxRaw[1] * outputShape[1],
boxRaw[2] * outputShape[0],
@ -10096,7 +10097,7 @@ async function process4(res, inputSize8, outputShape, config3) {
score: Math.round(100 * score) / 100,
class: j + 1,
label: labels[j].label,
box: box6.map((a) => Math.trunc(a)),
box: box4.map((a) => Math.trunc(a)),
boxRaw
};
results.push(result);
@ -10447,9 +10448,9 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
let keypoints = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints = keypoints.filter((a) => a.score > minConfidence2);
const score = getInstanceScore(poses, keypoints);
const box6 = getBoundingBox(keypoints);
const box4 = getBoundingBox(keypoints);
if (score > minConfidence2)
poses.push({ keypoints, box: box6, score: Math.round(100 * score) / 100 });
poses.push({ keypoints, box: box4, score: Math.round(100 * score) / 100 });
}
return poses;
}
@ -11688,7 +11689,7 @@ function calc2(newResult, config3) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else {
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 box4 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score,
@ -11720,14 +11721,14 @@ function calc2(newResult, config3) {
}
annotations2[name] = pt;
}
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw, keypoints, annotations: annotations2 };
bufferedResult.body[i] = { ...newResult.body[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else {
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 box4 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw = 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)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
@ -11741,14 +11742,14 @@ function calc2(newResult, config3) {
annotations2[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, keypoints, annotations: annotations2 };
bufferedResult.hand[i] = { ...newResult.hand[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else {
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 box4 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 } };
rotation.matrix = (_g = newResult.face[i].rotation) == null ? void 0 : _g.matrix;
@ -11761,16 +11762,16 @@ function calc2(newResult, config3) {
bearing: ((bufferedFactor - 1) * (((_u = (_t = bufferedResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.bearing) || 0) + (((_w = (_v = newResult.face[i].rotation) == null ? void 0 : _v.gaze) == null ? void 0 : _w.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_y = (_x = bufferedResult.face[i].rotation) == null ? void 0 : _x.gaze) == null ? void 0 : _y.strength) || 0) + (((_A = (_z = newResult.face[i].rotation) == null ? void 0 : _z.gaze) == null ? void 0 : _A.strength) || 0)) / bufferedFactor
};
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box4, boxRaw };
}
}
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else {
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 box4 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 };
bufferedResult.object[i] = { ...newResult.object[i], box: box4, boxRaw };
}
}
if (newResult.persons) {
@ -11779,7 +11780,7 @@ function calc2(newResult, config3) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else {
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((box4, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box4) / bufferedFactor);
}
}
}
@ -11862,10 +11863,10 @@ function join2(faces, bodies, hands, gestures, shape) {
}
const x = [];
const y = [];
const extractXY = (box6) => {
if (box6 && box6.length === 4) {
x.push(box6[0], box6[0] + box6[2]);
y.push(box6[1], box6[1] + box6[3]);
const extractXY = (box4) => {
if (box4 && box4.length === 4) {
x.push(box4[0], box4[0] + box4[2]);
y.push(box4[1], box4[1] + box4[3]);
}
};
extractXY((_k = person2.face) == null ? void 0 : _k.box);

View File

@ -4614,41 +4614,41 @@ var UV7 = VTX7.map((x) => UV468[x]);
// src/face/facemeshutil.ts
var createBox = (startEndTensor) => ({ startPoint: tf5.slice(startEndTensor, [0, 0], [-1, 2]), endPoint: tf5.slice(startEndTensor, [0, 2], [-1, 2]) });
var getBoxSize = (box6) => [Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box6.endPoint[1] - box6.startPoint[1])];
var getBoxCenter = (box6) => [box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2];
var getClampedBox = (box6, input) => box6 ? [
Math.trunc(Math.max(0, box6.startPoint[0])),
Math.trunc(Math.max(0, box6.startPoint[1])),
Math.trunc(Math.min(input.shape[2] || 0, box6.endPoint[0]) - Math.max(0, box6.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, box6.endPoint[1]) - Math.max(0, box6.startPoint[1]))
var getBoxSize = (box4) => [Math.abs(box4.endPoint[0] - box4.startPoint[0]), Math.abs(box4.endPoint[1] - box4.startPoint[1])];
var getBoxCenter = (box4) => [box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2, box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2];
var getClampedBox = (box4, input) => box4 ? [
Math.trunc(Math.max(0, box4.startPoint[0])),
Math.trunc(Math.max(0, box4.startPoint[1])),
Math.trunc(Math.min(input.shape[2] || 0, box4.endPoint[0]) - Math.max(0, box4.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, box4.endPoint[1]) - Math.max(0, box4.startPoint[1]))
] : [0, 0, 0, 0];
var getRawBox = (box6, input) => box6 ? [
box6.startPoint[0] / (input.shape[2] || 0),
box6.startPoint[1] / (input.shape[1] || 0),
(box6.endPoint[0] - box6.startPoint[0]) / (input.shape[2] || 0),
(box6.endPoint[1] - box6.startPoint[1]) / (input.shape[1] || 0)
var getRawBox = (box4, input) => box4 ? [
box4.startPoint[0] / (input.shape[2] || 0),
box4.startPoint[1] / (input.shape[1] || 0),
(box4.endPoint[0] - box4.startPoint[0]) / (input.shape[2] || 0),
(box4.endPoint[1] - box4.startPoint[1]) / (input.shape[1] || 0)
] : [0, 0, 0, 0];
var scaleBoxCoordinates = (box6, factor) => {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
var scaleBoxCoordinates = (box4, factor) => {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
return { startPoint, endPoint };
};
var cutBoxFromImageAndResize = (box6, image25, cropSize) => {
var cutBoxFromImageAndResize = (box4, image25, cropSize) => {
const h = image25.shape[1];
const w = image25.shape[2];
return tf5.image.cropAndResize(image25, [[box6.startPoint[1] / h, box6.startPoint[0] / w, box6.endPoint[1] / h, box6.endPoint[0] / w]], [0], cropSize);
return tf5.image.cropAndResize(image25, [[box4.startPoint[1] / h, box4.startPoint[0] / w, box4.endPoint[1] / h, box4.endPoint[0] / w]], [0], cropSize);
};
var enlargeBox = (box6, factor = 1.5) => {
const center = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var enlargeBox = (box4, factor = 1.5) => {
const center = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box6.landmarks };
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box4.landmarks };
};
var squarifyBox = (box6) => {
const centers = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var squarifyBox = (box4) => {
const centers = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = Math.max(...size2) / 2;
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box6.landmarks };
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box4.landmarks };
};
var calculateLandmarksBoundingBox = (landmarks) => {
const xs = landmarks.map((d) => d[0]);
@ -4716,8 +4716,8 @@ function generateAnchors(inputSize8) {
}
return anchors4;
}
function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / inputSize8 * (coord[0] - inputSize8 / 2),
boxSize[1] / inputSize8 * (coord[1] - inputSize8 / 2),
@ -4726,21 +4726,21 @@ function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8)
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1];
const boxCenter = [...getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint }), 1];
return coordsRotated.map((coord) => [
Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])),
Math.round(coord[2] || 0)
]);
}
function correctFaceRotation(box6, input, inputSize8) {
const symmetryLine = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[symmetryLine[0]], box6.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function correctFaceRotation(box4, input, inputSize8) {
const symmetryLine = box4.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box4.landmarks[symmetryLine[0]], box4.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]];
const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [inputSize8, inputSize8]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, rotated, [inputSize8, inputSize8]);
const face5 = tf5.div(cut, 255);
tf5.dispose(cut);
tf5.dispose(rotated);
@ -5173,13 +5173,13 @@ async function process3(res, outputShape, config3) {
detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y
];
const box6 = [
const box4 = [
Math.trunc(boxRaw[0] * outputShape[0]),
Math.trunc(boxRaw[1] * outputShape[1]),
Math.trunc(boxRaw[2] * outputShape[0]),
Math.trunc(boxRaw[3] * outputShape[1])
];
results.push({ id: i++, score, class: classVal, label, box: box6, boxRaw });
results.push({ id: i++, score, class: classVal, label, box: box4, boxRaw });
}
return results;
}
@ -5472,20 +5472,20 @@ var getLeftToRightEyeDepthDifference = (rawCoords) => {
return leftEyeZ - rightEyeZ;
};
var getEyeBox = (rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false, meshSize) => {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box6);
const box4 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box4);
let crop2 = tf11.image.cropAndResize(face5, [[
box6.startPoint[1] / meshSize,
box6.startPoint[0] / meshSize,
box6.endPoint[1] / meshSize,
box6.endPoint[0] / meshSize
box4.startPoint[1] / meshSize,
box4.startPoint[0] / meshSize,
box4.endPoint[1] / meshSize,
box4.endPoint[0] / meshSize
]], [0], [inputSize4, inputSize4]);
if (flip && env2.kernels.includes("flipleftright")) {
const flipped = tf11.image.flipLeftRight(crop2);
tf11.dispose(crop2);
crop2 = flipped;
}
return { box: box6, boxSize, crop: crop2 };
return { box: box4, boxSize, crop: crop2 };
};
var getEyeCoords = (eyeData, eyeBox, eyeBoxSize, flip = false) => {
const eyeRawCoords = [];
@ -5580,7 +5580,7 @@ async function predict6(input, config3) {
const faces = [];
const newBoxes = [];
let id = 0;
for (let box6 of boxCache) {
for (let box4 of boxCache) {
let angle = 0;
let rotationMatrix;
const face5 = {
@ -5595,21 +5595,21 @@ async function predict6(input, config3) {
annotations: {}
};
if (((_d = config3.face.detector) == null ? void 0 : _d.rotation) && ((_e = config3.face.mesh) == null ? void 0 : _e.enabled) && env2.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input, inputSize5);
} else {
rotationMatrix = IDENTITY_MATRIX;
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, input, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, input, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
face5.tensor = tf12.div(cut, 255);
tf12.dispose(cut);
}
face5.boxScore = Math.round(100 * box6.confidence) / 100;
face5.boxScore = Math.round(100 * box4.confidence) / 100;
if (!((_g = config3.face.mesh) == null ? void 0 : _g.enabled)) {
face5.box = getClampedBox(box6, input);
face5.boxRaw = getRawBox(box6, input);
face5.score = Math.round(100 * box6.confidence || 0) / 100;
face5.mesh = box6.landmarks.map((pt) => [
(box6.startPoint[0] + box6.endPoint[0]) / 2 + (box6.endPoint[0] + box6.startPoint[0]) * pt[0] / size(),
(box6.startPoint[1] + box6.endPoint[1]) / 2 + (box6.endPoint[1] + box6.startPoint[1]) * pt[1] / size()
face5.box = getClampedBox(box4, input);
face5.boxRaw = getRawBox(box4, input);
face5.score = Math.round(100 * box4.confidence || 0) / 100;
face5.mesh = box4.landmarks.map((pt) => [
(box4.startPoint[0] + box4.endPoint[0]) / 2 + (box4.endPoint[0] + box4.startPoint[0]) * pt[0] / size(),
(box4.startPoint[1] + box4.endPoint[1]) / 2 + (box4.endPoint[1] + box4.startPoint[1]) * pt[1] / size()
]);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize5]);
for (const key of Object.keys(blazeFaceLandmarks))
@ -5627,28 +5627,28 @@ async function predict6(input, config3) {
tf12.dispose(contourCoords);
tf12.dispose(coordsReshaped);
if (faceConfidence < (((_h = config3.face.detector) == null ? void 0 : _h.minConfidence) || 1)) {
box6.confidence = faceConfidence;
box4.confidence = faceConfidence;
} else {
if ((_i = config3.face.iris) == null ? void 0 : _i.enabled)
rawCoords = await augmentIris(rawCoords, face5.tensor, config3, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize5);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize5]);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box6.confidence };
box4 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box4.confidence };
for (const key of Object.keys(meshAnnotations))
face5.annotations[key] = meshAnnotations[key].map((index) => face5.mesh[index]);
if (((_j = config3.face.detector) == null ? void 0 : _j.rotation) && config3.face.mesh.enabled && ((_k = config3.face.description) == null ? void 0 : _k.enabled) && env2.kernels.includes("rotatewithoffset")) {
tf12.dispose(face5.tensor);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input, inputSize5);
}
face5.box = getClampedBox(box6, input);
face5.boxRaw = getRawBox(box6, input);
face5.score = Math.round(100 * faceConfidence || 100 * box6.confidence || 0) / 100;
face5.box = getClampedBox(box4, input);
face5.boxRaw = getRawBox(box4, input);
face5.score = Math.round(100 * faceConfidence || 100 * box4.confidence || 0) / 100;
face5.faceScore = Math.round(100 * faceConfidence) / 100;
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence };
box4 = { ...squarifyBox(box4), confidence: box4.confidence, faceConfidence };
}
}
faces.push(face5);
newBoxes.push(box6);
newBoxes.push(box4);
}
if ((_l = config3.face.mesh) == null ? void 0 : _l.enabled)
boxCache = newBoxes.filter((a) => {
@ -5704,10 +5704,10 @@ function enhance(input) {
const tensor3 = input.image || input.tensor || input;
if (!(tensor3 instanceof tf13.Tensor))
return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]];
const box4 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model9 == null ? void 0 : model9.inputs[0].shape))
return null;
const crop2 = tensor3.shape.length === 3 ? tf13.image.cropAndResize(tf13.expandDims(tensor3, 0), box6, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]) : tf13.image.cropAndResize(tensor3, box6, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]);
const crop2 = tensor3.shape.length === 3 ? tf13.image.cropAndResize(tf13.expandDims(tensor3, 0), box4, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]) : tf13.image.cropAndResize(tensor3, box4, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]);
const norm = tf13.mul(crop2, 255);
return norm;
});
@ -5758,65 +5758,126 @@ async function predict7(image25, config3, idx, count2) {
});
}
// src/handpose/handpose.ts
// src/hand/handpose.ts
var tf17 = __toModule(require_tfjs_esm());
// src/handpose/handdetector.ts
// src/hand/handposedetector.ts
var tf15 = __toModule(require_tfjs_esm());
// src/handpose/box.ts
// src/hand/handposeutil.ts
var tf14 = __toModule(require_tfjs_esm());
function getBoxSize2(box6) {
function getBoxSize2(box4) {
return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1])
Math.abs(box4.endPoint[0] - box4.startPoint[0]),
Math.abs(box4.endPoint[1] - box4.startPoint[1])
];
}
function getBoxCenter2(box6) {
function getBoxCenter2(box4) {
return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2
box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2,
box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2
];
}
function cutBoxFromImageAndResize2(box6, image25, cropSize) {
function cutBoxFromImageAndResize2(box4, image25, cropSize) {
const h = image25.shape[1];
const w = image25.shape[2];
const boxes = [[
box6.startPoint[1] / h,
box6.startPoint[0] / w,
box6.endPoint[1] / h,
box6.endPoint[0] / w
box4.startPoint[1] / h,
box4.startPoint[0] / w,
box4.endPoint[1] / h,
box4.endPoint[0] / w
]];
return tf14.image.cropAndResize(image25, boxes, [0], cropSize);
}
function scaleBoxCoordinates2(box6, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => {
function scaleBoxCoordinates2(box4, factor) {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
const palmLandmarks = box4.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord;
});
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence };
return { startPoint, endPoint, palmLandmarks, confidence: box4.confidence };
}
function enlargeBox2(box6, factor = 1.5) {
const center = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function enlargeBox2(box4, factor = 1.5) {
const center = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const newHalfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
const startPoint = [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: box4.palmLandmarks };
}
function squarifyBox2(box6) {
const centers = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function squarifyBox2(box4) {
const centers = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const maxEdge = Math.max(...size2);
const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks };
return { startPoint, endPoint, palmLandmarks: box4.palmLandmarks };
}
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot2(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot2(rotationComponent[0], translationComponent),
-dot2(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot2(homogeneousCoordinate, rotationMatrix[0]),
dot2(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/anchors.ts
// src/hand/handposeanchors.ts
var anchors2 = [
{ x: 0.015625, y: 0.015625 },
{ x: 0.015625, y: 0.015625 },
@ -8764,7 +8825,7 @@ var anchors2 = [
{ x: 0.9375, y: 0.9375 }
];
// src/handpose/handdetector.ts
// src/hand/handposedetector.ts
var HandDetector = class {
constructor(model14) {
__publicField(this, "model");
@ -8839,73 +8900,8 @@ var HandDetector = class {
}
};
// src/handpose/handpipeline.ts
// src/hand/handposepipeline.ts
var tf16 = __toModule(require_tfjs_esm());
// src/handpose/util.ts
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot2(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot2(rotationComponent[0], translationComponent),
-dot2(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot2(homogeneousCoordinate, rotationMatrix[0]),
dot2(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/handpipeline.ts
var palmBoxEnlargeFactor = 5;
var handBoxEnlargeFactor = 1.65;
var palmLandmarkIds = [0, 5, 9, 13, 17, 1, 2];
@ -9425,7 +9421,7 @@ function match(keypoints) {
return poses;
}
// src/handpose/handpose.ts
// src/hand/handpose.ts
var meshAnnotations2 = {
thumb: [1, 2, 3, 4],
index: [5, 6, 7, 8],
@ -9450,24 +9446,24 @@ async function predict8(input, config3) {
}
}
const keypoints = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let box4 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw = [0, 0, 0, 0];
if (keypoints && keypoints.length > 0) {
for (const pt of keypoints) {
if (pt[0] < box6[0])
box6[0] = pt[0];
if (pt[1] < box6[1])
box6[1] = pt[1];
if (pt[0] > box6[2])
box6[2] = pt[0];
if (pt[1] > box6[3])
box6[3] = pt[1];
if (pt[0] < box4[0])
box4[0] = pt[0];
if (pt[1] < box4[1])
box4[1] = pt[1];
if (pt[0] > box4[2])
box4[2] = pt[0];
if (pt[1] > box4[3])
box4[3] = pt[1];
}
box6[2] -= box6[0];
box6[3] -= box6[1];
boxRaw = [box6[0] / (input.shape[2] || 0), box6[1] / (input.shape[1] || 0), box6[2] / (input.shape[2] || 0), box6[3] / (input.shape[1] || 0)];
box4[2] -= box4[0];
box4[3] -= box4[1];
boxRaw = [box4[0] / (input.shape[2] || 0), box4[1] / (input.shape[1] || 0), box4[2] / (input.shape[2] || 0), box4[3] / (input.shape[1] || 0)];
} else {
box6 = predictions[i].box ? [
box4 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
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])),
@ -9487,7 +9483,7 @@ async function predict8(input, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand",
box: box6,
box: box4,
boxRaw,
keypoints,
annotations: annotations2,
@ -9533,9 +9529,9 @@ function calc(keypoints, outputSize2 = [1, 1]) {
const coords8 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
const min = [Math.min(...coords8[0]), Math.min(...coords8[1])];
const max3 = [Math.max(...coords8[0]), Math.max(...coords8[1])];
const box6 = [min[0], min[1], max3[0] - min[0], max3[1] - min[1]];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [min[0], min[1], max3[0] - min[0], max3[1] - min[1]];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function square(keypoints, outputSize2 = [1, 1]) {
const coords8 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
@ -9543,22 +9539,22 @@ function square(keypoints, outputSize2 = [1, 1]) {
const max3 = [Math.max(...coords8[0]), Math.max(...coords8[1])];
const center = [(min[0] + max3[0]) / 2, (min[1] + max3[1]) / 2];
const dist = Math.max(center[0] - min[0], center[1] - min[1], -center[0] + max3[0], -center[1] + max3[1]);
const box6 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function scale(box6, scaleFact) {
const dist = [box6[2] * scaleFact, box6[3] * scaleFact];
function scale(box4, scaleFact) {
const dist = [box4[2] * scaleFact, box4[3] * scaleFact];
const newBox = [
box6[0] - (dist[0] - box6[2]) / 2,
box6[1] - (dist[1] - box6[3]) / 2,
box4[0] - (dist[0] - box4[2]) / 2,
box4[1] - (dist[1] - box4[3]) / 2,
dist[0],
dist[1]
];
return newBox;
}
function crop(box6) {
const yxBox = [Math.max(0, box6[1]), Math.max(0, box6[0]), Math.min(1, box6[3] + box6[1]), Math.min(1, box6[2] + box6[0])];
function crop(box4) {
const yxBox = [Math.max(0, box4[1]), Math.max(0, box4[0]), Math.min(1, box4[3] + box4[1]), Math.min(1, box4[2] + box4[0])];
return yxBox;
}
@ -9738,6 +9734,11 @@ async function predict9(input, config3) {
}
}
}
for (let i = 0; i < cache3.hands.length; i++) {
const bbox = calc(cache3.hands[i].keypoints, outputSize);
cache3.hands[i].box = bbox.box;
cache3.hands[i].boxRaw = bbox.boxRaw;
}
resolve(cache3.hands);
});
}
@ -10086,7 +10087,7 @@ async function process4(res, inputSize8, outputShape, config3) {
];
let boxRaw = [x, y, w, h];
boxRaw = boxRaw.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [
const box4 = [
boxRaw[0] * outputShape[0],
boxRaw[1] * outputShape[1],
boxRaw[2] * outputShape[0],
@ -10097,7 +10098,7 @@ async function process4(res, inputSize8, outputShape, config3) {
score: Math.round(100 * score) / 100,
class: j + 1,
label: labels[j].label,
box: box6.map((a) => Math.trunc(a)),
box: box4.map((a) => Math.trunc(a)),
boxRaw
};
results.push(result);
@ -10448,9 +10449,9 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
let keypoints = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints = keypoints.filter((a) => a.score > minConfidence2);
const score = getInstanceScore(poses, keypoints);
const box6 = getBoundingBox(keypoints);
const box4 = getBoundingBox(keypoints);
if (score > minConfidence2)
poses.push({ keypoints, box: box6, score: Math.round(100 * score) / 100 });
poses.push({ keypoints, box: box4, score: Math.round(100 * score) / 100 });
}
return poses;
}
@ -11689,7 +11690,7 @@ function calc2(newResult, config3) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else {
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 box4 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score,
@ -11721,14 +11722,14 @@ function calc2(newResult, config3) {
}
annotations2[name] = pt;
}
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw, keypoints, annotations: annotations2 };
bufferedResult.body[i] = { ...newResult.body[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else {
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 box4 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw = 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)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
@ -11742,14 +11743,14 @@ function calc2(newResult, config3) {
annotations2[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, keypoints, annotations: annotations2 };
bufferedResult.hand[i] = { ...newResult.hand[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else {
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 box4 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 } };
rotation.matrix = (_g = newResult.face[i].rotation) == null ? void 0 : _g.matrix;
@ -11762,16 +11763,16 @@ function calc2(newResult, config3) {
bearing: ((bufferedFactor - 1) * (((_u = (_t = bufferedResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.bearing) || 0) + (((_w = (_v = newResult.face[i].rotation) == null ? void 0 : _v.gaze) == null ? void 0 : _w.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_y = (_x = bufferedResult.face[i].rotation) == null ? void 0 : _x.gaze) == null ? void 0 : _y.strength) || 0) + (((_A = (_z = newResult.face[i].rotation) == null ? void 0 : _z.gaze) == null ? void 0 : _A.strength) || 0)) / bufferedFactor
};
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box4, boxRaw };
}
}
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else {
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 box4 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 };
bufferedResult.object[i] = { ...newResult.object[i], box: box4, boxRaw };
}
}
if (newResult.persons) {
@ -11780,7 +11781,7 @@ function calc2(newResult, config3) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else {
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((box4, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box4) / bufferedFactor);
}
}
}
@ -11863,10 +11864,10 @@ function join2(faces, bodies, hands, gestures, shape) {
}
const x = [];
const y = [];
const extractXY = (box6) => {
if (box6 && box6.length === 4) {
x.push(box6[0], box6[0] + box6[2]);
y.push(box6[1], box6[1] + box6[3]);
const extractXY = (box4) => {
if (box4 && box4.length === 4) {
x.push(box4[0], box4[0] + box4[2]);
y.push(box4[1], box4[1] + box4[3]);
}
};
extractXY((_k = person2.face) == null ? void 0 : _k.box);

405
dist/human.node.js vendored
View File

@ -4613,41 +4613,41 @@ var UV7 = VTX7.map((x) => UV468[x]);
// src/face/facemeshutil.ts
var createBox = (startEndTensor) => ({ startPoint: tf5.slice(startEndTensor, [0, 0], [-1, 2]), endPoint: tf5.slice(startEndTensor, [0, 2], [-1, 2]) });
var getBoxSize = (box6) => [Math.abs(box6.endPoint[0] - box6.startPoint[0]), Math.abs(box6.endPoint[1] - box6.startPoint[1])];
var getBoxCenter = (box6) => [box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2, box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2];
var getClampedBox = (box6, input) => box6 ? [
Math.trunc(Math.max(0, box6.startPoint[0])),
Math.trunc(Math.max(0, box6.startPoint[1])),
Math.trunc(Math.min(input.shape[2] || 0, box6.endPoint[0]) - Math.max(0, box6.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, box6.endPoint[1]) - Math.max(0, box6.startPoint[1]))
var getBoxSize = (box4) => [Math.abs(box4.endPoint[0] - box4.startPoint[0]), Math.abs(box4.endPoint[1] - box4.startPoint[1])];
var getBoxCenter = (box4) => [box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2, box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2];
var getClampedBox = (box4, input) => box4 ? [
Math.trunc(Math.max(0, box4.startPoint[0])),
Math.trunc(Math.max(0, box4.startPoint[1])),
Math.trunc(Math.min(input.shape[2] || 0, box4.endPoint[0]) - Math.max(0, box4.startPoint[0])),
Math.trunc(Math.min(input.shape[1] || 0, box4.endPoint[1]) - Math.max(0, box4.startPoint[1]))
] : [0, 0, 0, 0];
var getRawBox = (box6, input) => box6 ? [
box6.startPoint[0] / (input.shape[2] || 0),
box6.startPoint[1] / (input.shape[1] || 0),
(box6.endPoint[0] - box6.startPoint[0]) / (input.shape[2] || 0),
(box6.endPoint[1] - box6.startPoint[1]) / (input.shape[1] || 0)
var getRawBox = (box4, input) => box4 ? [
box4.startPoint[0] / (input.shape[2] || 0),
box4.startPoint[1] / (input.shape[1] || 0),
(box4.endPoint[0] - box4.startPoint[0]) / (input.shape[2] || 0),
(box4.endPoint[1] - box4.startPoint[1]) / (input.shape[1] || 0)
] : [0, 0, 0, 0];
var scaleBoxCoordinates = (box6, factor) => {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
var scaleBoxCoordinates = (box4, factor) => {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
return { startPoint, endPoint };
};
var cutBoxFromImageAndResize = (box6, image25, cropSize) => {
var cutBoxFromImageAndResize = (box4, image25, cropSize) => {
const h = image25.shape[1];
const w = image25.shape[2];
return tf5.image.cropAndResize(image25, [[box6.startPoint[1] / h, box6.startPoint[0] / w, box6.endPoint[1] / h, box6.endPoint[0] / w]], [0], cropSize);
return tf5.image.cropAndResize(image25, [[box4.startPoint[1] / h, box4.startPoint[0] / w, box4.endPoint[1] / h, box4.endPoint[0] / w]], [0], cropSize);
};
var enlargeBox = (box6, factor = 1.5) => {
const center = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var enlargeBox = (box4, factor = 1.5) => {
const center = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box6.landmarks };
return { startPoint: [center[0] - halfSize[0], center[1] - halfSize[1]], endPoint: [center[0] + halfSize[0], center[1] + halfSize[1]], landmarks: box4.landmarks };
};
var squarifyBox = (box6) => {
const centers = getBoxCenter(box6);
const size2 = getBoxSize(box6);
var squarifyBox = (box4) => {
const centers = getBoxCenter(box4);
const size2 = getBoxSize(box4);
const halfSize = Math.max(...size2) / 2;
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box6.landmarks };
return { startPoint: [Math.round(centers[0] - halfSize), Math.round(centers[1] - halfSize)], endPoint: [Math.round(centers[0] + halfSize), Math.round(centers[1] + halfSize)], landmarks: box4.landmarks };
};
var calculateLandmarksBoundingBox = (landmarks) => {
const xs = landmarks.map((d) => d[0]);
@ -4715,8 +4715,8 @@ function generateAnchors(inputSize8) {
}
return anchors4;
}
function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize8) {
const boxSize = getBoxSize({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const coordsScaled = rawCoords.map((coord) => [
boxSize[0] / inputSize8 * (coord[0] - inputSize8 / 2),
boxSize[1] / inputSize8 * (coord[1] - inputSize8 / 2),
@ -4725,21 +4725,21 @@ function transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize8)
const coordsRotationMatrix = angle !== 0 ? buildRotationMatrix(angle, [0, 0]) : IDENTITY_MATRIX;
const coordsRotated = angle !== 0 ? coordsScaled.map((coord) => [...rotatePoint(coord, coordsRotationMatrix), coord[2]]) : coordsScaled;
const inverseRotationMatrix = angle !== 0 ? invertTransformMatrix(rotationMatrix) : IDENTITY_MATRIX;
const boxCenter = [...getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint }), 1];
const boxCenter = [...getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint }), 1];
return coordsRotated.map((coord) => [
Math.round(coord[0] + dot(boxCenter, inverseRotationMatrix[0])),
Math.round(coord[1] + dot(boxCenter, inverseRotationMatrix[1])),
Math.round(coord[2] || 0)
]);
}
function correctFaceRotation(box6, input, inputSize8) {
const symmetryLine = box6.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box6.landmarks[symmetryLine[0]], box6.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box6.startPoint, endPoint: box6.endPoint });
function correctFaceRotation(box4, input, inputSize8) {
const symmetryLine = box4.landmarks.length >= meshLandmarks.count ? meshLandmarks.symmetryLine : blazeFaceLandmarks.symmetryLine;
const angle = computeRotation(box4.landmarks[symmetryLine[0]], box4.landmarks[symmetryLine[1]]);
const faceCenter = getBoxCenter({ startPoint: box4.startPoint, endPoint: box4.endPoint });
const faceCenterNormalized = [faceCenter[0] / input.shape[2], faceCenter[1] / input.shape[1]];
const rotated = tf5.image.rotateWithOffset(input, angle, 0, faceCenterNormalized);
const rotationMatrix = buildRotationMatrix(-angle, faceCenter);
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, rotated, [inputSize8, inputSize8]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, rotated, [inputSize8, inputSize8]);
const face5 = tf5.div(cut, 255);
tf5.dispose(cut);
tf5.dispose(rotated);
@ -5172,13 +5172,13 @@ async function process3(res, outputShape, config3) {
detections[0][id][2] / inputSize3 - x,
detections[0][id][3] / inputSize3 - y
];
const box6 = [
const box4 = [
Math.trunc(boxRaw[0] * outputShape[0]),
Math.trunc(boxRaw[1] * outputShape[1]),
Math.trunc(boxRaw[2] * outputShape[0]),
Math.trunc(boxRaw[3] * outputShape[1])
];
results.push({ id: i++, score, class: classVal, label, box: box6, boxRaw });
results.push({ id: i++, score, class: classVal, label, box: box4, boxRaw });
}
return results;
}
@ -5471,20 +5471,20 @@ var getLeftToRightEyeDepthDifference = (rawCoords) => {
return leftEyeZ - rightEyeZ;
};
var getEyeBox = (rawCoords, face5, eyeInnerCornerIndex, eyeOuterCornerIndex, flip = false, meshSize) => {
const box6 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box6);
const box4 = squarifyBox(enlargeBox(calculateLandmarksBoundingBox([rawCoords[eyeInnerCornerIndex], rawCoords[eyeOuterCornerIndex]]), irisEnlarge));
const boxSize = getBoxSize(box4);
let crop2 = tf11.image.cropAndResize(face5, [[
box6.startPoint[1] / meshSize,
box6.startPoint[0] / meshSize,
box6.endPoint[1] / meshSize,
box6.endPoint[0] / meshSize
box4.startPoint[1] / meshSize,
box4.startPoint[0] / meshSize,
box4.endPoint[1] / meshSize,
box4.endPoint[0] / meshSize
]], [0], [inputSize4, inputSize4]);
if (flip && env2.kernels.includes("flipleftright")) {
const flipped = tf11.image.flipLeftRight(crop2);
tf11.dispose(crop2);
crop2 = flipped;
}
return { box: box6, boxSize, crop: crop2 };
return { box: box4, boxSize, crop: crop2 };
};
var getEyeCoords = (eyeData, eyeBox, eyeBoxSize, flip = false) => {
const eyeRawCoords = [];
@ -5579,7 +5579,7 @@ async function predict6(input, config3) {
const faces = [];
const newBoxes = [];
let id = 0;
for (let box6 of boxCache) {
for (let box4 of boxCache) {
let angle = 0;
let rotationMatrix;
const face5 = {
@ -5594,21 +5594,21 @@ async function predict6(input, config3) {
annotations: {}
};
if (((_d = config3.face.detector) == null ? void 0 : _d.rotation) && ((_e = config3.face.mesh) == null ? void 0 : _e.enabled) && env2.kernels.includes("rotatewithoffset")) {
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input, inputSize5);
} else {
rotationMatrix = IDENTITY_MATRIX;
const cut = cutBoxFromImageAndResize({ startPoint: box6.startPoint, endPoint: box6.endPoint }, input, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
const cut = cutBoxFromImageAndResize({ startPoint: box4.startPoint, endPoint: box4.endPoint }, input, ((_f = config3.face.mesh) == null ? void 0 : _f.enabled) ? [inputSize5, inputSize5] : [size(), size()]);
face5.tensor = tf12.div(cut, 255);
tf12.dispose(cut);
}
face5.boxScore = Math.round(100 * box6.confidence) / 100;
face5.boxScore = Math.round(100 * box4.confidence) / 100;
if (!((_g = config3.face.mesh) == null ? void 0 : _g.enabled)) {
face5.box = getClampedBox(box6, input);
face5.boxRaw = getRawBox(box6, input);
face5.score = Math.round(100 * box6.confidence || 0) / 100;
face5.mesh = box6.landmarks.map((pt) => [
(box6.startPoint[0] + box6.endPoint[0]) / 2 + (box6.endPoint[0] + box6.startPoint[0]) * pt[0] / size(),
(box6.startPoint[1] + box6.endPoint[1]) / 2 + (box6.endPoint[1] + box6.startPoint[1]) * pt[1] / size()
face5.box = getClampedBox(box4, input);
face5.boxRaw = getRawBox(box4, input);
face5.score = Math.round(100 * box4.confidence || 0) / 100;
face5.mesh = box4.landmarks.map((pt) => [
(box4.startPoint[0] + box4.endPoint[0]) / 2 + (box4.endPoint[0] + box4.startPoint[0]) * pt[0] / size(),
(box4.startPoint[1] + box4.endPoint[1]) / 2 + (box4.endPoint[1] + box4.startPoint[1]) * pt[1] / size()
]);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize5]);
for (const key of Object.keys(blazeFaceLandmarks))
@ -5626,28 +5626,28 @@ async function predict6(input, config3) {
tf12.dispose(contourCoords);
tf12.dispose(coordsReshaped);
if (faceConfidence < (((_h = config3.face.detector) == null ? void 0 : _h.minConfidence) || 1)) {
box6.confidence = faceConfidence;
box4.confidence = faceConfidence;
} else {
if ((_i = config3.face.iris) == null ? void 0 : _i.enabled)
rawCoords = await augmentIris(rawCoords, face5.tensor, config3, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box6, angle, rotationMatrix, inputSize5);
face5.mesh = transformRawCoords(rawCoords, box4, angle, rotationMatrix, inputSize5);
face5.meshRaw = face5.mesh.map((pt) => [pt[0] / (input.shape[2] || 0), pt[1] / (input.shape[1] || 0), (pt[2] || 0) / inputSize5]);
box6 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box6.confidence };
box4 = { ...enlargeBox(calculateLandmarksBoundingBox(face5.mesh), 1.5), confidence: box4.confidence };
for (const key of Object.keys(meshAnnotations))
face5.annotations[key] = meshAnnotations[key].map((index) => face5.mesh[index]);
if (((_j = config3.face.detector) == null ? void 0 : _j.rotation) && config3.face.mesh.enabled && ((_k = config3.face.description) == null ? void 0 : _k.enabled) && env2.kernels.includes("rotatewithoffset")) {
tf12.dispose(face5.tensor);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box6, input, inputSize5);
[angle, rotationMatrix, face5.tensor] = correctFaceRotation(box4, input, inputSize5);
}
face5.box = getClampedBox(box6, input);
face5.boxRaw = getRawBox(box6, input);
face5.score = Math.round(100 * faceConfidence || 100 * box6.confidence || 0) / 100;
face5.box = getClampedBox(box4, input);
face5.boxRaw = getRawBox(box4, input);
face5.score = Math.round(100 * faceConfidence || 100 * box4.confidence || 0) / 100;
face5.faceScore = Math.round(100 * faceConfidence) / 100;
box6 = { ...squarifyBox(box6), confidence: box6.confidence, faceConfidence };
box4 = { ...squarifyBox(box4), confidence: box4.confidence, faceConfidence };
}
}
faces.push(face5);
newBoxes.push(box6);
newBoxes.push(box4);
}
if ((_l = config3.face.mesh) == null ? void 0 : _l.enabled)
boxCache = newBoxes.filter((a) => {
@ -5703,10 +5703,10 @@ function enhance(input) {
const tensor3 = input.image || input.tensor || input;
if (!(tensor3 instanceof tf13.Tensor))
return null;
const box6 = [[0.05, 0.15, 0.85, 0.85]];
const box4 = [[0.05, 0.15, 0.85, 0.85]];
if (!(model9 == null ? void 0 : model9.inputs[0].shape))
return null;
const crop2 = tensor3.shape.length === 3 ? tf13.image.cropAndResize(tf13.expandDims(tensor3, 0), box6, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]) : tf13.image.cropAndResize(tensor3, box6, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]);
const crop2 = tensor3.shape.length === 3 ? tf13.image.cropAndResize(tf13.expandDims(tensor3, 0), box4, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]) : tf13.image.cropAndResize(tensor3, box4, [0], [model9.inputs[0].shape[2], model9.inputs[0].shape[1]]);
const norm = tf13.mul(crop2, 255);
return norm;
});
@ -5757,65 +5757,126 @@ async function predict7(image25, config3, idx, count2) {
});
}
// src/handpose/handpose.ts
// src/hand/handpose.ts
var tf17 = __toModule(require_tfjs_esm());
// src/handpose/handdetector.ts
// src/hand/handposedetector.ts
var tf15 = __toModule(require_tfjs_esm());
// src/handpose/box.ts
// src/hand/handposeutil.ts
var tf14 = __toModule(require_tfjs_esm());
function getBoxSize2(box6) {
function getBoxSize2(box4) {
return [
Math.abs(box6.endPoint[0] - box6.startPoint[0]),
Math.abs(box6.endPoint[1] - box6.startPoint[1])
Math.abs(box4.endPoint[0] - box4.startPoint[0]),
Math.abs(box4.endPoint[1] - box4.startPoint[1])
];
}
function getBoxCenter2(box6) {
function getBoxCenter2(box4) {
return [
box6.startPoint[0] + (box6.endPoint[0] - box6.startPoint[0]) / 2,
box6.startPoint[1] + (box6.endPoint[1] - box6.startPoint[1]) / 2
box4.startPoint[0] + (box4.endPoint[0] - box4.startPoint[0]) / 2,
box4.startPoint[1] + (box4.endPoint[1] - box4.startPoint[1]) / 2
];
}
function cutBoxFromImageAndResize2(box6, image25, cropSize) {
function cutBoxFromImageAndResize2(box4, image25, cropSize) {
const h = image25.shape[1];
const w = image25.shape[2];
const boxes = [[
box6.startPoint[1] / h,
box6.startPoint[0] / w,
box6.endPoint[1] / h,
box6.endPoint[0] / w
box4.startPoint[1] / h,
box4.startPoint[0] / w,
box4.endPoint[1] / h,
box4.endPoint[0] / w
]];
return tf14.image.cropAndResize(image25, boxes, [0], cropSize);
}
function scaleBoxCoordinates2(box6, factor) {
const startPoint = [box6.startPoint[0] * factor[0], box6.startPoint[1] * factor[1]];
const endPoint = [box6.endPoint[0] * factor[0], box6.endPoint[1] * factor[1]];
const palmLandmarks = box6.palmLandmarks.map((coord) => {
function scaleBoxCoordinates2(box4, factor) {
const startPoint = [box4.startPoint[0] * factor[0], box4.startPoint[1] * factor[1]];
const endPoint = [box4.endPoint[0] * factor[0], box4.endPoint[1] * factor[1]];
const palmLandmarks = box4.palmLandmarks.map((coord) => {
const scaledCoord = [coord[0] * factor[0], coord[1] * factor[1]];
return scaledCoord;
});
return { startPoint, endPoint, palmLandmarks, confidence: box6.confidence };
return { startPoint, endPoint, palmLandmarks, confidence: box4.confidence };
}
function enlargeBox2(box6, factor = 1.5) {
const center = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function enlargeBox2(box4, factor = 1.5) {
const center = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const newHalfSize = [factor * size2[0] / 2, factor * size2[1] / 2];
const startPoint = [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: box4.palmLandmarks };
}
function squarifyBox2(box6) {
const centers = getBoxCenter2(box6);
const size2 = getBoxSize2(box6);
function squarifyBox2(box4) {
const centers = getBoxCenter2(box4);
const size2 = getBoxSize2(box4);
const maxEdge = Math.max(...size2);
const halfSize = maxEdge / 2;
const startPoint = [centers[0] - halfSize, centers[1] - halfSize];
const endPoint = [centers[0] + halfSize, centers[1] + halfSize];
return { startPoint, endPoint, palmLandmarks: box6.palmLandmarks };
return { startPoint, endPoint, palmLandmarks: box4.palmLandmarks };
}
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot2(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot2(rotationComponent[0], translationComponent),
-dot2(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot2(homogeneousCoordinate, rotationMatrix[0]),
dot2(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/anchors.ts
// src/hand/handposeanchors.ts
var anchors2 = [
{ x: 0.015625, y: 0.015625 },
{ x: 0.015625, y: 0.015625 },
@ -8763,7 +8824,7 @@ var anchors2 = [
{ x: 0.9375, y: 0.9375 }
];
// src/handpose/handdetector.ts
// src/hand/handposedetector.ts
var HandDetector = class {
constructor(model14) {
__publicField(this, "model");
@ -8838,73 +8899,8 @@ var HandDetector = class {
}
};
// src/handpose/handpipeline.ts
// src/hand/handposepipeline.ts
var tf16 = __toModule(require_tfjs_esm());
// src/handpose/util.ts
function normalizeRadians2(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
function computeRotation2(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians2(radians);
}
var buildTranslationMatrix2 = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
function dot2(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
function getColumnFrom2DArr2(arr, columnIndex) {
const column = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
function multiplyTransformMatrices2(mat1, mat2) {
const product = [];
const size2 = mat1.length;
for (let row = 0; row < size2; row++) {
product.push([]);
for (let col = 0; col < size2; col++) {
product[row].push(dot2(mat1[row], getColumnFrom2DArr2(mat2, col)));
}
}
return product;
}
function buildRotationMatrix2(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix2(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices2(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix2(-center[0], -center[1]);
return multiplyTransformMatrices2(translationTimesRotation, negativeTranslationMatrix);
}
function invertTransformMatrix2(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot2(rotationComponent[0], translationComponent),
-dot2(rotationComponent[1], translationComponent)
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1]
];
}
function rotatePoint2(homogeneousCoordinate, rotationMatrix) {
return [
dot2(homogeneousCoordinate, rotationMatrix[0]),
dot2(homogeneousCoordinate, rotationMatrix[1])
];
}
// src/handpose/handpipeline.ts
var palmBoxEnlargeFactor = 5;
var handBoxEnlargeFactor = 1.65;
var palmLandmarkIds = [0, 5, 9, 13, 17, 1, 2];
@ -9424,7 +9420,7 @@ function match(keypoints) {
return poses;
}
// src/handpose/handpose.ts
// src/hand/handpose.ts
var meshAnnotations2 = {
thumb: [1, 2, 3, 4],
index: [5, 6, 7, 8],
@ -9449,24 +9445,24 @@ async function predict8(input, config3) {
}
}
const keypoints = predictions[i].landmarks;
let box6 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let box4 = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0];
let boxRaw = [0, 0, 0, 0];
if (keypoints && keypoints.length > 0) {
for (const pt of keypoints) {
if (pt[0] < box6[0])
box6[0] = pt[0];
if (pt[1] < box6[1])
box6[1] = pt[1];
if (pt[0] > box6[2])
box6[2] = pt[0];
if (pt[1] > box6[3])
box6[3] = pt[1];
if (pt[0] < box4[0])
box4[0] = pt[0];
if (pt[1] < box4[1])
box4[1] = pt[1];
if (pt[0] > box4[2])
box4[2] = pt[0];
if (pt[1] > box4[3])
box4[3] = pt[1];
}
box6[2] -= box6[0];
box6[3] -= box6[1];
boxRaw = [box6[0] / (input.shape[2] || 0), box6[1] / (input.shape[1] || 0), box6[2] / (input.shape[2] || 0), box6[3] / (input.shape[1] || 0)];
box4[2] -= box4[0];
box4[3] -= box4[1];
boxRaw = [box4[0] / (input.shape[2] || 0), box4[1] / (input.shape[1] || 0), box4[2] / (input.shape[2] || 0), box4[3] / (input.shape[1] || 0)];
} else {
box6 = predictions[i].box ? [
box4 = predictions[i].box ? [
Math.trunc(Math.max(0, predictions[i].box.topLeft[0])),
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])),
@ -9486,7 +9482,7 @@ async function predict8(input, config3) {
boxScore: Math.round(100 * predictions[i].boxConfidence) / 100,
fingerScore: Math.round(100 * predictions[i].fingerConfidence) / 100,
label: "hand",
box: box6,
box: box4,
boxRaw,
keypoints,
annotations: annotations2,
@ -9532,9 +9528,9 @@ function calc(keypoints, outputSize2 = [1, 1]) {
const coords8 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
const min = [Math.min(...coords8[0]), Math.min(...coords8[1])];
const max3 = [Math.max(...coords8[0]), Math.max(...coords8[1])];
const box6 = [min[0], min[1], max3[0] - min[0], max3[1] - min[1]];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [min[0], min[1], max3[0] - min[0], max3[1] - min[1]];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function square(keypoints, outputSize2 = [1, 1]) {
const coords8 = [keypoints.map((pt) => pt[0]), keypoints.map((pt) => pt[1])];
@ -9542,22 +9538,22 @@ function square(keypoints, outputSize2 = [1, 1]) {
const max3 = [Math.max(...coords8[0]), Math.max(...coords8[1])];
const center = [(min[0] + max3[0]) / 2, (min[1] + max3[1]) / 2];
const dist = Math.max(center[0] - min[0], center[1] - min[1], -center[0] + max3[0], -center[1] + max3[1]);
const box6 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box6[0] / outputSize2[0], box6[1] / outputSize2[1], box6[2] / outputSize2[0], box6[3] / outputSize2[1]];
return { box: box6, boxRaw };
const box4 = [Math.trunc(center[0] - dist), Math.trunc(center[1] - dist), Math.trunc(2 * dist), Math.trunc(2 * dist)];
const boxRaw = [box4[0] / outputSize2[0], box4[1] / outputSize2[1], box4[2] / outputSize2[0], box4[3] / outputSize2[1]];
return { box: box4, boxRaw };
}
function scale(box6, scaleFact) {
const dist = [box6[2] * scaleFact, box6[3] * scaleFact];
function scale(box4, scaleFact) {
const dist = [box4[2] * scaleFact, box4[3] * scaleFact];
const newBox = [
box6[0] - (dist[0] - box6[2]) / 2,
box6[1] - (dist[1] - box6[3]) / 2,
box4[0] - (dist[0] - box4[2]) / 2,
box4[1] - (dist[1] - box4[3]) / 2,
dist[0],
dist[1]
];
return newBox;
}
function crop(box6) {
const yxBox = [Math.max(0, box6[1]), Math.max(0, box6[0]), Math.min(1, box6[3] + box6[1]), Math.min(1, box6[2] + box6[0])];
function crop(box4) {
const yxBox = [Math.max(0, box4[1]), Math.max(0, box4[0]), Math.min(1, box4[3] + box4[1]), Math.min(1, box4[2] + box4[0])];
return yxBox;
}
@ -9737,6 +9733,11 @@ async function predict9(input, config3) {
}
}
}
for (let i = 0; i < cache3.hands.length; i++) {
const bbox = calc(cache3.hands[i].keypoints, outputSize);
cache3.hands[i].box = bbox.box;
cache3.hands[i].boxRaw = bbox.boxRaw;
}
resolve(cache3.hands);
});
}
@ -10085,7 +10086,7 @@ async function process4(res, inputSize8, outputShape, config3) {
];
let boxRaw = [x, y, w, h];
boxRaw = boxRaw.map((a) => Math.max(0, Math.min(a, 1)));
const box6 = [
const box4 = [
boxRaw[0] * outputShape[0],
boxRaw[1] * outputShape[1],
boxRaw[2] * outputShape[0],
@ -10096,7 +10097,7 @@ async function process4(res, inputSize8, outputShape, config3) {
score: Math.round(100 * score) / 100,
class: j + 1,
label: labels[j].label,
box: box6.map((a) => Math.trunc(a)),
box: box4.map((a) => Math.trunc(a)),
boxRaw
};
results.push(result);
@ -10447,9 +10448,9 @@ function decode(offsets, scores, displacementsFwd, displacementsBwd, maxDetected
let keypoints = decodePose(root, scores, offsets, displacementsFwd, displacementsBwd);
keypoints = keypoints.filter((a) => a.score > minConfidence2);
const score = getInstanceScore(poses, keypoints);
const box6 = getBoundingBox(keypoints);
const box4 = getBoundingBox(keypoints);
if (score > minConfidence2)
poses.push({ keypoints, box: box6, score: Math.round(100 * score) / 100 });
poses.push({ keypoints, box: box4, score: Math.round(100 * score) / 100 });
}
return poses;
}
@ -11688,7 +11689,7 @@ function calc2(newResult, config3) {
bufferedResult.body = JSON.parse(JSON.stringify(newResult.body));
} else {
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 box4 = newResult.body[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].box[j] + b) / bufferedFactor);
const boxRaw = newResult.body[i].boxRaw.map((b, j) => ((bufferedFactor - 1) * bufferedResult.body[i].boxRaw[j] + b) / bufferedFactor);
const keypoints = newResult.body[i].keypoints.map((keypoint, j) => ({
score: keypoint.score,
@ -11720,14 +11721,14 @@ function calc2(newResult, config3) {
}
annotations2[name] = pt;
}
bufferedResult.body[i] = { ...newResult.body[i], box: box6, boxRaw, keypoints, annotations: annotations2 };
bufferedResult.body[i] = { ...newResult.body[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.hand || newResult.hand.length !== bufferedResult.hand.length) {
bufferedResult.hand = JSON.parse(JSON.stringify(newResult.hand));
} else {
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 box4 = newResult.hand[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor);
const boxRaw = 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)
bufferedResult.hand[i].keypoints = newResult.hand[i].keypoints;
@ -11741,14 +11742,14 @@ function calc2(newResult, config3) {
annotations2[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, keypoints, annotations: annotations2 };
bufferedResult.hand[i] = { ...newResult.hand[i], box: box4, boxRaw, keypoints, annotations: annotations2 };
}
}
if (!bufferedResult.face || newResult.face.length !== bufferedResult.face.length) {
bufferedResult.face = JSON.parse(JSON.stringify(newResult.face));
} else {
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 box4 = newResult.face[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.face[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 } };
rotation.matrix = (_g = newResult.face[i].rotation) == null ? void 0 : _g.matrix;
@ -11761,16 +11762,16 @@ function calc2(newResult, config3) {
bearing: ((bufferedFactor - 1) * (((_u = (_t = bufferedResult.face[i].rotation) == null ? void 0 : _t.gaze) == null ? void 0 : _u.bearing) || 0) + (((_w = (_v = newResult.face[i].rotation) == null ? void 0 : _v.gaze) == null ? void 0 : _w.bearing) || 0)) / bufferedFactor,
strength: ((bufferedFactor - 1) * (((_y = (_x = bufferedResult.face[i].rotation) == null ? void 0 : _x.gaze) == null ? void 0 : _y.strength) || 0) + (((_A = (_z = newResult.face[i].rotation) == null ? void 0 : _z.gaze) == null ? void 0 : _A.strength) || 0)) / bufferedFactor
};
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box6, boxRaw };
bufferedResult.face[i] = { ...newResult.face[i], rotation, box: box4, boxRaw };
}
}
if (!bufferedResult.object || newResult.object.length !== bufferedResult.object.length) {
bufferedResult.object = JSON.parse(JSON.stringify(newResult.object));
} else {
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 box4 = newResult.object[i].box.map((b, j) => ((bufferedFactor - 1) * bufferedResult.object[i].box[j] + b) / bufferedFactor);
const boxRaw = 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 };
bufferedResult.object[i] = { ...newResult.object[i], box: box4, boxRaw };
}
}
if (newResult.persons) {
@ -11779,7 +11780,7 @@ function calc2(newResult, config3) {
bufferedResult.persons = JSON.parse(JSON.stringify(newPersons));
} else {
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((box4, j) => ((bufferedFactor - 1) * bufferedResult.persons[i].box[j] + box4) / bufferedFactor);
}
}
}
@ -11862,10 +11863,10 @@ function join2(faces, bodies, hands, gestures, shape) {
}
const x = [];
const y = [];
const extractXY = (box6) => {
if (box6 && box6.length === 4) {
x.push(box6[0], box6[0] + box6[2]);
y.push(box6[1], box6[1] + box6[3]);
const extractXY = (box4) => {
if (box4 && box4.length === 4) {
x.push(box4[0], box4[0] + box4[2]);
y.push(box4[1], box4[1] + box4[3]);
}
};
extractXY((_k = person2.face) == null ? void 0 : _k.box);

View File

@ -69,7 +69,7 @@
"@types/node": "^16.11.1",
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^5.1.0",
"@vladmandic/build": "^0.6.1",
"@vladmandic/build": "^0.6.2",
"@vladmandic/pilogger": "^0.3.3",
"canvas": "^2.8.0",
"dayjs": "^1.10.7",

View File

@ -6,9 +6,9 @@
import { log, join } from '../util/util';
import * as tf from '../../dist/tfjs.esm.js';
import * as handdetector from './handdetector';
import * as handpipeline from './handpipeline';
import * as fingerPose from '../hand/fingerpose';
import * as handdetector from './handposedetector';
import * as handpipeline from './handposepipeline';
import * as fingerPose from './fingerpose';
import type { HandResult, Box, Point } from '../result';
import type { Tensor, GraphModel } from '../tfjs/types';
import type { Config } from '../config';

View File

@ -4,8 +4,8 @@
*/
import * as tf from '../../dist/tfjs.esm.js';
import * as box from './box';
import * as anchors from './anchors';
import * as util from './handposeutil';
import * as anchors from './handposeanchors';
import type { Tensor, GraphModel } from '../tfjs/types';
export class HandDetector {
@ -81,7 +81,7 @@ export class HandDetector {
const palmLandmarks = await prediction.palmLandmarks.array();
tf.dispose(prediction.box);
tf.dispose(prediction.palmLandmarks);
hands.push(box.scaleBoxCoordinates({ startPoint, endPoint, palmLandmarks, confidence: prediction.confidence }, [inputWidth / this.inputSize, inputHeight / this.inputSize]));
hands.push(util.scaleBoxCoordinates({ startPoint, endPoint, palmLandmarks, confidence: prediction.confidence }, [inputWidth / this.inputSize, inputHeight / this.inputSize]));
}
return hands;
}

View File

@ -4,9 +4,8 @@
*/
import * as tf from '../../dist/tfjs.esm.js';
import * as box from './box';
import * as util from './util';
import type * as detector from './handdetector';
import * as util from './handposeutil';
import type * as detector from './handposedetector';
import type { Tensor, GraphModel } from '../tfjs/types';
import { env } from '../util/env';
@ -45,12 +44,12 @@ export class HandPipeline {
getBoxForPalmLandmarks(palmLandmarks, rotationMatrix) {
const rotatedPalmLandmarks = palmLandmarks.map((coord) => util.rotatePoint([...coord, 1], rotationMatrix));
const boxAroundPalm = this.calculateLandmarksBoundingBox(rotatedPalmLandmarks);
return box.enlargeBox(box.squarifyBox(boxAroundPalm), palmBoxEnlargeFactor);
return util.enlargeBox(util.squarifyBox(boxAroundPalm), palmBoxEnlargeFactor);
}
getBoxForHandLandmarks(landmarks) {
const boundingBox = this.calculateLandmarksBoundingBox(landmarks);
const boxAroundHand = box.enlargeBox(box.squarifyBox(boundingBox), handBoxEnlargeFactor);
const boxAroundHand = util.enlargeBox(util.squarifyBox(boundingBox), handBoxEnlargeFactor);
boxAroundHand.palmLandmarks = [];
for (let i = 0; i < palmLandmarkIds.length; i++) {
boxAroundHand.palmLandmarks.push(landmarks[palmLandmarkIds[i]].slice(0, 2));
@ -59,7 +58,7 @@ export class HandPipeline {
}
transformRawCoords(rawCoords, box2, angle, rotationMatrix) {
const boxSize = box.getBoxSize(box2);
const boxSize = util.getBoxSize(box2);
const scaleFactor = [boxSize[0] / this.inputSize, boxSize[1] / this.inputSize, (boxSize[0] + boxSize[1]) / this.inputSize / 2];
const coordsScaled = rawCoords.map((coord) => [
scaleFactor[0] * (coord[0] - this.inputSize / 2),
@ -72,7 +71,7 @@ export class HandPipeline {
return [...rotated, coord[2]];
});
const inverseRotationMatrix = util.invertTransformMatrix(rotationMatrix);
const boxCenter = [...box.getBoxCenter(box2), 1];
const boxCenter = [...util.getBoxCenter(box2), 1];
const originalBoxCenter = [
util.dot(boxCenter, inverseRotationMatrix[0]),
util.dot(boxCenter, inverseRotationMatrix[1]),
@ -112,12 +111,12 @@ export class HandPipeline {
if (!currentBox) continue;
if (config.hand.landmarks) {
const angle = config.hand.rotation ? util.computeRotation(currentBox.palmLandmarks[palmLandmarksPalmBase], currentBox.palmLandmarks[palmLandmarksMiddleFingerBase]) : 0;
const palmCenter = box.getBoxCenter(currentBox);
const palmCenter = util.getBoxCenter(currentBox);
const palmCenterNormalized = [palmCenter[0] / image.shape[2], palmCenter[1] / image.shape[1]];
const rotatedImage = config.hand.rotation && env.kernels.includes('rotatewithoffset') ? tf.image.rotateWithOffset(image, angle, 0, palmCenterNormalized) : image.clone();
const rotationMatrix = util.buildRotationMatrix(-angle, palmCenter);
const newBox = useFreshBox ? this.getBoxForPalmLandmarks(currentBox.palmLandmarks, rotationMatrix) : currentBox;
const croppedInput = box.cutBoxFromImageAndResize(newBox, rotatedImage, [this.inputSize, this.inputSize]);
const croppedInput = util.cutBoxFromImageAndResize(newBox, rotatedImage, [this.inputSize, this.inputSize]);
const handImage = tf.div(croppedInput, 255);
tf.dispose(croppedInput);
tf.dispose(rotatedImage);
@ -148,7 +147,7 @@ export class HandPipeline {
tf.dispose(keypoints);
} else {
// const enlarged = box.enlargeBox(box.squarifyBox(box.shiftBox(currentBox, HAND_BOX_SHIFT_VECTOR)), handBoxEnlargeFactor);
const enlarged = box.enlargeBox(box.squarifyBox(currentBox), handBoxEnlargeFactor);
const enlarged = util.enlargeBox(util.squarifyBox(currentBox), handBoxEnlargeFactor);
const result = {
confidence: currentBox.confidence,
boxConfidence: currentBox.confidence,

View File

@ -1,8 +1,3 @@
/**
* HandPose model implementation
* See `handpose.ts` for entry point
*/
import * as tf from '../../dist/tfjs.esm.js';
export function getBoxSize(box) {
@ -70,3 +65,73 @@ export function shiftBox(box, shiftFactor) {
const endPoint = [box.endPoint[0] + shiftVector[0], box.endPoint[1] + shiftVector[1]];
return { startPoint, endPoint, palmLandmarks: box.palmLandmarks };
}
export function normalizeRadians(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
export function computeRotation(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians(radians);
}
export const buildTranslationMatrix = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
export function dot(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
export function getColumnFrom2DArr(arr, columnIndex) {
const column: Array<number> = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
export function multiplyTransformMatrices(mat1, mat2) {
const product: Array<number[]> = [];
const size = mat1.length;
for (let row = 0; row < size; row++) {
product.push([]);
for (let col = 0; col < size; col++) {
product[row].push(dot(mat1[row], getColumnFrom2DArr(mat2, col)));
}
}
return product;
}
export function buildRotationMatrix(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix(-center[0], -center[1]);
return multiplyTransformMatrices(translationTimesRotation, negativeTranslationMatrix);
}
export function invertTransformMatrix(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot(rotationComponent[0], translationComponent),
-dot(rotationComponent[1], translationComponent),
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1],
];
}
export function rotatePoint(homogeneousCoordinate, rotationMatrix) {
return [
dot(homogeneousCoordinate, rotationMatrix[0]),
dot(homogeneousCoordinate, rotationMatrix[1]),
];
}

View File

@ -219,6 +219,11 @@ export async function predict(input: Tensor, config: Config): Promise<HandResult
}
}
}
for (let i = 0; i < cache.hands.length; i++) { // replace deteced boxes with calculated boxes in final output
const bbox = box.calc(cache.hands[i].keypoints, outputSize);
cache.hands[i].box = bbox.box;
cache.hands[i].boxRaw = bbox.boxRaw;
}
resolve(cache.hands);
});
}

View File

@ -1,69 +0,0 @@
export function normalizeRadians(angle) {
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
}
export function computeRotation(point1, point2) {
const radians = Math.PI / 2 - Math.atan2(-(point2[1] - point1[1]), point2[0] - point1[0]);
return normalizeRadians(radians);
}
export const buildTranslationMatrix = (x, y) => [[1, 0, x], [0, 1, y], [0, 0, 1]];
export function dot(v1, v2) {
let product = 0;
for (let i = 0; i < v1.length; i++) {
product += v1[i] * v2[i];
}
return product;
}
export function getColumnFrom2DArr(arr, columnIndex) {
const column: Array<number> = [];
for (let i = 0; i < arr.length; i++) {
column.push(arr[i][columnIndex]);
}
return column;
}
export function multiplyTransformMatrices(mat1, mat2) {
const product: Array<number[]> = [];
const size = mat1.length;
for (let row = 0; row < size; row++) {
product.push([]);
for (let col = 0; col < size; col++) {
product[row].push(dot(mat1[row], getColumnFrom2DArr(mat2, col)));
}
}
return product;
}
export function buildRotationMatrix(rotation, center) {
const cosA = Math.cos(rotation);
const sinA = Math.sin(rotation);
const rotationMatrix = [[cosA, -sinA, 0], [sinA, cosA, 0], [0, 0, 1]];
const translationMatrix = buildTranslationMatrix(center[0], center[1]);
const translationTimesRotation = multiplyTransformMatrices(translationMatrix, rotationMatrix);
const negativeTranslationMatrix = buildTranslationMatrix(-center[0], -center[1]);
return multiplyTransformMatrices(translationTimesRotation, negativeTranslationMatrix);
}
export function invertTransformMatrix(matrix) {
const rotationComponent = [[matrix[0][0], matrix[1][0]], [matrix[0][1], matrix[1][1]]];
const translationComponent = [matrix[0][2], matrix[1][2]];
const invertedTranslation = [
-dot(rotationComponent[0], translationComponent),
-dot(rotationComponent[1], translationComponent),
];
return [
rotationComponent[0].concat(invertedTranslation[0]),
rotationComponent[1].concat(invertedTranslation[1]),
[0, 0, 1],
];
}
export function rotatePoint(homogeneousCoordinate, rotationMatrix) {
return [
dot(homogeneousCoordinate, rotationMatrix[0]),
dot(homogeneousCoordinate, rotationMatrix[1]),
];
}

View File

@ -17,7 +17,7 @@ import * as face from './face/face';
import * as facemesh from './face/facemesh';
import * as faceres from './face/faceres';
import * as gesture from './gesture/gesture';
import * as handpose from './handpose/handpose';
import * as handpose from './hand/handpose';
import * as handtrack from './hand/handtrack';
import * as humangl from './tfjs/humangl';
import * as image from './image/image';

View File

@ -13,7 +13,7 @@ import * as efficientpose from './body/efficientpose';
import * as emotion from './gear/emotion';
import * as facemesh from './face/facemesh';
import * as faceres from './face/faceres';
import * as handpose from './handpose/handpose';
import * as handpose from './hand/handpose';
import * as handtrack from './hand/handtrack';
import * as iris from './face/iris';
import * as movenet from './body/movenet';

View File

@ -1,24 +1,24 @@
2021-10-19 11:25:08 INFO:  @vladmandic/human version 2.3.5
2021-10-19 11:25:08 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.10.0
2021-10-19 11:25:08 INFO:  Application: {"name":"@vladmandic/human","version":"2.3.5"}
2021-10-19 11:25:08 INFO:  Environment: {"profile":"production","config":"build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2021-10-19 11:25:08 INFO:  Toolchain: {"build":"0.6.1","esbuild":"0.13.8","typescript":"4.4.4","typedoc":"0.22.6","eslint":"8.0.1"}
2021-10-19 11:25:08 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2021-10-19 11:25:08 STATE: Clean: {"locations":["dist/*","types/*","typedoc/*"]}
2021-10-19 11:25:08 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1275}
2021-10-19 11:25:08 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":55,"inputBytes":523852,"outputBytes":434685}
2021-10-19 11:25:08 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1283}
2021-10-19 11:25:08 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":55,"inputBytes":523860,"outputBytes":434689}
2021-10-19 11:25:08 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1350}
2021-10-19 11:25:08 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":55,"inputBytes":523927,"outputBytes":434761}
2021-10-19 11:25:08 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1631}
2021-10-19 11:25:08 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":3085,"outputBytes":856}
2021-10-19 11:25:08 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":55,"inputBytes":523433,"outputBytes":436244}
2021-10-19 11:25:09 STATE: Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":3085,"outputBytes":2691961}
2021-10-19 11:25:09 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":55,"inputBytes":3214538,"outputBytes":1611255}
2021-10-19 11:25:10 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":55,"inputBytes":3214538,"outputBytes":2928109}
2021-10-19 11:25:28 STATE: Typings: {"input":"src/human.ts","output":"types","files":6}
2021-10-19 11:25:34 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":36,"generated":true}
2021-10-19 11:26:04 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":91,"errors":0,"warnings":0}
2021-10-19 11:26:05 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2021-10-19 11:26:05 INFO:  Done...
2021-10-20 09:09:37 INFO:  @vladmandic/human version 2.3.5
2021-10-20 09:09:37 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.10.0
2021-10-20 09:09:37 INFO:  Application: {"name":"@vladmandic/human","version":"2.3.5"}
2021-10-20 09:09:37 INFO:  Environment: {"profile":"production","config":"build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2021-10-20 09:09:37 INFO:  Toolchain: {"build":"0.6.2","esbuild":"0.13.8","typescript":"4.4.4","typedoc":"0.22.6","eslint":"8.0.1"}
2021-10-20 09:09:37 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2021-10-20 09:09:37 STATE: Clean: {"locations":["dist/*","types/*","typedoc/*"]}
2021-10-20 09:09:37 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1275}
2021-10-20 09:09:38 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":54,"inputBytes":524046,"outputBytes":434832}
2021-10-20 09:09:38 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1283}
2021-10-20 09:09:38 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":54,"inputBytes":524054,"outputBytes":434836}
2021-10-20 09:09:38 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1350}
2021-10-20 09:09:38 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":54,"inputBytes":524121,"outputBytes":434908}
2021-10-20 09:09:38 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1631}
2021-10-20 09:09:38 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":3085,"outputBytes":856}
2021-10-20 09:09:38 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":54,"inputBytes":523627,"outputBytes":436428}
2021-10-20 09:09:38 STATE: Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":3085,"outputBytes":2691961}
2021-10-20 09:09:39 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":54,"inputBytes":3214732,"outputBytes":1611375}
2021-10-20 09:09:39 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":54,"inputBytes":3214732,"outputBytes":2928293}
2021-10-20 09:09:58 STATE: Typings: {"input":"src/human.ts","output":"types","files":6}
2021-10-20 09:10:04 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":36,"generated":true}
2021-10-20 09:10:38 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":90,"errors":0,"warnings":0}
2021-10-20 09:10:39 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2021-10-20 09:10:39 INFO:  Done...

View File

@ -0,0 +1 @@
{"version":3,"file":"handpose.d.ts","sourceRoot":"","sources":["../../../src/hand/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

@ -6,4 +6,4 @@ export declare const anchors: {
x: number;
y: number;
}[];
//# sourceMappingURL=anchors.d.ts.map
//# sourceMappingURL=handposeanchors.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"handposeanchors.d.ts","sourceRoot":"","sources":["../../../src/hand/handposeanchors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,OAAO;;;GAi4FnB,CAAC"}

View File

@ -25,4 +25,4 @@ export declare class HandDetector {
confidence: number;
}[]>;
}
//# sourceMappingURL=handdetector.d.ts.map
//# sourceMappingURL=handposedetector.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"handposedetector.d.ts","sourceRoot":"","sources":["../../../src/hand/handposedetector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAExD,qBAAa,YAAY;IACvB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;gBAElB,KAAK,KAAA;IASjB,cAAc,CAAC,KAAK,KAAA;IAYpB,kBAAkB,CAAC,gBAAgB,KAAA,EAAE,KAAK,KAAA;IAOpC,QAAQ,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA;aAWA,MAAM;uBAAiB,MAAM;oBAAc,MAAM;;IAWvE,kBAAkB,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAmB9I"}

View File

@ -2,7 +2,7 @@
* HandPose model implementation
* See `handpose.ts` for entry point
*/
import type * as detector from './handdetector';
import type * as detector from './handposedetector';
import type { GraphModel } from '../tfjs/types';
export declare class HandPipeline {
handDetector: detector.HandDetector;
@ -43,4 +43,4 @@ export declare class HandPipeline {
};
}[]>;
}
//# sourceMappingURL=handpipeline.d.ts.map
//# sourceMappingURL=handposepipeline.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"handposepipeline.d.ts","sourceRoot":"","sources":["../../../src/hand/handposepipeline.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,KAAK,QAAQ,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAU,UAAU,EAAE,MAAM,eAAe,CAAC;AASxD,qBAAa,YAAY;IACvB,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC;IACpC,aAAa,EAAE,UAAU,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACrH,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;gBAEV,YAAY,KAAA,EAAE,aAAa,KAAA;IAUvC,6BAA6B,CAAC,SAAS,KAAA;;;;IAQvC,sBAAsB,CAAC,aAAa,KAAA,EAAE,cAAc,KAAA;;;;;IAMpD,sBAAsB,CAAC,SAAS,KAAA;;;;;IAUhC,kBAAkB,CAAC,SAAS,KAAA,EAAE,IAAI,KAAA,EAAE,KAAK,KAAA,EAAE,cAAc,KAAA;IA0BnD,aAAa,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA;mBAoBC,MAAM,EAAE;oBAAc,MAAM;uBAAiB,MAAM;0BAAoB,MAAM;aAAO;YAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAAC,WAAW,EAAE,MAAM,EAAE,CAAA;SAAE;;CA4DnK"}

View File

@ -1,7 +1,3 @@
/**
* HandPose model implementation
* See `handpose.ts` for entry point
*/
export declare function getBoxSize(box: any): number[];
export declare function getBoxCenter(box: any): any[];
export declare function cutBoxFromImageAndResize(box: any, image: any, cropSize: any): any;
@ -26,4 +22,13 @@ export declare function shiftBox(box: any, shiftFactor: any): {
endPoint: any[];
palmLandmarks: any;
};
//# sourceMappingURL=box.d.ts.map
export declare function normalizeRadians(angle: any): number;
export declare function computeRotation(point1: any, point2: any): number;
export declare const buildTranslationMatrix: (x: any, y: any) => any[][];
export declare function dot(v1: any, v2: any): number;
export declare function getColumnFrom2DArr(arr: any, columnIndex: any): number[];
export declare function multiplyTransformMatrices(mat1: any, mat2: any): number[][];
export declare function buildRotationMatrix(rotation: any, center: any): number[][];
export declare function invertTransformMatrix(matrix: any): any[][];
export declare function rotatePoint(homogeneousCoordinate: any, rotationMatrix: any): number[];
//# sourceMappingURL=handposeutil.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"handposeutil.d.ts","sourceRoot":"","sources":["../../../src/hand/handposeutil.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,GAAG,KAAA,YAK7B;AAED,wBAAgB,YAAY,CAAC,GAAG,KAAA,SAK/B;AAED,wBAAgB,wBAAwB,CAAC,GAAG,KAAA,EAAE,KAAK,KAAA,EAAE,QAAQ,KAAA,OAU5D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,KAAA,EAAE,MAAM,KAAA;;;;;EAQ9C;AAED,wBAAgB,UAAU,CAAC,GAAG,KAAA,EAAE,MAAM,SAAM;;;;EAO3C;AAED,wBAAgB,WAAW,CAAC,GAAG,KAAA;;;;EAQ9B;AAED,wBAAgB,QAAQ,CAAC,GAAG,KAAA,EAAE,WAAW,KAAA;;;;EASxC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,KAAA,UAErC;AAED,wBAAgB,eAAe,CAAC,MAAM,KAAA,EAAE,MAAM,KAAA,UAG7C;AAED,eAAO,MAAM,sBAAsB,6BAA8C,CAAC;AAElF,wBAAgB,GAAG,CAAC,EAAE,KAAA,EAAE,EAAE,KAAA,UAMzB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,KAAA,EAAE,WAAW,KAAA,YAMlD;AAED,wBAAgB,yBAAyB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,cAUnD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,KAAA,EAAE,MAAM,KAAA,cAQnD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,KAAA,WAY3C;AAED,wBAAgB,WAAW,CAAC,qBAAqB,KAAA,EAAE,cAAc,KAAA,YAKhE"}

View File

@ -1 +1 @@
{"version":3,"file":"handtrack.d.ts","sourceRoot":"","sources":["../../../src/hand/handtrack.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA8CxC,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;AA0FD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAwClF"}
{"version":3,"file":"handtrack.d.ts","sourceRoot":"","sources":["../../../src/hand/handtrack.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA8CxC,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;AA0FD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA6ClF"}

View File

@ -1 +0,0 @@
{"version":3,"file":"anchors.d.ts","sourceRoot":"","sources":["../../../src/handpose/anchors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,OAAO;;;GAi4FnB,CAAC"}

View File

@ -1 +0,0 @@
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../../src/handpose/box.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,UAAU,CAAC,GAAG,KAAA,YAK7B;AAED,wBAAgB,YAAY,CAAC,GAAG,KAAA,SAK/B;AAED,wBAAgB,wBAAwB,CAAC,GAAG,KAAA,EAAE,KAAK,KAAA,EAAE,QAAQ,KAAA,OAU5D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,KAAA,EAAE,MAAM,KAAA;;;;;EAQ9C;AAED,wBAAgB,UAAU,CAAC,GAAG,KAAA,EAAE,MAAM,SAAM;;;;EAO3C;AAED,wBAAgB,WAAW,CAAC,GAAG,KAAA;;;;EAQ9B;AAED,wBAAgB,QAAQ,CAAC,GAAG,KAAA,EAAE,WAAW,KAAA;;;;EASxC"}

View File

@ -1 +0,0 @@
{"version":3,"file":"handdetector.d.ts","sourceRoot":"","sources":["../../../src/handpose/handdetector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAExD,qBAAa,YAAY;IACvB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;gBAElB,KAAK,KAAA;IASjB,cAAc,CAAC,KAAK,KAAA;IAYpB,kBAAkB,CAAC,gBAAgB,KAAA,EAAE,KAAK,KAAA;IAOpC,QAAQ,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA;aAWA,MAAM;uBAAiB,MAAM;oBAAc,MAAM;;IAWvE,kBAAkB,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAmB9I"}

View File

@ -1 +0,0 @@
{"version":3,"file":"handpipeline.d.ts","sourceRoot":"","sources":["../../../src/handpose/handpipeline.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAU,UAAU,EAAE,MAAM,eAAe,CAAC;AASxD,qBAAa,YAAY;IACvB,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC;IACpC,aAAa,EAAE,UAAU,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACrH,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;gBAEV,YAAY,KAAA,EAAE,aAAa,KAAA;IAUvC,6BAA6B,CAAC,SAAS,KAAA;;;;IAQvC,sBAAsB,CAAC,aAAa,KAAA,EAAE,cAAc,KAAA;;;;;IAMpD,sBAAsB,CAAC,SAAS,KAAA;;;;;IAUhC,kBAAkB,CAAC,SAAS,KAAA,EAAE,IAAI,KAAA,EAAE,KAAK,KAAA,EAAE,cAAc,KAAA;IA0BnD,aAAa,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA;mBAoBC,MAAM,EAAE;oBAAc,MAAM;uBAAiB,MAAM;0BAAoB,MAAM;aAAO;YAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAAC,WAAW,EAAE,MAAM,EAAE,CAAA;SAAE;;CA4DnK"}

View File

@ -1 +0,0 @@
{"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,10 +0,0 @@
export declare function normalizeRadians(angle: any): number;
export declare function computeRotation(point1: any, point2: any): number;
export declare const buildTranslationMatrix: (x: any, y: any) => any[][];
export declare function dot(v1: any, v2: any): number;
export declare function getColumnFrom2DArr(arr: any, columnIndex: any): number[];
export declare function multiplyTransformMatrices(mat1: any, mat2: any): number[][];
export declare function buildRotationMatrix(rotation: any, center: any): number[][];
export declare function invertTransformMatrix(matrix: any): any[][];
export declare function rotatePoint(homogeneousCoordinate: any, rotationMatrix: any): number[];
//# sourceMappingURL=util.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/handpose/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,KAAK,KAAA,UAErC;AAED,wBAAgB,eAAe,CAAC,MAAM,KAAA,EAAE,MAAM,KAAA,UAG7C;AAED,eAAO,MAAM,sBAAsB,6BAA8C,CAAC;AAElF,wBAAgB,GAAG,CAAC,EAAE,KAAA,EAAE,EAAE,KAAA,UAMzB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,KAAA,EAAE,WAAW,KAAA,YAMlD;AAED,wBAAgB,yBAAyB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,cAUnD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,KAAA,EAAE,MAAM,KAAA,cAQnD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,KAAA,WAY3C;AAED,wBAAgB,WAAW,CAAC,qBAAqB,KAAA,EAAE,cAAc,KAAA,YAKhE"}