'How to find Voxel Grid Coordinates in open3d library?

import open3d as o3d import numpy as np

voxel_grid = o3d.geometry.VoxelGrid.create_from_point_cloud(pcd, voxel_size=0.05)

in this result, how can i found the coordinates of voxel grid?



Solution 1:[1]

To get each one of the voxels in the VoxelGrid, you can use:

voxels = voxel_grid.get_voxels()

Each of the voxels in the voxels list have a grid_index attribute which contains it's [x, y, z] index in the voxel grid.

If you want the specific coordinate for the center-point of voxel i, you can use

index = voxels[i].grid_index
center = voxel_grid.get_voxel_center_coordinate(index)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1