PCL-表面(Surface)Smoothing and normal estimation based on polynomial reconstruction

Moving Least Squares(MLS) 移动最小二乘法,可以用来平滑和重采样,接下来将介绍使用方法。https://en.wikipedia.org/wiki/Moving_least_squares(MLS介绍)

使用统计分析很难去除一些数据不规则(由小距离测量误差引起)。 要创建完整的模型,必须考虑光泽表面以及数据中的遮挡。 在无法获得额外扫描的情况下,解决方案是使用重采样算法,该算法尝试通过周围数据点之间的高阶多项式插值来重建表面的缺失部分。 通过执行重采样,可以校正这些小错误,并且可以将多次扫描注册所产生的“双道墙壁”一起平滑处理掉。

在上图的左侧,我们可以看到由两个注册点云组成的数据集的效果和估计表面法线。 由于对准误差,得到的法线有噪声。 在右侧,我们看到表面法线估计在使用移动最小二乘算法进行平滑后在同一数据集中的效果。 绘制每个点的曲率作为重采样之前和之后的特征值关系的度量,我们得到:

为了近似在点q处由局部邻点p1p2 … pk 定义的表面,我们使用简化的多项式高度函数,定义在一个稳定计算的参考平面。

代码

#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/surface/mls.h>

int
main (int argc, char** argv)
{
  // Load input file into a PointCloud<T> with an appropriate type 加载pcd
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());
  // Load bun0.pcd -- should be available with the PCL archive in test 
  pcl::io::loadPCDFile ("bun0.pcd", *cloud);

  // Create a KD-Tree 创建kd树
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);

  // Output has the PointNormal type in order to store the normals calculated by MLS
  pcl::PointCloud<pcl::PointNormal> mls_points;

  // Init object (second point type is for the normals, even if unused)
  pcl::MovingLeastSquares<pcl::PointXYZ, pcl::PointNormal> mls;
 
  mls.setComputeNormals (true);//计算法线,不要可省略

  // Set parameters
  mls.setInputCloud (cloud);
  mls.setPolynomialOrder (2);
  mls.setSearchMethod (tree);
  mls.setSearchRadius (0.03);

  // Reconstruct
  mls.process (mls_points);

  // Save output
  pcl::io::savePCDFile ("bun0-mls.pcd", mls_points);
}

猜你喜欢

转载自blog.csdn.net/sinat_23084397/article/details/86690128