pcl中文件的轉化

1、pcl中pcd文件轉換成ply文件

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

}

2、pcl中ply文件轉換爲vtk文件

typedef pcl::PointXYZRGB PointT;
typedef pcl::PointCloud<PointT> PointCloudT;

int ply2vtk(std::string polyFileName = "./plyFileName.ply",std::string vtkFileName = "./vtkFileName.vtk")
{
    PointCloudT::Ptr pc(new PointCloudT);
    if (pcl::io::loadPLYFile(plyFileName, *pc) == -1) {
        PCL_ERROR("Error reading point cloud %s\n", filename.c_str());
        return -1;
    }
    pcl::PCLPointCloud2 cloud2;
    pcl::toPCLPointCloud2(*pc, cloud2);
    pcl::io::saveVTKFile(vtkFileName, cloud2);
    
    return 0;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章