3d 可视化百度Apollo的数据开放平台中的激光点云障碍物检测分类数据

百度数据介绍页面:

http://data.apollo.auto/help?name=data_intro_3d&data_key=lidar_obstacle_label&data_type=0&locale=zh-cn&lang=zh

代码:

https://github.com/sofiathefirst/imagesCpp/tree/master/02pcl


#include   
#include 
//#include 
//#include 
//#include 
#include 
#include 

#include 
pcl::PointCloud boxcloud; 
pcl::PointXYZ pint;
int main(int argc, char** argv) 
{  
    //pcl::PointXYZ pint(1,2,3);
    FILE *f = fopen("002_00000000.bin","rb");
    float fa[4]={0};
    //unsigned char pos[16];
    //fread(pos,1,11840,f);//1180 char
    fseek (f , 0 , SEEK_END);       
    int lSize = ftell (f);  
    rewind (f); 
    //printf("\nfirst 40 bytes:  " );
    int ll =lSize; //atoi(argv[1]);
    for(int i = 0; i < ll; i+=16)
    {
        fread(fa,4,4,f);// 4 floats 
        // memcpy(fa,&pos[0],16);
        if(fa[3]>0 && fa[3]<=255)
        {
            pcl::PointXYZ pint(fa[0],fa[1],fa[2]);
            boxcloud.points.push_back(pint);
        }
       // printf("\n  i%d %f,%f,%f,%f\n  ",i, fa[0],fa[1],fa[2],fa[3] );
    }

    boxcloud.width = boxcloud.points.size();
    boxcloud.height =1;

    //sensor_msgs::PointCloud2 rosboxcloud;
    //pcl::toROSMsg (boxcloud, rosboxcloud);
    //boxpclpub.publish(rosboxcloud);
    pcl::io::savePCDFileASCII ("mbox.pcd", boxcloud);
    printf("\nsize : %d \n", lSize);
    return 0;  
} 

CMakeLists.txt

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(MY_GRAND_PROJECT)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test apolo_pcl.cpp)
target_link_libraries(pcd_write_test ${PCL_LIBRARIES})

3d 可视化百度Apollo的数据开放平台中的激光点云障碍物检测分类数据_第1张图片

你可能感兴趣的:(无人驾驶)