【发布时间】:2022-01-17 22:18:40
【问题描述】:
当我尝试使用 opencv 和 python 开始视频采集时,它根本无法加载。不显示任何问题,不返回任何内容。没什么!!!
代码是最简单的:
import cv2
import sys
video_capture = cv2.VideoCapture(0)
while True:
ret, frame = video_capture.read()
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
cv2.destroyAllWindows()
这是运行这个程序的结果
如果我逐行运行代码,这就是卡住的地方
如果我在执行最后一行时按 Ctrl+C,它会告诉我:
Trying to dispose element pipeline0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
【问题讨论】:
-
您的相机是否出现在
lsusb中?v4l2-ctl --list-devices呢? -
是的,在 lsusb 中它显示了我的相机,这是我为
v4l2-ctl --list-devices输出的:bcm2835-codec-decode (platform:bcm2835-codec): /dev/video10 /dev/video11 /dev/video12 /dev/video18 bcm2835-isp (platform:bcm2835-isp): /dev/video13 /dev/video14 /dev/video15 /dev/video16 USB Live camera : USB Live came (usb-0000:01:00.0-1.1): /dev/video0 /dev/video1 -
你的树莓派有显示器吗?树莓派能识别并使用这个显示器吗?还是通过 SSH 连接?
-
我是通过 ssh 连接的
标签: python opencv raspberry-pi camera