【问题标题】:cv2.VideoCapture.read() isn't workingcv2.VideoCapture.read() 不工作
【发布时间】:2017-07-29 08:44:28
【问题描述】:

我通过 opencv 拍摄了一张图像,以检查网络摄像头是否有问题,但网络摄像头正在工作。现在在下面提到的代码中,只有 else 语句正在执行,并且 frame 一直没有。

video = cv2.VideoCapture(0)
if video.isOpened():
    while True:
        check, frame = video.read()  
        if frame != None:
            cv2.imshow("Color Frame", frame) 
            key = cv2.waitKey(50)        
            if key == ord("q"):
                break
        else:
            print("Frame not available")
            print(video.isOpened()) 

【问题讨论】:

  • 读完后check等于什么?
  • checkFalse
  • 如果你使用linux检查是否有/dev/video0
  • 我使用的是 64 位 windows 7
  • 你试过 cv2.VideoCapture(1) 或 cv2.VideoCapture(2) 吗?您的代码可能无法访问您的主摄像头驱动程序

标签: python python-3.x opencv


【解决方案1】:

在 Raspberry Pi 3 中,我必须执行以下操作才能使其工作:

$ sudo modprobe bcm2835-v4l2

【讨论】:

    【解决方案2】:

    cv2.Videocapture.read() 返回 false,无,解决方案是运行: conda install -c conda-forge ffmpeg conda install -c conda-forge opencv

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-15
      • 2020-06-25
      • 2020-03-24
      • 2018-11-13
      • 1970-01-01
      • 2019-02-24
      • 1970-01-01
      相关资源
      最近更新 更多