在PCL注册方法中获取未被对应距离拒绝的内点。

3
我正在使用pcl实现的迭代最近点算法。我想能够使用任何配准方法中的内点点集进行操作。
当调用align函数时,registration类具有输出对齐点云的功能:
icp_.align(outcloud, guess);

PCLBase类具有以下功能:

indices = icp_.getIndices();

很不幸,getIndices只返回整个点云的索引。我已经测试了一个点云,通过距离对应拒绝的异常值(或内点)似乎无法检索? 我检查过,有些点应该被拒绝,如下图所示:

enter image description here

2个回答

5

基于D.J.Duff的答案,这里提供一种获取对应点的方法,但是它涉及到违反类的规则。该方法继承了IterativeClosestPointNonLinear类,并可以作为替代品使用。对于我的用例,我只需将其放置在任何想要使用IterativeClosestPointNonLinear并能够访问correspondences_成员的地方即可。任何其他配准接口也可以采用类似的方法。

/** \brief This is a mock class with the sole purpose of accessing a protected member of a class it inherits from.
*
* Some of the relevant documentation for correspondences: http://docs.pointclouds.org/trunk/correspondence_8h_source.html#l00092
*/
template <typename PointSource, typename PointTarget, typename Scalar = float>
class IterativeClosestPointNonLinear_Exposed : public pcl::IterativeClosestPointNonLinear<PointSource, PointTarget, Scalar> {
  public:
    pcl::CorrespondencesPtr getCorrespondencesPtr() {
      for (uint32_t i = 0; i < this->correspondences_->size(); i++) {
        pcl::Correspondence currentCorrespondence = (*this->correspondences_)[i];
        std::cout << "Index of the source point: " << currentCorrespondence.index_query << std::endl;
        std::cout << "Index of the matching target point: " << currentCorrespondence.index_match << std::endl;
        std::cout << "Distance between the corresponding points: " << currentCorrespondence.distance << std::endl;
        std::cout << "Weight of the confidence in the correspondence: " << currentCorrespondence.weight << std::endl;
      }
      return this->correspondences_;
    }
};

以下是以此方式获得的两个点云之间对应点之间绘制的一些线条。值得注意的是,两个点之间的pcl::Correspondence.distance值并不总是严格小于配准方法的maxCorrespondenceDistance值,因此您可能需要检查距离以确保您只获得想要的对应关系。

                               两个点云之间的点对应关系。


1

注意:ICP代码在不同版本的PCL中会发生变化,因此请查看您所使用版本的代码。 - D.J.Duff
肯定有比违反类的更好的方法。我还必须实现自己的函数来检索点。虽然这不是问题,但我认为pcl应该想到了这一点?谢谢你,我会开始实现的,我没有想到从icp继承来窃取它的受保护成员。 - Fantastic Mr Fox
我不认为这是一种违规行为。另一种选择是直接将适当的访问器方法放入类中。如果经过深思熟虑,我相信上游也不会介意您发送一个补丁。 - D.J.Duff

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接