当前位置:网站首页>Unknown point cloud structure file conversion requirements
Unknown point cloud structure file conversion requirements
2022-08-04 21:31:00 【moneymyone】
Unknown point cloud structure file conversion requirements
Description of Requirements
There is a collection of point clouds, binary, with fields of unconventional types.
But it can be seen that there are a total of 6 fields, two of which are
_, and there is no specific field.Now remove these two unknown fields and keep the remaining 4 fields
x y z intensity.

Format conversion
In the same way, the point cloud file conversion is realized by customizing the point type.
When defining a point type, setting the dash type to int or string has no effect on the result.
struct MyPointType //Define point type structure{PCL_ADD_POINT4D; //The point type has 4 elements/* try to add a custom */unsigned m; //Define your own new type name//Tested adding so many is no problemfloat intensity;unsigned k;EIGEN_MAKE_ALIGNED_OPERATOR_NEW //Ensure new operator alignment operation}EIGEN_ALIGN16; //Force SSE alignmentPOINT_CLOUD_REGISTER_POINT_STRUCT(MyPointType, //Register point type macro(float,x,x)(float,y,y)(float ,z,z)(unsigned char ,m,m)(float ,intensity,intensity)(unsigned ,k,k))The main code is as follows, which can realize batch conversion of all point cloud files in the folder:
/** @Description:* @version: 1.0.0* @Author: qianchengjun* @Date: 2022-02-22 14:33:45* @LastEditors: qianchengjun* @LastEditTime: 2022-02-22 16:49:34*/#include #include #include #include #include #include #include #include #include #include using namespace std;void ConvertPCD(std::string file){pcl::PointCloud cloudsrc;pcl::PointCloud cloudtar;if (pcl::io::loadPCDFile(file, cloudsrc) == -1){PCL_ERROR("Couldn'n read file! \n");return;}std::cout << cloudsrc.points.size() << std::endl;for (size_t i = 0; i < cloudsrc.points.size(); i++){pcl::PointXYZI pt;pt.x = cloudsrc[i].x;pt.y = cloudsrc[i].y;pt.z = cloudsrc[i].z;pt.intensity = cloudsrc[i].intensity;cloudtar.push_back(pt);}std::string newfile = file.replace(file.rfind(".pcd"),4,"_new.pcd");pcl::PCDWriter writer;writer.write (newfile, cloudtar, true); // save the file}int main(int argc, char** argv){// target folder pathstd::string folder = "/home/qiancj/Documents/M1/Underground_Garage/4.5mleft_head/";vector files;getFiles(folder.c_str(), files);for_each(files.begin(), files.end(), [](const string &file){ConvertPCD(file);cout << "finish convert file: " << file << endl; });return 0;} The result is as follows:
All newly converted files are named "XXXXX_new.pcd"

边栏推荐
- Common methods of js's new Function()
- JWT actively checks whether the Token has expired
- Arduino 电机测速
- LayaBox---TypeScript---structure
- ue unreal 虚幻 高分辨率无缩放 编辑器字太小 调整编辑器整体缩放
- 开发deepstram的自定义插件,使用gst-dseaxmple插件进行扩充,实现deepstream图像输出前的预处理,实现图像自定义绘制图(精四)
- SPSS-System Clustering Software Practice
- 如何一键重装Win11系统 一键重装系统方法
- LocalDate时间日期包的用法
- 【SQL之降龙十八掌】01——亢龙有悔:入门10题
猜你喜欢

如何一键重装Win11系统 一键重装系统方法

【手把手教你使用STM32HAL库的串口空闲中断】

8 年产品经验,我总结了这些持续高效研发实践经验 · 协同篇

AXI interface application of Zynq Fpga image processing - the use of axi_lite interface

PowerCLi 批量配置NTP

【ubuntu20.04安装MySQL以及MySQL-workbench可视化工具】

SPSS-System Clustering Software Practice

1、File对象学习

js data type, throttling/anti-shake, click event delegation optimization, transition animation

88. (the home of cesium) cesium polymerization figure
随机推荐
拼多多开放平台订单信息查询接口【pdd.order.basic.list.get订单基础信息列表查询接口(根据成交时间)】代码对接教程
硬件开发定制全流程解析
SPSS-unary regression practice
Android 面试——如何写一个又好又快的日志库?
JWT actively checks whether the Token has expired
mysql基础
STM32MP157A驱动开发 | 01- 板载LED作为系统心跳指示灯
Altium Designer 19.1.18 - 画多边形铜皮挖空时,针对光标胡乱捕获的解决方法
27. Dimensionality reduction
Common methods of js's new Function()
数电快速入门(三)(卡诺图化简法的介绍)
【编程思想】
【SQL之降龙十八掌】01——亢龙有悔:入门10题
Moke, dynamic image resource package display
NFT宝典:你需要知道NFT的术语和定义
Go----Go 语言基础之标识符、关键字、命名规范、变量、常量
AtCoder Beginner Contest 262 D - I Hate Non-integer Number
《剑指offer》刷题分类
括号匹配
【uiautomation】微信好友列表获取(存储到txt中)