一、代码
本文点云文件的转换只针对点云的顶点信息,它们之间的相互转换关系一共12种。这份代码没有用PCL,不需要配置PCL环境也可以使用
C++
pointTypeTrans.h
#ifndef POINTTYPETRANS_H
#define POINTTYPETRANS_H
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
struct Vertex {
float x, y, z;
};
class PointTypeTrans
{
public:
PointTypeTrans();
void writePLYHeader(std::ofstream& ply_file, int num_points);
void writePCDHeader(std::ofstream& pcdFile, int vertexCount);
int txtToPly(const std::string txt_filename, const std::string ply_filename);
int plyTotxt(const std::string ply_filename, const std::string txt_filename);
int txtToPcd(const std::string txt_filename, const std::string pcd_filename);
int pcdTotxt(const std::string pcd_filename, const std::string txt_filename);
int txtToObj(const std::string txt_filename, const std::string obj_filename);
int objTotxt(const std::string