环境:</p>
- ubuntu18
- pcl 1.8.0
一些代码如下:
// Greedy Projection triangulation
pcl::PolygonMesh triangulationGreedyProjection(pcl::PointCloud<pcl::PointXYZ>::Ptr xyzCloud) {
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normalEstimation;
pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
tree->setInputCloud(xyzCloud);
normalEstimation.setInputCloud(xyzCloud);
normalEstimation.setSearchMethod(tree);
normalEstimation.setKSearch(20);
normalEstimation.compute(*normals);
pcl::PointCloud<pcl::PointNormal>::Ptr cloudWithNormals(new pcl::PointCloud<pcl::PointNormal>);
// 将已获得的点数据和法向数据拼接
pcl::concatenateFields(*xyzCloud, *normals, *cloudWithNormals);
// another kd-tree for reconstruction
pcl::search::KdTree<pcl::PointNormal>::Ptr tree2(new pcl::search::KdTree<pcl::PointNormal>);
tree2->setInputCloud(cloudWithNormals);
// reconstruction
pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
pcl::PolygonMesh mesh;
// options
gp3.setSearchRadius(25);
gp3.setMu(2.5);
gp3.setMaximumNearestNeighbors(100);
gp3.setMaximumSurfaceAngle(M_PI / 2);
gp3.setMinimumAngle(M_PI / 18);
gp3.setMaximumAngle(2 * M_PI / 3);
gp3.setNormalConsistency(false);
gp3.setInputCloud(cloudWithNormals);
gp3.setSearchMethod(tree2);
gp3.reconstruct(mesh);
return mesh;
}
但是,在执行“gp3.reconstruct(mesh);”时,代码崩溃和断点显示“Memory.h”中的“std::free(ptr)”为流
:
EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr)
{
#if (EIGEN_DEFAULT_ALIGN_BYTES==0) || EIGEN_MALLOC_ALREADY_ALIGNED
std::free(ptr);
#else
handmade_aligned_free(ptr);
#endif
}
结果如下: