Skip to content

Instantly share code, notes, and snippets.

@sergeyprokudin
Created February 24, 2024 10:39
Show Gist options
  • Save sergeyprokudin/c57faa44c8b4dd2bf449efbbea5dc9fc to your computer and use it in GitHub Desktop.
Save sergeyprokudin/c57faa44c8b4dd2bf449efbbea5dc9fc to your computer and use it in GitHub Desktop.
Estimate normals and reconstruct mesh via Poisson
# Pymeshlab normal estimation (and optional Poisson)
# https://github.com/cnr-isti-vclab/PyMeshLab/blob/main/docs/filter_list.rst
# https://pymeshlab.readthedocs.io/en/0.2/tutorials/get_mesh_values.html
import pymeshlab
def get_normals_pymeshlab(x, k=10, smoothiter=0):
tmp_mesh_path = 'tmp.obj'
pcu.save_mesh_v(tmp_mesh_path, x)
ms = pymeshlab.MeshSet()
ms.load_new_mesh(tmp_mesh_path)
ms.compute_normal_for_point_clouds(k=k, smoothiter=smoothiter)
#ms.save_current_mesh(trg_path, save_vertex_normal=True)
#ms.generate_surface_reconstruction_screened_poisson(depth=8)
m = ms.current_mesh()
x = m.vertex_matrix()
n = m.vertex_normal_matrix()
return x, n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment