激光雷达(LiDAR) |
您所在的位置:网站首页 › 五种常用激光雷达 › 激光雷达(LiDAR) |
本节基于Open3D中的体素化实现点云的表面重建:支持点point和网格mesh来实现体素化处理。 1. 体素化介绍体素(voxel)即体积元素的简称,是数字数据在三维空间分割上的最小的单位。体素化就是通过创建三维体素网格来表示三维物体,是一种将无序点云变为有序点云的降采样的空间数据结构方法,便于实现点云的空间卷积。 2. 实现过程 # 加载包 import open3d as o3d import numpy as np 2.1 基于点的体素化采用create_from_point_cloud函数从点云创建体素网格,如果点云的至少一个点在体素内,则体素被占用。体素的颜色是体素内所有点的平均值。 # 读取点云 pcd = o3d.io.read_point_cloud("./tree/Tree_singel.pcd") o3d.visualization.draw_geometries([pcd],width = 700, height = 900) # fit to unit cube print(pcd) N = np.asarray(pcd.points).shape[0] pcd.scale(1 / np.max(pcd.get_max_bound() - pcd.get_min_bound()), center=pcd.get_center()) # From numpy to Open3D pcd.colors = o3d.utility.Vector3dVector(np.random.uniform(0,1,size=(N,3))) o3d.visualization.draw_geometries([pcd]) # 体素化 print('voxelization') voxel_grid = o3d.geometry.VoxelGrid.create_from_point_cloud(pcd, voxel_size=0.01) # 可视化 o3d.visualization.draw_geometries([voxel_grid]) # 同时显示点和体素 o3d.visualization.draw_geometries([pcd,voxel_grid],mesh_show_wireframe = True) # 判断点是否占用体素 queries = np.asarray(pcd.points) output = voxel_grid.check_if_included(o3d.utility.Vector3dVector(queries)) print(output[:20]) 2.2 基于网格的体素化采用create_from_triangle_mesh函数从点云创建体素网格,与三角形相交的所有体素设置为 1,所有其他体素设置为 0。 mesh = o3d.io.read_triangle_mesh("./bunny/bunny.ply") # fit to unit cube mesh.scale(1 / np.max(mesh.get_max_bound() - mesh.get_min_bound()),center=mesh.get_center()) o3d.visualization.draw_geometries([mesh]) mesh = o3d.io.read_triangle_mesh("./bunny/bunny.ply") # fit to unit cube mesh.scale(1 / np.max(mesh.get_max_bound() - mesh.get_min_bound()),center=mesh.get_center()) o3d.visualization.draw_geometries([mesh]) print('voxelization') voxel_grid = o3d.geometry.VoxelGrid.create_from_triangle_mesh(mesh, voxel_size=0.006) o3d.visualization.draw_geometries([voxel_grid]) o3d.visualization.draw_geometries([mesh,voxel_grid],mesh_show_wireframe = True) 2.3 补充采用create_from_point_cloud_within_bounds、create_from_triangle_mesh_within_bounds函数对点和网格的体素化方法。 a = o3d.geometry.VoxelGrid.create_from_point_cloud_within_bounds(pcd, 0.02, pcd.get_min_bound(), pcd.get_max_bound()) o3d.visualization.draw_geometries([a]) b = o3d.geometry.VoxelGrid.create_from_triangle_mesh_within_bounds(mesh, 0.01, mesh.get_min_bound(), mesh.get_max_bound()) o3d.visualization.draw_geometries([b]) |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |