【问题标题】:PCL library, how to access to organized point clouds?PCL 库,如何访问有组织的点云?
【发布时间】:2018-11-27 04:07:08
【问题描述】:

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

我有一个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) = ...

谢谢。

【问题讨论】:

  • cloud.at(column, row) 应该对你有用。你遇到过任何问题吗?您确定您的云是有序的 (cloud.isOrganized())?

标签: data-structures point-cloud-library


【解决方案1】:

您可以通过() 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;
      }

【讨论】:

  • 感谢您的回复,正是我想要的。但是函数签名是const PointT &amp; at (int column, int row) const,所以我认为应该切换 i 和 j,即在您的示例中应该是 organizedCloud.at( j, i )。至少在我的测试中它是这样工作的......
【解决方案2】:

要访问这些点,请执行以下操作:

// create the cloud as a pointer
pcl::PointCloud<pcl::PointXYZ> cloud(new pcl::PointCloud<pcl::PointXYZ>);

i成为你要访问的元素编号

cloud-&gt;points[i].x 会给你 x 坐标。

同样,cloud-&gt;points[i].ycloud-&gt;points[i].z 会为您提供 y 和 z 坐标。

【讨论】:

  • 这并不特定于有组织的点云。问题是关于有组织的云及其矩阵状结构。
猜你喜欢
  • 2023-01-18
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 2019-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-28
相关资源
最近更新 更多