Ask Your Question
0

Opencv 3.1 capture from multiple cameras.

asked 2016-07-19 12:17:11 -0600

dejnus gravatar image

I'm using 2 Logitech C170 usb webcams connected to USB 3.0 ports on my front panel on Windows 10 Opencv 3.1 Visual Studio 2015. I have no problem getting image from one camera at a time either 0 or 1 but while I'm trying to get both at the same time i get a message:

R doesn't work

in console which is linked to second camera not working in the same time, followed by error:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow

Code I'm using:

#include <opencv2\opencv.hpp>
#include <opencv\highgui.h>

using namespace cv;
using namespace std;

int main()
{
    VideoCapture captureL(0);
    if (!captureL.isOpened()) cout << "L doesn't work" << endl;
    VideoCapture captureR(1);
    if (!captureR.isOpened()) cout << "R doesn't work" << endl;

    Mat imageL, imageR;

    while (1)
    {
        captureL >> imageL;
        captureR >> imageR;
        imshow("OriginalL", imageL);
        imshow("OriginalR", imageR);
        waitKey(1);
    }
captureL.release();
captureR.release();
return 0;
}

Is there any way to fix that? It must be possible to get multiple captures at once. Maybe I'm doing something wrong since it is the newest Opencv 3.1.

edit retag flag offensive close merge delete

Comments

1

I dont't think that this is an OpenCV problem. It is more likely a hardware problem. USB webcams tend to use as much usb bandwidth as possible. So if your two cameras are connected to the same usb bus, the first webcam will take all the bandwidth and there is no space left for the second webcam. Maybe you could use two different usb hosts to connect both webcams.

Missing gravatar imageMissing ( 2016-07-20 02:38:14 -0600 )edit

I just took your advice and seems like it was the problem, I've tried every possible combination plugging it in the back of my pc and finally it worked!

dejnus gravatar imagedejnus ( 2016-07-20 06:56:57 -0600 )edit

That is the problem of USB cameras as stated before. Get yourself a decent stereo setup with firewire camera's or something else with a dedicated data line to each cam. Using seperate USB busses (one in the front, one in the back of your PC) is only a partial solution.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-07-20 07:01:49 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-04-22 11:26:13 -0600

f.istvan gravatar image

updated 2017-04-22 11:27:30 -0600

Old thread, but still rather relevant.
USB2.0 hubs don't have the bandwidth to handle more than one camera. It needs one hub per camera. In a desktop machine you can get it by using one PCI USB board for each camera.
The reason why USB3 does not help, is that the USB3.0 hub serves the USB2.0 camera by simply switching into 2.0 mode. So the minute you connect a 2.0 camera, you'll have a 2.0 hub on the other end, thus there is no way to utilize the extra bandwidth of the 3.0. with 2.0 cameras. The solution here is also to use more than one hubs.

edit flag offensive delete link more

Comments

I'm not sure of your answer. I can connect 2 logitech c270 on same usb bus but not three because current (A) delivers by usb bus is not suffisent

LBerger gravatar imageLBerger ( 2017-04-22 11:31:46 -0600 )edit

I have the same issue using multiple cameras connected to a USB3.0 hub. If I use independent USB ports it just works but using the hub fails. The problem is that I need to use a laptop so I can't use a PCI USB board. Interesting that nobody has posted a solution for this problem yet.

Ariel Bernal gravatar imageAriel Bernal ( 2018-01-25 01:35:43 -0600 )edit

Have you got a power supply on USB3.0 hub?

LBerger gravatar imageLBerger ( 2018-01-25 01:37:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-19 12:17:11 -0600

Seen: 13,122 times

Last updated: Apr 22 '17