使用块匹配算法获取纹理点云
Get textured pointcloud with Block-Matching-Algorithm
我想用两个图像中的原始图像颜色对生成的点云进行纹理处理。为此,我使用块匹配计算了视差图并进行了重建。另外,为.ply文件编写导出函数也没什么大不了的。我的问题是:如何从块匹配算法中获得颜色它确实在校正后的图像上寻找相似的像素,但没有保存找到的匹配位置的变量,称为API。之后就不可能恢复颜色了。
StereoBM sbm;
sbm(left_rectfied_image, right_rectified_image, disparity, CV_32F);
(我正在使用OpenCV 2.4.8)
是您正在计算的视差图是针对校正后的左侧图像的!您可以简单地将"左图像像素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;
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 使用指针从C++中的数组中获取最大值
- 如何获取std::result_of函数的返回类型
- 如何在openssl-ecc中获取十六进制格式的私钥
- 使用Unreal C++获取VR耳机的世界位置/方向
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- OpenInventor从9.8升级到10.4.2后,GLSL纹理返回零
- 从C字符串中获取奇怪的字符串长度
- 为什么我的for循环不能正确获取argv
- 无法获取要在 OpenGL ES2 中显示的 RGB 纹理
- 使用 assimp 获取纹理比例
- 获取 OpenGL 纹理中特定像素的颜色
- 有没有办法在OpenGL上获取旋转的纹理
- 如果我们有带有 doxygen 的纹理类层次结构,如何获取图形类层次结构
- 获取对象空间到纹理空间的切线
- 从 SDL2 纹理获取像素信息
- 使用块匹配算法获取纹理点云
- 获取蒙版纹理的OpenGL直方图