C++:文件读写
將txt格式的點(diǎn)云數(shù)據(jù)x y z 中間以空格的形式隔開,改寫為x,y,z中間以,(逗號(hào))的形式隔開。
思想是:先將其讀取出來,再將其增加逗號(hào)分隔符將其寫進(jìn)另外一個(gè)文件里邊。
代碼如下:
點(diǎn)云數(shù)據(jù)txt轉(zhuǎn)pcd格式
#include<iostream>
#include<fstream>
#include <string>
#include <vector>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>using namespace std;
//定義3D點(diǎn)的結(jié)構(gòu)體
struct Point3D
{float x;float y;float z;
};/*----------------------------
* 功能 : 讀取一個(gè)txt中的數(shù)據(jù),將數(shù)據(jù)放入vector中
*----------------------------
* 函數(shù) : ReadData
* 參數(shù) : str [in] 需要讀的txt文件名
* 參數(shù) : Data [in] 讀取xt文件數(shù)據(jù)存放在Data中
*/
int ReadData(const char* str, std::vector<Point3D>* Data)
{FILE *fp_txt;Point3D txtPoint;vector<Point3D> txtPoints;fp_txt = fopen(s
總結(jié)
- 上一篇: 点云第一期作业习题
- 下一篇: C++:名字空间的使用