公制比较两点云的相似性

问题描述 投票:0回答:2

有哪些指标或方法被广泛用于比较两点云对象的相似性? (例如,它可能是PCD文件或PLY文件)。

我在PCL库的文档中搜索但未找到。谷歌搜索它,发现了一些研究,但他们谈论的新方法,而不是广泛或已经使用的方法。

有没有比较点云相似性的基本方法?甚至PCL库中的某些功能可以完成这项工作吗?

point-cloud-library point-clouds
2个回答
2
投票

这是我的方法:

#include <algorithm>
#include <numeric>

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/common/geometry.h>
#include <pcl/search/kdtree.h>

template<typename TreeT, typename PointT>
float nearestDistance(const TreeT& tree, const PointT& pt)
{
  const int k = 1;
  std::vector<int> indices (k);
  std::vector<float> sqr_distances (k);

  tree.nearestKSearch(pt, k, indices, sqr_distances);

  return sqr_distances[0];
}

// compare cloudB to cloudA
// use threshold for identifying outliers and not considering those for the similarity
// a good value for threshold is 5 * <cloud_resolution>, e.g. 10cm for a cloud with 2cm resolution
template<typename CloudT>
float _similarity(const CloudT& cloudA, const CloudT& cloudB, float threshold)
{
  // compare B to A
  int num_outlier = 0;
  pcl::search::KdTree<typename CloudT::PointType> tree;
  tree.setInputCloud(cloudA.makeShared());
  auto sum = std::accumulate(cloudB.begin(), cloudB.end(), 0.0f, [&](auto current_sum, const auto& pt) {
    const auto dist = nearestDistance(tree, pt);

    if(dist < threshold)
    {
      return current_sum + dist;
    }
    else
    {
      num_outlier++;
      return current_sum;
    }
  });

  return sum / (cloudB.size() - num_outlier);
}

// comparing the clouds each way, A->B, B->A and taking the average
template<typename CloudT>
float similarity(const CloudT& cloudA, const CloudT& cloudB, float threshold = std::numeric_limits<float>::max())
{
  // compare B to A
  const auto similarityB2A = _similarity(cloudA, cloudB, threshold);
  // compare A to B
  const auto similarityA2B = _similarity(cloudB, cloudA, threshold);

  return (similarityA2B * 0.5f) + (similarityB2A * 0.5f);
}

这个想法是你通过搜索B的每个点到邻居的最近距离来比较点云B到A.通过平均找到的距离(排除异常值),你可以得到相当好的估计。


0
投票

不幸的是,我认为它没有正式记录,但PCL有一个命令行应用程序来报告两个云之间的Hausdorff distance。尝试运行pcl_compute_hausdorff。它也可以在PDAL库(https://pdal.io/apps/hausdorff.html)中使用,您可以在其中运行pdal hausdorff

另一个常见的是倒角距离(如https://arxiv.org/abs/1612.00603中所述),尽管我没有立即意识到实施。

© www.soinside.com 2019 - 2024. All rights reserved.