请查看以下错误并给我一个解决方案。该代码讨论了立体声匹配。
结果:显示视差图
import numpy as np
import cv2
imgL=cv2.imread('C:UsersharshaDesktopstereo visionimages_stereo_1cam2_object3.jpg')
imgR=cv2.imread('C:UsersharshaDesktopstereo visionimages_stereo_1cam3_object3.jpg')
stereo = cv2.StereoBM()
disp=stereo.compute(imgL,imgR,disptype=cv2.CV_8UC1)
CV2.imshow(window_name,disparity/255)
Error:
raceback (most recent call last):
File "C:Python27Scriptsstereo.py", line 21, in <module>
disp=stereo.compute(imgL,imgR,disptype=cv2.CV_8UC1)
error: ........opencvmodulescalib3dsrcstereobm.cpp:1089: error: (-215) disptype == CV_16S || disptype == CV_32F in function cv::StereoBM::operator ()
如果您只查看错误,您会发现您没有通过有效的disptype
。
改变
disp=stereo.compute(imgL,imgR,disptype=cv2.CV_8UC1)
自
disp=stereo.compute(imgL,imgR,disptype=cv2.CV_32F)