I am trying to get the depth map of two stereo images but error 'cv2.cv2' has no attribute 'STEREO_BM_BASIC_PRESET' occurred. the code:
import cv2
import numpy as np
from matplotlib import pyplot as plt
# Convert to depth image
imgL = cv2.imread('D:\Books\Pav Man\PICS\R.jpg',0)
imgR = cv2.imread('D:\Books\Pav Man\PICS\L.jpg',0)
stereo = cv2.StereoBM(cv2.STEREO_BM_BASIC_PRESET,ndisparities=16, SADWindowSize=15)
disparity = stereo.compute(imgL,imgR)
plt.imshow(disparity,'gray')
plt.show()
#-------------------
solved worked with OpenCV 4.
import cv2
import numpy as np
from matplotlib import pyplot as plt
# Convert to depth image
imgL = cv2.imread('D:\Books\Pav Man\PICS\R.jpg',0)
imgR = cv2.imread('D:\Books\Pav Man\PICS\L.jpg',0)
stereo = cv2.StereoBM_create(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL,imgR)
plt.imshow(disparity,'gray')
plt.show()