美文网首页PCL应用技术
PCL:将pcd文件转换成ply文件

PCL:将pcd文件转换成ply文件

作者: AI秘籍 | 来源:发表于2020-04-15 21:00 被阅读0次

PCL中的常用的点云存储文件为.pcd文件,但是很多场合下使用的点云存储文件为.ply文件,特别是要在meshlab中查看的时候。
PCL中有相应的类PLYWriter可以帮助我们实现从.pcd文件到.ply文件的转换。
在例程中,pcd2ply.cpp可以实现从.pcd文件到.ply文件的转换的一个cpp文件。

// pcd转ply
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include<pcl/PCLPointCloud2.h>
#include<iostream>
#include<string>

using namespace pcl;
using namespace pcl::io;
using namespace std;

int PCDtoPLYconvertor(string & input_filename ,string& output_filename)
{
  pcl::PCLPointCloud2 cloud;
  if (loadPCDFile(input_filename , cloud) < 0)
  {
  cout << "Error: cannot load the PCD file!!!"<< endl;
  return -1;
  }
  PLYWriter writer;
  writer.write(output_filename, cloud, Eigen::Vector4f::Zero(), Eigen::Quaternionf::Identity(),true,true);
  return 0;

}

int main()
{
  string input_filename = "/home/xxx/下载/1.pcd";
  string output_filename = "1.ply";
  PCDtoPLYconvertor(input_filename , output_filename);
  return 0;
}

结果就将pcd文件转换成ply文件了.


image.png image.png

参考:

  1. https://blog.csdn.net/ye_shen_wei_mian/article/details/50372806

相关文章

网友评论

    本文标题:PCL:将pcd文件转换成ply文件

    本文链接:https://www.haomeiwen.com/subject/jpgnyhtx.html