Friday, June 19, 2009

get real disparity map from OpenCV function cvFindStereoCorrespondenceBM()

The function cvFindStereoCorrespondenceBM() can give you a disparity map, but it's not real disparity map which we used to reconstruct real 3D world.

I have checked the source code and find this function uses Bitwise operator to shift the real disparity value. For false matching points, it give a certain value which is left shifted version of 'mindisp-1', here mindisp is the minimum disparity value. In this function, it shift 4 bits, which means if mindisp=-64, then after shifted , it become -1040; Shifting 4 bits equal the value*2^4; Here -1040=(-64-1)*2^4;

As I don't exactly sure if it's same shift way for right matching points, so leave this question to the authors. But If I unshift all datas, I find all disparity value go to the right range, it seems for all the disparity, the author left shift 4 bits. If it's true, then we can get real disparity map by


1 comment:

Veltrop said...

Thanks for figuring this out!