PCL(4)PCD格式转换为PLY格式
程序员文章站
2022-03-30 22:01:59
...
#include <iostream> //输入输出流头文件
#include <pcl/io/pcd_io.h> //打开关闭pcd类定义头文件
#include <pcl/point_types.h> //所有点类型定义头文件
#include <pcl/io/ply_io.h> //打开关闭ply类定义头文件
int main(int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
if (pcl::io::loadPCDFile<pcl::PointXYZ>("F://PCL online data//three//6//source//test.pcd", *cloud) == -1) //加载文件
{
PCL_ERROR("Couldn't read file \n");
system("PAUSE");
return (-1);
}
//显示点云数量
std::cout << "point number: "
<< cloud->width * cloud->height
<< std::endl;
//显示文件中各点数据
/*
for (size_t i = 0; i < cloud->points.size(); ++i)
std::cout << " " << cloud->points[i].x
<< " " << cloud->points[i].y
<< " " << cloud->points[i].z
<< std::endl;
*/
std::string filename("test1.ply");
pcl::PLYWriter writer;
writer.write("F://PCL online data//three//6//source//test1.ply", *cloud); //保存文件
system("PAUSE");
return (0);
}