1. 点云重采样
基于多项式平滑点云及法线估计的曲面重建以实现重采样,可以使得点云数据更规整一些,没之前那么杂乱。
- set_Compute_Normals(True) 可以通过在最小二乘法中进行法线估计,提高重采样准确度;
- set_polynomial_fit(True) 可以通过不需要多项式拟合来加快平滑速度,设置为True则在整个算法运行时采用多项式拟合来提高精度;
2. 效果如下:
重建前:
正面:
侧面:
重建后:
正面:
侧面:
可以看到重采样后点云的形状清晰了许多。
3. 源码
# -*- coding: utf-8 -*-
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
# <基于多项式平滑点云及法线估计的曲面重建重采样,使得数据更规整一些,没之前那么杂乱>Smoothing and normal estimation based on polynomial reconstructionhttp://pointclouds.org/documentation/tutorials/resampling.php#moving-least-squares
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
import pcldef main():# 加载点云cloud = pcl.load('D:/tests/examples/official/Surface/bun0.pcd')print('cloud(size) = ' + str(cloud.size))# 构建kd树tree = cloud.make_kdtree()# 重建mls = cloud.make_moving_least_squares()print('make_moving_least_squares')mls.set_Compute_Normals(True) # 设置在最小二乘计算中需要进行法线估计mls.set_polynomial_fit(True) # 可以通过不需要多项式拟合来加快平滑速度,设置为true时则在整个算法运行时采用多项式拟合来提高精度mls.set_Search_Method(tree)mls.set_search_radius(0.03)print('set parameters')mls_points = mls.process()print('mls_points(size) = ' + str(mls_points.size))# 存储重采样结果pcl.save_PointNormal(mls_points,'D:/tests/examples/official/Surface/bun0-mls-nonormas.pcd')if __name__ == "__main__":main()
参考:
- http://pointclouds.org/documentation/tutorials/resampling.php#moving-least-squares