diff --git a/src/draw/draw.ts b/src/draw/draw.ts index eb386837..99c18987 100644 --- a/src/draw/draw.ts +++ b/src/draw/draw.ts @@ -404,8 +404,8 @@ export async function hand(inCanvas: HTMLCanvasElement, result: Array, dra ctx.stroke(); } if (localOptions.drawPoints) { - if (h.landmarks && h.landmarks.length > 0) { - for (const pt of h.landmarks) { + if (h.keypoints && h.keypoints.length > 0) { + for (const pt of h.keypoints) { ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + (2 * pt[2])}, ${127.5 - (2 * pt[2])}, 255, 0.5)` : localOptions.color; point(ctx, pt[0], pt[1], 0, localOptions); } diff --git a/src/handpose/handpose.ts b/src/handpose/handpose.ts index 6f886790..1f6c3325 100644 --- a/src/handpose/handpose.ts +++ b/src/handpose/handpose.ts @@ -35,12 +35,12 @@ export async function predict(input, config): Promise { } } - const landmarks = predictions[i].landmarks as unknown as Array<[number, number, number]>; + const keypoints = predictions[i].landmarks as unknown as Array<[number, number, number]>; let box: [number, number, number, number] = [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, 0, 0]; // maximums so conditionals work let boxRaw: [number, number, number, number] = [0, 0, 0, 0]; - if (landmarks && landmarks.length > 0) { // if we have landmarks, calculate box based on landmarks - for (const pt of landmarks) { + if (keypoints && keypoints.length > 0) { // if we have landmarks, calculate box based on landmarks + for (const pt of keypoints) { if (pt[0] < box[0]) box[0] = pt[0]; if (pt[1] < box[1]) box[1] = pt[1]; if (pt[0] > box[2]) box[2] = pt[0]; @@ -63,7 +63,7 @@ export async function predict(input, config): Promise { (predictions[i].box.bottomRight[1] - predictions[i].box.topLeft[1]) / input.shape[1], ]; } - hands.push({ id: i, confidence: Math.round(100 * predictions[i].confidence) / 100, box, boxRaw, landmarks, annotations }); + hands.push({ id: i, confidence: Math.round(100 * predictions[i].confidence) / 100, box, boxRaw, keypoints, annotations }); } return hands; } diff --git a/src/interpolate.ts b/src/interpolate.ts index 4739f80b..27e4d9b4 100644 --- a/src/interpolate.ts +++ b/src/interpolate.ts @@ -48,16 +48,16 @@ export function calc(newResult: Result): Result { .map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].box[j] + b) / bufferedFactor)) as [number, number, number, number]; const boxRaw = (newResult.hand[i].boxRaw // update boxRaw .map((b, j) => ((bufferedFactor - 1) * bufferedResult.hand[i].boxRaw[j] + b) / bufferedFactor)) as [number, number, number, number]; - const landmarks = newResult.hand[i].landmarks // update landmarks + const keypoints = newResult.hand[i].keypoints // update landmarks .map((landmark, j) => landmark - .map((coord, k) => (((bufferedFactor - 1) * bufferedResult.hand[i].landmarks[j][k] + coord) / bufferedFactor)) as [number, number, number]); + .map((coord, k) => (((bufferedFactor - 1) * bufferedResult.hand[i].keypoints[j][k] + coord) / bufferedFactor)) as [number, number, number]); const keys = Object.keys(newResult.hand[i].annotations); // update annotations const annotations = {}; for (const key of keys) { annotations[key] = newResult.hand[i].annotations[key] .map((val, j) => val.map((coord, k) => ((bufferedFactor - 1) * bufferedResult.hand[i].annotations[key][j][k] + coord) / bufferedFactor)); } - bufferedResult.hand[i] = { ...newResult.hand[i], box, boxRaw, landmarks, annotations }; // shallow clone plus updated values + bufferedResult.hand[i] = { ...newResult.hand[i], box, boxRaw, keypoints, annotations }; // shallow clone plus updated values } } diff --git a/src/result.ts b/src/result.ts index f6f63c69..98742740 100644 --- a/src/result.ts +++ b/src/result.ts @@ -97,7 +97,7 @@ export interface Hand { confidence: number, box: [number, number, number, number], boxRaw: [number, number, number, number], - landmarks: Array<[number, number, number]>, + keypoints: Array<[number, number, number]>, annotations: Record>, }