当前位置: 首页 > article >正文

【Range Image】 创建Range Image

1 介绍

范围图像是一种将点云数据转换为二维图像的表示形式。它将点云中的每个点映射到图像中的像素,每个像素表示了点在三维空间中的距离信息。范围图像的每个像素包含了点的深度信息,可以用来表示物体的形状和几何结构。范围图像通常用于进行深度感知和三维重建等任务。

范围图像在PCL中使用 pcl::RangeImage 类型表示,它包含了范围图像的像素数据以及相关的参数和方法。范围图像可以从点云数据中创建,并可以通过可视化工具进行可视化。

2 创建Range Image代码

#include <pcl/range_image/range_image.h>

#include <pcl/visualization/pcl_visualizer.h>

int main ()
{
    pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloud(new pcl::PointCloud<pcl::PointXYZ>);

// 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::visualization::PCLVisualizer vis("cloud vis");
    pcl::visualization::PointCloudColorHandlerCustom<pcl::PointWithRange> color_handler(rangeImage.makeShared(), 255, 255 ,255);
    vis.addPointCloud<pcl::PointWithRange>(rangeImage.makeShared(), color_handler, "range_image");
    vis.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4, "range_image");
    vis.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_REPRESENTATION, pcl::visualization::PCL_VISUALIZER_REPRESENTATION_SURFACE, "range_image");

    while(!vis.wasStopped())
    {
        vis.spinOnce();
    }
}


http://www.kler.cn/a/144450.html

相关文章:

  • 05_使用API_Arrays与Lambda
  • 发送一个网络数据包的过程解析
  • Unity中Shader的Standard材质解析(一)
  • 开发者的 Debian 12 KDE 配置优化指南
  • 聚类笔记:HDBSCAN
  • 【ARM CoreLink 系列 3.1 -- CCI-500 详细介绍 -上半部】
  • 从裸机启动开始运行一个C++程序(十三)
  • 【自主探索】基于 rrt_exploration 的单个机器人自主探索建图
  • 【人生苦短,我学 Python】(2)Python 语言基础
  • 0003Java程序设计-ssm基于微信小程序的家教信息管理系统
  • 【洛谷 P1636】Einstein学画画 题解(图论+欧拉通路)
  • STM32通用定时器产生PWM信号
  • Oracle SQL 注入上的 Django GIS 函数和聚合漏洞 (CVE-2020-9402)
  • ElasticSearch查询语法及深度分页问题
  • C语言指针
  • C++类与对象(6)—初始化列表、explicit关键字、static成员
  • 日历视图,轻松解决时间管理难题丨三叠云
  • A. Weird Sum - 思维
  • 【AI认证笔记】NO.2人工智能的发展
  • 字符串函数