Win10系统下VisualStudio2019配置LasLib库

一、下载链接

LAStools官网
Github

二、源码编译

LASlib/LAStools:Win10 + VS2017 编译LASlib/LAStools

三、配置LASlib

1、将编译成功的laslib随便放一个盘里
在这里插入图片描述
2、打开属性页,VC++目录——包含目录——添加laslib的include路径

D:\PCL 1.11.1\Laslib\include

在这里插入图片描述
3、库目录中添加laslib的lib路径,
debug版本:

D:\PCL 1.11.1\Laslib\lib\debug

release版本:

D:\PCL 1.11.1\Laslib\lib\release

在这里插入图片描述
4、链接器——输入——附加依赖项
debug版本添加

LASlibD.lib

release版本添加

LASlib.lib

在这里插入图片描述

四、测试代码

#include <iostream>
#include <lasreader.hpp>
// PCL
#include <pcl/io/pcd_io.h>  
#include <pcl/point_types.h>  
#include <boost/thread/thread.hpp>
#include <pcl/visualization/pcl_visualizer.h>

using namespace std;

int main(int argc, char* argv[])
{
	LASreadOpener lasreadopener;
	LASreader* lasreader = lasreadopener.open(false, "test.las");// 第一个参数为是否只读取las头文件里的信息

	if (lasreader == 0)
	{
		fprintf(stderr, "ERROR: could not open lasreader\n");
	}

	printf("reading %I64d points from '%s'.\n", lasreader->npoints, lasreadopener.get_file_name());

	double xOffset = lasreader->header.x_offset;                // X方向的偏移量
	double yOffset = lasreader->header.y_offset;                // Y方向的偏移量
	double zOffset = lasreader->header.z_offset;                // Z方向的偏移量

	cout << "X方向的偏移量为:" << xOffset << "Y方向的偏移量为:" << yOffset << "Z方向的偏移量为:" << zOffset << endl;

	int pointAmount = lasreader->npoints;
	// ----------------------------使用PCL获取xyz坐标--------------------------------
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
	cloud->width = pointAmount;
	cloud->height = 1;
	cloud->resize(lasreader->npoints);
	cloud->is_dense = false;
	size_t i = 0;
	while (lasreader->read_point() && i < pointAmount)
	{
		// 与CloudCompare中减去偏移量操作对应
		cloud->points[i].x = lasreader->point.get_x() - xOffset;      // 获取X坐标
		cloud->points[i].y = lasreader->point.get_y() - yOffset;      // 获取Y坐标
		cloud->points[i].z = lasreader->point.get_z() - zOffset;      // 获取Z坐标

		++i;
	}
	lasreader->close();
	delete lasreader;
	lasreader = nullptr;
	// --------------------------使用PCL进行简单的可视化------------------------------
	boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));
	viewer->setBackgroundColor(0, 0, 0);
	viewer->setWindowName("LasLib读点云PCL可视化");

	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> single_color(cloud, 0, 255, 0);

	viewer->addPointCloud<pcl::PointXYZ>(cloud, single_color, "sample cloud");
	viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");

	while (!viewer->wasStopped())
	{
		viewer->spinOnce(100);
		boost::this_thread::sleep(boost::posix_time::microseconds(100000));
	}

	return 0;
}

五、测试结果

在这里插入图片描述

六、参考链接

[1] LASlib / LAStools
[2] LASlib库将PCL库点云类型数据转换为las格式保存
[3] .las数据转.pcd并显示
[4] 孙爱怡,王健.LAS格式的解析与转换[J].全球定位系统,2016,41(02):115-117+124.

  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 21
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

点云侠

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

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

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

打赏作者

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

抵扣说明:

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

余额充值