当前位置:网站首页>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"

边栏推荐
猜你喜欢

使用堡塔应用管理器配置laravel队列方法

LayaBox---TypeScript---Problems encountered at first contact

STM32MP157A驱动开发 | 01- 板载LED作为系统心跳指示灯

C language knowledge (1) - overview of C language, data types

【PCBA方案设计】握力计方案

Altium Designer 19.1.18 - 保护锁定的对象
![OD-Model [6]: YOLOv2](/img/3d/c81846ad0f20e055adf0192fbb8e07.png)
OD-Model [6]: YOLOv2

强网杯2022——WEB

【SQL之降龙十八掌】01——亢龙有悔:入门10题

js数据类型、节流/防抖、点击事件委派优化、过渡动画
随机推荐
buu web
3. Byte stream and character stream of IO stream
2022年江苏省大学生电子设计竞赛(TI杯)B题 飞机 省级一等奖记录 “一个摆烂人的独白”
Three ways to set a specific device UWP XAML view
Data warehouse (1) What is data warehouse and what are the characteristics of data warehouse
In action: 10 ways to implement delayed tasks, with code!
括号匹配
知识分享|如何设计有效的帮助中心,不妨来看看以下几点
SPSS-unary regression practice
Spss-系统聚类软件实操
OD-Model【6】:YOLOv2
dotnet 删除只读文件
NFT宝典:你需要知道NFT的术语和定义
【2022杭电多校5 1012题 Buy Figurines】STL的运用
Some problems with passing parameters of meta and params in routing (can be passed but not passed, empty, collocation, click to pass multiple parameters to report an error)
PCBA方案设计——厨房语音秤芯片方案
[2022 Hangzhou Electric Multi-School 5 1003 Slipper] Multiple Super Source Points + Shortest Path
使用堡塔应用管理器配置laravel队列方法
ini怎么使用? C#教程
Chapter7 : Network-Driven Drug Discovery