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
raspberry pi
Python 3.9.2
Canon 600D
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.
CodePudding user response:
you should add loop for your code. If u dont do this u always get only 1 frame from camera. Example:
import cv2
cap = cv2.VideoCapture('/dev/video0') # frozen
while true:
ret, frame = cap.read()
if not ret:
continue
print(ret, frame)
CodePudding user response:
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