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

1, problem description: using opencv to call the raspberry PI camera [cv2.videocapture (0)], when running the program, said can not open the camera.


2. Solution:

I looked for a method on the Internet, said to change 0 to -1, I changed, after the change, the system still said can not find the camera, let alone open.

and then I’m going to do the camera test and say

https://www.raspber rypi.org/documentation/configuration/camera.md

raspistill -v -o test.jpg

found that raspberry PI can take photos normally, indicating that there is no problem with the installation interface.

and search on the Internet, said to run the program to enter the following statement, that is, the raspberry PI system’s camera is ok, but opencv can not call. It can be called using this statement.

sudo modprobe bcm2835-v4l2

yes, the camera can be turned on after you type in this statement, but the screen will be bar by bar, for whatever reason, that’s not settled yet. Is the refresh too fast?

###############################################

https://blog.csdn.net/u012005313/article/details/70244747#C0, that’s a great blog

raspberry PI can call the camera and show the stripe instead of the original image, because the following two parameters mess up, comment out, it will work properly

# Set camera resolution
camera.set(cv2.cap_prop_frame_width, 620)
camera.set(cv2.cap_prop_frame_height, 480)

Read More: