【译】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

相关文章

Nexus安装和启动的实现教程

《Nexus安装和启动的实现教程》:本文主要介绍Nexus安装和启动的实现教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Nexus下载二、Nexus安装和启动三、关闭Nexus总结一、Nexus下载官方下载链接:DownloadWindows系统根

CnPlugin是PL/SQL Developer工具插件使用教程

《CnPlugin是PL/SQLDeveloper工具插件使用教程》:本文主要介绍CnPlugin是PL/SQLDeveloper工具插件使用教程,具有很好的参考价值,希望对大家有所帮助,如有错... 目录PL/SQL Developer工具插件使用安装拷贝文件配置总结PL/SQL Developer工具插

Java中的登录技术保姆级详细教程

《Java中的登录技术保姆级详细教程》:本文主要介绍Java中登录技术保姆级详细教程的相关资料,在Java中我们可以使用各种技术和框架来实现这些功能,文中通过代码介绍的非常详细,需要的朋友可以参考... 目录1.登录思路2.登录标记1.会话技术2.会话跟踪1.Cookie技术2.Session技术3.令牌技

Python使用Code2flow将代码转化为流程图的操作教程

《Python使用Code2flow将代码转化为流程图的操作教程》Code2flow是一款开源工具,能够将代码自动转换为流程图,该工具对于代码审查、调试和理解大型代码库非常有用,在这篇博客中,我们将深... 目录引言1nVflRA、为什么选择 Code2flow?2、安装 Code2flow3、基本功能演示

详解如何使用Python从零开始构建文本统计模型

《详解如何使用Python从零开始构建文本统计模型》在自然语言处理领域,词汇表构建是文本预处理的关键环节,本文通过Python代码实践,演示如何从原始文本中提取多尺度特征,并通过动态调整机制构建更精确... 目录一、项目背景与核心思想二、核心代码解析1. 数据加载与预处理2. 多尺度字符统计3. 统计结果可

Java Spring 中的监听器Listener详解与实战教程

《JavaSpring中的监听器Listener详解与实战教程》Spring提供了多种监听器机制,可以用于监听应用生命周期、会话生命周期和请求处理过程中的事件,:本文主要介绍JavaSprin... 目录一、监听器的作用1.1 应用生命周期管理1.2 会话管理1.3 请求处理监控二、创建监听器2.1 Ser

MySQL 安装配置超完整教程

《MySQL安装配置超完整教程》MySQL是一款广泛使用的开源关系型数据库管理系统(RDBMS),由瑞典MySQLAB公司开发,目前属于Oracle公司旗下产品,:本文主要介绍MySQL安装配置... 目录一、mysql 简介二、下载 MySQL三、安装 MySQL四、配置环境变量五、配置 MySQL5.1

MQTT SpringBoot整合实战教程

《MQTTSpringBoot整合实战教程》:本文主要介绍MQTTSpringBoot整合实战教程,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考... 目录MQTT-SpringBoot创建简单 SpringBoot 项目导入必须依赖增加MQTT相关配置编写

在Java中基于Geotools对PostGIS数据库的空间查询实践教程

《在Java中基于Geotools对PostGIS数据库的空间查询实践教程》本文将深入探讨这一实践,从连接配置到复杂空间查询操作,包括点查询、区域范围查询以及空间关系判断等,全方位展示如何在Java环... 目录前言一、相关技术背景介绍1、评价对象AOI2、数据处理流程二、对AOI空间范围查询实践1、空间查

Logback在SpringBoot中的详细配置教程

《Logback在SpringBoot中的详细配置教程》SpringBoot默认会加载classpath下的logback-spring.xml(推荐)或logback.xml作为Logback的配置... 目录1. Logback 配置文件2. 基础配置示例3. 关键配置项说明Appender(日志输出器