update handtrack skip algorithm

pull/356/head
Vladimir Mandic 2021-10-13 14:49:41 -04:00
parent 9505c8c80e
commit 37a8892cfe
3 changed files with 6 additions and 3 deletions

View File

@ -11,6 +11,7 @@
### **HEAD -> main** 2021/10/13 mandic00@live.com ### **HEAD -> main** 2021/10/13 mandic00@live.com
- add optional anti-spoofing module
- add node-match advanced example using worker thread pool - add node-match advanced example using worker thread pool
- package updates - package updates
- optimize image preprocessing - optimize image preprocessing

View File

@ -196,9 +196,11 @@ export async function predict(input: Tensor, config: Config): Promise<HandResult
return cache.hands; // return cached results without running anything return cache.hands; // return cached results without running anything
} }
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
if (config.skipFrame && skipped < 5 * (config.hand.skipFrames || 0) && cache.hands.length > 0) { // we have some cached results but although not sure if its enough we continute anyhow for bit longer if (config.skipFrame && cache.hands.length === config.hand.maxDetected) { // we have all detected hands
cache.hands = await Promise.all(cache.boxes.map((handBox) => detectFingers(input, handBox, config))); cache.hands = await Promise.all(cache.boxes.map((handBox) => detectFingers(input, handBox, config)));
} else { } else if (config.skipFrame && skipped < 3 * (config.hand.skipFrames || 0) && cache.hands.length > 0) { // we have some cached results but although not sure if its enough we continute anyhow for bit longer
cache.hands = await Promise.all(cache.boxes.map((handBox) => detectFingers(input, handBox, config)));
} else { // finally rerun detector
cache.boxes = await detectHands(input, config); cache.boxes = await detectHands(input, config);
cache.hands = await Promise.all(cache.boxes.map((handBox) => detectFingers(input, handBox, config))); cache.hands = await Promise.all(cache.boxes.map((handBox) => detectFingers(input, handBox, config)));
skipped = 0; skipped = 0;

View File

@ -173,7 +173,7 @@ async function test(Human, inputConfig) {
await human.load(); await human.load();
const models = Object.keys(human.models).map((model) => ({ name: model, loaded: (human.models[model] !== null) })); const models = Object.keys(human.models).map((model) => ({ name: model, loaded: (human.models[model] !== null) }));
const loaded = models.filter((model) => model.loaded); const loaded = models.filter((model) => model.loaded);
if (models.length === 20 && loaded.length === 10) log('state', 'passed: models loaded', models.length, loaded.length, models); if (models.length === 21 && loaded.length === 10) log('state', 'passed: models loaded', models.length, loaded.length, models);
else log('error', 'failed: models loaded', models.length, loaded.length, models); else log('error', 'failed: models loaded', models.length, loaded.length, models);
// increase defaults // increase defaults