1.las文件查看
下载cloudcompare
sudo snap install cloudcompare
打开cloudcompare图像查看窗口
cloudcompare.ccViewer
打开cloudcompar软件
cloudcompare.CloudCompare
2.liblas安装
下载liblas软件源码:https://liblas.org/download.html
cd liblas
mkdir build
cd build
cmake -G "Unix Makefiles" ../
make
sudo make install
查看安装是否完成,查看一个las文件的相关信息
lasinfo ***.las
3.las转pcd代码
las2pcd.cpp
#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>
using namespace std;
int main()
{
clock_t sT, tT,eT;
std::ifstream fp;
fp.open("../input.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();
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("../output.pcd",cloudOutput);
cloudOutput.clear();
eT = clock();
cout << "存入" << reader.GetHeader().GetPointRecordsCount() << "个点花费" << (double)(eT - tT) / CLOCKS_PER_SEC << "s" << endl;
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(main)
find_package(PCL 1.2 REQUIRED)
find_package(libLAS REQUIRED)
message("include: "${libLAS_INCLUDE_DIRS})
message("libraries: "${libLAS_LIBRARIES})
include_directories(${PCL_INCLUDE_DIRS} ${libLAS_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
find_package(Boost REQUIRED COMPONENTS serialization system filesystem program_options thread)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
add_definitions(-DBOOST_ALL_DYN_LINK)
endif()
add_executable(main main.cpp)
target_link_libraries (main ${PCL_LIBRARIES} ${libLAS_LIBRARIES} ${Boost_LIBRARIES} -lpthread -lm)
install(TARGETS main RUNTIME DESTINATION bin)