點雲法線計算
并行計算點雲法線
void normalEstimation(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,
pcl::PointCloud<pcl::Normal>::Ptr normals,
int k, unsigned int threads)
{
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>); // 建立用于最近鄰搜尋的KD-Tree
pcl::NormalEstimationOMP<pcl::PointXYZ, pcl::Normal> normalEstimation;
normalEstimation.setInputCloud(cloud); //輸入點雲
normalEstimation.setSearchMethod(tree);
// K近鄰确定方法,使用k個最近點,或者确定一個以r為半徑的圓内的點集來确定都可以,兩者選1即可
normalEstimation.setKSearch(k); // 使用目前點周圍最近的個數
//normalEstimation.setRadiusSearch(30); //對于每一個點都用半徑近鄰搜尋方式
normalEstimation.setNumberOfThreads(threads);
normalEstimation.compute(*normals); //計算法線
}