From 207ba461e27c8c44740d731a1a7d0a64ef71afa3 Mon Sep 17 00:00:00 2001 From: shwet Date: Mon, 16 Dec 2024 01:41:51 +0530 Subject: [PATCH 1/3] added extreme left points for lower lips --- examples/faceMesh-shapes-from-parts/sketch.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/faceMesh-shapes-from-parts/sketch.js b/examples/faceMesh-shapes-from-parts/sketch.js index 5f77f6cd..c5b71d02 100644 --- a/examples/faceMesh-shapes-from-parts/sketch.js +++ b/examples/faceMesh-shapes-from-parts/sketch.js @@ -34,8 +34,13 @@ function draw() { let face = faces[j]; noFill(); - // draw the lips + face.lips.keypoints.splice(10, 0, face.lips.keypoints[20]); + face.lips.keypoints.splice( + 32, + 0, + face.lips.keypoints[face.lips.keypoints.length - 1] + ); stroke(255, 0, 255); beginShape(); for (let i = 0; i < face.lips.keypoints.length; i++) { From 4aacdf163a7d8b954d59db387aa7d65fb88a932d Mon Sep 17 00:00:00 2001 From: shwet Date: Mon, 16 Dec 2024 01:44:08 +0530 Subject: [PATCH 2/3] some comments --- examples/faceMesh-shapes-from-parts/sketch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/faceMesh-shapes-from-parts/sketch.js b/examples/faceMesh-shapes-from-parts/sketch.js index c5b71d02..9afe0dfe 100644 --- a/examples/faceMesh-shapes-from-parts/sketch.js +++ b/examples/faceMesh-shapes-from-parts/sketch.js @@ -35,12 +35,12 @@ function draw() { noFill(); // draw the lips - face.lips.keypoints.splice(10, 0, face.lips.keypoints[20]); + face.lips.keypoints.splice(10, 0, face.lips.keypoints[20]); // Extreme left point for lower outer lip face.lips.keypoints.splice( 32, 0, face.lips.keypoints[face.lips.keypoints.length - 1] - ); + ); // Extreme left point for lower inner lip stroke(255, 0, 255); beginShape(); for (let i = 0; i < face.lips.keypoints.length; i++) { From 8b4d79ac408bde0f0d299c2459346dd6628a1775 Mon Sep 17 00:00:00 2001 From: shwet Date: Mon, 16 Dec 2024 10:27:27 +0530 Subject: [PATCH 3/3] made solution more elegent --- examples/faceMesh-shapes-from-parts/sketch.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/faceMesh-shapes-from-parts/sketch.js b/examples/faceMesh-shapes-from-parts/sketch.js index 9afe0dfe..995d41d9 100644 --- a/examples/faceMesh-shapes-from-parts/sketch.js +++ b/examples/faceMesh-shapes-from-parts/sketch.js @@ -34,10 +34,15 @@ function draw() { let face = faces[j]; noFill(); + const minPointsPerLip = Math.floor((face.lips.keypoints.length - 2) / 4); // draw the lips - face.lips.keypoints.splice(10, 0, face.lips.keypoints[20]); // Extreme left point for lower outer lip face.lips.keypoints.splice( - 32, + minPointsPerLip, + 0, + face.lips.keypoints[2 * minPointsPerLip] + ); // Extreme left point for lower outer lip + face.lips.keypoints.splice( + 3 * minPointsPerLip + 2, 0, face.lips.keypoints[face.lips.keypoints.length - 1] ); // Extreme left point for lower inner lip