【问题标题】:OpenCV USB-camera does not work on Raspberry Pi 4 32-bitOpenCV USB 摄像头不适用于 Raspberry Pi 4 32 位
【发布时间】: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


【解决方案1】:

也许不是一个真正的解决方案,但可以尝试像这样指定视频后端:

video_capture = cv2.VideoCapture(0, CAP_V4L2)

【讨论】:

    猜你喜欢
    • 2020-01-12
    • 1970-01-01
    • 1970-01-01
    • 2012-06-28
    • 1970-01-01
    • 1970-01-01
    • 2013-12-16
    • 2016-12-04
    • 1970-01-01
    相关资源
    最近更新 更多