pull/134/head
Vladimir Mandic 2021-06-05 15:10:28 -04:00
parent 14af225bdc
commit 613a86fbf4
10 changed files with 206485 additions and 4538 deletions

View File

@ -29,11 +29,13 @@ onmessage = async (msg) => {
}
if (result.canvas) { // convert canvas to imageData and send it by reference
const ctx = result.canvas.getContext('2d');
const img = ctx?.getImageData(0, 0, result.canvas.width, result.canvas.height);
const canvas = new OffscreenCanvas(result.canvas.width, result.canvas.height);
const ctx = canvas.getContext('2d');
if (ctx) ctx.drawImage(result.canvas, 0, 0);
const img = ctx ? ctx.getImageData(0, 0, result.canvas.width, result.canvas.height) : null;
result.canvas = null; // must strip original canvas from return value as it cannot be transfered from worker thread
// @ts-ignore tslint wrong type matching for worker
if (img) postMessage({ result, image: img.data.buffer, width: msg.data.width, height: msg.data.height }, [img?.data.buffer]);
if (img) postMessage({ result, image: img.data.buffer, width: msg.data.width, height: msg.data.height }, [img.data.buffer]);
// @ts-ignore tslint wrong type matching for worker
else postMessage({ result });
} else {

View File

@ -415,7 +415,10 @@ function webWorker(input, image, canvas, timestamp) {
}
ui.framesDetect++;
if (!ui.drawThread) drawResults(input);
if (!ui.drawThread) {
status();
drawResults(input);
}
// eslint-disable-next-line no-use-before-define
ui.detectThread = requestAnimationFrame((now) => runHumanDetect(input, canvas, now));
});
@ -455,7 +458,6 @@ function runHumanDetect(input, canvas, timestamp) {
const data = ctx.getImageData(0, 0, canvas.width, canvas.height);
// perform detection in worker
webWorker(input, data, canvas, timestamp);
status();
} else {
human.detect(input, userConfig).then((result) => {
status();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

69427
dist/human.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

69453
dist/human.js vendored

File diff suppressed because one or more lines are too long

12
dist/human.node.js vendored
View File

@ -1,10 +1,10 @@
/*
Human library
homepage: <https://github.com/vladmandic/human>
author: <https://github.com/vladmandic>'
*/
/*
Human library
homepage: <https://github.com/vladmandic/human>
author: <https://github.com/vladmandic>'
*/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

61140
dist/tfjs.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long