add id and boxraw on missing objects

pull/280/head
Vladimir Mandic 2021-05-22 12:41:29 -04:00
parent 714d95f6ed
commit 4b221c17ea
4 changed files with 8 additions and 3 deletions

View File

@ -9,7 +9,8 @@ import webRTC from './helpers/webrtc.js';
let human; let human;
const userConfig = { const userConfig = {
warmup: 'none', warmup: 'full',
/*
backend: 'webgl', backend: 'webgl',
async: false, async: false,
cacheSensitivity: 0, cacheSensitivity: 0,
@ -29,6 +30,7 @@ const userConfig = {
body: { enabled: true, modelPath: 'posenet.json' }, body: { enabled: true, modelPath: 'posenet.json' },
// body: { enabled: true, modelPath: 'blazepose.json' }, // body: { enabled: true, modelPath: 'blazepose.json' },
object: { enabled: false }, object: { enabled: false },
*/
}; };
// ui options // ui options

View File

@ -538,6 +538,7 @@ export class Human {
object: objectRes, object: objectRes,
performance: this.perf, performance: this.perf,
canvas: process.canvas, canvas: process.canvas,
timestamp: Date.now(),
}; };
// log('Result:', result); // log('Result:', result);
resolve(res); resolve(res);

View File

@ -32,7 +32,8 @@ export function getBoundingBox(keypoints) {
export function scalePoses(poses, [height, width], [inputResolutionHeight, inputResolutionWidth]) { export function scalePoses(poses, [height, width], [inputResolutionHeight, inputResolutionWidth]) {
const scaleY = height / inputResolutionHeight; const scaleY = height / inputResolutionHeight;
const scaleX = width / inputResolutionWidth; const scaleX = width / inputResolutionWidth;
const scalePose = (pose) => ({ const scalePose = (pose, i) => ({
id: i,
score: pose.score, score: pose.score,
bowRaw: [pose.box[0] / inputResolutionWidth, pose.box[1] / inputResolutionHeight, pose.box[2] / inputResolutionWidth, pose.box[3] / inputResolutionHeight], 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)], 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) }, 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; return scaledPoses;
} }

View File

@ -150,4 +150,5 @@ export interface Result {
object: Array<Item> object: Array<Item>
performance: { any }, performance: { any },
canvas: OffscreenCanvas | HTMLCanvasElement, canvas: OffscreenCanvas | HTMLCanvasElement,
timestamp: number,
} }