Search code examples
pythonopen3d

Can not downsample a point cloud in open3D


I am new to open3D pythong binding.

I am trying to downsample a point clout and I have this code:

import open3d as o3d
input_file='mypoints.ply'
pcd = o3d.io.read_point_cloud(input_file)
voxel_down_pcd = o3d.geometry.voxel_down_sample(pcd, voxel_size=0.02)
o3d.visualization.draw_geometries([voxel_down_pcd])

but when I run the code I am getting this error:

module 'open3d.cpu.pybind.geometry' has no attribute 'voxel_down_sample'

I got the sample from Open3D website tutorial

What is the problem and how I can fix it?


Solution

  • You need to call the voxel_down_sample() on the pcd object. For ex, in your case, it will be like this:

    import open3d as o3d
    input_file='mypoints.ply'
    pcd = o3d.io.read_point_cloud(input_file)
    voxel_down_pcd = pcd.voxel_down_sample(pcd, voxel_size=0.02)