Liblas环境配置

参考了网上两个比较详细的Liblas配置教程,过程很繁琐,并且还要配置其他的若干个库,自己没成功。现结合自己目前已经配置成功的方法介绍一种非常简单的配置liblas方法。(我所用的IDL为vs2013的x64,前提条件是该工程已经配置了PCL,否则会出错

(1)下载一个文件,下载链接为:https://download.csdn.net/download/qq_32867925/10703993

里面包含了三个文件夹,如下图所示。

(2)配置环境:

任意新建一个工程,右击该工程属性,在配置属性—VC++目录—包含目录下选择include文件夹,如下:(注意在release和debug下均要进行相同的操作,下面也相同,不再强调)

在vc++目录—库目录下选择lib文件所在路径,如下图所示:

在链接器—输入—附加依赖项中输入liblas.lib如下图所示:

右击该工程,选择在文件资源管理器中打开文件夹(X),然后再将bin文件夹下的liblas.dll拷贝到打开的文件即可。

#include <liblas\liblas.hpp>
#include <fstream>
#include <iostream>
#include <string>
#include<iomanip>
using namespace std;

void main(int argc, char *argv[])
{
	std::ifstream ifs;
	ifs.open("D:\\xi_an\\23.las", std::ios::in | std::ios::binary);
	liblas::ReaderFactory f;

	liblas::Reader reader = f.CreateWithStream(ifs);
	liblas::Header const& header = reader.GetHeader();
	int numberOfPoints = header.GetPointRecordsCount();//获取点的个数
	float Xscale = header.GetScaleX();//
	float Yscale = header.GetScaleY();//
	float Zscale = header.GetScaleZ();//
	cout << "Xscale:" << Xscale << endl;
	cout << "Yscale:" << Yscale << endl;
	cout << "Zscale:" << Zscale << endl;
	

	system("pause");
}

将一个las文件转换成另一个las文件:

 

#include <liblas\liblas.hpp>
#include <fstream>
#include <iostream>
#include <string>
#include<iomanip>
using namespace std;

struct point
{
	double x;
	double y;
	double z;
};
std::bitset<8> classname_buidling;
std::bitset<8> classname_ground;;
void initial()
{
	classname_buidling[0] = 0;
	classname_buidling[1] = 1;
	classname_buidling[2] = 1;
	classname_buidling[3] = 0;
	classname_buidling[4] = 0;
	classname_buidling[5] = 0;
	classname_buidling[6] = 0;
	classname_buidling[7] = 0;


	classname_ground[0] = 0;
	classname_ground[1] = 1;
	classname_ground[2] = 0;
	classname_ground[3] = 0;
	classname_ground[4] = 0;
	classname_ground[5] = 0;
	classname_ground[6] = 0;
	classname_ground[7] = 0;
}




void main(int argc, char *argv[])
{
	initial();

	std::ifstream ifs;
	ifs.open("D:\\LDR090818_034423_1.las", std::ios::in | std::ios::binary);
	liblas::ReaderFactory f;

	liblas::Reader reader = f.CreateWithStream(ifs);
	liblas::Header header = reader.GetHeader();
	int numberOfPoints = header.GetPointRecordsCount();//获取点的个数
	cout << "numberOfPoints:" << fixed << numberOfPoints << endl;

	liblas::ReaderFactory readerFactory;
	reader = readerFactory.CreateWithStream(ifs);




	vector<point> building;


	point temp;
	while (reader.ReadNextPoint())
	{
		std::bitset<8> classes = reader.GetPoint().GetClassification().GetClass();
		if (classes == classname_buidling)
		{
			temp.x = reader.GetPoint().GetX();
			temp.y = reader.GetPoint().GetY();
			temp.z = reader.GetPoint().GetZ();
			building.push_back(temp);
		}
	}
	cout << "building.size()=" << building.size() << endl;
	ifs.close();
	//将点写入
	

	/*liblas::Header header_write;
	header_write.SetPointRecordsCount(numberOfPoints);
	liblas::Writer writer(*ofs, header_write);*/
	liblas::Writer writer(ofs, header);
	liblas::Point point(&header);


	for (int i = 0; i < building.size(); i++)
	{
		point.SetX(building[i].x);
		point.SetY(building[i].y);
		point.SetZ(building[i].z);
		point.SetClassification(classname_buidling);
		writer.WritePoint(point);
	}
	cout << "结束" << endl;
	ofs.close();
	system("pause");
}

 

 

评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

点云实验室lab

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值