To convert PCD files into ply files in PCL __PCL

Source: Internet
Author: User

Reprint please indicate the source: Http://my.csdn.net/ye_shen_wei_mian

The commonly used point cloud in PCL stores files as. pcd files, but the point cloud used in many situations is a. ply file, especially when viewed in MeshLab.

A corresponding class Plywriter in PCL can help us implement conversions from. pcd files to. ply files. It is worth mentioning that in the PCL source Pcl-master in the Tools folder there are many examples of routines that can help us to realize many simple but basic functions. Among them, Pcd2ply.cpp is a CPP file that instructs us to convert from. pcd files to. ply files.

The following small procedure is written in accordance with the above guidance document. It is noteworthy that the following PCLPOINTCLOUD2 classes will not apply to the pcl-1.6.0 version of the PCL official web site because pcl-1.6.0 is too old to implement this class. The solution is to use the newer version of pcl-1.7.2, so that's it.

#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::P CLPOINTCLOUD2 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 = ".//source//cloud_pcd.pcd";
String output_filename = ".//result//cloud_ply.ply";
Pcdtoplyconvertor (Input_filename, output_filename);
return 0;
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.