Fenghe's Blog

Enable Camera on Your Raspberry Pi

By default, the camera interface is closed on your Raspberry Pi, so enabling using the camera on your Raspberry Pi is the first step for a Computer Vision project on your Raspberry Pi. Following is a simple tutorial.

In the command line tool, use the following command:

$ sudo raspi-config

Then choose the 5th option(Interfacing Options)

Then Camera.

Choose Yes.

Choose Ok.

Choose Finish.

Now if you are connecting to the Raspberry Pi remotely with ssh, you should reboot the Pi by using

$ sudo reboot

Fix the Potential Error & Test the Camera

Now let’s try the camera out!

$ workon cv

makes sure that you are in the virtual environment with cv2 installed.

But as you can see, there might be an ERROR as in my case.

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

To resolve it, exit the python command line, then run:

$ sudo modprobe bcm2835-v4l2

Now, feel free to start your project with the camera and opencv installed!

References:

  1. https://www.pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/
  2. https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html
  3. Fix the possible ERROR: http://answers.opencv.org/question/199105/videoio-error-v4l-cant-open-camera-by-index-0/

Leave a Reply

Your email address will not be published. Required fields are marked *