本文主要是介绍使用RadiusOutlierRemoval移除离群点,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
可以删除在输入的点云一定范围内没有至少达到足够多近邻的所有数据点。
关键成员函数:
void pcl::RadiusOutlierRemoval< PointT >::setRadiusSearch | ( | double | radius | ) |
Set the radius of the sphere that will determine which points are neighbors.
The number of points within this distance from the query point will need to be equal or greater than setMinNeighborsInRadius() in order to be classified as an inlier point (i.e. will not be filtered).
void pcl::RadiusOutlierRemoval< PointT >::setMinNeighborsInRadius | ( | int | min_pts | ) |
Set the number of neighbors that need to be present in order to be classified as an inlier.
The number of points within setRadiusSearch() from the query point will need to be equal or greater than this number in order to be classified as an inlier point (i.e. will not be filtered).
#include<iostream>
#include<pcl\point_cloud.h>
#include<pcl\point_types.h>
#include<pcl\io\io.h>
#include<pcl\filters\radius_outlier_removal.h>
using namespace std;
int main()
{pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>);cloud->width=5;cloud->height=1;cloud->points.resize(cloud->width*cloud->height);for(size_t i=0;i<cloud->points.size();i++){cloud->points[i].x=1024*rand()/(RAND_MAX+1.0f);cloud->points[i].y=1024*rand()/(RAND_MAX+1.0f);cloud->points[i].z=1024*rand()/(RAND_MAX+1.0f);}pcl::RadiusOutlierRemoval<pcl::PointXYZ> outrem;outrem.setInputCloud(cloud);outrem.setRadiusSearch(0.8);outrem.setMinNeighborsInRadius(2);outrem.filter(*cloud_filtered);std::cerr<<"cloud before filtering:"<<std::endl;for(size_t i=0;i<cloud->points.size();i++)std::cerr<<' '<<cloud->points[i].x<<' '<<cloud->points[i].y<<' '<<cloud->points[i].z<<std::endl;std::cerr<<"cloud after filtering:"<<std::endl;for(size_t i=0;i<cloud_filtered->points.size();i++)std::cerr<<' '<<cloud_filtered->points[i].x<<' '<<cloud_filtered->points[i].y<<' '<<cloud->points[i].z<<std::endl;system("pause");return 0;
}
这篇关于使用RadiusOutlierRemoval移除离群点的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!