opencv3.0 - Python2.7/OpenCV3.3: error in disparity map while using StereoBM_create in python -


i using opencv 3.3 in python 2.7 create disparity map. read ans1 ans2 ans3, no help. follow below steps:

  1. upload camera intrinsic , extrinsic matrices. uploaded rotation , translation matrices too.
  2. uploaded left , right images , use cv2.stereorectify p1,p2,r1 , r2.
  3. computes undistort , rectify maps using cv2.initundistortrectifymap.
  4. use cv2.remap rectified images.
  5. use cv2.stereobm_create block matching.
  6. and finally, compute disparity.

but disparity map full of noises. nothing clear. tried changing blocksize no help.

my code below:

import cv2 import numpy np import matplotlib.pyplot plt   cameramatrixl = np.load('mtx_left.npy') distcoeffsl = np.load('dist_left.npy') cameramatrixr = np.load('mtx_right.npy') distcoeffsr = np.load('dist_right.npy') r = np.load('r.npy') t = np.load('t.npy')  imgleft = cv2.imread('d:\python/triangulate in 3 d\left120.jpg',0) imgright = cv2.imread('d:\python/triangulate in 3 d/right120.jpg',0)  r1,r2,p1,p2,q,validpixroi1, validpixroi2 = cv2.stereorectify(cameramatrixl,distcoeffsl,cameramatrixr,distcoeffsr,(640,480),r,t,alpha=0)   #computes undistort , rectify maps mapxl, mapyl = cv2.initundistortrectifymap(cameramatrixl, distcoeffsl, r1, p1, (640,480), cv2.cv_32fc1) mapxr, mapyr = cv2.initundistortrectifymap(cameramatrixr, distcoeffsr, r2, p2, (640,480), cv2.cv_32fc1)   dstl = cv2.remap(imgleft, mapxl, mapyl,cv2.inter_linear) dstr = cv2.remap(imgright, mapxr, mapyr,cv2.inter_linear)  #cv2.imwrite('left.png',dstl) #cv2.imwrite('right.png',dstr)  stereo = cv2.stereobm_create(numdisparities=16, blocksize=15) disparity = stereo.compute(dstl,dstr)  plt.imshow(disparity,'gray') plt.show() 

various matrices , images used can downloaded here. also, want mention 1 thing here translation matrix come t = np.array([[-94.52],[-0.76],[24.45]]) can not 24.45 mm because set both cameras parallel. so, check factor changed t t = np.array([[-94.52],[-0.76],[0.45]]) got same result.

how can disparity map. calibrated cameras many times not getting disparity map. reprojection error both cameras comes out below 0.02 pixels.

thanks.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -