PCL1.8.1 Feature - PFH

PFH(Point Feature Histograms)

表面法線和曲率估計是某個點周圍的幾何特徵表示法,計算速度快,但沒法得到太多信息,由於它只是經過使用不多的幾個參數值來近似表示一個點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);
  }
}
相關文章
相關標籤/搜索