Skip to content

Instantly share code, notes, and snippets.

@nirajpandkar
Last active August 21, 2025 00:33
Show Gist options
  • Select an option

  • Save nirajpandkar/9c86b8ef3721f48179ce915552dc3f2c to your computer and use it in GitHub Desktop.

Select an option

Save nirajpandkar/9c86b8ef3721f48179ce915552dc3f2c to your computer and use it in GitHub Desktop.
FaceBase Landmarking Software Instructions (2025 August)

These are the additional (to the facebase steps) steps taken to make the FaceBase automatic landmarking software work - https://www.facebase.org/resources/human/facial_landmarking/

Installations

  1. Matlab - https://www.mathworks.com/help/install/ug/install-products-with-internet-connection.html
  2. PyMeshlab - https://pymeshlab.readthedocs.io/en/latest/installation.html
  3. Install Statistics and Machine Learning Toolbox add-on in Matlab for the pdist function.

Steps taken

  1. Get_compute_many_Windows generates a now defunct command using meshlabserver.exe. This executable has been deprecated since 2020. We need to use PyMeshlab library in python instead.
  2. Use compute_curvature.py instead. This utility generates the curvature of each object .obj file and converts it into a .ply file with C information in it required by the landmarking method. Currently, if you open .obj file, you'll find V (vertices) and F (faces) information.
  3. You'll need to extend that program to make it work for several object files. Add a for loop appropriately.
  4. princomp is removed. Use pca instead in auto_LM_face.m file.
  5. Install Statistics and Machine Learning Toolbox add-on in Matlab.
  6. Load (double click) Meanshape.mat (template landmarks) in matlab.
  7. Run savemesh.m. This should create a .mat file for each of your .ply images.
  8. Run Landmarking.m.
  9. This should give you a Landmarks.xls file in the format -

<obj_filename>,p1_x, p1_y, p1_z, p2_x, p2_y, p2_z,.... p29_z

You'll have 29 landmarks for each face object.

import pymeshlab
def convert_mesh_with_mlx_script(input_file, output_file, mlx_script_path="meancurvature.mlx"):
"""
Alternative approach if you have an existing meancurvature.mlx script
"""
# Create a new MeshSet
ms = pymeshlab.MeshSet()
# Load the input mesh
ms.load_new_mesh(input_file)
# If you have an existing MLX script, you can load and apply it
try:
ms.load_filter_script(mlx_script_path)
ms.apply_filter_script()
print(f"Applied MLX script: {mlx_script_path}")
except Exception as e:
print(f"Could not load MLX script {mlx_script_path}: {e}")
print("Falling back to direct PyMeshLab approach...")
# Fallback to direct PyMeshLab approach
ms.compute_curvature_principal_directions_per_vertex(
method='Pseudoinverse Quadric Fitting',
curvcolormethod='Mean Curvature'
)
# Save the mesh as PLY with vertex colors
ms.save_current_mesh(
output_file + '.ply',
save_vertex_color=True
)
print(f"Successfully processed {input_file} -> {output_file}.ply")
if __name__ == "__main__":
# Example usage
input_file = "test.obj"
output_file = "test"
# Method 2: With MLX script fallback
convert_mesh_with_mlx_script(input_file, output_file, "meancurvature.mlx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment