diff --git a/assets/facemesh.png b/assets/facemesh.png new file mode 100644 index 00000000..a976dd4d Binary files /dev/null and b/assets/facemesh.png differ diff --git a/src/gesture.js b/src/gesture.js index 618765c9..228b44c4 100644 --- a/src/gesture.js +++ b/src/gesture.js @@ -22,13 +22,20 @@ exports.face = (res) => { if (!res) return []; const gestures = []; for (const face of res) { - 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'}`); - } + // 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'}`); + // } + 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 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 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; }; diff --git a/src/human.js b/src/human.js index 1fe89b1a..c0984976 100644 --- a/src/human.js +++ b/src/human.js @@ -363,7 +363,7 @@ class Human { let gestureRes = []; if (this.config.gesture.enabled) { 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); else if (this.perf.gesture) delete this.perf.gesture; } diff --git a/wiki b/wiki index 63c2347b..17d21d19 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 63c2347b5256777d5154bd5d502b2a075d3d950d +Subproject commit 17d21d19953ab16616c4a07423c0eada76577686