Wednesday, February 2, 2022

[SOLVED] opencv - unable to capture frame from camera on raspberry pi

Issue

My pi camera is connected and enabled, raspistill takes photos successfully. In python, cv2.VideoCapture(-1).read() always returns (False, None). I'm stumped.

id='dv3'>

Solution

OpenCV relies on the V4L2 (Video for Linux) module, so try adding the following line at the bottom of the file /etc/modules and rebooting your Raspberry Pi.

bcm2835-v4l2

Mine now looks like this in toto:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

bcm2835-v4l2

This ensures that the Broadcom Video For Linux 2 (v4l2) driver is loaded at all subsequent reboots.



Answered By - Mark Setchell
Answer Checked By - David Goodson (WPSolving Volunteer)