使用easypcd库
pip install easypcd
from easypcd import ep
ep_pcd = ep.read_pcd("cloud_normal.pcd")
points = ep_pcd.points
"""
功能:使用Moving Least Squares Smooth进行点云的平滑
必要参数:
points: 点云数据[[x1,y1,z1],[x2,y2,z2],...,[xn,yn,zn]]
radius: 邻居搜索半径
tau: 权重系数
可选参数:
weights_name: 权重函数,可选:
gaussian:高斯权重函数。根据距离计算权重,权重随
epanechnikov:Epanechnikov核权重函数。在一定范围内提供权重,超出这个范围权重急剧下降。
cubic_spline:三次样条权重函数。使用三次样条函数计算权重,提供平滑的权重变化。
uniform:均匀权重函数。为所有点提供相同的权重。
inverse_distance:距离反比权重函数。根据距离的反比例来计算权重。
wendland:Wendland权重函数。使用Wendland函数计算局部光滑的权重。
shepard_weight:Shepard权重函数。使用距离的负幂计算权重,权重随距离增大而减小。
"""
upsampling_points = ep.Moving_Least_Squares_Smoothing(points,radius=50,tau=0.5,weights_name="gaussian")
ep.write_pcd("Smoothing.pcd", upsampling_points)