1

我有一个多摄像头设置和一个一直在使用两个摄像头工作的 OpenCV 应用程序。一个摄像头是罗技 C310,另一个是我 MacBook Pro 上的内置摄像头。在初始化时,我调用 cvCaptureFromCAM(),每台摄像机调用一次。但是,连接第二个 Logitech C310(总共 3 个摄像头)会导致我的 MacBook Pro 摄像头对 cvCaptureFromCAM() 的调用挂起。

两个罗技相机配合得很好。一旦我为我的 MacBook 相机调用 cvQueryFrame() ,它就会挂起,但最终可能在 2-3 分钟后它返回似乎是一个有效指针(即不是 NULL),但该相机没有初始化。我没有从该相机接收到任何帧,并且在使用相机时通常为绿色的灯没有亮起。

这是我的代码片段:

for( size_t i = 0; i < NUM_CAMERAS; i++ ) // Works fine when NUM_CAMERAS is 2, but hangs when it is 3
{
    capture[i] = cvCaptureFromCAM( i );

    if( capture[i] != NULL )
    {
        // Start a thread for each camera
    }
}

// Threads manage calling cvQueryFrame() for each camera.

我确信这不是多线程的问题,因为 cvQueryFrame() 总是挂起,即使我没有启动任何新线程。

感谢您的帮助 - 我无法找到其他有类似问题的人。

OpenCV 2.4.5 OSX 10.8.4 gcc 4.2 Qt 5.0.2 Boost 版本 105300 2.4GHz Intel Core i7, Retina Mac, 8BG RAM 2 x Logitech C310, 1 x MacBook Pro Camera 1 x Frustrated Dude

4

1 回答 1

2

Turns out this is a limitation with my MacBook Pro. Running 2 USB cameras as well as the built-in iSight (which I believe is also USB internally), initialization of the 3rd device hangs. I can't provide a technical reason, but it seems it is a USB bandwidth issue.

I resolved this by using a Thunderbolt dock (http://www.belkin.com/us/p/P-F4U055) which has additional USB ports. Now my application works fine and initializes all cameras as it should. Also verified an Apple Thunderbolt display (which has a built in USB hub) also works.

Cheers!

于 2013-08-26T16:49:33.567 回答