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

相关文章

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

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

Java的IO模型、Netty原理解析

《Java的IO模型、Netty原理解析》Java的I/O是以流的方式进行数据输入输出的,Java的类库涉及很多领域的IO内容:标准的输入输出,文件的操作、网络上的数据传输流、字符串流、对象流等,这篇... 目录1.什么是IO2.同步与异步、阻塞与非阻塞3.三种IO模型BIO(blocking I/O)NI

基于Flask框架添加多个AI模型的API并进行交互

《基于Flask框架添加多个AI模型的API并进行交互》:本文主要介绍如何基于Flask框架开发AI模型API管理系统,允许用户添加、删除不同AI模型的API密钥,感兴趣的可以了解下... 目录1. 概述2. 后端代码说明2.1 依赖库导入2.2 应用初始化2.3 API 存储字典2.4 路由函数2.5 应

Python使用date模块进行日期处理的终极指南

《Python使用date模块进行日期处理的终极指南》在处理与时间相关的数据时,Python的date模块是开发者最趁手的工具之一,本文将用通俗的语言,结合真实案例,带您掌握date模块的六大核心功能... 目录引言一、date模块的核心功能1.1 日期表示1.2 日期计算1.3 日期比较二、六大常用方法详

python中time模块的常用方法及应用详解

《python中time模块的常用方法及应用详解》在Python开发中,时间处理是绕不开的刚需场景,从性能计时到定时任务,从日志记录到数据同步,时间模块始终是开发者最得力的工具之一,本文将通过真实案例... 目录一、时间基石:time.time()典型场景:程序性能分析进阶技巧:结合上下文管理器实现自动计时

一文教你解决Python不支持中文路径的问题

《一文教你解决Python不支持中文路径的问题》Python是一种广泛使用的高级编程语言,然而在处理包含中文字符的文件路径时,Python有时会表现出一些不友好的行为,下面小编就来为大家介绍一下具体的... 目录问题背景解决方案1. 设置正确的文件编码2. 使用pathlib模块3. 转换路径为Unicod

C#集成DeepSeek模型实现AI私有化的流程步骤(本地部署与API调用教程)

《C#集成DeepSeek模型实现AI私有化的流程步骤(本地部署与API调用教程)》本文主要介绍了C#集成DeepSeek模型实现AI私有化的方法,包括搭建基础环境,如安装Ollama和下载DeepS... 目录前言搭建基础环境1、安装 Ollama2、下载 DeepSeek R1 模型客户端 ChatBo

SpringBoot快速接入OpenAI大模型的方法(JDK8)

《SpringBoot快速接入OpenAI大模型的方法(JDK8)》本文介绍了如何使用AI4J快速接入OpenAI大模型,并展示了如何实现流式与非流式的输出,以及对函数调用的使用,AI4J支持JDK8... 目录使用AI4J快速接入OpenAI大模型介绍AI4J-github快速使用创建SpringBoot

Node.js net模块的使用示例

《Node.jsnet模块的使用示例》本文主要介绍了Node.jsnet模块的使用示例,net模块支持TCP通信,处理TCP连接和数据传输,具有一定的参考价值,感兴趣的可以了解一下... 目录简介引入 net 模块核心概念TCP (传输控制协议)Socket服务器TCP 服务器创建基本服务器服务器配置选项服

定价129元!支持双频 Wi-Fi 5的华为AX1路由器发布

《定价129元!支持双频Wi-Fi5的华为AX1路由器发布》华为上周推出了其最新的入门级Wi-Fi5路由器——华为路由AX1,建议零售价129元,这款路由器配置如何?详细请看下文介... 华为 Wi-Fi 5 路由 AX1 已正式开售,新品支持双频 1200 兆、配有四个千兆网口、提供可视化智能诊断功能,建