pythonopencvraspberry-pilibgphoto2

Python opencv cv2.VideoCapture freeze


My code always freezes on me. I'm testing it on this code.

import cv2

cap = cv2.VideoCapture('/dev/video0') # frozen
ret, frame = cap.read()
print(ret, frame)

My configuration is

this command works normally

gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0

There may be a bug in the Cannon 600D.


Solution

  • it needed to run

    sudo modprobe v4l2loopback

    and

    gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0
    

    and gphoto2 run