Error:module 'cv2.cv2' has no attribute 'STEREO_BM_BASIC_PRESET'
Error:module 'cv2.cv2' has no attribute 'STEREO_BM_BASIC_PRESET'
我正在尝试获取两个立体图像的深度图,但发生错误 'cv2.cv2' 没有属性 'STEREO_BM_BASIC_PRESET'。
代码:
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()
#-------------------
解决了使用 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()
我正在尝试获取两个立体图像的深度图,但发生错误 'cv2.cv2' 没有属性 'STEREO_BM_BASIC_PRESET'。 代码:
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()
#-------------------
解决了使用 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()