PCL1.8.1 提取分割后的点云

主宰稳场 提交于 2019-12-06 02:00:22

使用分割算法分割完成后,会将分割的点云索引保存在pcl::PointIndices类型的数据中,实际上是一个vector的数组。通过该indices使用pcl::ExtractIndices<PointT>把点云提取到单独的点云中。

http://pointclouds.org/documentation/tutorials/cylinder_segmentation.php#cylinder-segmentation

#include <pcl/filters/extract_indices.h>


typedef pcl::PointXYZ PointT;
//分割的输入点云
pcl::PointCloud<PointT>::Ptr cloud(new pcl::PointCloud<PointT>);
//保存分割后点云的数据索引
pcl::PointIndices::Ptr inliers_plane(new pcl::PointIndices);

//提取
pcl::ExtractIndices<PointT> extract;

extract.setInputCloud(cloud);
extract.setIndices(inliers_plane);
//保存提取的plane点云
extract.setNegative(false);
//存放提取的plane点云
pcl::PointCloud<PointT>::Ptr cloud_plane(new pcl::PointCloud<PointT>());
extract.filter(*cloud_plane);


// Remove the planar inliers, extract the rest
extract.setNegative(true);
pcl::PointCloud<PointT>::Ptr cloud_filtered2(new pcl::PointCloud<PointT>);
//提取剩余的点云
extract.filter(*cloud_filtered2);

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!