data-structures - PCL 库,如何访问有组织的点云?

标签 data-structures point-cloud-library

我有一个非常简单的问题:

我有一个 organized点云存储在 pcl::PointCloud<pcl::PointXYZ>数据结构。

如果我没有弄错,有组织的点云应该存储在类似矩阵的结构中。

所以,我的问题是:有没有办法用行和列索引访问这个结构?而不是以通常的方式访问它,即作为线性数组。

举个例子:

//data structure
pcl::PointCloud<pcl::PointXYZ> cloud;

//linearized access
cloud[j + cols*i] = ....

//matrix-like access
cloud.at(i,j) = ...

谢谢。

最佳答案

您可以通过 () operator 访问积分

    //creating the cloud
    PointCloud<PointXYZ> organizedCloud;
    organizedCloud.width = 2;
    organizedCloud.height = 3;
    organizedCloud.is_dense = false;
    organizedCloud.points.resize(organizedCloud.height*organizedCloud.width);

    //setting random values
for(std::size_t i=0; i<organizedCloud.height; i++){
        for(std::size_t j=0; j<organizedCloud.width; j++){
            organizedCloud.at(i,j).x = 1024*rand() / (RAND_MAX + 1.0f);
            organizedCloud.at(i,j).y = 1024*rand() / (RAND_MAX + 1.0f);
            organizedCloud.at(i,j).z = 1024*rand() / (RAND_MAX + 1.0f);
        }
    }

    //display
    std::cout << "Organized Cloud" <<std:: endl; 

    for(std::size_t i=0; i<organizedCloud.height; i++){
        for(std::size_t j=0; j<organizedCloud.width; j++){
           std::cout << organizedCloud.at(i,j).x << organizedCloud.at(i,j).y  <<  organizedCloud.at(i,j).z << " - "; }
          std::cout << std::endl;
      }

关于data-structures - PCL 库,如何访问有组织的点云?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50907298/

相关文章:

c++ - 我应该使用冒泡排序、插入排序等排序算法,还是应该使用 C++ 中内置的 sort() 函数对数组进行排序?

sql-server - SQL Server 优先级排序

c++ - 如何评估任何给定的表达式

c++ - 点云文件格式 (PCL)

c++ - PCL : Visualize a point cloud

c++ - 使用点云库 (PCL) 时的 Boost 问题

algorithm - 范围查询如何与排序字符串表一起使用?

java - 选择正确的数据结构

c++ - 使用 pcl 1.6 将 pcloudXYZ 转换为 pcloudXYZRGB

c++ - 从 pcl::PointCloud<pcl::PointXYZRGB> 中删除点