How to get occupancy state of the voxel grid

Hi All,

I am using open3D library for my 3D convolution neural networks project and my first task is it create a voxel grid from a 3D point cloud data (.ply format) and to get the occupancy state of each grid. i.e. If the voxelgrid is occupied with point clouds the occupancy state should be 1 otherwise 0.

Is there any simpler method to do this using the open3D library.

Also I would like to know the command to generate just the voxelgrid

Looking forward for some help

Regards
Aadithya

import open3d as o3d
import numpy as np

ply_file = o3d.io.read_point_cloud(“cloud.ply”)
voxel_grid = o3d.geometry.VoxelGrid.create_from_point_cloud(ply_file,voxel_size=0.5)

queries = np.asarray(ply_file.points)
output = voxel_grid.check_if_included(o3d.utility.Vector3dVector(queries))
print(output[:])