Get grid_indices from voxelgrid

Hi All,

I was able to generate a voxelgrid for an input .ply point cloud data. And the code is mentioned below. I would like to get the grid_index of every voxel from the voxel_grid. Can someone kindly tell me how can I achieve that ?

from open3d import *
cloud_ply_file = open3d.io.read_point_cloud("./cloud.ply") # Reads the point cloud file
print(cloud_ply_file)
my_voxel_grid = open3d.geometry.VoxelGrid.create_from_point_cloud(cloud_ply_file,voxel_size=0.5)
print(my_voxel_grid)
print(my_voxel_grid.voxels)

And the output is as follows

geometry::PointCloud with 200641 points.
geometry::VoxelGrid with 330 voxels
Traceback (most recent call last):
File “open3d_implementation.py”, line 22, in
print(my_voxel_grid.voxels)
TypeError: unhashable type: ‘numpy.ndarray’

Instead of saying VoxelGrid with 330 voxels … I would like to have the list of voxels containing in the voxel grid.
Can someone help me to solve the above TypeError ?

Regards
Aadithya

my_voxel_grid.get_voxels()

1 Like