Mac上的OpenCV不打开USB网络摄像头 [英] OpenCV on Mac is not opening USB web camera

查看:795
本文介绍了Mac上的OpenCV不打开USB网络摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 OpenCV 的VideoCapture.open(int)无法成功获取视频捕获从我的 MacBook Pro 中的USB网络摄像头运行Mac OS X  v10.7(Lion )。使用open(0)成功地从iSight摄像机捕获。但我没有任何运气试图找到WebCam。

I have been unsuccessful using OpenCV's VideoCapture.open(int) to get video capture from a USB web cam in my MacBook Pro running Mac OS X v10.7 (Lion). Using open(0) successfully gets capture from the iSight camera. But I didn't have any luck trying to find the WebCam.

WebCam安装和工作很好与 Skype macam 驱动程序应用程序。

The WebCam is installed and works well with Skype, and the macam driver application.

这里是我使用的代码的一部分:

Here is a portion of the code that I'm using:

VideoCapture cap; 
for (int i = 1; i < 1500; i++) {
    if (cap.open(i))
    {
        cout << "Found camera %d\n" << i;
        break;
    }
}
if(!cap.isOpened()) {  // Check if we succeeded
    return -1;
}

如果我初始化 i 用0,它立即找到iSight摄像机。如果我用1初始化 i ,那么当 i = 500时,它再次找到iSight。

If I initialize i with 0 it immediately finds the iSight camera. If I initialize i with 1, then it finds iSight again when i = 500.

如何解决这个问题?

推荐答案

code> break; 。可能你会发现不只一个摄像头,其中一个将WebCam。

请注意, cap.open 的参数不仅是相机 - 它还定义了您要使用的API:

相机调度方法:index是相机编号。

*如果给定索引从0到99,它会尝试找到可访问给定摄像机索引的第一个

* API。

*添加100的倍数以选择一个API。
来自cap.cpp的注释)

可能性:

CV_CAP_ANY = 0,// autodetect

CV_CAP_MIL = 100,// MIL专有驱动程序

CV_CAP_VFW = 200,//平台本机

CV_CAP_V4L = 200,
CV_CAP_V4L2 = 200,

CV_CAP_FIREWARE = 300,// IEEE 1394驱动程序

CV_CAP_FIREWIRE = 300,

CV_CAP_IEEE1394 = 300,

CV_CAP_DC1394 = 300,

CV_CAP_CMU1394 = 300,

CV_CAP_STEREO = 400,// TYZX专有驱动程序

CV_CAP_TYZX = 400,

CV_TYZX_LEFT = 400,

CV_TYZX_RIGHT = 401,

CV_TYZX_COLOR = 402,

CV_TYZX_Z = 403,

CV_CAP_QT = 500,// QuickTime

CV_CAP_UNICAP = 600,// Unicap驱动程序

CV_CAP_DSHOW = 700,// DirectShow(通过videoInput)

CV_CAP_PVAPI = 800,// PvAPI,Prosilica GigE SDK

CV_CAP_OPENNI = 900,// OpenNI br>
CV_CAP_OPENNI_ASUS = 910,// OpenNI(用于Asus Xtion)

CV_CAP_ANDROID = 1000,// Android

CV_CAP_XIAPI = 1100,// XIMEA Camera API

CV_CAP_AVFOUNDATION = 1200 // iOS的AVFoundation框架(OS X Lion将具有相同的API)
(来自highgui_c.h)

可能 CV_CAP_AVFOUNDATION = 1200 是你正在寻找的 - 尝试从1200开始循环,不要忘记删除 break; 你会发现你在找什么。

Try to run your code without this line: break;. Probably you will find more than just one camera, and one of them will WebCam.
Note that parameter of cap.open is not only the number of camera - it also defines which API you want to use:
Camera dispatching method: index is the camera number.
* If given an index from 0 to 99, it tries to find the first
* API that can access a given camera index.
* Add multiples of 100 to select an API.
(comment from cap.cpp)
Possibilities:
CV_CAP_ANY =0, // autodetect
CV_CAP_MIL =100, // MIL proprietary drivers
CV_CAP_VFW =200, // platform native
CV_CAP_V4L =200, CV_CAP_V4L2 =200,
CV_CAP_FIREWARE =300, // IEEE 1394 drivers
CV_CAP_FIREWIRE =300,
CV_CAP_IEEE1394 =300,
CV_CAP_DC1394 =300,
CV_CAP_CMU1394 =300,
CV_CAP_STEREO =400, // TYZX proprietary drivers
CV_CAP_TYZX =400,
CV_TYZX_LEFT =400,
CV_TYZX_RIGHT =401,
CV_TYZX_COLOR =402,
CV_TYZX_Z =403,
CV_CAP_QT =500, // QuickTime
CV_CAP_UNICAP =600, // Unicap drivers
CV_CAP_DSHOW =700, // DirectShow (via videoInput)
CV_CAP_PVAPI =800, // PvAPI, Prosilica GigE SDK
CV_CAP_OPENNI =900, // OpenNI (for Kinect)
CV_CAP_OPENNI_ASUS =910, // OpenNI (for Asus Xtion)
CV_CAP_ANDROID =1000, // Android
CV_CAP_XIAPI =1100, // XIMEA Camera API
CV_CAP_AVFOUNDATION = 1200 // AVFoundation framework for iOS (OS X Lion will have the same API)
(from highgui_c.h)
Probably CV_CAP_AVFOUNDATION = 1200 is what you are looking for - try to start you loop from 1200 and don't forget to remove break; and i think that you will find what you are looking for.

这篇关于Mac上的OpenCV不打开USB网络摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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