init project

This commit is contained in:
hofee
2024-09-19 13:26:58 -05:00
parent 4e3ab91bf1
commit 85f606a2a3
4 changed files with 402 additions and 0 deletions

19
reconstruction.py Normal file
View File

@@ -0,0 +1,19 @@
import numpy as np
import open3d as o3d
class ReconstructionUtil:
@staticmethod
def reconstruct_with_pts(pts):
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(pts)
pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.001, max_nn=30))
mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pcd, depth=9)
densities = np.asarray(densities)
vertices_to_remove = densities < np.quantile(densities, 0.03)
mesh.remove_vertices_by_mask(vertices_to_remove)
return mesh
if __name__ == "__main__":
path = r"C:\Document\Local Project\nbv_rec_visualize\mis\sampled_model_points.txt"
test_pts = np.loadtxt(path)
mesh = ReconstructionUtil.reconstruct_with_pts(test_pts)
o3d.io.write_triangle_mesh("output_mesh.obj", mesh)