Ask Your Question

Professor_X's profile - activity

2020-05-08 00:58:49 -0600 received badge  Popular Question (source)
2018-03-04 03:04:22 -0600 marked best answer How to resolve a SADWindowSize error?

I have Python version 3.6 and OpenCV version 3.4.0

I am currently working through the OpenCV (Python) tutorial Depth Map from Stereo Images. I get how the code works (below):

import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
imgL = cv.imread('tsukuba_l.png',0)
imgR = cv.imread('tsukuba_r.png',0)
stereo = cv.StereoBM_create(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL,imgR)
plt.imshow(disparity,'gray')
plt.show()

This is similar to the previous StackOverflow question Python/OpenCV: Why is cv2.StereoBM not working in this case?, however, unlike that question, when I get to the line:

disparity = stereo.compute(imgL,imgR)

I encounter the error:

error Traceback (most recent call last) <ipython-input-26-5ea252da384c> in <module>() ----> 1 disp = stereo.compute(imgl, imgr)

error: C:\projects\opencv-python\opencv\modules\calib3d\src\stereobm.cpp:1090: error: (-211) SADWindowSize must be odd, be within 5..255 and be not larger than image width or height in function cv::StereoBMImpl::compute

and can go no further. I checked and confirmed that the images are of the exact same size. I do understand what the SADWindowSize does (Sum of Absolute Differences), but do not know where and how to change this parameter to fix the error. How can I fix the SADWindowSize to fix this error?

2018-03-04 03:00:26 -0600 commented question How to resolve a SADWindowSize error?

Hi @berak, I just came to the same conclusion as well - I am not sure why either, but it now works! Thank you very kindl

2018-03-04 02:40:57 -0600 commented question How to resolve a SADWindowSize error?

I know it is reading the images as I can get the details of the images and even show them.

2018-03-04 02:28:36 -0600 commented question How to resolve a SADWindowSize error?

Hi @berak yes, I checked and it is reading the images fine - the error remains

2018-03-04 00:36:19 -0600 received badge  Organizer (source)
2018-03-04 00:22:08 -0600 received badge  Editor (source)
2018-03-04 00:22:08 -0600 edited question How to resolve a SADWindowSize error?

How to resolve a SADWindowSize error? I have Python version 3.6 and OpenCV version 3.4.0 I am currently working through

2018-03-04 00:03:31 -0600 asked a question How to resolve a SADWindowSize error?

How to resolve a SADWindowSize error? I have Python version 3.6 and OpenCV version 3.4.0 I am currently working through