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

相关文章

0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeek R1模型的操作流程

《0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeekR1模型的操作流程》DeepSeekR1模型凭借其强大的自然语言处理能力,在未来具有广阔的应用前景,有望在多个领域发... 目录0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeek R1模型,3步搞定一个应

Deepseek R1模型本地化部署+API接口调用详细教程(释放AI生产力)

《DeepseekR1模型本地化部署+API接口调用详细教程(释放AI生产力)》本文介绍了本地部署DeepSeekR1模型和通过API调用将其集成到VSCode中的过程,作者详细步骤展示了如何下载和... 目录前言一、deepseek R1模型与chatGPT o1系列模型对比二、本地部署步骤1.安装oll

Spring AI Alibaba接入大模型时的依赖问题小结

《SpringAIAlibaba接入大模型时的依赖问题小结》文章介绍了如何在pom.xml文件中配置SpringAIAlibaba依赖,并提供了一个示例pom.xml文件,同时,建议将Maven仓... 目录(一)pom.XML文件:(二)application.yml配置文件(一)pom.xml文件:首

如何在本地部署 DeepSeek Janus Pro 文生图大模型

《如何在本地部署DeepSeekJanusPro文生图大模型》DeepSeekJanusPro模型在本地成功部署,支持图片理解和文生图功能,通过Gradio界面进行交互,展示了其强大的多模态处... 目录什么是 Janus Pro1. 安装 conda2. 创建 python 虚拟环境3. 克隆 janus

Python利用自带模块实现屏幕像素高效操作

《Python利用自带模块实现屏幕像素高效操作》这篇文章主要为大家详细介绍了Python如何利用自带模块实现屏幕像素高效操作,文中的示例代码讲解详,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1、获取屏幕放缩比例2、获取屏幕指定坐标处像素颜色3、一个简单的使用案例4、总结1、获取屏幕放缩比例from

本地私有化部署DeepSeek模型的详细教程

《本地私有化部署DeepSeek模型的详细教程》DeepSeek模型是一种强大的语言模型,本地私有化部署可以让用户在自己的环境中安全、高效地使用该模型,避免数据传输到外部带来的安全风险,同时也能根据自... 目录一、引言二、环境准备(一)硬件要求(二)软件要求(三)创建虚拟环境三、安装依赖库四、获取 Dee

nginx-rtmp-module模块实现视频点播的示例代码

《nginx-rtmp-module模块实现视频点播的示例代码》本文主要介绍了nginx-rtmp-module模块实现视频点播,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习... 目录预置条件Nginx点播基本配置点播远程文件指定多个播放位置参考预置条件配置点播服务器 192.

DeepSeek模型本地部署的详细教程

《DeepSeek模型本地部署的详细教程》DeepSeek作为一款开源且性能强大的大语言模型,提供了灵活的本地部署方案,让用户能够在本地环境中高效运行模型,同时保护数据隐私,在本地成功部署DeepSe... 目录一、环境准备(一)硬件需求(二)软件依赖二、安装Ollama三、下载并部署DeepSeek模型选

Golang的CSP模型简介(最新推荐)

《Golang的CSP模型简介(最新推荐)》Golang采用了CSP(CommunicatingSequentialProcesses,通信顺序进程)并发模型,通过goroutine和channe... 目录前言一、介绍1. 什么是 CSP 模型2. Goroutine3. Channel4. Channe

多模块的springboot项目发布指定模块的脚本方式

《多模块的springboot项目发布指定模块的脚本方式》该文章主要介绍了如何在多模块的SpringBoot项目中发布指定模块的脚本,作者原先的脚本会清理并编译所有模块,导致发布时间过长,通过简化脚本... 目录多模块的springboot项目发布指定模块的脚本1、不计成本地全部发布2、指定模块发布总结多模