我正在按照 PCL 文档的教程计算 2D Convex Hull ,请参见此处。
我有一个云和一些索引,将它们投影在具有给定系数的平面上,然后计算凸包。这是代码:
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);
我有点卡在这里。如果我将其设置为二维,为什么它会失败?如果我将其设置为 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.
我知道如果我有平面投影就是这种情况,但是如何避免这种情况呢?