Created
September 22, 2022 14:02
-
-
Save okanyenigun/75049a36474a68ab995baec138acf1e7 to your computer and use it in GitHub Desktop.
voxel grid wellington
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import laspy as lp | |
import numpy as np | |
import open3d as o3d | |
path = "NZ19_Wellington.las" | |
#read point cloud data | |
point_cloud=lp.read(path) | |
#convert to o3d | |
pcd = o3d.geometry.PointCloud() | |
#points | |
pcd.points = o3d.utility.Vector3dVector(np.vstack((point_cloud.x, point_cloud.y, point_cloud.z)).transpose()) | |
#colors | |
pcd.colors = o3d.utility.Vector3dVector(np.vstack((point_cloud.red, point_cloud.green, point_cloud.blue)).transpose()/65535) | |
#voxel grid | |
v_size=round(max(pcd.get_max_bound()-pcd.get_min_bound())*0.005,4) | |
voxel_grid=o3d.geometry.VoxelGrid.create_from_point_cloud(pcd,voxel_size=v_size) | |
o3d.visualization.draw_geometries([voxel_grid]) | |
voxels=voxel_grid.get_voxels() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment