当前位置: 移动技术网 > 移动技术>移动开发>IOS > 用C++读pcd文件

用C++读pcd文件

2020年09月20日  | 移动技术网移动技术  | 我要评论
好久没有练过读文件的操作了,正好看到点云库里的pcd文件,试着把pcd文件点的个数给读出来。pcd文件:来源最经典的斯坦福兔子#include<iostream>#include<fstream>#include<vector>#include<string>using namespace std;int main() {ifstream ifs("bunny.pcd",ios::in);char s1[11][1024];//用来记录

好久没有练过读文件的操作了,正好看到点云库里的pcd文件,试着把pcd文件点的个数给读出来。
pcd文件:来源最经典的斯坦福兔子

#include<iostream>
#include<fstream>
#include<vector>
#include<string>
using namespace std;
int main() {

	ifstream ifs("bunny.pcd",ios::in);
	char s1[11][1024];//用来记录pcd文件前面的信息
	for (int i = 0; i < 11; i++)//pcd文件前11行都是描述信息的语句,获取点的数量
	{
		ifs.getline(s1[i], 1024);//按行读取
		if (i == 9)
		{
			string s3 = s1[9];
			int pose = s3.find("POINTS");
			int size = s3.size();
			string s4 = s3.substr(pose + 7, size);
			int point_num = atoi(s4.c_str());//c_str()将string转换为char,atoi是将char转化为int数字
			cout << "一共有" << point_num << "个点" << endl;
		}


	}


	system("pause");
	return 0;
}

本文地址:https://blog.csdn.net/code_leader/article/details/108693219

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网