PCL滤波 StatisticalOutlierRemoval去除噪声

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/statistical_outlier_removal.h>

int
main(int argc, char** argv)
{
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud		(new pcl::PointCloud<pcl::PointXYZ>());
	pcl::PointCloud < pcl::PointXYZ>::Ptr cloud_ft	(new pcl::PointCloud<pcl::PointXYZ>());


	std::cerr << "waiting for loading the file..." << std::endl;
	pcl::PCDReader reader;
	reader.read("C:\\table_scene_mug_stereo_textured_plane.pcd", *cloud);

	std::cerr << "Cloud before filtering:" << *cloud <<std::endl;

	pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;

	sor.setInputCloud(cloud);
	sor.setMeanK(50); //设置 中心点附近 50个点为计算值
	sor.setStddevMulThresh(1.0);//标准差分布设置为1.所有的与计算值偏差超过1的将被标记成outlier并被删除
	sor.filter(*cloud_ft);

	std::cerr << "Cloud after filtering" << *cloud_ft << std::endl;


	pcl::PCDWriter writer;
	writer.write("C:\\filtered_table.pcd", *cloud_ft, false);



	std::cerr << "finished and quit from main" << std::endl;




	return 0;

}
上一篇:PCL计算ConvexHull凸包、ConcaveHull凹包


下一篇:ubuntu20.04虚拟机编译安装pcl1.11.0