Ask Your Question

Revision history [back]

StereoBM compute does not take in CV_8UC1 python ndarray?

Here is my code:

v1 = cv2.VideoCapture(1)
v2 = cv2.VideoCapture(2)
stereo = cv2.StereoBM_create(numDisparities=16, blockSize=15)

ret, frame1 = v1.read()
ret, frame2 = v2.read()
frame1_new = cv2.cvtColor(frame1, cv2.CV_8UC1)
frame2_new = cv2.cvtColor(frame2, cv2.CV_8UC1)
disparities = stereo.compute(frame2_new, frame1_new)

Running this code gets me the error:

cv2.error: ...opencv\modules\clib3d\src\stereobm.cpp:1047: error: (-210) Both input images must have CV_8UC1 in function cv::StereoBMImpl::compute

I've tried different color mappings to see if it needed a different color, but none of them have worked. What am I doing wrong here?

I am using OpenCV 3.0.0.