PCL中Sample_consensus模块支持的几何模型

2023-11-06 22:58

本文主要是介绍PCL中Sample_consensus模块支持的几何模型,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

As of PCL 1.0, the following models are supported: 

(1)SACMODEL_PLANE(三维平面)

  • used to determine plane models. The four coefficients of the plane are itsHessian Normal form: [normal_x normal_y normal_z d
    • a : the X coordinate of the plane's normal (normalized)
    • b : the Y coordinate of the plane's normal (normalized)
    • c : the Z coordinate of the plane's normal (normalized)
    • d : the fourth Hessian component of the plane's equation
(2) SACMODEL_LINE(三维直线)
  • used to determine line models. The six coefficients of the line are given by a point on the line and the direction of the line as: [point_on_line.x point_on_line.y point_on_line.z line_direction.x line_direction.y line_direction.z
    • point_on_line.x : the X coordinate of a point on the line
    • point_on_line.y : the Y coordinate of a point on the line
    • point_on_line.z : the Z coordinate of a point on the line
    • line_direction.x : the X coordinate of a line's direction
    • line_direction.y : the Y coordinate of a line's direction
    • line_direction.z : the Z coordinate of a line's direction

(3) SACMODEL_CIRCLE2D(二维圆)
  • used to determine 2D circles in a plane. The circle's three coefficients are given by its center and radius as: [center.x center.y radius
    • center.x : the X coordinate of the circle's center
    • center.y : the Y coordinate of the circle's center
    • radius : the circle's radius
(4) SACMODEL_CIRCLE3D

  • not implemented yet 
(5) SACMODEL_SPHERE(球)
  • used to determine sphere models. The four coefficients of the sphere are given by its 3D center and radius as: [center.x center.y center.z radius]  
    • center.x : the X coordinate of the sphere's center
    • center.y : the Y coordinate of the sphere's center
    • center.z : the Z coordinate of the sphere's center
    • radius : the sphere's radius 
(6) SACMODEL_CYLINDER(柱)

  • used to determine cylinder models. The seven coefficients of the cylinder are given by a point on its axis, the axis direction, and a radius, as: [point_on_axis.x point_on_axis.y point_on_axis.z axis_direction.x axis_direction.y axis_direction.z radius
    • point_on_axis.x : the X coordinate of a point located on the cylinder axis
    • point_on_axis.y : the Y coordinate of a point located on the cylinder axis
    • point_on_axis.z : the Z coordinate of a point located on the cylinder axis
    • axis_direction.x : the X coordinate of the cylinder's axis direction
    • axis_direction.y : the Y coordinate of the cylinder's axis direction
    • axis_direction.z : the Z coordinate of the cylinder's axis direction
    • radius : the cylinder's radius 
(7) SACMODEL_CONE 
  • not implemented yet 
(8)SACMODEL_TORUS

  • not implemented yet 
(9) SACMODEL_PARALLEL_LINE(平行线)

  • a model for determining a line parallel with a given axis, within a maximum specified angular deviation. The line coefficients are similar toSACMODEL_LINE. 

SampleConsensusModelParallelLine defines a model for 3D line segmentation using additional angular constraints.  

The model coefficients are defined as:

  • point_on_line.x : the X coordinate of a point on the line
  • point_on_line.y : the Y coordinate of a point on the line
  • point_on_line.z : the Z coordinate of a point on the line
  • line_direction.x : the X coordinate of a line's direction
  • line_direction.y : the Y coordinate of a line's direction
  • line_direction.z : the Z coordinate of a line's direction 
(10) SACMODEL_PERPENDICULAR_PLANE
  • a model for determining a plane perpendicular to an user-specified axis, within a maximum specified angular deviation. The plane coefficients are similar to SACMODEL_PLANE. 
SampleConsensusModelPerpendicularPlane defines a model for 3D plane segmentation using additional angular constraints.

The plane must be perpendicular to an user-specified axis (setAxis), up to an user-specified angle threshold (setEpsAngle). The model coefficients are defined as:

  • a : the X coordinate of the plane's normal (normalized)
  • b : the Y coordinate of the plane's normal (normalized)
  • c : the Z coordinate of the plane's normal (normalized)
  • d : the fourth Hessian component of the plane's equation

Code example for a plane model, perpendicular (within a 15 degrees tolerance) with the Z axis:

 SampleConsensusModelPerpendicularPlane<pcl::PointXYZ> model (cloud);model.setAxis (Eigen::Vector3f (0.0, 0.0, 1.0));model.setEpsAngle (pcl::deg2rad (15));
Note:
Please remember that you need to specify an angle > 0 in order to activate the axis-angle constraint!


(11)SACMODEL_PARALLEL_LINES - not implemented yet 

(12) SACMODEL_NORMAL_PLANE
  • a model for determining plane models using an additional constraint: the surface normals at each inlier point has to be parallel to the surface normal of the output plane, within a maximum specified angular deviation. The plane coefficients are similar to SACMODEL_PLANE. 

    SampleConsensusModelNormalPlane defines a model for 3D plane segmentation using additional surface normal constraints. 、

    Basically this means that checking for inliers will not only involve a "distance to model" criterion, but also an additional "maximum angular deviation" between the plane's normal and the inlier points normals.

    The model coefficients are defined as:

    • a : the X coordinate of the plane's normal (normalized)
    • b : the Y coordinate of the plane's normal (normalized)
    • c : the Z coordinate of the plane's normal (normalized)
    • d : the fourth Hessian component of the plane's equation 

    To set the influence of the surface normals in the inlier estimation process, set the normal weight (0.0-1.0), e.g.:

     SampleConsensusModelNormalPlane<pcl::PointXYZ, pcl::Normal> sac_model;...sac_model.setNormalDistanceWeight (0.1);...


(13) SACMODEL_PARALLEL_PLANE
  • a model for determining a plane parallel to an user-specified axis, within a maximim specified angular deviation. SACMODEL_PLANE. 

SampleConsensusModelParallelPlane defines a model for 3D plane segmentation using additional angular constraints.

The plane must be parallel to a user-specified axis (setAxis) within an user-specified angle threshold (setEpsAngle).

Code example for a plane model, parallel (within a 15 degrees tolerance) with the Z axis:

 SampleConsensusModelParallelPlane<pcl::PointXYZ> model (cloud);model.setAxis (Eigen::Vector3f (0.0, 0.0, 1.0));model.setEpsAngle (pcl::deg2rad (15));

(14) SACMODEL_NORMAL_PARALLEL_PLANE
  • defines a model for 3D plane segmentation using additional surface normal constraints. The plane must lieparallel to a user-specified axis. SACMODEL_NORMAL_PARALLEL_PLANE therefore is equivallent to SACMODEL_NORMAL_PLANE + SACMODEL_PARALLEL_PLANE. The plane coefficients are similar toSACMODEL_PLANE. 

SampleConsensusModelNormalParallelPlane defines a model for 3D plane segmentation using additional surface normal constraints. 


Basically this means that checking for inliers will not only involve a "distance to model" criterion, but also an additional "maximum angular deviation" between the plane's normal and the inlier points normals. In addition, the plane normal must lie parallel to an user-specified axis.

The model coefficients are defined as:

  • a : the X coordinate of the plane's normal (normalized)
  • b : the Y coordinate of the plane's normal (normalized)
  • c : the Z coordinate of the plane's normal (normalized)
  • d : the fourth Hessian component of the plane's equation

To set the influence of the surface normals in the inlier estimation process, set the normal weight (0.0-1.0), e.g.:

 SampleConsensusModelNormalPlane<pcl::PointXYZ, pcl::Normal> sac_model;...sac_model.setNormalDistanceWeight (0.1);...
举例:(使用参数化模型投影点云到三维平面)

用到ModelCoefficients结构和ProjectInliers滤波器

说明:填充ModelCoefficients的值,例子中使用了一个ax+by+cz+d=0的平面模型,其中a=b=d=0,c=1;

创建了ProjectInliers对象,并使用刚定义好的 ModelCoefficients作为投影对象的模型参数。


#include<iostream>
#include<pcl\point_cloud.h>
#include<pcl\point_types.h>
#include<pcl\ModelCoefficients.h>
#include<pcl\filters\project_inliers.h>
using namespace std;
int main()
{pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected(new pcl::PointCloud<pcl::PointXYZ>);cloud->width=5;cloud->height=1;cloud->points.resize(cloud->width*cloud->height);for(size_t i=0;i<cloud->points.size();i++){cloud->points[i].x=1024*rand()/(RAND_MAX+1.0f);cloud->points[i].y=1024*rand()/(RAND_MAX+1.0f);cloud->points[i].z=1024*rand()/(RAND_MAX+1.0f);}std::cerr<<"Cloud before projection:"<<std::endl;for(size_t i=0;i<cloud->points.size();i++)std::cerr<<' '<<cloud->points[i].x<<' '<<cloud->points[i].y<<' '<<cloud->points[i].z<<std::endl;//定义模型系数对象,并填充对应的数据pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());coefficients->values.resize(4);coefficients->values[0]=coefficients->values[1]=coefficients->values[3]=0;coefficients->values[2]=1.0;pcl::ProjectInliers<pcl::PointXYZ> proj;//创建投影滤波对象proj.setModelType(pcl::SACMODEL_PLANE);//设置对象对应的投影模型proj.setInputCloud(cloud);      //设置输入点云proj.setModelCoefficients(coefficients);//设置模型对应的系数proj.filter(*cloud_projected);std::cerr<<"Cloud after projection:"<<std::endl;for(size_t i=0;i<cloud->points.size();i++)std::cerr<<' '<<cloud_projected->points[i].x<<' '<<cloud_projected->points[i].y<<' '<<cloud_projected->points[i].z<<std::endl;system("pause");return 0;
}

总结:投影钱的z轴都不为0,是随机产生的值,投影之后,打印结果表明,x,y没有改变,z都变成0。

该投影滤波类输入为点云和投影模型,输出为投影到模型上之后的点云。

这篇关于PCL中Sample_consensus模块支持的几何模型的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

Python datetime 模块概述及应用场景

《Pythondatetime模块概述及应用场景》Python的datetime模块是标准库中用于处理日期和时间的核心模块,本文给大家介绍Pythondatetime模块概述及应用场景,感兴趣的朋... 目录一、python datetime 模块概述二、datetime 模块核心类解析三、日期时间格式化与

Python如何调用指定路径的模块

《Python如何调用指定路径的模块》要在Python中调用指定路径的模块,可以使用sys.path.append,importlib.util.spec_from_file_location和exe... 目录一、sys.path.append() 方法1. 方法简介2. 使用示例3. 注意事项二、imp

Python中模块graphviz使用入门

《Python中模块graphviz使用入门》graphviz是一个用于创建和操作图形的Python库,本文主要介绍了Python中模块graphviz使用入门,具有一定的参考价值,感兴趣的可以了解一... 目录1.安装2. 基本用法2.1 输出图像格式2.2 图像style设置2.3 属性2.4 子图和聚

Python的time模块一些常用功能(各种与时间相关的函数)

《Python的time模块一些常用功能(各种与时间相关的函数)》Python的time模块提供了各种与时间相关的函数,包括获取当前时间、处理时间间隔、执行时间测量等,:本文主要介绍Python的... 目录1. 获取当前时间2. 时间格式化3. 延时执行4. 时间戳运算5. 计算代码执行时间6. 转换为指

Python正则表达式语法及re模块中的常用函数详解

《Python正则表达式语法及re模块中的常用函数详解》这篇文章主要给大家介绍了关于Python正则表达式语法及re模块中常用函数的相关资料,正则表达式是一种强大的字符串处理工具,可以用于匹配、切分、... 目录概念、作用和步骤语法re模块中的常用函数总结 概念、作用和步骤概念: 本身也是一个字符串,其中

Python中的getopt模块用法小结

《Python中的getopt模块用法小结》getopt.getopt()函数是Python中用于解析命令行参数的标准库函数,该函数可以从命令行中提取选项和参数,并对它们进行处理,本文详细介绍了Pyt... 目录getopt模块介绍getopt.getopt函数的介绍getopt模块的常用用法getopt模

python logging模块详解及其日志定时清理方式

《pythonlogging模块详解及其日志定时清理方式》:本文主要介绍pythonlogging模块详解及其日志定时清理方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录python logging模块及日志定时清理1.创建logger对象2.logging.basicCo

Qt spdlog日志模块的使用详解

《Qtspdlog日志模块的使用详解》在Qt应用程序开发中,良好的日志系统至关重要,本文将介绍如何使用spdlog1.5.0创建满足以下要求的日志系统,感兴趣的朋友一起看看吧... 目录版本摘要例子logmanager.cpp文件main.cpp文件版本spdlog版本:1.5.0采用1.5.0版本主要

Spring Security基于数据库的ABAC属性权限模型实战开发教程

《SpringSecurity基于数据库的ABAC属性权限模型实战开发教程》:本文主要介绍SpringSecurity基于数据库的ABAC属性权限模型实战开发教程,本文给大家介绍的非常详细,对大... 目录1. 前言2. 权限决策依据RBACABAC综合对比3. 数据库表结构说明4. 实战开始5. MyBA

SpringKafka消息发布之KafkaTemplate与事务支持功能

《SpringKafka消息发布之KafkaTemplate与事务支持功能》通过本文介绍的基本用法、序列化选项、事务支持、错误处理和性能优化技术,开发者可以构建高效可靠的Kafka消息发布系统,事务支... 目录引言一、KafkaTemplate基础二、消息序列化三、事务支持机制四、错误处理与重试五、性能优