Simple CPU implementation from scratch of Block Matching using simple Sum of Square difference, rank transform or census transform followed by hamming distance as matching cost. Defualt version use OpenMP optimization (save about 200ms execution time per image), also have the option to use Visual c++ (for windows user) concurrency module to parallellize the code execution (but slower than openMP in my case)
You can either compile the code to executable with gcc or visual studio with Opencv installed. This have been tested in Windows 10 and ubuntu 20.04
left image:

right image:

disparity image with fixed windows ssd:

disparity image with rank transform:

disparity image with census transform:

Clearly, choosing rank transform or census transform as matching cost make disparity map less noisy, probably the nature of these transform make left and right images less sensitive to illumination changes. p.s. using census transform is slower than using rank transform
$OPENCV
Compile
bash ./build.sh
Usage cd build ./stereo_mathing -left= -right= -max-disparity= -window_size= -tranwin_size= -output= -parallel= -cost= -windows=
Examples
./stereo_matching -left=im1.png -right=im2.png -max-disparity=50 -window_size=6 -tranwin_size=7 -output=depth_new.png -parallel=yes -cost=rank -windows=yes
If you find this repo useful to you please consider click the button below to donate and support my work!
