pcl滤除特定范围内部的点云

pcl的直通滤波和条件滤波都只能删除特定范围外部点云,故编写以下函数实现滤除点云内部的点

pcl::PointCloud<pcl::PointXYZI>::Ptr Reserve_specific_areas(pcl::PointCloud<pcl::PointXYZI>::Ptr& cloud,float x1,float x2,float y1,float y2,float z1,float z2)

{

pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_z(new pcl::PointCloud<pcl::PointXYZI>);

pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_z_end(new pcl::PointCloud<pcl::PointXYZI>);

pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_x(new pcl::PointCloud<pcl::PointXYZI>);

pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_x_end(new pcl::PointCloud<pcl::PointXYZI>);

pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_y(new pcl::PointCloud<pcl::PointXYZI>);

pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_y_end(new pcl::PointCloud<pcl::PointXYZI>);

pcl::PassThrough<pcl::PointXYZI> pass; //创建直通滤波器对象

pass.setInputCloud(cloud); //设置输入的点云

pass.setFilterFieldName("z"); //设置过滤时所需要点云类型为Z字段

pass.setFilterLimits(z1, z2); //设置在过滤字段的范围

pass.setFilterLimitsNegative(true); //设置保留还是过滤掉字段范围内的点,设置为true表示过滤掉字段范围内的点

pass.filter(*cloud_z); //执行滤波

pass.setFilterLimitsNegative(false); //设置保留还是过滤掉字段范围内的点,设置为true表示过滤掉字段范围内的点

pass.filter(*cloud_z_end); //执行滤波

pass.setInputCloud(cloud_z_end); //设置输入的点云

pass.setFilterFieldName("x"); //设置过滤时所需要点云类型为Z字段

pass.setFilterLimits(x1, x2); //设置在过滤字段的范围

pass.setFilterLimitsNegative(true); //设置保留还是过滤掉字段范围内的点,设置为true表示过滤掉字段范围内的点

pass.filter(*cloud_x); //执行滤波

pass.setFilterLimitsNegative(false); //设置保留还是过滤掉字段范围内的点,设置为true表示过滤掉字段范围内的点

pass.filter(*cloud_x_end); //执行滤波

pass.setInputCloud(cloud_x_end); //设置输入的点云

pass.setFilterFieldName("y"); //设置过滤时所需要点云类型为Z字段

pass.setFilterLimits(y1, y2); //设置在过滤字段的范围

pass.setFilterLimitsNegative(true); //设置保留还是过滤掉字段范围内的点,设置为true表示过滤掉字段范围内的点

pass.filter(*cloud_y); //执行滤波

pass.setFilterLimitsNegative(false); //设置保留还是过滤掉字段范围内的点,设置为true表示过滤掉字段范围内的点

pass.filter(*cloud_y_end); //执行滤波

*cloud_z+=*cloud_y;

*cloud_z+=*cloud_x;

return cloud_z;

}

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值