mirror of https://github.com/vladmandic/human
update gestures
parent
203178e28f
commit
547d599479
|
@ -9,8 +9,9 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
|
|||
|
||||
## Changelog
|
||||
|
||||
### **HEAD -> main** 2021/04/16 mandic00@live.com
|
||||
### **HEAD -> main** 2021/04/18 mandic00@live.com
|
||||
|
||||
- full test run
|
||||
- full rebuild
|
||||
- new look
|
||||
- added benchmarks
|
||||
|
|
|
@ -64,6 +64,7 @@ const ui = {
|
|||
framesDetect: 0, // internal, statistics on frames detected
|
||||
bench: true, // show gl fps benchmark window
|
||||
lastFrame: 0, // time of last frame processing
|
||||
viewportSet: false, // internal, has custom viewport been set
|
||||
};
|
||||
|
||||
// global variables
|
||||
|
@ -559,10 +560,12 @@ function setupMenu() {
|
|||
}
|
||||
|
||||
async function resize() {
|
||||
window.onresize = null;
|
||||
const viewportScale = Math.min(1, Math.round(100 * window.innerWidth / 960) / 100);
|
||||
const viewport = document.querySelector('meta[name=viewport]');
|
||||
viewport.setAttribute('content', `width=device-width, shrink-to-fit=yes, minimum-scale=0.2, maximum-scale=2.0, user-scalable=yes, initial-scale=${viewportScale}`);
|
||||
if (!ui.viewportSet) {
|
||||
const viewport = document.querySelector('meta[name=viewport]');
|
||||
viewport.setAttribute('content', `width=device-width, shrink-to-fit=yes, minimum-scale=0.2, maximum-scale=2.0, user-scalable=yes, initial-scale=${viewportScale}`);
|
||||
ui.viewportSet = true;
|
||||
}
|
||||
const x = [`${document.getElementById('btnDisplay').offsetLeft}px`, `${document.getElementById('btnImage').offsetLeft}px`, `${document.getElementById('btnProcess').offsetLeft}px`, `${document.getElementById('btnModel').offsetLeft}px`];
|
||||
|
||||
const top = `${document.getElementById('menubar').clientHeight - 3}px`;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -66,3 +66,20 @@
|
|||
2021-04-18 19:33:09 [36mINFO: [39m Generate types: ["src/human.ts"]
|
||||
2021-04-18 19:33:14 [36mINFO: [39m Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
|
||||
2021-04-18 19:33:14 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"]
|
||||
2021-04-19 09:25:22 [36mINFO: [39m @vladmandic/human version 1.6.0
|
||||
2021-04-19 09:25:22 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v15.7.0
|
||||
2021-04-19 09:25:22 [36mINFO: [39m Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true,"sourcemap":true,"bundle":true,"metafile":true,"target":"es2018"}
|
||||
2021-04-19 09:25:22 [35mSTATE:[39m Build for: node type: tfjs: {"imports":1,"importBytes":39,"outputBytes":733,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-19 09:25:22 [35mSTATE:[39m Build for: node type: node: {"imports":46,"importBytes":547188,"outputBytes":305386,"outputFiles":"dist/human.node.js"}
|
||||
2021-04-19 09:25:22 [35mSTATE:[39m Build for: nodeGPU type: tfjs: {"imports":1,"importBytes":43,"outputBytes":737,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-19 09:25:22 [35mSTATE:[39m Build for: nodeGPU type: node: {"imports":46,"importBytes":547192,"outputBytes":305394,"outputFiles":"dist/human.node-gpu.js"}
|
||||
2021-04-19 09:25:22 [35mSTATE:[39m Build for: nodeWASM type: tfjs: {"imports":1,"importBytes":81,"outputBytes":783,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-19 09:25:23 [35mSTATE:[39m Build for: nodeWASM type: node: {"imports":46,"importBytes":547238,"outputBytes":305438,"outputFiles":"dist/human.node-wasm.js"}
|
||||
2021-04-19 09:25:23 [35mSTATE:[39m Build for: browserNoBundle type: tfjs: {"imports":1,"importBytes":2488,"outputBytes":1394,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-19 09:25:23 [35mSTATE:[39m Build for: browserNoBundle type: esm: {"imports":46,"importBytes":547849,"outputBytes":305385,"outputFiles":"dist/human.esm-nobundle.js"}
|
||||
2021-04-19 09:25:23 [35mSTATE:[39m Build for: browserBundle type: tfjs: {"modules":1262,"moduleBytes":4068263,"imports":7,"importBytes":2488,"outputBytes":1097287,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-19 09:25:24 [35mSTATE:[39m Build for: browserBundle type: iife: {"imports":46,"importBytes":1643742,"outputBytes":1398814,"outputFiles":"dist/human.js"}
|
||||
2021-04-19 09:25:24 [35mSTATE:[39m Build for: browserBundle type: esm: {"imports":46,"importBytes":1643742,"outputBytes":1398772,"outputFiles":"dist/human.esm.js"}
|
||||
2021-04-19 09:25:24 [36mINFO: [39m Generate types: ["src/human.ts"]
|
||||
2021-04-19 09:25:30 [36mINFO: [39m Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
|
||||
2021-04-19 09:25:30 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"]
|
||||
|
|
|
@ -49,7 +49,7 @@ export const options: DrawOptions = {
|
|||
labelColor: <string>'rgba(173, 216, 230, 1)', // 'lightblue' with dark alpha channel
|
||||
shadowColor: <string>'black',
|
||||
font: <string>'small-caps 16px "Segoe UI"',
|
||||
lineHeight: <number>20,
|
||||
lineHeight: <number>24,
|
||||
lineWidth: <number>6,
|
||||
pointSize: <number>2,
|
||||
roundRect: <number>28,
|
||||
|
|
|
@ -52,14 +52,27 @@ export const iris = (res) => {
|
|||
const sizeYRight = res[i].annotations.rightEyeIris[4][1] - res[i].annotations.rightEyeIris[2][1];
|
||||
const areaRight = Math.abs(sizeXRight * sizeYRight);
|
||||
|
||||
let center = false;
|
||||
const difference = Math.abs(areaLeft - areaRight) / Math.max(areaLeft, areaRight);
|
||||
if (difference < 0.25) gestures.push({ iris: i, gesture: 'facing center' });
|
||||
if (difference < 0.25) {
|
||||
center = true;
|
||||
gestures.push({ iris: i, gesture: 'facing center' });
|
||||
}
|
||||
|
||||
const rightIrisCenterX = Math.abs(res[i].mesh[33][0] - res[i].annotations.rightEyeIris[0][0]) / res[i].annotations.rightEyeIris[0][0];
|
||||
const leftIrisCenterX = Math.abs(res[i].mesh[263][0] - res[i].annotations.leftEyeIris[0][0]) / res[i].annotations.leftEyeIris[0][0];
|
||||
if (leftIrisCenterX > 0.025 && rightIrisCenterX > 0.025) gestures.push({ iris: i, gesture: 'looking center' });
|
||||
else if (leftIrisCenterX > 0.025) gestures.push({ iris: i, gesture: 'looking right' });
|
||||
else if (rightIrisCenterX > 0.025) gestures.push({ iris: i, gesture: 'looking left' });
|
||||
if (leftIrisCenterX > 0.033 || rightIrisCenterX > 0.033) center = false;
|
||||
if (leftIrisCenterX > 0.033) gestures.push({ iris: i, gesture: 'looking right' });
|
||||
if (rightIrisCenterX > 0.033) gestures.push({ iris: i, gesture: 'looking left' });
|
||||
|
||||
const rightIrisCenterY = Math.abs(res[i].mesh[145][1] - res[i].annotations.rightEyeIris[0][1]) / res[i].annotations.rightEyeIris[0][1];
|
||||
const leftIrisCenterY = Math.abs(res[i].mesh[374][1] - res[i].annotations.leftEyeIris[0][1]) / res[i].annotations.leftEyeIris[0][1];
|
||||
if (leftIrisCenterY < 0.015 || rightIrisCenterY < 0.015 || leftIrisCenterY > 0.030 || rightIrisCenterY > 0.030) center = false;
|
||||
if (leftIrisCenterY < 0.015 || rightIrisCenterY < 0.015) gestures.push({ iris: i, gesture: 'looking down' });
|
||||
if (leftIrisCenterY > 0.030 || rightIrisCenterY > 0.030) gestures.push({ iris: i, gesture: 'looking up' });
|
||||
|
||||
// still center;
|
||||
if (center) gestures.push({ iris: i, gesture: 'looking center' });
|
||||
}
|
||||
return gestures;
|
||||
};
|
||||
|
|
|
@ -401,7 +401,12 @@ export class Human {
|
|||
|
||||
// disable video optimization for inputs of type image
|
||||
let previousVideoOptimized;
|
||||
if (input && this.config.videoOptimized && (input instanceof HTMLImageElement || input instanceof Image || input instanceof ImageData || (typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) || input instanceof tf.Tensor)) {
|
||||
if (input && this.config.videoOptimized && (
|
||||
(typeof HTMLImageElement !== 'undefined' && input instanceof HTMLImageElement)
|
||||
|| (typeof Image !== 'undefined' && input instanceof Image)
|
||||
|| (typeof ImageData !== 'undefined' && input instanceof ImageData)
|
||||
|| (typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap))
|
||||
) {
|
||||
log('disabling video optimization');
|
||||
previousVideoOptimized = this.config.videoOptimized;
|
||||
this.config.videoOptimized = false;
|
||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit ddf8fb116b159dc3dabea4cb858b608fa5914355
|
||||
Subproject commit a137e535d323ce971865ff3d592eaf964ea65ee2
|
Loading…
Reference in New Issue