Not able to group points using Open3d detect_planar_patch

289 Views Asked by At

Overall goal - to detect elements (points/lines/surfaces) that are in a plane in a 3D CAD file.

Current procedure - convert the CAD file into a point cloud and use plane segmentation using open3D

I am trying to implement detect_planar_patch method from open3d. I am getting expected results for the example given on the website. enter image description here

This point cloud is generated from a mesh that contains 7 planara surfaces (so I am expecting 7 planes to be detected)

Source file

enter image description here

Generated point cloud using

mesh = o3d.io.read_triangle_mesh(path to .stl file)
pointcloud = mesh.sample_points_uniformly(1000)

enter image description here

This is the code in the tutorial

ply_point_cloud = o3d.data.PLYPointCloud()
pcd = o3d.io.read_point_cloud(ply_point_cloud.path)
# dataset = o3d.data.PCDPointCloud()
# pcd = o3d.io.read_point_cloud(dataset.path)
# pcd = pointcloud
# pcd = pcl

assert (pcd.has_normals())

# using all defaults
oboxes = pcd.detect_planar_patches(
    normal_variance_threshold_deg=60,
    coplanarity_deg=75,
    outlier_ratio=0.75,
    min_plane_edge_length=0,
    min_num_points=0,
    search_param=o3d.geometry.KDTreeSearchParamKNN(knn=30))

print("Detected {} patches".format(len(oboxes)))

geometries = []
for obox in oboxes:
    mesh = o3d.geometry.TriangleMesh.create_from_oriented_bounding_box(obox, scale=[1, 1, 0.0001])
    mesh.paint_uniform_color(obox.color)
    geometries.append(mesh)
    geometries.append(obox)
geometries.append(pcd)

o3d.visualization.draw_geometries(geometries,
                                  zoom=0.6,
                                  front=[0.4361, -0.2632, -0.8605],
                                  lookat=[2.4947, 1.7728, 1.5541],
                                  up=[-0.1726, -0.9630, 0.2071])

and it detects planes well enter image description here

But for my input cloud it doesn't detect any planes/ patches I have tried playing with the parameters and looking for other open2d tutorials but can't seem to solve this.

Open to suggestions with or without use of open3d library, but preferably in python.

0

There are 0 best solutions below