[英]Accessing the disparity value in OpenCV when disparity map is type CV_8U?
I saw from a previous post that when you obtain the disparity value in the disparity map in open cv with disptype==CV_16S
you divide by 16.0
. 我从之前的帖子中看到,当您在open cv中使用
disptype==CV_16S
获得视差图中的disptype==CV_16S
,除以16.0
。 How about when the disparity map is type CV_8U
? 当视差图是
CV_8U
类型时CV_8U
样?
Do you have to divide by 8.0
to obtain the real disparity value? 你必须除以
8.0
来获得真正的差异值吗? I haven't found any documentation on this particular type. 我还没有找到有关此特定类型的任何文档。
You divide by 16 because the original disparity output of StereoSGBM is scaled by 16 and not because of the bit depth/disptype of the disparity. 除以16,因为StereoSGBM的原始视差输出缩放16,而不是因为视差的位深度/显示类型。
If you use sgbm->compute(left, right, disp);
如果你使用
sgbm->compute(left, right, disp);
the output disptype is CV_16S
even if you previously initialised disp
to be of type CV_8U
. 即使您先前
CV_16S
disp
初始化为CV_8U
类型,输出disptype也是CV_8U
。 Therefore, using convertTo
and dividing by 16.f
is the correct way. 因此,使用
convertTo
并除以16.f
是正确的方法。 (If you for some reason want to modify disp
before you use convertTo
and reprojectImageTo3D
then I don't know how you would get the real disparity values. It is, however, possible to convertTo
CV_8U
instead of CV_32F
but the results will obviously not be exactly similar.) (如果你因为某些原因需要修改
disp
您使用之前convertTo
和reprojectImageTo3D
然后我不知道你将如何得到真正的差异值。然而,有可能到convertTo
CV_8U
而不是CV_32F
但结果显然不会完全相似。)
Disparity map of CV_8U can be obtained from disparity map of CV_16S type by using imgDisparity16S.convertTo( imgDisparity8U, CV_8UC1, range);
通过使用
imgDisparity16S.convertTo( imgDisparity8U, CV_8UC1, range);
可以从CV_16S类型的视差图获得CV_8U的视差图imgDisparity16S.convertTo( imgDisparity8U, CV_8UC1, range);
where range is calculated as range = 255 / maxVal - minVal
and minMaxLoc( imgDisparity16S, &minVal, &maxVal );
其中range的计算
range = 255 / maxVal - minVal
为range = 255 / maxVal - minVal
和minMaxLoc( imgDisparity16S, &minVal, &maxVal );
So i guess the reciprocal of range ie 1 / range
will convert CV_8U to CV_16S and then you can have actual disparity value. 所以我猜范围的倒数即
1 / range
会将CV_8U转换为CV_16S然后你可以得到实际的差异值。
PS : I haven't tried this. PS:我没试过这个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.