表面法线和曲率估计是某个点周围的几何特征表示法,计算速度快,但没法得到太多信息,由于它只是经过使用不多的几个参数值来近似表示一个点K的邻域的几何特性。 经过点特征直方图能够提供一个可度量的信息空间,详细可查看论文:Persistent Point Feature Histograms for 3D Point Clouds.php
最近计算PFH的点云大小和输入的点云大小相同,即pfhs->points.size() s= cloud->points.size()ide
http://www.pointclouds.org/documentation/tutorials/pfh_estimation.php#pfh-estimationspa
#include <pcl/point_types.h> #include <pcl/features/pfh.h> { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal> ()); //此处代码参考法向量 ... read, pass in or create a point cloud with normals ... ... (note: you can create a single PointCloud<PointNormal> if you want) ... // Create the PFH estimation class, and pass the input dataset+normals to it pcl::PFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::PFHSignature125> pfh; pfh.setInputCloud (cloud); pfh.setInputNormals (normals); // alternatively, if cloud is of tpe PointNormal, do pfh.setInputNormals (cloud); // Create an empty kdtree representation, and pass it to the PFH estimation object. // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ()); //pcl::KdTreeFLANN<pcl::PointXYZ>::Ptr tree (new pcl::KdTreeFLANN<pcl::PointXYZ> ()); -- older call for PCL 1.5- pfh.setSearchMethod (tree); // Output datasets pcl::PointCloud<pcl::PFHSignature125>::Ptr pfhs (new pcl::PointCloud<pcl::PFHSignature125> ()); // Use all neighbors in a sphere of radius 5cm // IMPORTANT: the radius used here has to be larger than the radius used to estimate the surface normals!!! pfh.setRadiusSearch (0.05); // Compute the features pfh.compute (*pfhs); // pfhs->points.size () should have the same size as the input cloud->points.size ()* }
在计算PFH时,考虑到效率的问题,没有对法向量进行空和无穷大检测,所以在计算FPH前须要进行法向量的判断,使用以下代码:.net
for (int i = 0; i < normals->points.size(); i++) { if (!pcl::isFinite<pcl::Normal>(normals->points[i])) { PCL_WARN("normals[%d] is not finite\n", i); } }