#include<pcl/point_types.h>#include<pcl/features/normal_3d.h>{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);... read, pass in or create a point cloud ...//法向估计类(此处泛型指应用位置XYZ坐标的数据求解出法向量坐标结果)
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
ne.setInputCloud (cloud);// 创建Kdtree对象// 以Kdtree形式组织输入的数据,以便内部查询各点邻域
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>());
ne.setSearchMethod (tree);// 输出集,pcl::Normal法向点类型即保存法向量的XYZ坐标,其中0-2个分量为XYZ坐标,第3个分量为曲率
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);// 设置各点查询的邻域范围
ne.setRadiusSearch (0.03);// 计算法向量
ne.compute (*cloud_normals);// cloud_normals->size () should have the same size as the input cloud->size ()*}
PCL教程指南-Estimating Surface Normals in a PointCloud(估计点云法向量)官方原文档点云法向指每个点的法向量,它是基于各点所在邻域范围内估计而出,常用方法如最小二乘估计邻域平面进而求出法向量,PCA求解邻域协方差最小特征向量等。具体详细原理另行查询。文档代码注释与接口扩展#include <pcl/point_types.h>#include <pcl/features/normal_3d.h>{ pcl::Point