我必须将点云数据从一维组织到二维。我已经有了一个一维点云数据,它只保存强度为255的像素(称为有效像素)的数据。因此,我必须根据图像组织点云。访问二维点云时遇到问题。我不知道怎么做。
// 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’)
发布于 2019-05-08 22:56:03
我很确定问题出在您的点云访问呼叫中。你需要使用逗号表示法而不是第二个括号,我也相信(如果我错了,请纠正我)坐标需要在列中,行顺序。*而不是您的行顺序。
我还将您的云更改为xyz,因为您不会在其中插入任何强度(而只是检查图像以确定点的存在)。
最后,确保你知道点存储在你的3d云中的顺序(row和col),并确保你以相同的方式循环。
// 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++;
}
}https://stackoverflow.com/questions/55982087
复制相似问题