Annoying persistent problem - Assertion failed (dims <= 2 && step[0] > 0) in locateROI, file /home/pi/opencv-3.3.0/modules/core/src/matrix.cpp, line 981

asked 2018-03-12 00:24:53 -0500

Hello everyone,

I asked this on StackOverflow and no one had an answer:

I've had this issue all day since installing my USB (well technically an AV to USB) camera and testing out just a basic video script.

I have confirmed it is nothing on my code's end but something to do with the format the camera displays at (YUYV).

So far I have tried:

cv2.imshow(img,cv2.imdecode(img,-1)) Note: this gave me a new error of: OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/pi/opencv-3.3.0/modules/ running cap.set(cv2.CAP_PROP_CONVERT_RGB, True) using the qv4l2 tool (worked 100% fine) None of which fixed the problem of getting the camera to work with OpenCV. Does anyone have any possible solutions?

Mega thank yous to anyone who has any idea!

If you would like to see my code, I will gladly post it. I am using a Raspberry Pi 3 for reference.

edit retag flag offensive close merge delete


python users never check any return values, like if the camera opened, if read() succeeded, etc, thus they run into those funny problems.

it's called murphy's law, dear ...

berak gravatar imageberak ( 2018-03-12 03:01:57 -0500 )edit