I am using 2 webcams. Base Line is 110mm.
I calibrate 2 webcams. Then I could get calibrate.npz file.
stereoMatcher = cv2.StereoBM_create()
stereoMatcher.setMinDisparity(4)
stereoMatcher.setNumDisparities(128)
stereoMatcher.setBlockSize(21)
stereoMatcher.setROI1(leftROI)
stereoMatcher.setROI2(rightROI)
stereoMatcher.setSpeckleRange(16)
stereoMatcher.setSpeckleWindowSize(45)
fixedLeft = cv2.remap(left, leftMapX, leftMapY, REMAP_INTERPOLATION)
fixedRight = cv2.remap(right, rightMapX, rightMapY, REMAP_INTERPOLATION)
grayLeft = cv2.cvtColor(fixedLeft, cv2.COLOR_BGR2GRAY)
grayRight = cv2.cvtColor(fixedRight, cv2.COLOR_BGR2GRAY)
disp = stereoMatcher.compute(grayLeft, grayRight)
disp = disp.astype(np.uint8)
depth = BASE_LINE * CAMERA_FOCAL / disp
np.save(numpy_path, depth)
#disp = cv2.cvtColor(disp, cv2.COLOR_GRAY2BGR)
#disp = cv2.applyColorMap(disp, cv2.COLORMAP_JET)
cv2.imwrite(depth_path, disp)
But, my result is not so good.
Above all things, It seems like that disparity is just 2 parts. (I mean that background and something weired parts.)
How to fix it?? My calibration is wrong??