1

I have a multiple camera setup and an OpenCV application that has been working using two cameras. One camera is a Logitech C310, and the other has been my built-in camera on my MacBook Pro. On initialization I call cvCaptureFromCAM(), once for each camera. However, hooking up a second Logitech C310 (total of 3 cameras) causes the call to cvCaptureFromCAM() to hang for my MacBook pro camera.

Both Logitech cameras work together just fine. Once I call cvQueryFrame() for my MacBook camera it hangs, but eventually after maybe 2-3 minutes it returns what appears to be a valid pointer (i.e. not NULL), but that camera is not initialized. I receive no frames from that camera, and the light that is typically green when the camera is in use is not lit.

Here is a snippet of my code:

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.

I am certain this is not an issue with multiple threads, because cvQueryFrame() always hangs, even if I do not start any new threads.

Thanks for any help - I'm having trouble finding anyone else with a similar issue.

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

Jamie
  • 76
  • 3
  • Probably it will not work, but you may try to use different API(maybe there is some bug in default one) - http://stackoverflow.com/questions/14187866/opencv-on-mac-not-opening-usb-web-camera/14188280#14188280 – cyriel Aug 22 '13 at 23:30
  • I'm continuing to dig into this, but it looks like this may not have anything to do with OpenCV, and perhaps just an issue with my MacBook Pro. If I connect 2 webcams to my laptop (plus 1 built in iSight) and view the live video, the first two work fine but the third one locks up and never initializes. – Jamie Aug 23 '13 at 15:49

1 Answers1

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!

Jamie
  • 76
  • 3
  • USB 2.0 bandwidth is a likely cause, there is quite a number of topics here on this limit - http://stackoverflow.com/questions/11222813/2-usb-cameras-not-working-with-opencv?lq=1 – Roman R. Aug 26 '13 at 17:18