PCL學習筆記——讀入txt格式點雲資料,寫入到PCD檔案中
阿新 • • 發佈:2018-11-11
讀入txt格式點雲資料,寫入PCD檔案中
// An highlighted block
// pointclouds_octree.cpp: 定義控制檯應用程式的入口點。
//
#include "stdafx.h"
#include<iostream>
#include<fstream>
#include<opencv.hpp>
#include<pcl/io/pcd_io.h>
#include<pcl/point_types.h>
using namespace std;
using namespace cv;
int main ()
{
fstream file_name1, file_name2;
file_name1.open("Result3D_end42.txt");
file_name2.open("Result3D_end52.txt");
pcl::PointCloud<pcl::PointXYZ> cloudA;
pcl::PointCloud<pcl::PointXYZ> cloudB;
cloudA.width = 230088;
cloudA.height = 1;
cloudA.is_dense = false;
cloudA.points.resize (cloudA.width*cloudA.height);
cloudB.width = 250025;
cloudB.height = 1;
cloudB.is_dense = false; //點雲密度,非密集型
cloudB.points.resize (cloudB.width*cloudB.height);
Vec3d dd;
for (size_t i = 0; i < cloudA.points.size(); i++) {
file_name1 >> dd[0];
file_name1 >> dd[1];
file_name1 >> dd[2];
cloudA.points[i].x = dd[0];
cloudA.points[i].y = dd[1];
cloudA.points[i].z = dd[2];
}
for (size_t j = 0; j < cloudB.points.size(); j++) {
file_name2 >> dd[0];
file_name2 >> dd[1];
file_name2 >> dd[2];
cloudB.points[j].x = dd[0];
cloudB.points[j].y = dd[1];
cloudB.points[j].z = dd[2];
}
pcl::io::savePCDFileASCII("pointA.pcd", cloudA);
pcl::io::savePCDFileASCII("pointB.pcd", cloudB);
return 0;
}