【问题标题】:Matching Pixel data and Point Cloud匹配像素数据和点云
【发布时间】:2019-09-22 17:24:12
【问题描述】:

我必须将点云数据从一维组织到二维。 我已经有一个一维点云数据,它只保存强度为 255 的像素(称为有效像素)的数据。 所以我必须根据图像来组织点云。 我在访问 2D 点云时遇到问题。我不知道该怎么做。

// Here the data from in_ThreeD_cloud which is of type tDistanceData is converted to tVec3f
const rrlib::math::tVec3f *points = reinterpret_cast<const rrlib::math::tVec3f*>(in_ThreeD_cloud->DataPtr());

int num_valid_points = 0;

// An object to class PointCloud is created
pcl::PointCloud<pcl::PointXYZI> cloud; 

// Image data from the camera is accessed as Matrix
cv::Mat image  = rrlib::coviroa::AccessImageAsMat(in_img->at(0));

// Dimensions of the point cloud is sent as parameters to overloaded constuctor
cloud(image.cols, image.rows); 

// The point cloud is expected to store the vector3f data in a 2D format
for(int i = 0; i <= image.rows; ++i)
for(int j = 0; j <= image.cols; ++j)
{
     if( image.at<uchar>(i,j) == 255)
     {
       // Error shown here
       cloud.points[i][j].getVector3fMap() = &points[num_valid_points];
       num_valid_points++;

      }


}

显示的错误是: 错误:“operator[]”不匹配(操作数类型为“__gnu_cxx::__alloc_traits >::value_type {aka pcl::PointXYZI}”和“int”)

【问题讨论】:

  • “in_ThreeD_cloud”是有组织的云吗?在stackoverflow.com/a/49749230/6812182 中回答可以为您提供帮助。
  • 如果是:使用 cloud.at(i,j).getVector3fMap() 访问您的云(cloud.points 是一个 std::vector)
  • in_ThreeD_cloud 不是一个有组织的云
  • in_ThreeD_cloud中的点是按行列排列的吗?

标签: point-cloud-library point-clouds


【解决方案1】:

很确定问题出在您的点云访问调用中。您需要使用逗号符号而不是第二个括号,我也相信(如果我错了,请纠正我)坐标需要按列、行顺序排列。 *而不是您的 [row][col] 顺序。

我还将您的云更改为 xyz,因为您没有在其中插入任何强度(而只是检查图像以确定点的存在)。

最后,确保您知道点存储在 3d 云中的顺序(行与列),并确保以相同的方式循环。

// An object to class PointCloud is created
pcl::PointCloud<pcl::PointXYZ> cloud; 

// Image data from the camera is accessed as Matrix
cv::Mat image  = rrlib::coviroa::AccessImageAsMat(in_img->at(0));

// Dimensions of the point cloud is sent as parameters to overloaded constuctor
cloud(image.cols, image.rows); 

// The point cloud is expected to store the vector3f data in a 2D format
for(int i = 0; i <= image.rows; ++i)
for(int j = 0; j <= image.cols; ++j)
{
     if( image.at<uchar>(i,j) == 255)
     {
       // Error shown here
       cloud.points[j,i].getVector3fMap() = &points[num_valid_points];
       num_valid_points++;

      }
}

【讨论】:

    猜你喜欢
    • 2023-01-30
    • 2020-02-29
    • 2019-07-20
    • 2016-01-04
    • 2021-06-27
    • 2017-08-19
    • 2020-04-08
    • 2013-09-30
    • 1970-01-01
    相关资源
    最近更新 更多