pcl 滤波

pcl::ShadowPoints

去除边缘不连续点云

#include <pcl/filters/shadowpoints.h>
#include <pcl/features/normal_3d.h>

pcl::PointCloud<pcl::PointXYZI>::Ptr ShadowsCloudFilter(pcl::PointCloud<pcl::PointXYZI>::Ptr cloud)
{
    pcl::ShadowPoints<pcl::PointXYZI, pcl::Normal> shadowfilters(true);
	//sets the source point cloud
	shadowfilters.setInputCloud(cloud->makeShared());

    pcl::NormalEstimation<pcl::PointXYZI, pcl::Normal> ne;
    ne.setInputCloud(cloud->makeShared());
	pcl::search::KdTree<pcl::PointXYZI>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZI>());
	ne.setSearchMethod(tree);
	pcl::PointCloud<pcl::Normal>::Ptr cloud_normals(new pcl::PointCloud<pcl::Normal>);
	double normalsThreshold = 100;
	ne.setRadiusSearch(normalsThreshold);
	ne.compute(*cloud_normals);

    	//sets normals into shadowfilters
	shadowfilters.setNormals(cloud_normals);
	//sets threshold
	double shadowThreshold = 0.1;
	shadowfilters.setThreshold(shadowThreshold);

	//filters
    pcl::PointCloud<pcl::PointXYZI>::Ptr outCloud(new pcl::PointCloud<pcl::PointXYZI>());
	shadowfilters.filter(*outCloud);
	cout << outCloud->points.size() << endl;
    return outCloud;
}

 耗时较高,怎么降低?

查看源码,分析耗时主要集中在计算法向量,检索了一下,可以加速的包含:

换pcl::kdtree->nanoflann还有openmmp

这篇文章测试openmmp没有作用: 

【点云处理】点云法向量估计及其加速(2)_openex::pointnormal::ptr normal_cloud;_昌山小屋的博客-CSDN博客

【点云处理】点云法向量估计及其加速(5)_nanoflann_昌山小屋的博客-CSDN博客

[FLANN] "Discussion around FLANN maintenance, possibility to use nanoflann" · Issue #4699 · PointCloudLibrary/pcl · GitHub

 GitHub - erikbern/ann-benchmarks: Benchmarks of approximate nearest neighbor libraries in Python

http://docs.ros.org/en/hydro/api/libnabo/html/index.html 

pcl::StatisticalOutlierRemoval

统计滤波: 去除小部分杂点,留下大部分点

#include <pcl/filters/statistical_outlier_removal.h>

pcl::PointCloud<pcl::PointXYZI>::Ptr FilterCloud(pcl::PointCloud<pcl::PointXYZI>::Ptr cloud)
{
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZI>);
    cout << "->正在进行统计滤波..." << endl;
    pcl::StatisticalOutlierRemoval<pcl::PointXYZI> sor;	//创建滤波器对象
	sor.setInputCloud(cloud);				//设置待滤波点云
	sor.setMeanK(50);						//设置查询点近邻点的个数
	sor.setStddevMulThresh(0.1);			//设置标准差乘数,来计算是否为离群点的阈值
	//sor.setNegative(true);				//默认false,保存内点;true,保存滤掉的离群点
	sor.filter(*cloud_filtered);	//执行滤波,保存滤波结果于cloud_filtered
    return cloud_filtered;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值