Full face stack that runs entirely in the browser. Detection, 576-point 3D mesh, recognition, anti-spoof, smile — all WebAssembly, zero server. Apache 2.0.
C avx-512avx2biometricsc99computer-visioncpu-inferencedeep-learningedge-aiembedded-aiface-embeddingface-recognitionface-verificationlow-latencyonnx-runtimeproduction-readysimdzero-dependencies
demo: lips turn red when mouth opens wide (tongue-out heuristic)
facex2df74351ef67
diff --git a/docs/demo/index.html b/docs/demo/index.htmlindex ac669ec..5d9f8a1 100644--- a/docs/demo/index.html+++ b/docs/demo/index.html@@ -1355,13 +1355,28 @@ function drawHybrid(pts3d, matchFlag) {ctx.stroke();}+ // Mouth-open / tongue-out heuristic: vertical distance between upper inner+ // lip (MP idx 13) and lower inner lip (idx 14), normalized by horizontal+ // mouth width (78 ↔ 308). If the ratio is high → user is sticking the+ // tongue out (or yawning) → dye the LIPS group red for visual feedback.+ const tongueOut = isMouthWide(pts3d);+for (const [a, b] of meshTopology.TESSELATION) shadedEdge(a, b, 0.75);- for (const grp of [meshTopology.FACE_OVAL, meshTopology.LIPS,+ for (const grp of [meshTopology.FACE_OVAL,meshTopology.LEFT_EYE, meshTopology.RIGHT_EYE,meshTopology.LEFT_EYEBROW, meshTopology.RIGHT_EYEBROW,meshTopology.NOSE]) {for (const [a, b] of grp) shadedEdge(a, b, 1.0);}+ // LIPS — red when mouth wide open (tongue likely visible)+ if (tongueOut) {+ const sR = baseR, sG = baseG, sB = baseB;+ baseR = 255; baseG = 40; baseB = 70;+ for (const [a, b] of meshTopology.LIPS) shadedEdge(a, b, 1.6);+ baseR = sR; baseG = sG; baseB = sB;+ } else {+ for (const [a, b] of meshTopology.LIPS) shadedEdge(a, b, 1.0);+ }for (const grp of [meshTopology.LEFT_IRIS, meshTopology.RIGHT_IRIS]) {for (const [a, b] of grp) shadedEdge(a, b, 1.15);}@@ -1369,6 +1384,20 @@ function drawHybrid(pts3d, matchFlag) {ctx.restore();}+// MediaPipe FaceMesh indices: 13 = upper inner lip center,+// 14 = lower inner lip center, 78 = left inner mouth corner,+// 308 = right inner mouth corner. Compare vertical opening to horizontal+// mouth width — high ratio means mouth wide open / tongue out.+function isMouthWide(pts) {+ if (!pts || pts.length < 309) return false;+ const u = pts[13], l = pts[14], lc = pts[78], rc = pts[308];+ if (!u || !l || !lc || !rc) return false;+ const mouthH = Math.abs(l[1] - u[1]);+ const mouthW = Math.abs(rc[0] - lc[0]);+ if (mouthW < 5) return false;+ return (mouthH / mouthW) > 0.35; // threshold tuned for "deliberate open"+}+// Render the true-3D mesh from 478 predicted (x,y,z) landmarks.// Each edge is shaded by the average z of its endpoints (forward = brighter, thicker).function drawTrue3D(pts3d, matchFlag) {@@ -1416,15 +1445,25 @@ function drawTrue3D(pts3d, matchFlag) {}// (1) Full tessellation — dense mesh+ const tongueOut = isMouthWide(pts3d);+for (const [a, b] of meshTopology.TESSELATION) shadedEdge(a, b, 0.75);// (2) Brighter anatomical outlines on top- for (const grp of [meshTopology.FACE_OVAL, meshTopology.LIPS,+ for (const grp of [meshTopology.FACE_OVAL,meshTopology.LEFT_EYE, meshTopology.RIGHT_EYE,meshTopology.LEFT_EYEBROW, meshTopology.RIGHT_EYEBROW,meshTopology.NOSE]) {for (const [a, b] of grp) shadedEdge(a, b, 1.0);}+ if (tongueOut) {+ const sR = baseR, sG = baseG, sB = baseB;+ baseR = 255; baseG = 40; baseB = 70;+ for (const [a, b] of meshTopology.LIPS) shadedEdge(a, b, 1.6);+ baseR = sR; baseG = sG; baseB = sB;+ } else {+ for (const [a, b] of meshTopology.LIPS) shadedEdge(a, b, 1.0);+ }// Iris circles, very brightfor (const grp of [meshTopology.LEFT_IRIS, meshTopology.RIGHT_IRIS]) {for (const [a, b] of grp) shadedEdge(a, b, 1.15);diff --git a/wasm/demo_mesh.html b/wasm/demo_mesh.htmlindex ac669ec..5d9f8a1 100644--- a/wasm/demo_mesh.html+++ b/wasm/demo_mesh.html@@ -1355,13 +1355,28 @@ function drawHybrid(pts3d, matchFlag) {ctx.stroke();}+ // Mouth-open / tongue-out heuristic: vertical distance between upper inner+ // lip (MP idx 13) and lower inner lip (idx 14), normalized by horizontal+ // mouth width (78 ↔ 308). If the ratio is high → user is sticking the+ // tongue out (or yawning) → dye the LIPS group red for visual feedback.+ const tongueOut = isMouthWide(pts3d);+for (const [a, b] of meshTopology.TESSELATION) shadedEdge(a, b, 0.75);- for (const grp of [meshTopology.FACE_OVAL, meshTopology.LIPS,+ for (const grp of [meshTopology.FACE_OVAL,meshTopology.LEFT_EYE, meshTopology.RIGHT_EYE,meshTopology.LEFT_EYEBROW, meshTopology.RIGHT_EYEBROW,meshTopology.NOSE]) {for (const [a, b] of grp) shadedEdge(a, b, 1.0);}+ // LIPS — red when mouth wide open (tongue likely visible)+ if (tongueOut) {+ const sR = baseR, sG = baseG, sB = baseB;+ baseR = 255; baseG = 40; baseB = 70;+ for (const [a, b] of meshTopology.LIPS) shadedEdge(a, b, 1.6);+ baseR = sR; baseG = sG; baseB = sB;+ } else {+ for (const [a, b] of meshTopology.LIPS) shadedEdge(a, b, 1.0);+ }for (const grp of [meshTopology.LEFT_IRIS, meshTopology.RIGHT_IRIS]) {for (const [a, b] of grp) shadedEdge(a, b, 1.15);}@@ -1369,6 +1384,20 @@ function drawHybrid(pts3d, matchFlag) {ctx.restore();}+// MediaPipe FaceMesh indices: 13 = upper inner lip center,+// 14 = lower inner lip center, 78 = left inner mouth corner,+// 308 = right inner mouth corner. Compare vertical opening to horizontal+// mouth width — high ratio means mouth wide open / tongue out.+function isMouthWide(pts) {+ if (!pts || pts.length < 309) return false;+ const u = pts[13], l = pts[14], lc = pts[78], rc = pts[308];+ if (!u || !l || !lc || !rc) return false;+ const mouthH = Math.abs(l[1] - u[1]);+ const mouthW = Math.abs(rc[0] - lc[0]);+ if (mouthW < 5) return false;+ return (mouthH / mouthW) > 0.35; // threshold tuned for "deliberate open"+}+// Render the true-3D mesh from 478 predicted (x,y,z) landmarks.// Each edge is shaded by the average z of its endpoints (forward = brighter, thicker).function drawTrue3D(pts3d, matchFlag) {@@ -1416,15 +1445,25 @@ function drawTrue3D(pts3d, matchFlag) {}// (1) Full tessellation — dense mesh+ const tongueOut = isMouthWide(pts3d);+for (const [a, b] of meshTopology.TESSELATION) shadedEdge(a, b, 0.75);// (2) Brighter anatomical outlines on top- for (const grp of [meshTopology.FACE_OVAL, meshTopology.LIPS,+ for (const grp of [meshTopology.FACE_OVAL,meshTopology.LEFT_EYE, meshTopology.RIGHT_EYE,meshTopology.LEFT_EYEBROW, meshTopology.RIGHT_EYEBROW,meshTopology.NOSE]) {for (const [a, b] of grp) shadedEdge(a, b, 1.0);}+ if (tongueOut) {+ const sR = baseR, sG = baseG, sB = baseB;+ baseR = 255; baseG = 40; baseB = 70;+ for (const [a, b] of meshTopology.LIPS) shadedEdge(a, b, 1.6);+ baseR = sR; baseG = sG; baseB = sB;+ } else {+ for (const [a, b] of meshTopology.LIPS) shadedEdge(a, b, 1.0);+ }// Iris circles, very brightfor (const grp of [meshTopology.LEFT_IRIS, meshTopology.RIGHT_IRIS]) {for (const [a, b] of grp) shadedEdge(a, b, 1.15);