【发布时间】: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