如何使 USB 摄像头与 OpenCV 配合使用? [英] How to make USB camera work with OpenCV?

查看:61
本文介绍了如何使 USB 摄像头与 OpenCV 配合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 https://stackoverflow.com/a/34588758/210342 复制了代码并使用默认(内置-in)相机,它起作用了.然后我连接了 USB 摄像头,用 VLC 对其进行了测试并更改了代码以打开摄像头 1:

I copied code from https://stackoverflow.com/a/34588758/210342 and used with default (built-in) camera, it worked. Then I attached USB camera, tested it with VLC and changed the code to open camera 1:

cam = cv2.VideoCapture(1)

我检查相机是否打开 cam.isOpened() -- 它是 -- 但相机没有启用(它的硬件指示灯,LED,关闭),实际上我看到的都是屏幕黑框.

I check whether the camera is open cam.isOpened() -- it is -- but the camera is not enabled (its hardware indicator, LED, is off) and indeed all I see on the screen is black frame.

是否需要添加一些额外的特殊代码来启用 USB 摄像头?

Is there some extra special code to add in order to enable USB camera?

推荐答案

你确定 USB 摄像头是摄像头 1,我以前做过这个,不得不使用 cv2.VideoCapture(0)

Are you sure the usb camera is camera 1, i've done this before and had to use cv2.VideoCapture(0)

这篇关于如何使 USB 摄像头与 OpenCV 配合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆