mirror of https://github.com/vladmandic/human
added additional gestures
parent
52d2bfa8da
commit
8b7c134b10
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
|
@ -32959,11 +32959,16 @@ var rL = we((pc) => {
|
||||||
return [];
|
return [];
|
||||||
const t = [];
|
const t = [];
|
||||||
for (const e of n) {
|
for (const e of n) {
|
||||||
e.annotations.rightCheek && e.annotations.leftCheek && e.annotations.rightCheek.length > 0 && e.annotations.leftCheek.length > 0 && t.push(`facing ${e.annotations.rightCheek[0][2] > 0 || e.annotations.leftCheek[0][2] < 0 ? "right" : "left"}`);
|
const r = e.mesh[35][2] - e.mesh[263][2];
|
||||||
const r = Math.abs(e.mesh[374][1] - e.mesh[386][1]) / Math.abs(e.mesh[443][1] - e.mesh[450][1]);
|
Math.abs(r) < 10 ? t.push("facing camera") : t.push(`facing ${r < 0 ? "right" : "left"}`);
|
||||||
r < 0.2 && t.push("blink left eye");
|
const i = Math.abs(e.mesh[374][1] - e.mesh[386][1]) / Math.abs(e.mesh[443][1] - e.mesh[450][1]);
|
||||||
const i = Math.abs(e.mesh[145][1] - e.mesh[159][1]) / Math.abs(e.mesh[223][1] - e.mesh[230][1]);
|
i < 0.2 && t.push("blink left eye");
|
||||||
i < 0.2 && t.push("blink right eye");
|
const a = Math.abs(e.mesh[145][1] - e.mesh[159][1]) / Math.abs(e.mesh[223][1] - e.mesh[230][1]);
|
||||||
|
a < 0.2 && t.push("blink right eye");
|
||||||
|
const s = Math.min(100, 500 * Math.abs(e.mesh[13][1] - e.mesh[14][1]) / Math.abs(e.mesh[10][1] - e.mesh[152][1]));
|
||||||
|
s > 10 && t.push(`mouth ${Math.trunc(s)}% open`);
|
||||||
|
const o = e.mesh[152][2];
|
||||||
|
Math.abs(o) > 10 && t.push(`head ${o < 0 ? "up" : "down"}`);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
};
|
};
|
||||||
|
@ -33258,7 +33263,7 @@ class hG {
|
||||||
const l = sG.process(n, this.config);
|
const l = sG.process(n, this.config);
|
||||||
this.perf.image = Math.trunc(ut() - e), this.analyze("Get Image:"), this.config.async ? (o = this.config.face.enabled ? this.detectFace(l.tensor) : [], this.perf.face && delete this.perf.face) : (this.state = "run:face", e = ut(), o = this.config.face.enabled ? await this.detectFace(l.tensor) : [], this.perf.face = Math.trunc(ut() - e)), this.analyze("Start Body:"), this.config.async ? (a = this.config.body.enabled ? this.models.posenet.estimatePoses(l.tensor, this.config) : [], this.perf.body && delete this.perf.body) : (this.state = "run:body", e = ut(), a = this.config.body.enabled ? await this.models.posenet.estimatePoses(l.tensor, this.config) : [], this.perf.body = Math.trunc(ut() - e)), this.analyze("End Body:"), this.analyze("Start Hand:"), this.config.async ? (s = this.config.hand.enabled ? this.models.handpose.estimateHands(l.tensor, this.config.hand) : [], this.perf.hand && delete this.perf.hand) : (this.state = "run:hand", e = ut(), s = this.config.hand.enabled ? await this.models.handpose.estimateHands(l.tensor, this.config.hand) : [], this.perf.hand = Math.trunc(ut() - e)), this.config.async && ([o, a, s] = await Promise.all([o, a, s])), l.tensor.dispose(), this.config.scoped && Kt.engine().endScope(), this.analyze("End Scope:");
|
this.perf.image = Math.trunc(ut() - e), this.analyze("Get Image:"), this.config.async ? (o = this.config.face.enabled ? this.detectFace(l.tensor) : [], this.perf.face && delete this.perf.face) : (this.state = "run:face", e = ut(), o = this.config.face.enabled ? await this.detectFace(l.tensor) : [], this.perf.face = Math.trunc(ut() - e)), this.analyze("Start Body:"), this.config.async ? (a = this.config.body.enabled ? this.models.posenet.estimatePoses(l.tensor, this.config) : [], this.perf.body && delete this.perf.body) : (this.state = "run:body", e = ut(), a = this.config.body.enabled ? await this.models.posenet.estimatePoses(l.tensor, this.config) : [], this.perf.body = Math.trunc(ut() - e)), this.analyze("End Body:"), this.analyze("Start Hand:"), this.config.async ? (s = this.config.hand.enabled ? this.models.handpose.estimateHands(l.tensor, this.config.hand) : [], this.perf.hand && delete this.perf.hand) : (this.state = "run:hand", e = ut(), s = this.config.hand.enabled ? await this.models.handpose.estimateHands(l.tensor, this.config.hand) : [], this.perf.hand = Math.trunc(ut() - e)), this.config.async && ([o, a, s] = await Promise.all([o, a, s])), l.tensor.dispose(), this.config.scoped && Kt.engine().endScope(), this.analyze("End Scope:");
|
||||||
let u = [];
|
let u = [];
|
||||||
this.config.gesture.enabled && (e = ut(), u = {body: nf.body(a), hand: nf.hand(s), face: nf.face(o)}, this.config.async ? this.perf.gesture && delete this.perf.gesture : this.perf.gesture = Math.trunc(ut() - e)), this.perf.total = Math.trunc(ut() - c), this.state = "idle", i({face: o, body: a, hand: s, gesture: u, performance: this.perf, canvas: l.canvas});
|
this.config.gesture.enabled && (e = ut(), u = {face: nf.face(o), body: nf.body(a), hand: nf.hand(s)}, this.config.async ? this.perf.gesture && delete this.perf.gesture : this.perf.gesture = Math.trunc(ut() - e)), this.perf.total = Math.trunc(ut() - c), this.state = "idle", i({face: o, body: a, hand: s, gesture: u, performance: this.perf, canvas: l.canvas});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -23,7 +23,7 @@
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"dist/human.esm.js": {
|
"dist/human.esm.js": {
|
||||||
"bytes": 1278518,
|
"bytes": 1278633,
|
||||||
"imports": []
|
"imports": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -31,13 +31,13 @@
|
||||||
"dist/demo-browser-index.js.map": {
|
"dist/demo-browser-index.js.map": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {},
|
"inputs": {},
|
||||||
"bytes": 5534714
|
"bytes": 5535482
|
||||||
},
|
},
|
||||||
"dist/demo-browser-index.js": {
|
"dist/demo-browser-index.js": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"dist/human.esm.js": {
|
"dist/human.esm.js": {
|
||||||
"bytesInOutput": 1664968
|
"bytesInOutput": 1665139
|
||||||
},
|
},
|
||||||
"dist/human.esm.js": {
|
"dist/human.esm.js": {
|
||||||
"bytesInOutput": 8716
|
"bytesInOutput": 8716
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
"bytesInOutput": 16209
|
"bytesInOutput": 16209
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bytes": 1712336
|
"bytes": 1712507
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -194,7 +194,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytes": 2680,
|
"bytes": 3233,
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"src/hand/anchors.js": {
|
"src/hand/anchors.js": {
|
||||||
|
@ -301,7 +301,7 @@
|
||||||
"dist/human.esm-nobundle.js.map": {
|
"dist/human.esm-nobundle.js.map": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {},
|
"inputs": {},
|
||||||
"bytes": 620981
|
"bytes": 621753
|
||||||
},
|
},
|
||||||
"dist/human.esm-nobundle.js": {
|
"dist/human.esm-nobundle.js": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
|
@ -394,7 +394,7 @@
|
||||||
"bytesInOutput": 1219
|
"bytesInOutput": 1219
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytesInOutput": 1459
|
"bytesInOutput": 1574
|
||||||
},
|
},
|
||||||
"src/imagefx.js": {
|
"src/imagefx.js": {
|
||||||
"bytesInOutput": 11013
|
"bytesInOutput": 11013
|
||||||
|
@ -415,7 +415,7 @@
|
||||||
"bytesInOutput": 0
|
"bytesInOutput": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bytes": 216844
|
"bytes": 216959
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -371,7 +371,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytes": 2680,
|
"bytes": 3233,
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"src/hand/anchors.js": {
|
"src/hand/anchors.js": {
|
||||||
|
@ -513,7 +513,7 @@
|
||||||
"dist/human.esm.js.map": {
|
"dist/human.esm.js.map": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {},
|
"inputs": {},
|
||||||
"bytes": 5416966
|
"bytes": 5417738
|
||||||
},
|
},
|
||||||
"dist/human.esm.js": {
|
"dist/human.esm.js": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
|
@ -663,7 +663,7 @@
|
||||||
"bytesInOutput": 1197
|
"bytesInOutput": 1197
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytesInOutput": 1460
|
"bytesInOutput": 1575
|
||||||
},
|
},
|
||||||
"src/imagefx.js": {
|
"src/imagefx.js": {
|
||||||
"bytesInOutput": 11014
|
"bytesInOutput": 11014
|
||||||
|
@ -684,7 +684,7 @@
|
||||||
"bytesInOutput": 0
|
"bytesInOutput": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bytes": 1278518
|
"bytes": 1278633
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -371,7 +371,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytes": 2680,
|
"bytes": 3233,
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"src/hand/anchors.js": {
|
"src/hand/anchors.js": {
|
||||||
|
@ -513,7 +513,7 @@
|
||||||
"dist/human.js.map": {
|
"dist/human.js.map": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {},
|
"inputs": {},
|
||||||
"bytes": 5416962
|
"bytes": 5417734
|
||||||
},
|
},
|
||||||
"dist/human.js": {
|
"dist/human.js": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
|
@ -663,7 +663,7 @@
|
||||||
"bytesInOutput": 1197
|
"bytesInOutput": 1197
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytesInOutput": 1460
|
"bytesInOutput": 1575
|
||||||
},
|
},
|
||||||
"src/imagefx.js": {
|
"src/imagefx.js": {
|
||||||
"bytesInOutput": 11014
|
"bytesInOutput": 11014
|
||||||
|
@ -681,7 +681,7 @@
|
||||||
"bytesInOutput": 7312
|
"bytesInOutput": 7312
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bytes": 1278563
|
"bytes": 1278678
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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
|
@ -194,7 +194,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytes": 2680,
|
"bytes": 3233,
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"src/hand/anchors.js": {
|
"src/hand/anchors.js": {
|
||||||
|
@ -301,7 +301,7 @@
|
||||||
"dist/human.node-nobundle.js.map": {
|
"dist/human.node-nobundle.js.map": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {},
|
"inputs": {},
|
||||||
"bytes": 635158
|
"bytes": 635930
|
||||||
},
|
},
|
||||||
"dist/human.node-nobundle.js": {
|
"dist/human.node-nobundle.js": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
|
@ -394,7 +394,7 @@
|
||||||
"bytesInOutput": 1219
|
"bytesInOutput": 1219
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytesInOutput": 1459
|
"bytesInOutput": 1574
|
||||||
},
|
},
|
||||||
"src/imagefx.js": {
|
"src/imagefx.js": {
|
||||||
"bytesInOutput": 11013
|
"bytesInOutput": 11013
|
||||||
|
@ -415,7 +415,7 @@
|
||||||
"bytesInOutput": 7256
|
"bytesInOutput": 7256
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bytes": 216851
|
"bytes": 216966
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,20 @@ exports.face = (res) => {
|
||||||
if (!res) return [];
|
if (!res) return [];
|
||||||
const gestures = [];
|
const gestures = [];
|
||||||
for (const face of res) {
|
for (const face of res) {
|
||||||
if (face.annotations['rightCheek'] && face.annotations['leftCheek'] && (face.annotations['rightCheek'].length > 0) && (face.annotations['leftCheek'].length > 0)) {
|
// if (face.annotations['rightCheek'] && face.annotations['leftCheek'] && (face.annotations['rightCheek'].length > 0) && (face.annotations['leftCheek'].length > 0)) {
|
||||||
gestures.push(`facing ${((face.annotations['rightCheek'][0][2] > 0) || (face.annotations['leftCheek'][0][2] < 0)) ? 'right' : 'left'}`);
|
// gestures.push(`facing ${((face.annotations['rightCheek'][0][2] > 0) || (face.annotations['leftCheek'][0][2] < 0)) ? 'right' : 'left'}`);
|
||||||
}
|
// }
|
||||||
|
const eyeFacing = face.mesh[35][2] - face.mesh[263][2];
|
||||||
|
if (Math.abs(eyeFacing) < 10) gestures.push('facing camera');
|
||||||
|
else gestures.push(`facing ${eyeFacing < 0 ? 'right' : 'left'}`);
|
||||||
const openLeft = Math.abs(face.mesh[374][1] - face.mesh[386][1]) / Math.abs(face.mesh[443][1] - face.mesh[450][1]); // center of eye inner lid y coord div center of wider eye border y coord
|
const openLeft = Math.abs(face.mesh[374][1] - face.mesh[386][1]) / Math.abs(face.mesh[443][1] - face.mesh[450][1]); // center of eye inner lid y coord div center of wider eye border y coord
|
||||||
if (openLeft < 0.2) gestures.push('blink left eye');
|
if (openLeft < 0.2) gestures.push('blink left eye');
|
||||||
const openRight = Math.abs(face.mesh[145][1] - face.mesh[159][1]) / Math.abs(face.mesh[223][1] - face.mesh[230][1]); // center of eye inner lid y coord div center of wider eye border y coord
|
const openRight = Math.abs(face.mesh[145][1] - face.mesh[159][1]) / Math.abs(face.mesh[223][1] - face.mesh[230][1]); // center of eye inner lid y coord div center of wider eye border y coord
|
||||||
if (openRight < 0.2) gestures.push('blink right eye');
|
if (openRight < 0.2) gestures.push('blink right eye');
|
||||||
|
const mouthOpen = Math.min(100, 500 * Math.abs(face.mesh[13][1] - face.mesh[14][1]) / Math.abs(face.mesh[10][1] - face.mesh[152][1]));
|
||||||
|
if (mouthOpen > 10) gestures.push(`mouth ${Math.trunc(mouthOpen)}% open`);
|
||||||
|
const chinDepth = face.mesh[152][2];
|
||||||
|
if (Math.abs(chinDepth) > 10) gestures.push(`head ${chinDepth < 0 ? 'up' : 'down'}`);
|
||||||
}
|
}
|
||||||
return gestures;
|
return gestures;
|
||||||
};
|
};
|
||||||
|
|
|
@ -363,7 +363,7 @@ class Human {
|
||||||
let gestureRes = [];
|
let gestureRes = [];
|
||||||
if (this.config.gesture.enabled) {
|
if (this.config.gesture.enabled) {
|
||||||
timeStamp = now();
|
timeStamp = now();
|
||||||
gestureRes = { body: gesture.body(poseRes), hand: gesture.hand(handRes), face: gesture.face(faceRes) };
|
gestureRes = { face: gesture.face(faceRes), body: gesture.body(poseRes), hand: gesture.hand(handRes) };
|
||||||
if (!this.config.async) this.perf.gesture = Math.trunc(now() - timeStamp);
|
if (!this.config.async) this.perf.gesture = Math.trunc(now() - timeStamp);
|
||||||
else if (this.perf.gesture) delete this.perf.gesture;
|
else if (this.perf.gesture) delete this.perf.gesture;
|
||||||
}
|
}
|
||||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
||||||
Subproject commit 63c2347b5256777d5154bd5d502b2a075d3d950d
|
Subproject commit 17d21d19953ab16616c4a07423c0eada76577686
|
Loading…
Reference in New Issue