PCL点云库(4) — console模块

news/2024/10/18 5:53:20/

目录

4.1 time时间打印

4.2 print

4.3 parse

◆ find_switch()

◆ find_argument()

◆ parse()

◆ parse_2x_arguments() 

◆ parse_3x_arguments() 

◆ parse_x_arguments() 

◆ parse_multiple_arguments() 

◆ parse_multiple_2x_arguments()

◆ parse_multiple_3x_arguments()

◆ parse_file_extension_argument() 

4.4 程序示例


console模块官方文档:Point Cloud Library (PCL): pcl::console Namespace Reference

4.1 time时间打印

头文件#include <pcl/console/time.h>
pcl::console::TicToc time; 定义类
void tic()获取单前时间
double toc() const获取时间差
void toc_print() const打印时间

4.2 print

#define PCL_ALWAYS(...)  pcl::console::print (pcl::console::L_ALWAYS, __VA_ARGS__)
#define PCL_ERROR(...)   pcl::console::print (pcl::console::L_ERROR, __VA_ARGS__)
#define PCL_WARN(...)    pcl::console::print (pcl::console::L_WARN, __VA_ARGS__)
#define PCL_INFO(...)    pcl::console::print (pcl::console::L_INFO, __VA_ARGS__)
#define PCL_DEBUG(...)   pcl::console::print (pcl::console::L_DEBUG, __VA_ARGS__)
#define PCL_VERBOSE(...) pcl::console::print (pcl::console::L_VERBOSE, __VA_ARGS__)

4.3 parse

◆ find_switch()

功能判断argv命令行中是否有argument_name

函数原型

bool pcl::console::find_switch (int argc, //参数列表的数量

                const char *const *argv, //参数列表

                const char *argument_name //搜索的值 )

◆ find_argument()

功能查找名称为"argument_name"的参数在参数列表"argv"中的位置。

函数原型

int pcl::console::find_argument ( int  argc,        //参数列表的数量

                                                    const char *const *argv,  //参数列表
                                                    const char *argument_name  //搜索的值)    

◆ parse()

功能判断argv命令行中是否有argument_name

函数原型

int pcl::console::parse    (int argc,      //参数列表的数量
                         const char *const *argv,   //参数列表
                         const char *argument_name,    //搜索的值
                         Type & value     //输出:返回的值
                        )    

◆ parse_2x_arguments() 

功能输出argv参数列表中2个str数据

函数原型

​PCL_EXPORTS int pcl::console::parse_2x_arguments(int argc,   //参数列表的数量
                                                 const char *const *argv,      //参数列表
                                                 const char *str,       //搜索的值
                                                 double &f,        //第一个输出值
                                                 double &s,        //第二个输出值
                                                 bool debug = true       //是否打印调试信息
)    

◆ parse_3x_arguments() 

功能输出argv参数列表中3个str数据

函数原型

​PCL_EXPORTS int pcl::console::parse_3x_arguments(int argc,   //参数列表的数量
                                                 const char *const *argv,      //参数列表
                                                 const char *str,       //搜索的值
                                                 double &f,        //第1个输出值
                                                 double &s,        //第2个输出值

                                                 double &t,          //第3个输出值
                                                 bool debug = true       //是否打印调试信息
)    

◆ parse_x_arguments() 

功能输出argv参数列表中符合条件的str数据

函数原型

​PCL_EXPORTS int pcl::console::parse_x_arguments(int argc,   //参数列表的数量
                                                 const char *const *argv,      //参数列表
                                                 const char *str,       //搜索的值
                                               std::vector< double > &v,        //符合条件的值存入数组中
)    

◆ parse_multiple_arguments() 

功能输出argv参数列表中含有多个str的解析

函数原型

bool pcl::console::parse_multiple_arguments( int argc,//参数列表的数量

                                                                          const char *const *  argv   //参数列表

                                                                          const char * str,  //搜索的值

                                                                          std::vector< double > & values,//多次出现相同的命令行参数 )    

◆ parse_multiple_2x_arguments()

功能输出argv参数列表含有多个str有2个数据的解析

函数原型

bool pcl::console::parse_multiple_arguments( int argc,//参数列表的数量

                                                                          const char *const *  argv   //参数列表

                                                                          const char * str,  //搜索的值

                                                                          std::vector< double > & values_f,//输出值的第1个向量

                                                                          std::vector< double > & values_s,//输出值的第2个向量)    

◆ parse_multiple_3x_arguments()

功能输出argv参数列表含有多个str有3个数据的解析

函数原型

bool pcl::console::parse_multiple_arguments( int argc,//参数列表的数量

                                                                          const char *const *  argv   //参数列表

                                                                          const char * str,  //搜索的值

                                                                          std::vector< double > & values_f,//输出值的第1个向量

                                                                          std::vector< double > & values_s,//输出值的第2个向量)      

                                                                          std::vector< double > & values_s,//输出值的第3个向量)    

◆ parse_file_extension_argument() 

功能判断argv文件后缀是否有argument_name

函数原型

bool pcl::console::find_switch (int argc, //命令行参数的数量

                const char *const *argv, //命令行参数

                const std::vector<std::string> //要搜索的扩展

)

4.4 程序示例

#include <iostream>
#include <pcl/console/parse.h>
#include <pcl/console/print.h>
#include <pcl/console/time.h>
#include <pcl/point_types.h>using namespace std;int main(int argc, char *argv[])
{cout << "--- 01 time ---" << endl;pcl::console::TicToc time;  //创建TicToc类time.tic();time.toc_print();cout << "--- 02 print ---" << endl;PCL_ALWAYS(stdout,"%d\n",12);PCL_ERROR(stdout,"%s","Error msg.\n");PCL_INFO(stdout,"%s\n","Info msg.");PCL_DEBUG(stdout,"%s","Pcl info.\n");PCL_VERBOSE(stdout,"%s\n","Pcl verbose.");cout << "--- 03 print ---" << endl;cout << "--- 3.1 find_switch ---" << endl;bool ret = pcl::console::find_switch(argc,argv,"-d");cout << ret << endl;cout << "--- 3.2 find_argument ---" << endl;int idx = pcl::console::find_argument(argc,argv,"-d");cout << idx << endl;cout << "--- 3.3 parse ---" << endl;std::string value;pcl::console::parse(argc,argv,"-d",value);cout << value << endl;cout << "--- 3.4 parse_argument ---" << endl;int ivalue;pcl::console::parse_argument(argc,argv,"-i",ivalue);cout << ivalue << endl;cout << "--- 3.5 parse_2x_arguments ---" << endl;float fv1; float fv2;pcl::console::parse_2x_arguments(argc,argv,"-v",fv1,fv2);cout << fv1 << " " << fv2 << endl;cout << "--- 3.6 parse_3x_arguments ---" << endl;double dv1, dv2,dv3;pcl::console::parse_3x_arguments(argc,argv,"-dbl",dv1,dv2,dv3);cout << dv1 << " " << dv2  << " " << dv3 << endl;cout << "--- 3.7 parse_x_arguments ---" << endl;std::vector<double> vs;pcl::console::parse_x_arguments(argc,argv,"-dbl",vs);for(const auto &iv : vs)cout << iv << " " ;cout << endl;cout << "--- 3.8 parse_multiple_arguments ---" << endl;std::vector<int> mvs;pcl::console::parse_multiple_arguments(argc,argv,"-mv",mvs);for(const auto &iv : mvs)cout << iv << " " ;cout << endl;cout << "--- 3.9 parse_multiple_2x_arguments ---" << endl;std::vector<double> fmvs,smvs;pcl::console::parse_multiple_2x_arguments(argc,argv,"-2mv",fmvs,smvs);for(const auto &iv : fmvs)cout << iv << " " ;cout << endl;for(const auto &iv : smvs)cout << iv << " " ;cout << endl;cout << "--- 3.10 parse_multiple_3x_arguments ---" << endl;std::vector<double> f_mvs,s_mvs,t_mvs;pcl::console::parse_multiple_3x_arguments(argc,argv,"-3mv",f_mvs,s_mvs,t_mvs);for(const auto &iv : f_mvs)cout << iv << " " ;cout << endl;for(const auto &iv : s_mvs)cout << iv << " " ;cout << endl;for(const auto &iv : t_mvs)cout << iv << " " ;cout << endl;cout << "--- 3.11 parse_file_extension_argument ---" << endl;std::vector<int> idxs = pcl::console::parse_file_extension_argument(argc,argv,".pcd");for(const auto &iv : idxs)cout << iv << " ";cout << endl;return 0;
}

 打开终端进行验证解析,输入./程序名 待解析字段

***:~/studydata/pcl/18console/build$ ./console -d -i -v 1.1,1.2 -db 1.1,1.2,1.3 -db 1.0,2.0,3.0,4.0 -mv 1 -mv 4 -2mv 8,9 -2mv 10,11 -3mv 12,13,14 -3mv 15,16,17 -3mv 18,19,20
--- 01 time ---
6e-05 ms
--- 02 print ---
12
Error msg.
Info msg.
--- 03 print ---
--- 3.1 find_switch ---
1
--- 3.2 find_argument ---
1
--- 3.3 parse ---
-i
--- 3.4 parse_argument ---
0
--- 3.5 parse_2x_arguments ---
1.1 1.2
--- 3.6 parse_3x_arguments ---
1.1 1.2 1.3
--- 3.7 parse_x_arguments ---
1.1 1.2 1.3 
--- 3.8 parse_multiple_arguments ---
1 4 
--- 3.9 parse_multiple_2x_arguments ---
8 10 
9 11 
--- 3.10 parse_multiple_3x_arguments ---
12 15 18 
13 16 19 
14 17 20 
--- 3.11 parse_file_extension_argument ---


http://www.ppmy.cn/news/55551.html

相关文章

阿里云服务器通用算力u1性能测评CPU处理器网络PPS

阿里云服务器u1通用算力型Universal实例高性价比&#xff0c;CPU采用Intel(R) Xeon(R) Platinum&#xff0c;主频是2.5 GHz&#xff0c;云服务器U1实例的基准vCPU算力与5代企业级实例持平&#xff0c;最高vCPU算力与6代企业级实例持平&#xff0c;提供2c-32c规格和1:1/2/4/8丰富…

Python小姿势 - Python学习笔记——类与对象

Python学习笔记——类与对象 类与对象是面向对象编程的两个基本概念。类是对象的抽象概念&#xff0c;对象是类的具体表现。 类是对一类事物的抽象&#xff0c;它是描述一类事物的模板&#xff0c;而对象是类的具体表现。对象是类的实例&#xff0c;类是对象的模板。 举个例子&…

使用ChatGPT生成了十种排序算法

前言 当前ChatGPT非常火爆&#xff0c;对于程序员来说&#xff0c;ChatGPT可以帮助编写很多有用的代码。比如&#xff1a;在算法的实现上&#xff0c;就可以替我们省很多事。所以&#xff0c;小试牛刀一下&#xff0c;看看ChatGPT生成了排序算法怎么样&#xff1f; 简介 排序…

Vue3通透教程【七】生命周期函数

文章目录 🌟 写在前面🌟 生命周期钩子函数🌟 组合式API生命周期🌟 写在最后🌟 写在前面 专栏介绍: 凉哥作为 Vue 的忠实 粉丝输出过大量的 Vue 文章,应粉丝要求开始更新 Vue3 的相关技术文章,Vue 框架目前的地位大家应该都晓得,所谓三大框架使用人数最多,公司选…

Python中“is”和“==”的区别(避坑)

2.3 “is”和“”的区别 在Python编写代码时&#xff0c;经常会遇到需要判断2个对象是否相等的情况&#xff0c;这个时候一般就会想到使用is和&#xff0c;is和好像都可以用来判断对象是否相等&#xff0c;经常会傻傻分不清&#xff0c;但其实这其中还是有区别的。 不过在这之…

漏洞分析和利用

1 安全漏洞生命周期 在渗透测试流程中,核心内容是找出目标系统中存在的安全漏洞,并实施渗透攻击,从而进入到目标系统中。而这一过程最主要的底层基础是目标系统中存在的安全漏洞(Vulnerability)。安全漏洞指信息系统中存在的缺陷或不适当的配置,它们可使攻击者在未授权情况…

C语言从入门到精通第11天(数组的基本操作)

数组的基本操作 数组的概念一维数组二维数组 数组的概念 在程序设计中&#xff0c;为了方便处理数据把具有相同类型的若干变量按有序形式集合在一起&#xff0c;这些按序排列的同类数据元素的集合称为数组。 在C语言中&#xff0c;数组属于构造数据类型&#xff0c;一个数组可…

三维可视化智慧档案馆之八防环境监控系统平台白皮书

目录 一、智慧档案馆建设目的 二、智慧档案馆集成度 三、智慧档案馆架构 3.1库房环境监测 3.2库房安防监控 四、智慧档案馆功能简介 4.1档案室一体化控制管理系统建设方案 4.2温湿度检测建设方案 4.3恒温控制建设方案 4.4烟雾感应检测系统 4.5安防系统建设…