0

I followed the installation tutorial at https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/#comment-451314 , and everything installed fine.

But I can't actually get opencv to work at all.

>>> import cv2
>>> cap = cv2.VideoCapture(0)
>>> cap.isOpened()
False

Any attempt to capture video or images with cv2 basically doesn't work. I don't even know where to look for logs. Can anyone tell me where to start looking?

EDIT: I'm using the Raspberry Pi camera module, which apparently needs additional drivers or something. I'll post a solution if I find one, but in the meantime I'm still listening!

0

I was getting the same error while using opencv in anaconda3 virtual environment. I checked the buildinformation (cv2.getBuildInformation()) for current opencv version and ffmpeg wasn't marked "yes". To resolve this

  1. I uninstalled opencv from my conda environment ( conda uninstall opencv)

  2. Installed latest ffmpeg using conda-forge channel

  3. Then installed opencv again using conda-forge channel ( conda install -c conda-forge opencv) . Don't install using menpo channel

Doing this resolved the issue for me.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.