Ask Your Question
0

StereoBM compute does not take in CV_8UC1 python ndarray?

asked 2015-12-19 02:22:07 -0600

arbitraryname gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-12-19 04:26:29 -0600

berak gravatar image

your enum value for cvtColor is wrong. please try like:

cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-12-19 02:22:07 -0600

Seen: 4,183 times

Last updated: Dec 19 '15