点云库中的凸包计算在 2 维和 3 维中均失败

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

我正在按照 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 无法...”或根据 ConvexHull 的值的奇怪结果.

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);

我有点卡在这里。如果我将它设置为 2 维,为什么它会失败?如果我将它设置为 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
3个回答
1
投票

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


1
投票

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

我会向pcl-people提交请求,增加对版本号的要求。


0
投票

我有同样的问题,但是把数据放到PCL_VIEWER上后,它显示的点云是一组平行线,所以当我操作平面投影时,原始数据变成了平面线,ConvelHull算法不能接受这样的输入,我还是没有解决。

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