2

I am trying set up a multi-camera system in VS17 win10 OpenCV environment using VideoCapture function from OpenCV library. Cameras are Basler USB 3.0 (3840*2748 monochrome). I had no issue to open and stream up to four cameras. However, the fifth camera or more was not able to be opened. Whereas, all six cameras can be accessed with no issue using Basler software. I am not sure if there is a hardware limitation (like USB bandwidth or PCI bus), which should not be because in Basler SDK, all cameras can be used as normal.

I have tried to set lower resolution image to see if it is USB bandwidth limit, but still not working.

int main(){

    VideoCapture cap0(0), cap1(1), cap2(2), cap3(3), cap4(4), cap5(5);
Mat ca1, ca2, ca3, ca4, ca5, ca6;
cv::namedWindow("Camera1", WINDOW_NORMAL);
cv::namedWindow("Camera2", WINDOW_NORMAL);
cv::namedWindow("Camera3", WINDOW_NORMAL);
cv::namedWindow("Camera4", WINDOW_NORMAL);
cv::namedWindow("Camera5", WINDOW_NORMAL);
cv::namedWindow("Camera6", WINDOW_NORMAL);
while (true) {
    if (cap0.grab()) {
        cap0.retrieve(ca1);
    }
    if (!cap0.grab()) {
        std::cout << "camera 0 cannot be grabbed\n";
    }
    if (cap1.grab()) {
        cap1.retrieve(ca2);
    }
    if (!cap1.grab()) {
        std::cout << "camera 1 cannot be grabbed\n";
    }
    if (cap2.grab()) {
        cap2.retrieve(ca3);
    }
    if (!cap2.grab()) {
        std::cout << "camera 2 cannot be grabbed\n";
    }
    if (cap3.grab()) {
        cap3.retrieve(ca4);
    }
    if (!cap3.grab()) {
        std::cout << "camera 3 cannot be grabbed\n";
    }
    if (cap4.grab()) {
        cap3.retrieve(ca5);
    }
    if (!cap4.grab()) {
        std::cout << "camera 4 cannot be grabbed\n";
    }
    if (cap5.grab()) {
        cap3.retrieve(ca6);
    }
    if (!cap5.grab()) {
        std::cout << "camera 5 cannot be grabbed\n";
    }
    cv::imshow("Camera1", ca1);
    cv::imshow("Camera2", ca2);
    cv::imshow("Camera3", ca3);
    cv::imshow("Camera4", ca4);
    cv::imshow("Camera5", ca5);
    cv::imshow("Camera6", ca6);
    char c = waitKey(1);
    if (c == 'q') {
        destroyAllWindows();
        break;
    }
}
cap0.release();
cap1.release();
cap2.release();
cap3.release();
cap4.release();
cap5.release();

return 0;

}

Compile fails at cap4.grab(), basically it said camera 4 and 5 cannot be grabbed (opened). Can someone please help? Thank you very much in advance.

image

nathancy
  • 42,661
  • 14
  • 115
  • 137
UT-Doug
  • 21
  • 3
  • Just use the Basler SDK for your image acquisition. – Dan Mašek May 23 '19 at 00:09
  • But I am trying to automate the image processing process. It would be easier to use opencv.. – UT-Doug May 23 '19 at 01:23
  • 1
    Well, then create a bug report on the opencv github, but honestly I wouldn't hold my breath. How many maintainers of an open source library do you think have 6 of those cameras sitting around to even try to reproduce the issue? | Plus, the VideoCapture API is a least common denominator to support several dozen different backends. You have much more control using the SDK directly. – Dan Mašek May 23 '19 at 01:50
  • Thanks for your input. – UT-Doug May 23 '19 at 04:42

0 Answers0