main.cpp
#include<iostream>
#include<pcl/io/pcd_io.h>
#include<pcl/point_types.h>
int main(int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ> cloud;
cloud.width =5;
cloud.height=1;
cloud.is_dense=false;
cloud.points.resize(cloud.width*cloud.height);
for(size_t i=0; i<cloud.points.size(); ++i)
{
cloud.points[i].x=1024*rand()/(RAND_MAX + 1.0f);
cloud.points[i].y=1024*rand()/(RAND_MAX + 1.0f);
cloud.points[i].z=1024*rand()/(RAND_MAX + 1.0f);
}
pcl::io::savePCDFileASCII("test_pcd.pcd", cloud);
std::cerr<<"Saved"<<cloud.points.size()<<"data points to test_pcd.pcd"<<std::endl;
for(size_t i=0; i<cloud.points.size(); ++i)
{
std::cerr<<" "<<cloud.points[i].x<<" "<<cloud.points[i].y<<' '<<cloud.points[i].z<<std::endl;
}
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
project(pcd_write)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_library(pcl01 src/pcl01.cpp)
add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES})
网友评论