Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Is there any implementation Available for 'Euclidean Cluster Extraction' using Open3D ?

Open Resays opened this issue 7 years ago • 11 comments

I am looking to Separate a point cloud into unconnected objects, as shown in the image. There are 6 Unconnected objects. that means 6 Clusters of points in one file, right? I just want to Separate them in 6 different point cloud files.

18S5S

Found a solution using PCL Euclidean Cluster Extraction But I am implementing the code using Open3D The file is .ply with ASCII true, all the point (x y z r g b) Is there any solution to achieve the target?

Resays avatar Nov 14 '19 11:11 Resays

DBCluster might work. Look here.

griegler avatar Nov 14 '19 11:11 griegler

Thanks for the response, I'm a bit newbie with of open3D so can you provide any example with

cluster_dbscan(self, eps, min_points, print_progress=False)

eps means? I have point cloud file and how to use it with cluster_dbscan ?

Resays avatar Nov 14 '19 12:11 Resays

For an example you can have a look here.

griegler avatar Nov 14 '19 12:11 griegler

Getting errors:

  File "C:/Open3D/examples/Python/Basic/clustering.py", line 35, in <module>
    for pcl_name, pcl, eps in pointcloud_generator():

  File "C:/Open3D/examples/Python/Basic/clustering.py", line 15, in pointcloud_generator
    yield 'cube', o3d.geometry.TriangleMesh.create_sphere().sample_points_uniformly(int(1e4)), 0.4

AttributeError: type object 'open3d.open3d.geometry.TriangleMesh' has no attribute 'create_sphere'

what should i do ?

Resays avatar Nov 14 '19 13:11 Resays

Which version of Open3D is installed? The examples assumes v0.8.

griegler avatar Nov 14 '19 13:11 griegler

Im usig v0.7, tried with this code as well, error is same:

def pointcloud_generator():
    yield 'cube', o3d.geometry.TriangleMesh.create_sphere(
    ).sample_points_uniformly(int(1e4)), 0.4

    mesh = o3d.geometry.TriangleMesh.create_torus().scale(5)
    mesh += o3d.geometry.TriangleMesh.create_torus()
    yield 'torus', mesh.sample_points_uniformly(int(1e4)), 0.75

    d = 4
    mesh = o3d.geometry.TriangleMesh.create_tetrahedron().translate((-d, 0, 0))
    mesh += o3d.geometry.TriangleMesh.create_octahedron().translate((0, 0, 0))
    mesh += o3d.geometry.TriangleMesh.create_icosahedron().translate((d, 0, 0))
    mesh += o3d.geometry.TriangleMesh.create_torus().translate((-d, -d, 0))
    mesh += o3d.geometry.TriangleMesh.create_moebius(twists=1).translate(
        (0, -d, 0))
    mesh += o3d.geometry.TriangleMesh.create_moebius(twists=2).translate(
        (d, -d, 0))
    yield 'shapes', mesh.sample_points_uniformly(int(1e4)), 0.5

if __name__ == "__main__":
    cmap = plt.get_cmap('Set2')
    for pcl_name, pcl, eps in pointcloud_generator():
        labels = np.array(pcl.cluster_dbscan(eps=eps, min_points=10))
        max_label = labels.max()
        print('%s has %d clusters' % (pcl_name, max_label + 1))

        colors = cmap(labels / (max_label if max_label > 0 else 1))
        colors[labels < 0] = 0
        pcl.colors = o3d.utility.Vector3dVector(colors[:, :3])
        o3d.visualization.draw_geometries([pcl])

Resays avatar Nov 14 '19 13:11 Resays

Some how code is working now, but getting this in console

File "C:Open3D/examples/Python/reg_combined/clustering.py", line 45, in <module>
   pcl.cluster_dbscan(eps=eps, min_points=10, print_progress=True))

AttributeError: 'open3d.open3d.geometry.PointCloud' object has no attribute 'cluster_dbscan'

am I doing something wrong or what? .. don't have any idea

Resays avatar Nov 14 '19 13:11 Resays

你好,我想请问一下,我自己的ply文件进行聚类分割,为什么出来没有颜色,报颜色被毁 image请问怎么jie'jue解决

sevenandseven avatar Apr 15 '20 03:04 sevenandseven

@griegler anything similar to directly apply for TriangleMesh available in our toolbox?

scimad avatar May 08 '20 02:05 scimad

@scimad not at the moment. But you could convert the mesh to a pointcloud first, either using sampling or directly using the vertices.

griegler avatar May 08 '20 08:05 griegler

Thanks @griegler . Found that but was wondering if there was better more direct way.

scimad avatar May 08 '20 10:05 scimad