找到立体图像对的视差图

时间:2016-07-13 08:25:35

标签: python python-2.7 opencv image-processing

请查看以下错误并给我一个解决方案。该代码讨论了立体匹配。

结果:显示视差图

import numpy as np
import cv2
imgL=cv2.imread('C:\Users\harsha\Desktop\stereo  vision\images_stereo_1\cam2_object3.jpg')
imgR=cv2.imread('C:\Users\harsha\Desktop\stereo  vision\images_stereo_1\cam3_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:\Python27\Scripts\stereo.py", line 21, in <module>
    disp=stereo.compute(imgL,imgR,disptype=cv2.CV_8UC1)

error: ..\..\..\..\opencv\modules\calib3d\src\stereobm.cpp:1089: error: (-215) disptype == CV_16S || disptype == CV_32F in function cv::StereoBM::operator ()

1 个答案:

答案 0 :(得分:0)

如果你只看过你的错误,你会发现你没有传递有效的disptype

更改

disp=stereo.compute(imgL,imgR,disptype=cv2.CV_8UC1)

disp=stereo.compute(imgL,imgR,disptype=cv2.CV_32F)