PCL 点云特征描述及提取

参考:https://zhuanlan.zhihu.com/p/470786175

对应类对应头文件算法描述
pcl::ShapeContext3DEstimation< PointInT, PointNT, PointOutT >#include <pcl/features/3dsc.h>实现3D形状内容描述子算法
pcl::BOARDLocalReferenceFrameEstimation< PointInT, PointNT, PointOutT >实现局部坐标系估计的方法 特别是处理点云边缘或有孔洞有特殊的处理方式
pcl::BoundaryEstimation< PointInT, PointNT, PointOutT >实现估计一组点集是否处于指定点的投影区域的边缘位置
pcl::CRHEstimation< PointInT, PointNT, PointOutT >实现摄像头旋转直方图描述子,利用概算法主要进行刚体对象的位姿估计
pcl::CVFHEstimation< PointInT, PointNT, PointOutT >实现聚类视点直方图CVFH描述子的计算 主要是针对解决有残缺的点云识别问题
pcl::ESFEstimation< PointInT, PointOutT >实现ESF描述子,主要用于实时对三维场景中的点云模型进行分类而提出的
pcl::PFHEstimation< PointInT, PointNT, PointOutT >#include <pcl/features/fpfh.h>快速点特征直方图描述子
pcl::MomentOfInertiaEstimation< PointInT>#include <pcl/features/moment_of_inertia_estimation.h>基于偏心率和惯性矩的描述特征
pcl::ROPSEstimation< PointInT, PointOutT >#include <pcl/features/rops_estimation.h>Rops(Rotational Projection Statistics)旋转投影统计特征
pcl::SHOTEstimation< PointInT, PointOutT >#include <pcl/features/shot.h>SHOT(Signature of Histograms of OrienTations)方向直方图特征

PFH特征提取

#include<iostream>
#include<vector>
#include <pcl/point_types.h>
#include <pcl/features/pfh.h>
#include <pcl/io/pcd_io.h>//点云文件pcd 读写
#include <pcl/features/normal_3d.h>//法线特征
#include <pcl/visualization/pcl_plotter.h>// 直方图的可视化 方法2

using namespace std;
int main(int argc, char** argv)
{

    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>);
    //======【1】 读取点云文件 填充点云对象======
    pcl::PCDReader reader;
    reader.read("mesh.pcd", *cloud_ptr);
    // =====【2】计算法线========创建法线估计类====================================
    pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
    ne.setInputCloud(cloud_ptr);
   
    pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>());
    ne.setSearchMethod(tree);//设置近邻搜索算法
    // 输出点云 带有法线描述
    pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_ptr(new pcl::PointCloud<pcl::Normal>);
    pcl::PointCloud<pcl::Normal>& cloud_normals = *cloud_normals_ptr;
    // Use all neighbors in a sphere of radius 3cm
    ne.setRadiusSearch(0.03);//半价内搜索临近点 3cm
    // 计算表面法线特征
    ne.compute(cloud_normals);

    //=======【3】创建PFH估计对象pfh,并将输入点云数据集cloud和法线normals传递给它=================
    pcl::PFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::PFHSignature125> pfh;// phf特征估计其器
    pfh.setInputCloud(cloud_ptr);
    pfh.setInputNormals(cloud_normals_ptr);
    //如果点云是类型为PointNormal,则执行pfh.setInputNormals (cloud);
    //创建一个空的kd树表示法,并把它传递给PFH估计对象。
    //基于已给的输入数据集,建立kdtree
    pcl::search::KdTree<pcl::PointXYZ>::Ptr tree2(new pcl::search::KdTree<pcl::PointXYZ>());
    //pcl::KdTreeFLANN<pcl::PointXYZ>::Ptr tree2 (new pcl::KdTreeFLANN<pcl::PointXYZ> ()); //-- older call for PCL 1.5-
    pfh.setSearchMethod(tree2);//设置近邻搜索算法
    //输出数据集
    pcl::PointCloud<pcl::PFHSignature125>::Ptr pfh_fe_ptr(new pcl::PointCloud<pcl::PFHSignature125>());//phf特征
    //使用半径在5厘米范围内的所有邻元素。
    //注意:此处使用的半径必须要大于估计表面法线时使用的半径!!!
    pfh.setRadiusSearch(0.05);
    //计算pfh特征值
    pfh.compute(*pfh_fe_ptr);
    cout << "phf feature size : " << pfh_fe_ptr->points.size() << endl;
    // 应该与input cloud->points.size ()有相同的大小,即每个点都有一个pfh特征向量

    // ========直方图可视化=============================
      pcl::visualization::PCLPlotter plotter;
      plotter.addFeatureHistogram(*pfh_fe_ptr, 300); //设置的很坐标长度,该值越大,则显示的越细致
      plotter.plot();

    return 0;
}

SHOT特征提取

在这里插入图片描述

基本原理:

  1. 根据特征点球邻域信息建立局部参考坐标系LRF,对特征点的球邻域分别沿径向(内外球)、经度(时区)和纬度方向(南北半球)进行区域划分。通常径向划分为2,经度划分为8,纬度划分为2,总共32个小区域。

  2. 分别统计每个小区域内的法向量夹角余弦值分布情况,法向量划分为11个bin。最终SHOT的长度为:32x11=352。

  3. 代码如下:

    void KeyPoints::getFeatures(PointCloudXYZ::Ptr &cloud, PointCloudXYZ::Ptr &keys, pcl::PointCloud<pcl::SHOT352>::Ptr features, pcl::PointCloud<pcl::Normal>::Ptr cloud_normal)
    {
    	clock_t begin = clock();
    
    	//pcl::SHOTEstimation<pcl::PointXYZ, pcl::Normal, pcl::SHOT352> shot;
    	pcl::SHOTEstimationOMP<pcl::PointXYZ, pcl::Normal, pcl::SHOT352> shot;
    	shot.setRadiusSearch(KeyPoints::search_radius);
    	shot.setInputCloud(keys);
    	shot.setSearchSurface(cloud);
    	shot.setInputNormals(cloud_normal);
    	shot.compute(*features);
    	clock_t end = clock();
    	std::cout << "compute feature time is "<<(end-begin)<<"\n";
    	cout << "输入点云的大小是" << cloud->points.size() << endl;
    }
    
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AICVer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值