mirror of https://github.com/vladmandic/human
added iris gesture
parent
ea5e50de6c
commit
c099c1006f
|
@ -219,7 +219,7 @@ async function setupCamera() {
|
|||
// silly font resizing for paint-on-canvas since viewport can be zoomed
|
||||
const size = Math.trunc(window.devicePixelRatio * (8 + (4 * canvas.width / window.innerWidth)));
|
||||
ui.baseFont = ui.baseFontProto.replace(/{size}/, `${size}px`);
|
||||
ui.baseLineHeight = size + 4;
|
||||
ui.baseLineHeight = size + 2;
|
||||
if (live) video.play();
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if (live && !ui.detectThread) runHumanDetect(video, canvas);
|
||||
|
|
26
package.json
26
package.json
|
@ -22,20 +22,20 @@
|
|||
"dependencies": {},
|
||||
"peerDependencies": {},
|
||||
"devDependencies": {
|
||||
"@tensorflow/tfjs": "^2.8.2",
|
||||
"@tensorflow/tfjs-backend-cpu": ">=2.8.2",
|
||||
"@tensorflow/tfjs-backend-wasm": "^2.8.2",
|
||||
"@tensorflow/tfjs-backend-webgl": "^2.8.2",
|
||||
"@tensorflow/tfjs-converter": "^2.8.2",
|
||||
"@tensorflow/tfjs-core": "^2.8.2",
|
||||
"@tensorflow/tfjs-data": "^2.8.2",
|
||||
"@tensorflow/tfjs-layers": "^2.8.2",
|
||||
"@tensorflow/tfjs-node": "^2.8.2",
|
||||
"@tensorflow/tfjs-node-gpu": "^2.8.2",
|
||||
"@tensorflow/tfjs": "^2.8.3",
|
||||
"@tensorflow/tfjs-backend-cpu": "^2.8.3",
|
||||
"@tensorflow/tfjs-backend-wasm": "^2.8.3",
|
||||
"@tensorflow/tfjs-backend-webgl": "^2.8.3",
|
||||
"@tensorflow/tfjs-converter": "^2.8.3",
|
||||
"@tensorflow/tfjs-core": "^2.8.3",
|
||||
"@tensorflow/tfjs-data": "^2.8.3",
|
||||
"@tensorflow/tfjs-layers": "^2.8.3",
|
||||
"@tensorflow/tfjs-node": "^2.8.3",
|
||||
"@tensorflow/tfjs-node-gpu": "^2.8.3",
|
||||
"@vladmandic/pilogger": "^0.2.11",
|
||||
"chokidar": "^3.4.3",
|
||||
"dayjs": "^1.10.1",
|
||||
"esbuild": "^0.8.29",
|
||||
"chokidar": "^3.5.0",
|
||||
"dayjs": "^1.10.3",
|
||||
"esbuild": "^0.8.31",
|
||||
"eslint": "^7.17.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
|
|
|
@ -39,6 +39,25 @@ exports.face = (res) => {
|
|||
return gestures;
|
||||
};
|
||||
|
||||
exports.iris = (res) => {
|
||||
if (!res) return [];
|
||||
const gestures = [];
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
if (!res[i].annotations || !res[i].annotations.leftEyeIris || !res[i].annotations.rightEyeIris) continue;
|
||||
const sizeXLeft = res[i].annotations.leftEyeIris[3][0] - res[i].annotations.leftEyeIris[1][0];
|
||||
const sizeYLeft = res[i].annotations.leftEyeIris[4][1] - res[i].annotations.leftEyeIris[2][1];
|
||||
const areaLeft = Math.abs(sizeXLeft * sizeYLeft);
|
||||
|
||||
const sizeXRight = res[i].annotations.rightEyeIris[3][0] - res[i].annotations.rightEyeIris[1][0];
|
||||
const sizeYRight = res[i].annotations.rightEyeIris[4][1] - res[i].annotations.rightEyeIris[2][1];
|
||||
const areaRight = Math.abs(sizeXRight * sizeYRight);
|
||||
|
||||
const difference = Math.abs(areaLeft - areaRight) / Math.max(areaLeft, areaRight);
|
||||
if (difference < 0.25) gestures.push({ iris: i, gesture: 'looking at camera' });
|
||||
}
|
||||
return gestures;
|
||||
};
|
||||
|
||||
exports.hand = (res) => {
|
||||
if (!res) return [];
|
||||
const gestures = [];
|
||||
|
|
|
@ -449,7 +449,7 @@ class Human {
|
|||
let gestureRes = [];
|
||||
if (this.config.gesture.enabled) {
|
||||
timeStamp = now();
|
||||
gestureRes = [...gesture.face(faceRes), ...gesture.body(poseRes), ...gesture.hand(handRes)];
|
||||
gestureRes = [...gesture.face(faceRes), ...gesture.body(poseRes), ...gesture.hand(handRes), ...gesture.iris(faceRes)];
|
||||
if (!this.config.async) this.perf.gesture = Math.trunc(now() - timeStamp);
|
||||
else if (this.perf.gesture) delete this.perf.gesture;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue