在 python-opencv 中列出可用设备 [英] Listing available devices in python-opencv

查看:44
本文介绍了在 python-opencv 中列出可用设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的笔记本电脑上连接了两个网络摄像头(一个内置),它们都可以工作.(如果我使用 Cheese,一个 Ubuntu 附带的网络摄像头,它使用外部摄像头).如果我使用

cap = cv.CreateCameraCapture(0)

cap = cv.CreateCameraCapture(-1)

我得到了我的内置网络摄像头.如果我使用

cap = cv.CreateCameraCapture(1)

它不起作用,对象cap"显示为:

与 CaptureFromCAM 相同.所以我想知道 openCV 试图做什么以及为什么它似乎不知道第二个摄像头.应该有两个设备可用(两者都有/dev/videoN 条目).

解决方案

这是 OpenCV 的一个普遍问题,如下所示.似乎只有内置的,或者第一个 USB cam(只有当你没有内置的 cam)才能在 OpenCV 中工作:

如何在 OpenCV 中使用相机

无法通过 OpenCV、Cygwin 访问 USB 网络摄像头

从 USB 而非 iSight (OSX) 捕获 OpenCV

目前,无法提取此功能请求中列出的摄像机数量:

https://code.ros.org/trac/opencv/ticket/935

I have two webcams attached to my laptop (one built in), both of which work. (If I use Cheese, a webcam thingy that comes with Ubuntu, it uses the external one). If I use

cap = cv.CreateCameraCapture(0)

or

cap = cv.CreateCameraCapture(-1)

I get my built in webcam. If I use

cap = cv.CreateCameraCapture(1)

It doesn't work and the object `cap' displays as:

<Capture (nil)>

Same with CaptureFromCAM. So I'd like to know what openCV is trying to do and why it doesn't seem to know about the second camera. There should be two devices available (there are /dev/videoN entries for both).

解决方案

This is a general problem of the OpenCV, as you can see below. It seems that only the builtin, or the first USB cam (only if you do not have a buildin cam) works in OpenCV:

How to use a camera with OpenCV

Cannot access usb webcam through OpenCV, Cygwin

OpenCV capture from USB not iSight (OSX)

Currently, there is no way to extract the number of cameras, as listed in this feature request:

https://code.ros.org/trac/opencv/ticket/935

这篇关于在 python-opencv 中列出可用设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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