Qt工程中c++实现wrl到pcd格式转换
pcl1.8.0+QT5.7.0+vs2013 win7 x64环境配置
//读取文本型和二进制型点云数据
void onOpen()
{//打开文件QString fileName = QFileDialog::getOpenFileName(this,tr("Open PointCloud"), ".",tr("Open PCD files(*.pcd);;Open WRL files(*.wrl)"));//filename类型转换std::string file_name = fileName.toStdString();//获取文件名称以及扩展名vector<string> tokens;boost::char_separator<char> sep(".");boost::tokenizer<boost::char_separator<char> > tok(file_name, sep);tokens.clear();std::copy(tok.begin(), tok.end(), std::back_inserter(tokens));if (!fileName.isEmpty()){//若是其他类型if (tokens[1] != "pcd"){//查找特定位置(所需点坐标)l为所在行数;l-35为点云个数string fout_name = tokens[0] + ".pcd";int linenum = 0;int l;ifstream in(file_name);string line;string s;int i = 0;string key = "texCoord DEF texcoord0 TextureCoordinate";while (getline(in, line)){if (line.find(key) != string::npos){// cout << linenum << " ";l = linenum;}linenum++;}//写入ofstream outfile(fout_name, ios::out | ios::trunc);outfile << "# .PCD v.5 - Point Cloud Data file format" << endl;outfile << "VERSION .5" << endl;outfile << "FIELDS x y z" << endl;outfile << "SIZE 4 4 4" << endl;outfile << "TYPE F F F" << endl;outfile << "COUNT 1 1 1" << endl;outfile << "WIDTH " << l - 35 << endl;outfile << "HEIGHT 1" << endl;outfile << "POINTS " << l - 35 << endl;outfile << "DATA ascii" << endl;//添加点ifstream inFile;inFile.open(file_name);while (getline(inFile, s, '\n')){if (i > 32 && i < l - 2)outfile << s << endl;i++;}inFile.close();outfile.close();//显示pcl::PCLPointCloud2 cloud2;//pcl::PointCloud<Eigen::MatrixXf> cloud2;Eigen::Vector4f origin;Eigen::Quaternionf orientation;int pcd_version;int data_type;unsigned int data_idx;int offset = 0;pcl::PCDReader rd;rd.readHeader(fout_name, cloud2, origin, orientation, pcd_version, data_type, data_idx);if (data_type == 0){pcl::io::loadPCDFile(fout_name, *cloud);}else if (data_type == 2){pcl::PCDReader reader;reader.read<pcl::PointXYZ>(fout_name, *cloud);}viewer->updatePointCloud(cloud, "cloud");viewer->resetCamera();ui.qvtkWidget->update();}else{//sensor_msgs::PointCloud2 cloud2;pcl::PCLPointCloud2 cloud2;//pcl::PointCloud<Eigen::MatrixXf> cloud2;Eigen::Vector4f origin;Eigen::Quaternionf orientation;int pcd_version;int data_type;unsigned int data_idx;int offset = 0;pcl::PCDReader rd;rd.readHeader(file_name, cloud2, origin, orientation, pcd_version, data_type, data_idx);if (data_type == 0){pcl::io::loadPCDFile(fileName.toStdString(), *cloud);}else if (data_type == 2){pcl::PCDReader reader;reader.read<pcl::PointXYZ>(fileName.toStdString(), *cloud);}viewer->updatePointCloud(cloud, "cloud");viewer->resetCamera();ui.qvtkWidget->update();}}
}
运行结果
Qt工程中c++实现wrl到pcd格式转换相关推荐
- 【qt】qt工程中包含c++标准库头文件,提示找不到。
问题: 在qt工程中包含c++标准库头文件,提示找不到. 如下: #include <vector> using namespace std; 解决办法: 在*.pro文件中增加vecto ...
- logstash中Ruby代码把@timestamp时间戳格式转换
logstash中ruby代码把@timestamp时间戳格式转换 filter{ ruby {code => "event.set('xxx_time',(event.get('@t ...
- python批量提取word文档中的图片(含图片格式转换和GUI)
作者:小小明 文章目录 doc格式批量转为docx 批量提取docx文档的图片 批量图片格式转换 完整代码 GUI图形化工具开发 打包exe 给GUI加入进度条 日常工作中,领导要求你将一份 Word ...
- Qt工程中如何添加.pri文件
pri文件中的i 是包含(include)的首字母.类似于C.C++中的头文件就是我们可以把 .pro 文件内需要include的一部分或者多个工程相同的部分单独放到一个 .pri 文件内,然后包含到 ...
- java 当前时间格式_JAVA中获取当前系统时间及格式转换
一. 获取当前系统时间和日期并格式化输出: import java.util.Date; import java.text.SimpleDateFormat; public class NowStri ...
- Java 系统时间转为date_JAVA中获取当前系统时间及格式转换
一. 获取当前系统时间和日期并格式化输出: import java.util.Date; import java.text.SimpleDateFormat; public class NowStri ...
- oracle截取日期类型的字符串,oracle截取字段中的部分字符串:日期格式转换
##从数据库中导出excel数据后,造数据,然后重新导入oracel数据库中,查询后显示导入成功 但是页面还是显示是老的数据,后来发现日期自动变化了2016-05-06变化为2016/05/06 导致 ...
- MacOS中afconvert的使用(音频格式转换)
MacOS的强大一方面也在于其继承了众多实用工具,比如今天介绍的这个afconvert. 位置:/usr/bin/afconvert 用法:需要使用命令行操作,在终端cd到bin下即可使用 参数说明: ...
- Google 源码中电池百分比获取方法和格式转换
Google 源码的电池百分比获取和转换 package com.android.settingslib;public class Utils {/** Formats a double from 0 ...
最新文章
- python读写excel
- 分数混合运算简便方法_分数四则混合运算
- flume高可用-balance-配置文件编写
- Linux 性能分析大概步骤
- flask基础之jinja2模板-语法定义
- python爬虫好学不_python爬虫好学吗
- Java基础学习总结(131)——项目开发中真的有必要使用Lombok插件么?
- html css 圆形按钮 仿uc,10款基于jquery的web前端动画特效
- iOS xcode4 编译环境
- 宏定义处理特殊字符 -_c语言编译与预处理命令
- 如何识别媒体偏见_面部识别软件:宝贵资产,还是社会偏见的体现?
- php公众号失物招领系统,【服务】微信公众平台『失物招领』功能上线
- shiro721复现
- Qt实现网格显示(图标文本)功能
- 捕鱼源码 免费提供和分享,仅供unity和Java初学者学习参考,希望能带来帮助
- 自己做的一个c#超大浮点数bigFloat
- delphi 两行代码实现合并多张图片生成mp4视频
- 运动控制卡讲解及实例应用
- 建一个网站需要花多少钱?
- 乐观锁与悲观锁、自旋锁