3d激光雷达开发(pcd数据读取)

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】

        之前谈到了,如果从lidar获取数据,那么需要保存成pcd的形式。这个在https://feixiaoxing.blog.csdn.net/article/details/123292126里面谈到过。那么如何从pcd加载数据,其实方法也是一样的。相关内容可以参考这个链接

https://pcl.readthedocs.io/projects/tutorials/en/master/reading_pcd.html#reading-pcd

1、编写pcd_read.cpp文件

 #include <iostream>
 #include <pcl/io/pcd_io.h>
 #include <pcl/point_types.h>
 
 int
 main ()
 {
   pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
 
  if (pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud) == -1) //* load the file
  {
    PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
    return (-1);
  }
  std::cout << "Loaded "
            << cloud->width * cloud->height
            << " data points from test_pcd.pcd with the following fields: "
            << std::endl;
  for (const auto& point: *cloud)
    std::cout << "    " << point.x
              << " "    << point.y
              << " "    << point.z << std::endl;

  return (0);
}

2、编写CMakeLists.txt

 cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
 
 project(pcd_read)
 
 find_package(PCL 1.2 REQUIRED)
 
 include_directories(${PCL_INCLUDE_DIRS})
 link_directories(${PCL_LIBRARY_DIRS})
 add_definitions(${PCL_DEFINITIONS})

add_executable (pcd_read pcd_read.cpp)
target_link_libraries (pcd_read ${PCL_LIBRARIES})

3、准备生成sln文件

mkdir build
cd build
cmake ..

        不出意外,应该可以正常编译通过

4、运行pcd_read.exe

        在运行前,有两个事情需要注意一下:第一,保证exe需要的dll都已经拷贝到当前目录下面;第二,保证test_pcd.pcd文件已经准备好。如果一切ok,就会得到下面这些输出,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌入式-老费

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值