Face contours #281
-
Hi friends! Just wondering if there's a good way to essentially create an outline of the detected face? I've tried using the (The numbers are mesh indexes, which should correspond to the contour, but visually don't seem to.) Interestingly, the mesh does have the information to cover the entire face (at least more of the cheek), but I can't seem to find the right indexes that work consistently for all rotations: Essentially I am trying to do something like this, but I don't want the open mouth to appear in the black overlay, so I figured I would draw a polygon around the entire detected face (hence the need for a silhouette / contour that covers the entire face): Here is the raw image: |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
best is to consider sets of connected points as triangles and fill them. so for each face mesh point, there are 2 other points that should be considered to form a triangle - that then covers entire face precisely and leaves areas such as open mouth as unmarked by default as its not part of any triangle. and that is exactly how its already implemented - simply set if you want to see how to map the triangles, see now, it can also be done using and one more approach (best if you're dealing with some 3d framework) is to use uv map projections. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your reply! This is incredibly useful. So, based on what I'm reading, However, the issue is that const f = result.face[0];
const opt = {
fillPolygons: true,
useDepth: false,
color: 'black'
};
lines(ctx, f.annotations.silhouette, opt); If I use the const f = result.face[0];
const triangulation = human.faceTriangulation;
const opt = {
fillPolygons: true,
useDepth: false,
color: 'black'
};
for (let i = 0; i < triangulation.length / 3; i++) {
const points = [
triangulation[i * 3 + 0],
triangulation[i * 3 + 1],
triangulation[i * 3 + 2]
].map((index) => f.mesh[index]);
lines(ctx, points, opt);
} I guess I could combine the two, but I feel like I'm missing something. |
Beta Was this translation helpful? Give feedback.
-
issue with i'd stick with
|
Beta Was this translation helpful? Give feedback.
-
Got it! Thank you kindly for the explanation, I'm glad I'm not missing anything obvious. Both of those strategies are straight-forward enough, so I'll do some experimentation and see 😄 |
Beta Was this translation helpful? Give feedback.
issue with
silhouette
is that edges are really close to ears so plane it defines goes through head (z-axis), not in front of face - so when you turn your head, cheekbones or nose can project more to the left/right than position of the edge of the face.i'd stick with
triangulation
method and augment it with either:(you can see the points at https://github.com/vladmandic/human/blob/main/assets/facemesh.png)
use
lipsUpperOuter
andlipsLowerOuter
landmarks instead ofsilhouette