mirror of https://github.com/vladmandic/human
update gestures
parent
e0666cebe2
commit
d270a45492
|
@ -9,8 +9,9 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### **HEAD -> main** 2021/04/16 mandic00@live.com
|
### **HEAD -> main** 2021/04/18 mandic00@live.com
|
||||||
|
|
||||||
|
- full test run
|
||||||
- full rebuild
|
- full rebuild
|
||||||
- new look
|
- new look
|
||||||
- added benchmarks
|
- added benchmarks
|
||||||
|
|
|
@ -64,6 +64,7 @@ const ui = {
|
||||||
framesDetect: 0, // internal, statistics on frames detected
|
framesDetect: 0, // internal, statistics on frames detected
|
||||||
bench: true, // show gl fps benchmark window
|
bench: true, // show gl fps benchmark window
|
||||||
lastFrame: 0, // time of last frame processing
|
lastFrame: 0, // time of last frame processing
|
||||||
|
viewportSet: false, // internal, has custom viewport been set
|
||||||
};
|
};
|
||||||
|
|
||||||
// global variables
|
// global variables
|
||||||
|
@ -559,10 +560,12 @@ function setupMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resize() {
|
async function resize() {
|
||||||
window.onresize = null;
|
|
||||||
const viewportScale = Math.min(1, Math.round(100 * window.innerWidth / 960) / 100);
|
const viewportScale = Math.min(1, Math.round(100 * window.innerWidth / 960) / 100);
|
||||||
const viewport = document.querySelector('meta[name=viewport]');
|
if (!ui.viewportSet) {
|
||||||
viewport.setAttribute('content', `width=device-width, shrink-to-fit=yes, minimum-scale=0.2, maximum-scale=2.0, user-scalable=yes, initial-scale=${viewportScale}`);
|
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 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`;
|
const top = `${document.getElementById('menubar').clientHeight - 3}px`;
|
||||||
|
|
|
@ -49,7 +49,7 @@ export const options: DrawOptions = {
|
||||||
labelColor: <string>'rgba(173, 216, 230, 1)', // 'lightblue' with dark alpha channel
|
labelColor: <string>'rgba(173, 216, 230, 1)', // 'lightblue' with dark alpha channel
|
||||||
shadowColor: <string>'black',
|
shadowColor: <string>'black',
|
||||||
font: <string>'small-caps 16px "Segoe UI"',
|
font: <string>'small-caps 16px "Segoe UI"',
|
||||||
lineHeight: <number>20,
|
lineHeight: <number>24,
|
||||||
lineWidth: <number>6,
|
lineWidth: <number>6,
|
||||||
pointSize: <number>2,
|
pointSize: <number>2,
|
||||||
roundRect: <number>28,
|
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 sizeYRight = res[i].annotations.rightEyeIris[4][1] - res[i].annotations.rightEyeIris[2][1];
|
||||||
const areaRight = Math.abs(sizeXRight * sizeYRight);
|
const areaRight = Math.abs(sizeXRight * sizeYRight);
|
||||||
|
|
||||||
|
let center = false;
|
||||||
const difference = Math.abs(areaLeft - areaRight) / Math.max(areaLeft, areaRight);
|
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 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];
|
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' });
|
if (leftIrisCenterX > 0.033 || rightIrisCenterX > 0.033) center = false;
|
||||||
else if (leftIrisCenterX > 0.025) gestures.push({ iris: i, gesture: 'looking right' });
|
if (leftIrisCenterX > 0.033) gestures.push({ iris: i, gesture: 'looking right' });
|
||||||
else if (rightIrisCenterX > 0.025) gestures.push({ iris: i, gesture: 'looking left' });
|
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;
|
return gestures;
|
||||||
};
|
};
|
||||||
|
|
|
@ -401,7 +401,12 @@ export class Human {
|
||||||
|
|
||||||
// disable video optimization for inputs of type image
|
// disable video optimization for inputs of type image
|
||||||
let previousVideoOptimized;
|
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');
|
log('disabling video optimization');
|
||||||
previousVideoOptimized = this.config.videoOptimized;
|
previousVideoOptimized = this.config.videoOptimized;
|
||||||
this.config.videoOptimized = false;
|
this.config.videoOptimized = false;
|
||||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
||||||
Subproject commit ddf8fb116b159dc3dabea4cb858b608fa5914355
|
Subproject commit a137e535d323ce971865ff3d592eaf964ea65ee2
|
Loading…
Reference in New Issue