点云学习(1): 获取点云的包络框

1. 记录一些容易忘记的点云操作

----后续一定补充

1.获取点云的包络框

下面的get_axis_aligned_bounding_box(),get_min_bound(),get_max_bound()等函数非常好用

import open3d as o3d
import numpy as np

# 读取点云数据
pcd = o3d.io.read_point_cloud("input.pcd")

# 获得点云边界
bbox = pcd.get_axis_aligned_bounding_box()

# 获得边界最小值和最大值
min_bound = bbox.get_min_bound()
max_bound = bbox.get_max_bound()

# 生成采样点云
interpolation_distance =  0.05
interpolated_pcd = o3d.geometry.PointCloud()
for x in np.arange(min_bound[0], max_bound[0], interpolation_distance):
    for y in np.arange(min_bound[1], max_bound[1], interpolation_distance):
        for z in np.arange(min_bound[2], max_bound[2], interpolation_distance):
            point = np.array([x, y, z])

            interpolated_pcd.points.append(point)

# 显示采样点云
o3d.visualization.draw_geometries([interpolated_pcd])

你可能感兴趣的:(小技巧,python,numpy,开发语言,open3d,点云)