From 4b221c17ea1904899e513bfd382cd6c9d8ccafb7 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 22 May 2021 12:41:29 -0400 Subject: [PATCH] add id and boxraw on missing objects --- demo/index.js | 4 +++- src/human.ts | 1 + src/posenet/utils.ts | 5 +++-- src/result.ts | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/demo/index.js b/demo/index.js index dc568476..c4cf54a3 100644 --- a/demo/index.js +++ b/demo/index.js @@ -9,7 +9,8 @@ import webRTC from './helpers/webrtc.js'; let human; const userConfig = { - warmup: 'none', + warmup: 'full', + /* backend: 'webgl', async: false, cacheSensitivity: 0, @@ -29,6 +30,7 @@ const userConfig = { body: { enabled: true, modelPath: 'posenet.json' }, // body: { enabled: true, modelPath: 'blazepose.json' }, object: { enabled: false }, + */ }; // ui options diff --git a/src/human.ts b/src/human.ts index 89ec09db..0f2926b3 100644 --- a/src/human.ts +++ b/src/human.ts @@ -538,6 +538,7 @@ export class Human { object: objectRes, performance: this.perf, canvas: process.canvas, + timestamp: Date.now(), }; // log('Result:', result); resolve(res); diff --git a/src/posenet/utils.ts b/src/posenet/utils.ts index 2423d791..a38dd8e0 100644 --- a/src/posenet/utils.ts +++ b/src/posenet/utils.ts @@ -32,7 +32,8 @@ export function getBoundingBox(keypoints) { export function scalePoses(poses, [height, width], [inputResolutionHeight, inputResolutionWidth]) { const scaleY = height / inputResolutionHeight; const scaleX = width / inputResolutionWidth; - const scalePose = (pose) => ({ + const scalePose = (pose, i) => ({ + id: i, score: pose.score, bowRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight], box: [Math.trunc(pose.box[0] * scaleX), Math.trunc(pose.box[1] * scaleY), Math.trunc(pose.box[2] * scaleX), Math.trunc(pose.box[3] * scaleY)], @@ -42,7 +43,7 @@ export function scalePoses(poses, [height, width], [inputResolutionHeight, input position: { x: Math.trunc(position.x * scaleX), y: Math.trunc(position.y * scaleY) }, })), }); - const scaledPoses = poses.map((pose) => scalePose(pose)); + const scaledPoses = poses.map((pose, i) => scalePose(pose, i)); return scaledPoses; } diff --git a/src/result.ts b/src/result.ts index 84f5df00..814426c2 100644 --- a/src/result.ts +++ b/src/result.ts @@ -150,4 +150,5 @@ export interface Result { object: Array performance: { any }, canvas: OffscreenCanvas | HTMLCanvasElement, + timestamp: number, }