PCL使用滤波器去除异常值

激光扫描通常会生成不同点密度的点云数据集。此外,测量误差会导致稀疏异常值,从而进一步破坏结果。这会使局部点云特征(例如表面法线或曲率变化)的估计复杂化,从而导致错误的值,进而可能导致点云配准失败。其中一些不规则性可以通过对每个点的邻域进行统计分析并修剪不符合特定标准的那些来解决。我们的稀疏异常值去除基于输入数据集中点到邻居距离分布的计算。对于每个点,我们计算从它到所有邻居的平均距离。通过假设结果分布是具有均值和标准偏差的高斯分布。

首先,下载数据集table_scene_lms400.pcd 

一、StatisticalOutlierRemoval

创建startistical_remove.cpp文件

源码:
 

 1#include 
 2#include 
 3#include 
 4#include 
 5
 6int
 7main ()
 8{
 9  pcl::PointCloud::Ptr cloud (new pcl::PointCloud);
10  pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud);
11
12  // Fill in the cloud data
13  pcl::PCDReader reader;
14  // Replace the path below with the path where you saved your file
15  reader.read ("table_scene_lms400.pcd", *cloud);
16
17  std::cerr << "Cloud before filtering: " << std::endl;
18  std::cerr << *cloud << std::endl;
19
20  // Create the filtering object
21  pcl::StatisticalOutlierRemoval sor;
22  sor.setInputCloud (cloud);
23  sor.setMeanK (50);
24  sor.setStddevMulThresh (1.0);
25  sor.filter (*cloud_filtered);
26
27  std::cerr << "Cloud after filtering: " << std::endl;
28  std::cerr << *cloud_filtered << std::endl;
29
30  pcl::PCDWriter writer;
31  writer.write ("table_scene_lms400_inliers.pcd", *cloud_filtered, false);
32
33  sor.setNegative (true);
34  sor.filter (*cloud_filtered);
35  writer.write ("table_scene_lms400_outliers.pcd", *cloud_filtered, false);
36
37  return (0);
38}

说明:
1、所需要的头文件,创建点云对象

 1#include 
 2#include 
 3#include 
 4#include 
 5
 6int
 7main ()
 8{
 9  pcl::PointCloud::Ptr cloud (new pcl::PointCloud);
10  pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud);

2、 读取点云信息

  // Fill in the cloud data
  pcl::PCDReader reader;
  // Replace the path below with the path where you saved your file
  reader.read ("table_scene_lms400.p

你可能感兴趣的:(pcl学习,pcl,滤波器)