读取scan001.3d格式数据

读取*.3d格式数据

1、.3d格式数据是机器人常用的数据保存格式,Robotic 3D Scan Repository

2、注意:部分.3d数据,直接将.3d改为.txt可直接打开。

3、针对这样格式的数据,利用C++和pcl编写读取函数,将.3d转为pcl::PointXYZ:

using namespace std;

// 自定义读取函数
void load3DFile(const std::string& filename, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud) {
	std::ifstream infile(filename);
	std::string line;
	while (std::getline(infile, line)) {
		std::istringstream iss(line);
		pcl::PointXYZ point;
		if (!(iss >> point.x >> point.y >> point.z)) {
			break; // Error
		}
		cloud->push_back(point);
	}
}

int main(int argc, char** argv) {

	string filename = "./Robotic 3D Scan Repository/25/wue_city/scan005.3d";

	ofstream fout("scan005.txt");

	std::ifstream infile(filename);
	std::string line;
	while (std::getline(infile, line)) {
		std::istringstream iss(line);
		float x = 0, y = 0, z = 0;
		if (!(iss >> x >> y >> z)) {
			break; // Error
		}
		fout << x << ' ' << y << ' ' << z << endl;
	}
	//pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
	//load3DFile("./Robotic 3D Scan Repository/25/wue_cityscan005.3d", cloud);
	//std::cout << "Loaded " << cloud->points.size() << " points" << std::endl;
	//pcl::visualization::CloudViewer viewer("Cloud Viewer");
	//viewer.showCloud(cloud);
	//while (!viewer.wasStopped()) {
	//}
	//return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值