是的! 您正在计算的视差图适用于校正后的左图像!您可以简单地对 3D 中的所有点使用左图像像素 XY 坐标值。例如
reprojectImageTo3D(disp_32, xyz, Q, true);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr (new pcl::PointCloud<pcl::PointXYZRGB>);
const double max_z = 1.0e4;
for (int Row = 0; Row < xyz.rows; Row++)
{
for (int Col = 0; Col < xyz.cols; Col++)
{
pcl::PointXYZRGB point;
vec3b Pix;
//Just taking the Z Axis alone
Vec3f Depth= xyz.at<Vec3f>(Row,Col);
point.x = Depth[0];
point.y = Depth[1];
point.z = Depth[2];
if(fabs(Depth[2] - max_z) < FLT_EPSILON || fabs(Depth[2]) > max_z|| Depth[2] > 0)
continue;
Pix= mCamFrame_Left.at<vec3b>(Row,Col);
uint32_t rgb = (static_cast<uint32_t>(Pix.val[0]) << 16 |static_cast<uint32_t>(Pix.val[1]) << 8 | static_cast<uint32_t>(Pix.val[2]));
point.rgb = *reinterpret_cast<float*>(&rgb);
point_cloud_ptr->points.push_back (point);
}
}
point_cloud_ptr->width = (int) point_cloud_ptr->points.size();
point_cloud_ptr->height = 1;