当前位置:网站首页>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"
边栏推荐
- 《剑指offer》刷题分类
- 88.(cesium之家)cesium聚合图
- 强网杯2022——WEB
- DSPE-PEG-Aldehyde, DSPE-PEG-CHO, Phospholipid-Polyethylene Glycol-Aldehyde A hydrophobic 18-carbon phospholipid
- 【手把手教你使用STM32HAL库的串口空闲中断】
- Axure9基本交互操作(一)
- AI/ML无线通信
- Yolov7:Trainable bag-of-freebies sets new state-of-the-art for real-time objectdetectors
- unity2D横版游戏教程8-音效
- 后缀式的计算
猜你喜欢
LayaBox---TypeScript---Problems encountered at first contact
DSPE-PEG-Aldehyde,DSPE-PEG-CHO,磷脂-聚乙二醇-醛基一种疏水18碳磷脂
动手学深度学习_NiN
unity2D横版游戏教程8-音效
PowerCLi import license to vCenter 7
AXI interface application of Zynq Fpga image processing - the use of axi_lite interface
[2022 Hangzhou Electric Power Multi-School 5 1012 Questions Buy Figurines] Application of STL
Android 面试——如何写一个又好又快的日志库?
2、字符集-编码-解码
国内的PMP证书含金量到底如何
随机推荐
硬件开发定制全流程解析
模拟对抗之红队免杀开发实践
matlab 画图
【编程思想】
Common methods of js's new Function()
[2022 Nioke Duo School 5 A Question Don't Starve] DP
PCBA方案设计——厨房语音秤芯片方案
数字重塑客观世界,全空间GIS发展正当其时
y87.第五章 分布式链路追踪系统 -- 分布式链路追踪系统起源(一)
win10 uwp use WinDbg to debug
强网杯2022——WEB
boostrap多选PID查找端口 window
js data type, throttling/anti-shake, click event delegation optimization, transition animation
PowerCLi 导入License到vCenter 7
国际项目管理师PMP证书,值得考嘛?
OD-Model [6]: YOLOv2
Pinduoduo open platform order information query interface [pdd.order.basic.list.get order basic information list query interface (according to transaction time)] code docking tutorial
Red team kill-free development practice of simulated confrontation
SPSS-unary regression practice
命名路由、组件中name的作用