?
main.cc
#include <iostream>
#include <vector>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <boost/thread/thread.hpp>
int main(int argc, char** argv)
{
if (argc <= 1) {
std::cout << "please input pcd file path, for example, run ./pcl_read_pcd_by_reader /home/test.pcd" << std::endl;
return 0;
}
std::string pcd_path = argv[1];
pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>); // Generate pointcloud data,新建指针cloud存放点云
pcl::PCDReader reader;
reader.read<pcl::PointXYZI>(pcd_path, *cloud);//读取pcd文件,用指针传递给cloud。
//可视化 方法一
pcl::visualization::CloudViewer viewer1("Cloud Viewer");
viewer1.showCloud(cloud);
while(!viewer1.wasStopped());
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(pcl_read_pcd_by_reader)
find_package(PCL 1.2 REQUIRED)
# 加入Boost setting
find_package(Boost COMPONENTS program_options REQUIRED )
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(${PROJECT_NAME} main.cc)
target_link_libraries (${PROJECT_NAME} ${PCL_LIBRARIES} ${Boost_LIBRARIES})
|