Tuesday 26 September 2023

open3d create_from_point_cloud_poisson adds weird plane not present in original point cloud model

I have this script which is supposed to convert a point cloud into a reconstructed surface using open3d. It works for most point cloud models, but I don't understand why it always adds this generated plane between the original shape. How do I get rid of it?

enter image description here

Here's the script:

import bpy
import numpy as np
import open3d as o3d

mesh_obj = bpy.data.objects['Sphere']
vertices = np.array([v.co.xyz for v in mesh_obj.data.vertices], dtype=np.float64)

pd = o3d.geometry.PointCloud()
pd.points = o3d.utility.Vector3dVector(vertices)
pd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0, max_nn=100))

mesh_path = 'C:/Users/harry/OneDrive/Desktop/pc.ply'
o3d.io.write_point_cloud(mesh_path, pd)

surface, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pd, depth=10, width=0, scale=1, linear_fit=True)

vertices = np.asarray(surface.vertices)
faces = np.asarray(surface.triangles)

mesh_name = 'reconstructed_mesh'
mesh = bpy.data.meshes.new(mesh_name)
mesh.from_pydata(vertices, [], faces)
obj = bpy.data.objects.new(mesh_name, mesh)

scene = bpy.context.scene
scene.collection.objects.link(obj)


from open3d create_from_point_cloud_poisson adds weird plane not present in original point cloud model

No comments:

Post a Comment