从视差图的OpenCv深度估计 [英] OpenCv depth estimation from Disparity map

查看:606
本文介绍了从视差图的OpenCv深度估计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用OpenCV从一个立体对图像估计深度。我有差异图和深度估计可以获得为:

I'm trying to estimate depth from a stereo pair images with OpenCV. I have disparity map and depth estimation can be obtained as:

             (Baseline*focal)
depth  =     ------------------
           (disparity*SensorSize)

我已经使用块匹配技术找到两个校正图像中的相同点。
OpenCV允许设置一些块匹配参数,例如 BMState-> numberOfDisparities

I have used Block Matching technique to find the same points in the two rectificated images. OpenCV permits to set some block matching parameter, for example BMState->numberOfDisparities.

块匹配过程后:

cvFindStereoCorrespondenceBM( frame1r, frame2r, disp, BMState);
cvConvertScale( disp, disp, 16, 0 );
cvNormalize( disp, vdisp, 0, 255, CV_MINMAX );

我发现深度值为:

if(cvGet2D(vdisp,y,x).val[0]>0)
   {
   depth =((baseline*focal)/(((cvGet2D(vdisp,y,x).val[0])*SENSOR_ELEMENT_SIZE)));
   }

但是深度值不同于以前公式计算的值到 BMState-> numberOfDisparities 的值更改结果值。

But the depth value obtaied is different from the value obtaied with the previous formula due to the value of BMState->numberOfDisparities that changes the result value.

如何设置此参数?如何更改此参数?

How can I set this parameter? what to change this parameter?

感谢

推荐答案

当且仅当从左侧摄像机到右侧摄像机的运动是纯平移(特别是平行于水平图像轴)时,才是有效的。

The simple formula is valid if and only if the motion from left camera to right one is a pure translation (in particular, parallel to the horizontal image axis).

这种情况。例如,通常在更正后执行匹配。图像,即,在使用已知的基本矩阵扭曲它们之后,使得对应的像素被约束为属于同一行。一旦您在
上匹配已校正的图像,就可以使用校正翘曲的逆来将它们重映射到原始图像上,然后三角剖分到3D空间中以重建场景。 OpenCV有一个例程: reprojectImageTo3d

In practice this is hardly ever the case. It is common, for example, to perform the matching after rectifying the images, i.e. after warping them using a known Fundamental Matrix, so that corresponding pixels are constrained to belong to the same row. Once you have matches on the rectified images, you can remap them onto the original images using the inverse of the rectifying warp, and then triangulate into 3D space to reconstruct the scene. OpenCV has a routine to do that: reprojectImageTo3d

这篇关于从视差图的OpenCv深度估计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆