las格式转pcd

在配置好liblas库之后实现了las与pcd格式的转换。在代码中顺便测试了一下转换的速度。

主要代码如下:

#include <liblas\liblas.hpp>
#include <fstream>
#include <iostream>
#include <string>
#include<vector>
#include<pcl\io\pcd_io.h>
#include<pcl\point_types.h>
#include<time.h>
int main()
{
	clock_t sT, tT,eT;
	//打开文件
	ifstream fp;
	fp.open("1.las",ios::in|ios::binary);
	sT = clock();
	//读取
	liblas::ReaderFactory readerFactory;
	liblas::Reader reader = readerFactory.CreateWithStream(fp);
	tT = clock();
	cout << "读取" << reader.GetHeader().GetPointRecordsCount() <<"个点花费"<<(double)(tT-sT)/CLOCKS_PER_SEC<<"s"<<endl;
	//点云类型
	pcl::PointCloud<pcl::PointXYZ> cloudOutput;
	cloudOutput.clear();
	//转换xyz
	while (reader.ReadNextPoint())
	{
		double x = reader.GetPoint().GetX();
		double y = reader.GetPoint().GetY();
		double z = reader.GetPoint().GetZ();
		pcl::PointXYZ thePt(x,y,z);
		cloudOutput.push_back(thePt);
	}
	cloudOutput.width = cloudOutput.size();
	cloudOutput.height = 1;
	cloudOutput.is_dense = false;
	cloudOutput.resize(cloudOutput.width*cloudOutput.height);
	pcl::io::savePCDFileASCII("1.pcd",cloudOutput);
	cloudOutput.clear();
	eT = clock();
	cout << "存入" << reader.GetHeader().GetPointRecordsCount() << "个点花费" << (double)(eT - tT) / CLOCKS_PER_SEC << "s" << endl;
	return 0;
}

测试结果:

速度很慢。。,但是终究实现了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值