当前位置:网站首页>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"
边栏推荐
- 零基础都能拿捏的七夕浪漫代码,快去表白或去制造惊喜吧
- DSPE-PEG-Aldehyde,DSPE-PEG-CHO,磷脂-聚乙二醇-醛基一种疏水18碳磷脂
- PyTorch Geometric (PyG) 安装教程
- Win11如何开启Telnet客户端?
- 基于 Milvus 和 ResNet50 的图像搜索(部署及应用)
- PCBA方案设计——厨房语音秤芯片方案
- unity2D横版游戏教程9-对话框dialog
- 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)
- LayaBox---knowledge point
- dotnet 删除只读文件
猜你喜欢
随机推荐
3. Byte stream and character stream of IO stream
PowerCLi batch configuration of NTP
Hands-on Deep Learning_NiN
PowerCLi 导入License到vCenter 7
2022年江苏省大学生电子设计竞赛(TI杯)B题 飞机 省级一等奖记录 “一个摆烂人的独白”
LayaBox---TypeScript---Problems encountered at first contact
【2022杭电多校5 1003 Slipper】多个超级源点+最短路
【线性代数02】AX=b的2种解释和矩阵乘法的5种视角
如何根据“前序遍历,中序遍历”,“中序遍历,后序遍历”构建按二叉树
国际项目管理师PMP证书,值得考嘛?
mysql基础
DSPE-PEG-Aldehyde,DSPE-PEG-CHO,磷脂-聚乙二醇-醛基一种疏水18碳磷脂
DSPE-PEG-Aldehyde, DSPE-PEG-CHO, Phospholipid-Polyethylene Glycol-Aldehyde A hydrophobic 18-carbon phospholipid
dotnet 删除只读文件
【线性代数03】消元法展示以及AX=b的4种解情况
Go----Go 语言基础之标识符、关键字、命名规范、变量、常量
jekyll adds a flowchart to the blog
【分布式】分布式ID生成策略
Moke, dynamic image resource package display
[2022 Hangzhou Electric Multi-School 5 1003 Slipper] Multiple Super Source Points + Shortest Path