是否有任何函数可以提取从裁剪框生成的索引 [英] Is there any function to extract the indices generated from a cropbox

查看:106
本文介绍了是否有任何函数可以提取从裁剪框生成的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了 pcl::cropbox 并根据提供给cropbox 的最小和最大 x、y、z 值过滤了云.我得到的新云只包含裁剪框限制内的点.不幸的是,我不需要单独的云,但需要位于框中的索引.注意:我从旧云中获得了删除的索引,但不是cropbox 中的索引.

I've tried the pcl::cropbox and filtered a cloud based on the min and max x,y,z values given to the cropbox. I get the new cloud which contains only the point within the cropbox limits. Unfortunately I don't need a separate cloud, but need the indices which lie within the box. Note : I get the removed indices from the old cloud, but not the indices which lie inside cropbox.

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile ("D:\ism_test.pcd", *cloud);


pcl::PointCloud<pcl::PointXYZ>::Ptr bodyFiltered (new pcl::PointCloud<pcl::PointXYZ>);

pcl::CropBox<pcl::PointXYZ> boxFilter(true);
boxFilter.setMin(Eigen::Vector4f(minX, minY, minZ, 1.0));
boxFilter.setMax(Eigen::Vector4f(maxX, maxY, maxZ, 1.0));
boxFilter.setInputCloud(cloud);
boxFilter.FilterIndices(*bodyFiltered);
pcl::IndicesConstPtr removedIndices = boxFilter.getRemovedIndices();
pcl::IndicesConstPtr actualindices = boxFilter.getIndices();

//blocks until the cloud is actually rendered
pcl::visualization::CloudViewer filteredviewer("Filtered Viewer");
filteredviewer.showCloud(bodyFiltered);

推荐答案

pcl::CropBox 继承了 filter (std::vector< int > &indices) 所以你应该能够调用它获取位于框中的索引请参阅此处以供参考>

pcl::CropBox inherited filter (std::vector< int > &indices) so you should be able to call it to get the indices which lie within the box see here for reference

pcl::CropBox<pcl::PointXYZ> boxFilter;
...
#
std::vector<int> indices_inside;
boxFilter.filter(indices_inside);

如果您需要盒子外面的点,您可以使用 std 检索它::set_difference,例如

If you need the points out side the box, you can retrieve it with std::set_difference, for example

std::vector<int> all_points(cloud.size());
std::iota(all_points.begin(), all_points.end()) // fill with 0, 1, 2, ..., n
std::vector<int> indices_inside = ...(from previous);
std::vector<int> indices_outside;

// process: indices_outside = all_points - indices_inside 
std::set_difference(all_points.begin(), all_points.end(),
                    indices_inside.begin(), indices_inside.end(), 
                    std::inserter(indices_outside, indices_outside.begin()));

这篇关于是否有任何函数可以提取从裁剪框生成的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆