当前位置:网站首页>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"
边栏推荐
猜你喜欢
Arduino 电机测速
PowerCLi batch configuration of NTP
Altium Designer 19.1.18 - 保护锁定的对象
js数据类型、节流/防抖、点击事件委派优化、过渡动画
3、IO流之字节流和字符流
Hands-on Deep Learning_NiN
国际项目管理师PMP证书,值得考嘛?
[2022 Hangzhou Electric Power Multi-School 5 1012 Questions Buy Figurines] Application of STL
如何将二叉搜索树转化为一个有序的双向链表(原树上修改)
数电快速入门(二)(复合逻辑运算和逻辑代数的基本定律的介绍)
随机推荐
mdk5.14 cannot be burned
【线性代数02】AX=b的2种解释和矩阵乘法的5种视角
LayaBox---knowledge point
matlab drawing
buu web
如何一键重装win7系统?重装win7系统详细教程
OD-Model [6]: YOLOv2
Yolov7:Trainable bag-of-freebies sets new state-of-the-art for real-time objectdetectors
LayaBox---TypeScript---structure
零基础都能拿捏的七夕浪漫代码,快去表白或去制造惊喜吧
Codeforces Round #811 (Div. 3)
Dotnet using WMI software acquisition system installation
matlab 画图
LeetCode: 406. 根据身高重建队列
Android 面试——如何写一个又好又快的日志库?
命名路由、组件中name的作用
ROS播包可视化
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
PowerCLi batch configuration of NTP
Re24:读论文 IOT-Match Explainable Legal Case Matching via Inverse Optimal Transport-based Rationale Ext