美文网首页
2018-01-01:Writing Point Cloud d

2018-01-01:Writing Point Cloud d

作者: ShapeYourself | 来源:发表于2018-01-01 22:48 被阅读0次

    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})
    

    相关文章

      网友评论

          本文标题:2018-01-01:Writing Point Cloud d

          本文链接:https://www.haomeiwen.com/subject/udyxnxtx.html