【译】PCL官网教程翻译(21):旋转投影统计(RoPs)特征 - RoPs (Rotational Projection Statistics) feature

本文主要是介绍【译】PCL官网教程翻译(21):旋转投影统计(RoPs)特征 - RoPs (Rotational Projection Statistics) feature,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

英文原网址查看

旋转投影统计(RoPs)特征

在本教程中,我们将学习如何使用pcl::ROPSEstimation类来提取点特性。在这门课中实现的特征提取方法是由Yulan Guo, Ferdous Sohel, Mohammed Bennamoun, Min Lu and Jianwei Wanalso在他们的文章《旋转投影统计用于三维局部表面描述和目标识别》中提出的。

理论基础

特征提取方法的思想如下。有了网格和一组必须计算特征的点,我们执行一些简单的步骤。首先,对于给定的兴趣点,局部表面被裁剪。局部曲面由给定支撑半径内的点和三角形组成。对给定的局部表面LRF(局部参考帧)进行了计算。LRF只是向量的一个三元组,关于如何计算这些向量的综合信息可以在本文中找到。真正重要的是利用这些向量我们可以提供点云旋转的不变性。为此,我们简单地平移局部表面的点,使感兴趣的点成为原点,然后旋转局部表面,使LRF向量与Ox、Oy和Oz轴对齐。完成这些之后,我们就开始特征提取。对于每一个坐标轴Ox, Oy, Oz执行以下步骤,我们将这些坐标轴称为当前轴:

  • 局部曲面绕当前轴旋转一定角度;
  • 将旋转后的局部曲面的点投影到XY、XZ、YZ三个平面上;
  • 对于每一个投影分布矩阵的建立,这个矩阵只是简单地显示有多少点落在每个bin上。bin的数表示矩阵维数,为算法参数,为支撑半径;
  • 计算每个分布矩阵的中心矩:M11、M12、M21、M22, E,其中E为香农熵;
  • 然后将计算值连接起来形成子特性。

我们重复这些步骤几次。迭代次数取决于给定的旋转次数。不同轴的子特性被连接起来形成最终的RoPS描述符。

代码

在本教程中,我们将使用皇后数据集中的模型。您可以选择任何其他点云,但是为了使代码工作,您需要使用三角剖分算法来获得多边形。你可在此找到建议的模型:

  • 点-包含点云
  • 索引——包含必须计算RoPs的点的索引
  • 三角形——包含多边形

接下来你需要做的是在任何你喜欢的编辑器中创建一个文件rops_features .cpp,并在其中复制以下代码:

#include <pcl/features/rops_estimation.h>
#include <pcl/io/pcd_io.h>int main (int argc, char** argv)
{if (argc != 4)return (-1);pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());if (pcl::io::loadPCDFile (argv[1], *cloud) == -1)return (-1);pcl::PointIndicesPtr indices (new pcl::PointIndices);std::ifstream indices_file;indices_file.open (argv[2], std::ifstream::in);for (std::string line; std::getline (indices_file, line);){std::istringstream in (line);unsigned int index = 0;in >> index;indices->indices.push_back (index - 1);}indices_file.close ();std::vector <pcl::Vertices> triangles;std::ifstream triangles_file;triangles_file.open (argv[3], std::ifstream::in);for (std::string line; std::getline (triangles_file, line);){pcl::Vertices triangle;std::istringstream in (line);unsigned int vertex = 0;in >> vertex;triangle.vertices.push_back (vertex - 1);in >> vertex;triangle.vertices.push_back (vertex - 1);in >> vertex;triangle.vertices.push_back (vertex - 1);triangles.push_back (triangle);}float support_radius = 0.0285f;unsigned int number_of_partition_bins = 5;unsigned int number_of_rotations = 3;pcl::search::KdTree<pcl::PointXYZ>::Ptr search_method (new pcl::search::KdTree<pcl::PointXYZ>);search_method->setInputCloud (cloud);pcl::ROPSEstimation <pcl::PointXYZ, pcl::Histogram <135> > feature_estimator;feature_estimator.setSearchMethod (search_method);feature_estimator.setSearchSurface (cloud);feature_estimator.setInputCloud (cloud);feature_estimator.setIndices (indices);feature_estimator.setTriangles (triangles);feature_estimator.setRadiusSearch (support_radius);feature_estimator.setNumberOfPartitionBins (number_of_partition_bins);feature_estimator.setNumberOfRotations (number_of_rotations);feature_estimator.setSupportRadius (support_radius);pcl::PointCloud<pcl::Histogram <135> >::Ptr histograms (new pcl::PointCloud <pcl::Histogram <135> > ());feature_estimator.compute (*histograms);return (0);
}

解释

现在让我们研究一下这段代码的目的。

  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());if (pcl::io::loadPCDFile (argv[1], *cloud) == -1)return (-1);

这些行只是从.pcd文件加载点云。

  pcl::PointIndicesPtr indices (new pcl::PointIndices);std::ifstream indices_file;indices_file.open (argv[2], std::ifstream::in);for (std::string line; std::getline (indices_file, line);){std::istringstream in (line);unsigned int index = 0;in >> index;indices->indices.push_back (index - 1);}indices_file.close ();

这里加载了必须计算RoPS特性的点的索引。如果你想要的,您可以对它进行注释,并为云中的每个点计算特性。

  std::vector <pcl::Vertices> triangles;std::ifstream triangles_file;triangles_file.open (argv[3], std::ifstream::in);for (std::string line; std::getline (triangles_file, line);){pcl::Vertices triangle;std::istringstream in (line);unsigned int vertex = 0;in >> vertex;triangle.vertices.push_back (vertex - 1);in >> vertex;triangle.vertices.push_back (vertex - 1);in >> vertex;triangle.vertices.push_back (vertex - 1);triangles.push_back (triangle);}

这些行加载关于多边形的信息。如果只有点云而不是网格,可以用三角剖分的代码替换它们。

  float support_radius = 0.0285f;unsigned int number_of_partition_bins = 5;unsigned int number_of_rotations = 3;

这些代码定义了重要的算法参数:支持局部曲面裁剪的半径、用于形成分布矩阵的分区桶数和旋转数。最后一个参数影响描述符的长度。

  pcl::search::KdTree<pcl::PointXYZ>::Ptr search_method (new pcl::search::KdTree<pcl::PointXYZ>);search_method->setInputCloud (cloud);

这些行设置了算法将使用的搜索方法。

  pcl::ROPSEstimation <pcl::PointXYZ, pcl::Histogram <135> > feature_estimator;feature_estimator.setSearchMethod (search_method);feature_estimator.setSearchSurface (cloud);feature_estimator.setInputCloud (cloud);feature_estimator.setIndices (indices);feature_estimator.setTriangles (triangles);feature_estimator.setRadiusSearch (support_radius);feature_estimator.setNumberOfPartitionBins (number_of_partition_bins);feature_estimator.setNumberOfRotations (number_of_rotations);feature_estimator.setSupportRadius (support_radius);

这里是pcl::ROPSEstimation类实例化的地方。它有两个参数:

  • PointInT - 输入点的类型;
  • PointOutT - 输出点的类型。

之后,我们立即设置了用于特征计算的所有必要数据的输入。

  pcl::PointCloud<pcl::Histogram <135> >::Ptr histograms (new pcl::PointCloud <pcl::Histogram <135> > ());feature_estimator.compute (*histograms);

这里是启动计算过程的地方。

编译和运行程序

在CMakeLists.txt文件中添加以下行:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)project(rops_feature)find_package(PCL 1.8 REQUIRED)include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})add_executable (rops_feature rops_feature.cpp)
target_link_libraries (rops_feature ${PCL_LIBRARIES})

完成可执行文件后,就可以运行它了。只是做的事:

$ ./rops_feature points.pcd indices.txt triangles.txt

这篇关于【译】PCL官网教程翻译(21):旋转投影统计(RoPs)特征 - RoPs (Rotational Projection Statistics) feature的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1126983

相关文章

Linux卸载自带jdk并安装新jdk版本的图文教程

《Linux卸载自带jdk并安装新jdk版本的图文教程》在Linux系统中,有时需要卸载预装的OpenJDK并安装特定版本的JDK,例如JDK1.8,所以本文给大家详细介绍了Linux卸载自带jdk并... 目录Ⅰ、卸载自带jdkⅡ、安装新版jdkⅠ、卸载自带jdk1、输入命令查看旧jdkrpm -qa

Java使用Curator进行ZooKeeper操作的详细教程

《Java使用Curator进行ZooKeeper操作的详细教程》ApacheCurator是一个基于ZooKeeper的Java客户端库,它极大地简化了使用ZooKeeper的开发工作,在分布式系统... 目录1、简述2、核心功能2.1 CuratorFramework2.2 Recipes3、示例实践3

springboot简单集成Security配置的教程

《springboot简单集成Security配置的教程》:本文主要介绍springboot简单集成Security配置的教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录集成Security安全框架引入依赖编写配置类WebSecurityConfig(自定义资源权限规则

MySQL Workbench 安装教程(保姆级)

《MySQLWorkbench安装教程(保姆级)》MySQLWorkbench是一款强大的数据库设计和管理工具,本文主要介绍了MySQLWorkbench安装教程,文中通过图文介绍的非常详细,对大... 目录前言:详细步骤:一、检查安装的数据库版本二、在官网下载对应的mysql Workbench版本,要是

通过Docker Compose部署MySQL的详细教程

《通过DockerCompose部署MySQL的详细教程》DockerCompose作为Docker官方的容器编排工具,为MySQL数据库部署带来了显著优势,下面小编就来为大家详细介绍一... 目录一、docker Compose 部署 mysql 的优势二、环境准备与基础配置2.1 项目目录结构2.2 基

Linux安装MySQL的教程

《Linux安装MySQL的教程》:本文主要介绍Linux安装MySQL的教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux安装mysql1.Mysql官网2.我的存放路径3.解压mysql文件到当前目录4.重命名一下5.创建mysql用户组和用户并修

一文详解SQL Server如何跟踪自动统计信息更新

《一文详解SQLServer如何跟踪自动统计信息更新》SQLServer数据库中,我们都清楚统计信息对于优化器来说非常重要,所以本文就来和大家简单聊一聊SQLServer如何跟踪自动统计信息更新吧... SQL Server数据库中,我们都清楚统计信息对于优化器来说非常重要。一般情况下,我们会开启"自动更新

最新Spring Security实战教程之Spring Security安全框架指南

《最新SpringSecurity实战教程之SpringSecurity安全框架指南》SpringSecurity是Spring生态系统中的核心组件,提供认证、授权和防护机制,以保护应用免受各种安... 目录前言什么是Spring Security?同类框架对比Spring Security典型应用场景传统

最新Spring Security实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)

《最新SpringSecurity实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)》本章节介绍了如何通过SpringSecurity实现从配置自定义登录页面、表单登录处理逻辑的配置,并简单模拟... 目录前言改造准备开始登录页改造自定义用户名密码登陆成功失败跳转问题自定义登出前后端分离适配方案结语前言

Centos环境下Tomcat虚拟主机配置详细教程

《Centos环境下Tomcat虚拟主机配置详细教程》这篇文章主要讲的是在CentOS系统上,如何一步步配置Tomcat的虚拟主机,内容很简单,从目录准备到配置文件修改,再到重启和测试,手把手带你搞定... 目录1. 准备虚拟主机的目录和内容创建目录添加测试文件2. 修改 Tomcat 的 server.X