title: Error displaying video stream using Opencv on raspberry pi
body: <p>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 <a href="https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/" rel="noreferrer">this tutorial</a> (shoutout to Adrian Rosenbrock).</p>
  
  <p>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. </p>
  
  <p>Code and error message</p>
  
  <p><img src="https://i.stack.imgur.com/JITx7.jpg" alt=""></p>
  
  <blockquote>
    <p>VIDEOIO ERROR: V4L: can't open camera by index 0</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>I'm relatively new to OpenCV and RPi so I might just be missing something simple. Any suggestion is much appreciated, thanks!</p>