【发布时间】: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