google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.51k stars 5.15k forks source link

There is a problem with the meshing instance image of face_geometry #3484

Closed YongHe999 closed 2 years ago

YongHe999 commented 2 years ago

There is a problem with the meshing sample image of face_geometry,

Below is a sample image from github

https://github.com/google/mediapipe/blob/master/mediapipe/modules/face_geometry/data/canonical_face_model_uv_visualization.png

However, the image generated by the program is like the following one

https://mediapipe.dev/assets/img/photos/faceMesh.jpg

There are some differences in the division of the mesh between the two pictures. According to the line data of face_mesh_connections.py, the correct one should be the one below.

The triangle mesh list is created with reference to the coordinate point connection relationship in face_mesh_connections.py https://github.com/google/mediapipe/pull/3419

andrechen commented 2 years ago

Can't find that face_model_landmarks_triangles.txt. But as i checked canonical_face_model.obj and geometry_pipeline_metadata_landmarks.pbtxt. Both files are coincident with canonical_face_model_uv_visualization.png. I can also construct the exactly the same image as canonical_face_model_uv_visualization.png from canonical_face_model.obj.

the 1st triangle's vertex indices are { 174, 156, 134 } (note obj file uses one-indexed) https://github.com/google/mediapipe/blob/63e679d99ca45b30514a9d84c9351a2d77bb9ba0/mediapipe/modules/face_geometry/data/canonical_face_model.obj#L937

compare to the 1st first triangle indices { 173, 155, 133 } (zero-indexed) https://github.com/google/mediapipe/blob/63e679d99ca45b30514a9d84c9351a2d77bb9ba0/mediapipe/modules/face_geometry/data/geometry_pipeline_metadata_landmarks.pbtxt#L2392-L2394

YongHe999 commented 2 years ago

There may be some problems with my expression, the grid displayed by the sample code on Python Colab is as follows,

1

canonical_face_model_uv_visualization.png is as follows,It is obvious that the meshing in the forehead is different。 2

As for face_model_landmarks_triangles.txt, it's in https://github.com/google/mediapipe/pull/3419/files, just a list of grid indices。It's just that the division is different, and when I look at face_mesh_connections.py, I see that its result is in line with the first picture. Maybe these references need to be unified, because when I was looking at a question about indexing in the grid, someone pointed to canonical_face_model_uv_visualization.png.

andrechen commented 2 years ago

So to speak, face_mesh_connections.py is incorrect and your triangle list file is not correct, either. Better to use triangle indices from above obj or pbtxt files.

YongHe999 commented 2 years ago

Mesh generation is a form of expression. The official Python example code shows that mesh generation and face mesh connections.py is the same as canonical face model uv visualization.png is different. There needs to be a unity between the two. Maybe they need to modify the sample code.

andrechen commented 2 years ago

mediapipe/mediapipe/modules/face_geometry/data/canonical_face_model.fbx image

mediapipe/mediapipe/modules/face_geometry/data/canonical_face_model.obj image

sureshdagooglecom commented 2 years ago

Hi @YongHe999 , Are you still facing any issue.