Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error displaying video stream using Opencv on raspberry pi

Tags:

I'm trying to access a live video feed from my Raspberry Pi with a PiCam attached. I have enabled the camera in the interface settings and even tested it by snapping some pictures and videos using the PiCam library. However, OpenCV is giving me troubles. I installed open CV following this tutorial (shoutout to Adrian Rosenbrock).

Check out the screenshot below for the code and the error message. I'm running everything from within a virtual environment with OpenCV installed, like Adrian suggests.

Code and error message

VIDEOIO ERROR: V4L: can't open camera by index 0

From what I've read from other problems people have had, this error is sometimes resolved by playing with the index value. If i change the index value to -1 or 1, like most solutions suggest, i either get the same thing or a slightly different "can't access camera" error.

I'm relatively new to OpenCV and RPi so I might just be missing something simple. Any suggestion is much appreciated, thanks!

like image 305
lewesche Avatar asked Aug 02 '18 04:08

lewesche


1 Answers

You may need to enable access to the camera. Try typing: sudo modprobe bcm2835-v4l2 in terminal on your RPI.

like image 161
JLid Avatar answered Oct 11 '22 14:10

JLid