3d激光雷达开发(生成RangeImage)

本文档介绍了如何使用PCL库创建RangeImage,即深度图。通过一个简单的C++示例,展示了如何从点云数据生成RangeImage,并调整参数如角度分辨率、最大角度宽度等。最后,利用PCL的可视化工具展示RangeImage。学习此教程有助于理解PCL中处理深度信息的方法。
摘要由CSDN通过智能技术生成

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

        RangeImage,这个英文单词不太好翻译,姑且称之为深度图。因为点云数据中,每一个点其实都是有深度信息的。想象一下,如果把点云数据转换成一幅图片的话,那么图片中每个像素的数值就是这个深度信息。那RangeImage就是根据这个生成的。不仅于此,用户可以自己调节距离、视场角,生成不同的深度图。文中代码的出处在这里,https://pcl.readthedocs.io/projects/tutorials/en/latest/range_image_creation.html#range-image-creation。

1、准备range_image_creation.cpp文件

#include <pcl/range_image/range_image.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/visualization/range_image_visualizer.h>


int main () {
  pcl::PointCloud<pcl::PointXYZ> pointCloud;
  
  // Generate the data
  for (float y=-0.5f; y<=0.5f; y+=0.01f) {
    for (float z=-0.5f; z<=0.5f; z+=0.01f) {
      pcl::PointXYZ point;
      point.x = 2.0f - y;
      point.y = y;
      point.z = z;
      pointCloud.push_back(point);
    }
  }
  pointCloud.width = pointCloud.size();
  pointCloud.height = 1;
  
  // We now want to create a range image from the above point cloud, with a 1deg angular resolution
  float angularResolution = (float) (  1.0f * (M_PI/180.0f));  //   1.0 degree in radians
  float maxAngleWidth     = (float) (360.0f * (M_PI/180.0f));  // 360.0 degree in radians
  float maxAngleHeight    = (float) (180.0f * (M_PI/180.0f));  // 180.0 degree in radians
  Eigen::Affine3f sensorPose = (Eigen::Affine3f)Eigen::Translation3f(0.0f, 0.0f, 0.0f);
  pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME;
  float noiseLevel=0.00;
  float minRange = 0.0f;
  int borderSize = 1;
  
  pcl::RangeImage rangeImage;
  rangeImage.createFromPointCloud(pointCloud, angularResolution, maxAngleWidth, maxAngleHeight,
                                  sensorPose, coordinate_frame, noiseLevel, minRange, borderSize);
  
  std::cout << rangeImage << "\n";

  //pcl::RangeImage rangeImage;
  pcl::visualization::RangeImageVisualizer range_image_widget("Range image");
  range_image_widget.showRangeImage(rangeImage);

  while (!range_image_widget.wasStopped())
  {
	  range_image_widget.spinOnce();

  }
}

2、创建CMakeLists.txt

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)

project(range_image_creation)

find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

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

3、创建sln工程,准备编译

4、执行range_image_creation.exe文件 

        和以前一样,有一串信息打印,

        除此之外,还有一个小型的彩色窗口,

 

        因为像素实在太少,所以只能有这么多的点显示。图形中的内容就是所谓的RangeImage。在这过程中,需要关注的主要是一些配置的参数,要弄清楚这些参数的意义,这是比较重要的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

嵌入式-老费

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

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

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

打赏作者

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

抵扣说明:

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

余额充值