点云学习笔记之三(未整理版)

txt格式为 x y z(中间含有空格)
-154.881 76.365 -3.768
-154.906 76.386 -3.860
-154.804 76.427 -3.861

txt转换pcd:
// 将txt文件转换为pcd文件
#if 1
#include
#include
#include
#include
#include
#include

using namespace std;

int main()
{
fstream fsread;
pcl::PointCloudpcl::PointXYZ cloud;
pcl::PCDWriter writer;

fsread.open("C:\\Users\\86182\\Desktop\\aaa.txt");
pcl::PointXYZ pclPnt;
while (!fsread.eof())
{
    fsread >> pclPnt.x >> pclPnt.y >> pclPnt.z;
    cloud.push_back(pclPnt);
}
fsread.close();
writer.write("C:\\Users\\86182\\Desktop\\aaalidar.pcd", cloud);
return 0;

}

#endif

转换成功格式:

.PCD v0.7 - Point Cloud Data file format

VERSION 0.7
FIELDS x y z
SIZE 4

你可能感兴趣的:(点云,PCL,c++)