点云pcd格式与ply格式互相转换
程序员文章站
2022-03-31 09:35:44
...
1. pcd转ply
#include <iostream>
#include <pcl/io/ply_io.h>
#include <pcl/io/pcd_io.h>
using namespace std;
int main()
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudOrigin(new pcl::PointCloud<pcl::PointXYZ>);
//pcl::PLYReader reader;
pcl::PCDReader reader;
reader.read("D:\\MatLab\\workspace\\Point-cloud-Edge-and-Corner-Detection-master\\data\\panel_line3.pcd", *cloudOrigin);
/*for循环避免出现数据中出现nan*/
for (int i = 0; i < cloudOrigin->points.size(); i++)
{
if (isnan(cloudOrigin->points[i].x))
{
cloudOrigin->points[i].x = 0;
cloudOrigin->points[i].y = 0;
cloudOrigin->points[i].z = 0;
}
}
//pcl::PCDWriter writer;
pcl::PLYWriter writer;
writer.write("D:\\MatLab\\workspace\\Point-cloud-Edge-and-Corner-Detection-master\\data\\panel_line3.ply", *cloudOrigin);
cout << "finished..." << endl;
return 0;
}
2. ply转pcd
#include <iostream>
#include <pcl/io/ply_io.h>
#include <pcl/io/pcd_io.h>
using namespace std;
int main()
{
pcd::PointCloud<pcl::PointXYZ>::Ptr cloudOrigin(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PLYReader reader;
reader.read("D:\\MatLab\\workspace\\Point-cloud-Edge-and-Corner-Detection-master\\data\\panel_line3.ply", *cloudOrigin);
pcl::PCDWriter writer;
writer.writeASCII("D:\\MatLab\\workspace\\Point-cloud-Edge-and-Corner-Detection-master\\data\\panel_line3.pcd", *cloudOrigin);
cout << "finished..." << endl;
return 0;
}
上一篇: 将String转化成java对象
下一篇: js将html转化成json
推荐阅读
-
mssql sqlserver时间戳与时间格式互相转换的方法分享
-
知识点——C#日期格式转换 格式化与区域无关
-
PCL——(3)PCD(点云数据)文件格式简介
-
用Access将XLS与MDB文件格式互相转换
-
浅析Js(Jquery)中,字符串与JSON格式互相转换的示例(直接运行实例)_jquery
-
javascript-JS 的时间格式与JSON时间格式如何互相转换?
-
浅析Js(Jquery)中,字符串与JSON格式互相转换的示例(直接运行实例)
-
时间戳与时间格式互相转换
-
浅析Js(Jquery)中,字符串与JSON格式互相转换的示例(直接运行实例)_jquery
-
mssql sqlserver时间戳与时间格式互相转换的方法分享