2016-07-13 52 views
0

請查看以下錯誤並給我一個解決方案。代碼講述了立體匹配。查找立體圖像對的視差圖

結果:顯示視差映射

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() 

回答

0

如果你也只有看你的錯誤,你會看到,你是不是通過一個有效的disptype

變化

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

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