【问题标题】:Convex Hull calculation in Point Cloud Library fails in 2 as well as 3 dimensions点云库中的凸包计算在 2 维和 3 维中失败
【发布时间】:2013-12-29 07:30:30
【问题描述】:

我正在按照 PCL 文档的教程计算 2D Convex Hull see here

我有一个云和一些索引,将它们投影到具有给定系数的平面上,然后计算凸包。代码如下:

PointCloud<PointXYZ>::Ptr tmpInliers(new PointCloud<PointXYZ>());

ProjectInliers<PointXYZ> proj;
proj.setModelType(SACMODEL_PLANE);
proj.setInputCloud(someCloud); 
proj.setIndices(someIndices); 
proj.setModelCoefficients(someCoefficients);
proj.filter(*tmpInliers);

PointCloud<PointXYZ>::Ptr hull(new PointCloud<PointXYZ>());
ConvexHull<PointXYZ> chull;
chull.setInputCloud(tmpInliers);
chull.setComputeAreaVolume(true);
chull.setDimension(3); <--- see below
chull.reconstruct(*hull);

我得到的总面积和体积的结果是:

  Area & Volume of convex hull: 7.8726e-312 2.122e-314

对于 tmpInliers 范围内的值

(-0.80562,-0.787018,2.25184)
(-0.477351,-0.798953,2.11432)
(-0.633823,-0.750283,2.96717)
[....]

如果我将“setDimensions”更改为“2”,则会出现以下错误

[pcl::ConvexHull::performReconstrution2D] ERROR: qhull was unable to compute a convex hull for the given point cloud (size of cloud)!

在下面的示例中,我正在构建一个示例,并且在每种情况下都失败(setDimension 设置为 2 或 3),其中一个失败是之前的失败(“qhull 无法...”或根据来自值的奇怪结果凸包。

PointCloud<PointXYZ>::Ptr hugeBox(new PointCloud<PointXYZ>());
hugeBox->push_back(PointXYZ(10, 10, 10));
hugeBox->push_back(PointXYZ(10, 10, -10));
hugeBox->push_back(PointXYZ(10, -10, 10));
hugeBox->push_back(PointXYZ(10, -10, -10));
hugeBox->push_back(PointXYZ(-10, 10, 10));
hugeBox->push_back(PointXYZ(-10, 10, -10));
hugeBox->push_back(PointXYZ(-10, -10, 10));
hugeBox->push_back(PointXYZ(-10, -10, -10));

// Project inliers onto plane model
PointCloud<PointXYZ>::Ptr hugePlane(new PointCloud<PointXYZ>());
ProjectInliers<PointXYZ> proj;
proj.setModelType(SACMODEL_PLANE);
proj.setInputCloud(hugeBox);
proj.setModelCoefficients(coefficients);
proj.filter(*hugePlane);

// get the convex hull of plane
vector<Vertices> polygonsOut;
PointCloud<PointXYZ>::Ptr hugeHull(new PointCloud<PointXYZ>());
ConvexHull<PointXYZ> chull;
chull.setInputCloud(hugePlane);
chull.setDimension(2);
chull.reconstruct(*hugeHull, polygonsOut);

我有点卡在这里。如果我将其设置为二维,为什么它会失败?如果我将其设置为 3 维,我偶尔会发出以下警告:

qhull precision warning: 
The initial hull is narrow (cosine of min. angle is 0.9999999999999991).
A coplanar point may lead to a wide facet.

我知道,如果我有平面投影,就会出现这种情况,但是如何避免这种情况呢?

【问题讨论】:

    标签: c++ point-cloud-library point-clouds convex-hull qhull


    【解决方案1】:

    好的,问题是 PCL 从系统链接到旧的 libqhull (v0.5),而不是新的 v0.6 存在但未正确链接。 问题不会经常出现,但在旧版本的某些特殊情况下,例如,如果您有一个从 3d 到 2d 的平面投影并尝试在其周围放置一个外壳。

    我将向 pcl-people 提交请求以添加对版本号的要求。

    【讨论】:

      【解决方案2】:

      我不知道您使用的框架,但让我猜一下:您正在将点投影到嵌入 3 维体积的平面上,对吗? 3 维凸包算法失败很简单,因为投影在平面上的点是共面的——根据定义。反过来说,即使它们被投影到嵌入在 3 维空间中的平面上,这些点也位于 3 维空间中——我猜。另一方面,二维凸包算法期望真正的二维点 - 最有可能。因此,我认为它会通过某种映射将投影点减少到真实的二维空间,然后应用二维凸包算法。

      【讨论】:

      • 2d 算法也失败了,请参阅我帖子中的第 4 个代码块。如果我在船体计算中将 PointXYZ 更改为 PointXY,则会出现链接器错误。似乎不是为此而建造的。此外,我从官方 PCL-Docs 区域获取了部分代码。
      • 这正是我想要指出的完全。您必须知道如何通过某种转换将 PointXYZ 转换为 PointXY - 而不仅仅是替换类型 - 然后尝试运行它。
      • 我通过 copyPointCloud(*in, *out) 尝试了这个,没有用。但是我发现了问题,请参阅下面的帖子。谢谢!
      猜你喜欢
      • 2016-10-06
      • 2018-05-07
      • 2013-08-27
      • 2012-08-04
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 2019-02-23
      相关资源
      最近更新 更多