las转pcd格式编译不通过的问题(7月24号未解决)

91 篇文章 103 订阅

las2pcd.cpp如下: 

#include <iostream>
#include <cstdlib>
#include <liblas/liblas.hpp>//liblas tou wen jin
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

#include <liblas/reader.hpp>
#include <liblas/factory.hpp>
#include <liblas/detail/fwd.hpp>
#include <liblas/point.hpp>

using namespace std;

int main (int argc, char** argv)
{
    std::ifstream ifs(argv[1], std::ios::in | std::ios::binary); // 打开las文件
    liblas::ReaderFactory f;
    liblas::Reader reader = f.CreateWithStream(ifs); // 读取las文件

	unsigned long int nbPoints=reader.GetHeader().GetPointRecordsCount();//获取las数据点的个数

	pcl::PointCloud<pcl::PointXYZRGB> cloud;
	cloud.width    = nbPoints;	//保证与las数据点的个数一致	
	cloud.height   = 1;			
	cloud.is_dense = false;
	cloud.points.resize (cloud.width * cloud.height);

	int i=0;				
	uint16_t r1, g1, b1;	
	int r2, g2, b2;			
	uint32_t rgb;			

	while(reader.ReadNextPoint()) 
	{
		// 获取las数据的x,y,z信息
		cloud.points[i].x = (reader.GetPoint().GetX());
	    cloud.points[i].y = (reader.GetPoint().GetY());
	    cloud.points[i].z = (reader.GetPoint().GetZ());
		
		//获取las数据的r,g,b信息
		r1 = (reader.GetPoint().GetColor().GetRed());
		g1 = (reader.GetPoint().GetColor().GetGreen());
		b1 = (reader.GetPoint().GetColor().GetBlue()); 
		r2 = ceil(((float)r1/65536)*(float)256);
		g2 = ceil(((float)g1/65536)*(float)256);
		b2 = ceil(((float)b1/65536)*(float)256);
		rgb = ((int)r2) << 16 | ((int)g2) << 8 | ((int)b2);
		cloud.points[i].rgb = *reinterpret_cast<float*>(&rgb);
					
		i++; 
	}
  
	pcl::io::savePCDFileASCII ("pointcloud.pcd", cloud);//存储为pcd类型文件
	return (0);
}

CMakeLists.txt如下: 

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(las2pcd)
find_package(PCL 1.7 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/libLAS/include")

link_directories(${PCL_LIBRARY_DIRS})
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/libLAS/lib")
add_definitions(${PCL_DEFINITIONS})
		
add_executable (las2pcd las2pcd.cpp)
target_link_libraries (las2pcd ${PCL_LIBRARIES})

target_link_libraries (las2pcd "${CMAKE_CURRENT_SOURCE_DIR}/libLAS/lib/liblas.lib" )
target_link_libraries (las2pcd "${CMAKE_CURRENT_SOURCE_DIR}/libLAS/lib/liblas_c.lib" )


set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(DLL_LIBLAS "${CMAKE_CURRENT_SOURCE_DIR}/libLAS/dll/liblas.dll" "${CMAKE_CURRENT_SOURCE_DIR}/libLAS/dll/gdal111.dll" "${CMAKE_CURRENT_SOURCE_DIR}/libLAS/dll/geotiff.dll" "${CMAKE_CURRENT_SOURCE_DIR}/libLAS/dll/libtiff.dll")

file(COPY ${DLL_LIBLAS} DESTINATION ${EXECUTABLE_OUTPUT_PATH}/release)
file(COPY ${DLL_LIBLAS} DESTINATION ${EXECUTABLE_OUTPUT_PATH}/debug)

错误如下:

[ 50%] Building CXX object CMakeFiles/las2pcd.dir/las2pcd.cpp.o
[100%] Linking CXX executable ../bin/las2pcd
CMakeFiles/las2pcd.dir/las2pcd.cpp.o:在函数‘main’中:
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:19:对‘liblas::ReaderFactory::CreateWithStream(std::istream&)’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:21:对‘liblas::Reader::GetHeader() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:21:对‘liblas::Header::GetPointRecordsCount() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:34:对‘liblas::Reader::ReadNextPoint()’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:37:对‘liblas::Reader::GetPoint() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:37:对‘liblas::Point::GetX() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:38:对‘liblas::Reader::GetPoint() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:38:对‘liblas::Point::GetY() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:39:对‘liblas::Reader::GetPoint() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:39:对‘liblas::Point::GetZ() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:42:对‘liblas::Reader::GetPoint() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:42:对‘liblas::Point::GetColor() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:43:对‘liblas::Reader::GetPoint() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:43:对‘liblas::Point::GetColor() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:44:对‘liblas::Reader::GetPoint() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:44:对‘liblas::Point::GetColor() const’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:19:对‘liblas::Reader::~Reader()’未定义的引用
/home/s/pcl_study/chapter3/5/source/las2pcd.cpp:19:对‘liblas::Reader::~Reader()’未定义的引用
collect2: error: ld returned 1 exit status
CMakeFiles/las2pcd.dir/build.make:357: recipe for target '../bin/las2pcd' failed
make[3]: *** [../bin/las2pcd] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/las2pcd.dir/all' failed
make[2]: *** [CMakeFiles/las2pcd.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/las2pcd.dir/rule' failed
make[1]: *** [CMakeFiles/las2pcd.dir/rule] Error 2
Makefile:118: recipe for target 'las2pcd' failed
make: *** [las2pcd] Error 2

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Tech沉思录

点赞加投币,感谢您的资瓷~

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

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

打赏作者

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

抵扣说明:

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

余额充值