本人使用了PCL1.12以及VS2019进行点云操作编程,但是在运行过程中发现程序无法正常运行或退出,会蹦出memory.h 中我的exe触发了一个断点的提示,如图。
可能有问题的代码如下:
想请问解决办法。即使跑官方例程也会有这样的问题。
代码会在运行完cout<<"1"<<endl;后蹦出断点提示,for循环只运行了一次。如果把后面三角化的代码块去掉则程序会把for循环运行完,但是最终也会蹦出断点提示,程序会非正常退出。
pcl::PointCloud<pcl::PointXYZ> cloud_filtered;
pcl::PointCloud<pcl::PointXYZ> cloud_downSp;
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
pcl::PointCloud<pcl::Normal> normals;
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointNormal> cloud_with_normals;
pcl::search::KdTree<pcl::PointNormal>::Ptr tree2(new pcl::search::KdTree<pcl::PointNormal>);
pcl::PolygonMesh triangle;
vector<pcl::PolygonMesh> triangleSeries;
for (int i = 0; i < cloudSeries.size(); i++) {
//Deal with the cloudSeries[i] seperetely.
cloudPointNum.push_back(cloudSeries[i].size());
//1st, Filtering the outliner points.
cout << "Filtering " << i << " cloud outliner points." << endl;
pcl::StatisticalOutlierRemoval<pcl::PointXYZ> outliner;
outliner.setInputCloud(cloudSeries[i].makeShared());
outliner.setMeanK(50);
outliner.setStddevMulThresh(1.0);
outliner.filter(cloud_filtered);
cout << "Down sampling " << i << " cloud points." << endl;
pcl::VoxelGrid<pcl::PointXYZ> DownSp;
DownSp.setInputCloud(cloud_filtered.makeShared());
DownSp.setLeafSize(0.15f, 0.15f, 0.15f);
DownSp.filter(cloud_downSp);
cloud_filtered.clear();
cout << "Cal normals." << endl;
tree->setInputCloud(cloud_downSp.makeShared());
n.setInputCloud(cloud_downSp.makeShared());
n.setSearchMethod(tree);
n.setKSearch(20);
n.compute(normals);
pcl::concatenateFields(cloud_downSp, normals, cloud_with_normals);
cloud_downSp.clear();
normals.clear();
cout << "Triangling." << endl;
tree2->setInputCloud(cloud_with_normals.makeShared());
pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
gp3.setSearchRadius(0.03);
gp3.setMu(2.5);
gp3.setMaximumNearestNeighbors(100);
gp3.setMaximumSurfaceAngle(M_PI / 4);
gp3.setMinimumAngle(M_PI / 18);
gp3.setMaximumAngle(2 * M_PI / 3);
gp3.setNormalConsistency(false);
gp3.setInputCloud(cloud_with_normals.makeShared());
gp3.setSearchMethod(tree2);
gp3.reconstruct(triangle);
triangleSeries.push_back(triangle);
cloud_with_normals.clear();
cout << "1" << endl;
}