void estimate_Borders(CP& cloudIn) {
pcl::console::TicToc time; time.tic();
int cloudIn_size = cloudIn->size();
int k = 1;
int each_count = cloudIn_size / k;
vector<CloudT> cloudIdx(k);
vector<CloudT> cloudRes(k);
#pragma omp parallel for
for (int i = 0; i < k; i++) {
for (int j = each_count * i; j < each_count * (i + 1); j++) {
cloudIdx[i].emplace_back(cloudIn->points[j]);
}
pcl::PointCloud<pcl::Boundary> boundaries;
pcl::BoundaryEstimation<PointT, pcl::Normal, pcl::Boundary> boundEst;
CP temp = cloudIdx[i].makeShared();
normals_cloud = find_pcl_kdtree_faxian(temp); //点云法向量
boundEst.setInputCloud(temp);
boundEst.setInputNormals(normals_cloud);
boundEst.setRadiusSearch(0.3f);
boundEst.setAngleThreshold(M_PI / 2);
boundEst.setSearchMethod(pcl::search::KdTree<PointT>::Ptr(new pcl::search::KdTree<PointT>));
boundEst.compute(boundaries);
for (int m = 0; m < cloudIdx[i].size(); m++) {
if (boundaries[m].boundary_point > 0) {
cloudRes[i].emplace_back(cloudIdx[i].points[m]);
}
}
}
cloud = cloudRes[0].makeShared();
for (int i = 1; i < k; i++) {
for(int j = 0;j< cloudRes[i].size();j++)
cloud->emplace_back(cloudRes[i].points[j]);
}
cout << "边界提取用时:" << time.toc() << "ms" << endl;
//my_view(cloud);这里是可视化
return;
}
不过耗时相对比较久.就算加了多线程
忘了说了
typedef pcl::PointXYZ PointT;
typedef pcl::PointCloud<PointT> CloudT;
typedef CloudT::Ptr CP;
using namespace std;
using namespace Eigen;
find_pcl_kdtree_faxian()函数在pcl的NormalEstimation计算法向量-CSDN博客