2

The question is a bit similar to this question.

The main difference is that I'm using a different camera (the Raspberry Pi camera board). I've spend a few days exploring Python and OpenCV. I'm writing a script on my Windows laptop that I want to run on my Raspberry Pi.

My Raspberry Pi has OpenCV 2.3.1 installed. I could make images using PiCamera, or I could write:

import os, sys os.system('raspistill -o /var/www/images/image.jpg') 

However, I want to use cv2.VideoCapture(int device). The documentation says:

Parameters:

  • filename – name of the opened video file
  • device – id of the opened video capturing device (i.e. a camera index). If there is a single camera connected, just pass 0.

cv2.CreateCapture(0) works perfectly fine on my laptop. On the Raspberry Pi however, it's unable to open the camera. I'm not experienced with Raspbian, so I'm not sure if 0 is the correct device ID.

Any help will be greatly appreciated.

1
  • I’ve had a similar issue an found that adding a 500 ms wait to allow the window to initialize works. Commented Jul 31, 2021 at 19:50

1 Answer 1

3

Until recently this wasn't possible - it requires a V4L2 driver for the camera which was previously absent. This is now available, just follow the instructions here to set up the driver and cv2 videocapture should work fine.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.