[英]Accessing Beaglebone python opencv usb camera but the display showing black screen
使用beagle-bone黑色无线访问USB摄像头时遇到问题。 首先错误是“选择超时”除外,它被解决了这个帖子
现在我面对输出中的黑屏。
这是我正在使用的测试代码。
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。
问题是您需要在while循环中调用'cam.read() and
imshow()`。
您正在做的是先阅读第一帧,然后显示它,而while
循环却什么也没做。 相机启动时,第一帧只是空白屏幕,这就是您所看到的。
该代码应该更像:
while True:
s, img = cam.read()
imshow("cam-test",img)
key = waitKey(30)
if key == ord('q') :
destroyWindow("cam-test")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.