首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >匹配像素数据和点云

匹配像素数据和点云
EN

Stack Overflow用户
提问于 2019-05-04 19:32:51
回答 1查看 545关注 0票数 0

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

代码语言:javascript
复制
// 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++;

      }


}

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

EN

回答 1

Stack Overflow用户

发布于 2019-05-08 22:56:03

我很确定问题出在您的点云访问呼叫中。你需要使用逗号表示法而不是第二个括号,我也相信(如果我错了,请纠正我)坐标需要在列中,行顺序。*而不是您的行顺序。

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

最后,确保你知道点存储在你的3d云中的顺序(row和col),并确保你以相同的方式循环。

代码语言:javascript
复制
// 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++;

      }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55982087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档