compute_nearest_neighbor_distance
方法计算点云中每个点与其最近邻点之间的距离。
distances = open3d.geometry.PointCloud.compute_nearest_neighbor_distance(self)
无参数
distances
: ndarray, shape (n_points,)返回一个由每个点与其最近邻点之间的距离组成的一维数组,n_points
表示点云中点的数量。
import open3d as o3d
import numpy as np
# 创建点云
pcd = o3d.geometry.PointCloud()
points = np.array([[0, 0, 0], [0, 1, 0], [1, 0, 0], [0, 0, 1]])
pcd.points = o3d.utility.Vector3dVector(points)
# 计算每个点与其最近邻点之间的距离
distances = pcd.compute_nearest_neighbor_distance()
#输出结果
print(distances)
输出:
[1. , 1. , 1. , 1.41421356]
该方法使用 KD-Tree 数据结构计算每个点与其最近邻点之间的距离。
[1] Open3D Documentation. http://www.open3d.org/docs/latest/python_api/open3d.geometry.PointCloud.html#open3d.geometry.PointCloud.compute_nearest_neighbor_distance