首页 > 解决方案 > 返回相同索引的点云的顺序采样

问题描述

我正在编写一个用于点云的 ransac 实现,我知道pcl也有一些,但我的需求更具体一些,并且以这种pcl风格编写自定义模型似乎不是很清楚。

为此,我需要从点云中统一采样点而不进行替换,为此我认为我应该使用pcl::RandomSample. 但是,按顺序应用它,例如:

pcl::RandomSample<pcl::PointXYZRGB> sample(false);
sample.setInputCloud(cloud);
sample.setSample(5);

pcl::Indices indices;
sample.filter(indices);
for (auto &i : indices) {
  std::cout << i << std::endl;
}

std::cout << "==========" << std::endl;

indices.clear();
sample.filter(indices);
for (auto &i : indices) {
  std::cout << i << std::endl;
}

导致相同的索引,这不是特别随机。我可能做错了什么?

编辑:使用随机生成的 500 个元素的点云,在一种情况下,上述代码的返回是

42
145
195
196
290
==========
42
145
195
196
290

标签: c++randompoint-cloud-library

解决方案


推荐阅读