【问题标题】:Accessing Beaglebone python opencv usb camera but the display showing black screen访问 Beaglebone python opencv usb 摄像头但显示黑屏
【发布时间】:2018-05-08 07:00:45
【问题描述】:

我在使用 beagle-bone black 无线访问 USB 摄像头时遇到问题。 首先错误是由this post解决的“选择超时”异常@

现在我在输出中面临黑屏。

这是我正在使用的测试代码。

from cv2 import *
# initialize the camera
cam = VideoCapture(0)   # 0 -> index of camera
print "Cam capture"
cam.set(3,320)
cam.set(4,240)
print "Cam set"
s, img = cam.read()
print "Cam read"
if s:    # frame captured without any errors
    namedWindow("cam-test",CV_WINDOW_AUTOSIZE)
    imshow("cam-test",img)
    while True:
        key = waitKey(30)
        if key == ord('q') :
                destroyWindow("cam-test")

我已经检查了 /dev 目录中的 video0。

【问题讨论】:

    标签: python opencv video usb webcam-capture


    【解决方案1】:

    问题是您需要在 while 循环中调用 'cam.read()andimshow()`

    你正在做的是你正在阅读第一帧,然后显示它,而你 whileloop 没有做任何事情。开机时,第一帧只是一个空白屏幕,这就是你所看到的。

    代码应该更像:

        while True:
            s, img = cam.read()
            imshow("cam-test",img)
            key = waitKey(30)
            if key == ord('q') :
                    destroyWindow("cam-test")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-17
      • 1970-01-01
      • 2017-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多