My disparity map is only 2parts.

asked 2018-10-12 01:06:52 -0500

hotteock gravatar image

updated 2018-10-12 01:08:18 -0500

I am using 2 webcams. Base Line is 110mm.

I calibrate 2 webcams. Then I could get calibrate.npz file.

stereoMatcher = cv2.StereoBM_create()

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, 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??

image description

image description

image description

edit retag flag offensive close merge delete


in general, please try to spare us duplicate questions to the same topic

berak gravatar imageberak ( 2018-10-12 01:28:44 -0500 )edit

Sorry. I fix my code, baseline, etc.... So, I should write new question. Now, I had deleted last one.

hotteock gravatar imagehotteock ( 2018-10-12 01:40:02 -0500 )edit

The stereo match algorithm does not detect row offset (disparity in y axis), only column offset (disparity along the x axis).

What are your left and right camera stereo calibration matrices (K, D, R, P)? In other words, are these left and right images undistorted and rectified prior to stereo match?

I have some concern that they are not, for example the lowest drawer knob on the left image is higher than the knob on the right image. If the left and right images are not transformed into epipolar images prior to stereo matching, you will have poor stereo match results. Once that is no longer a problem, it's good to try different parameter settings to examine results.

opalmirror gravatar imageopalmirror ( 2018-10-15 13:15:15 -0500 )edit