multiple cameras [closed]

asked 2013-06-19 02:19:45 -0600

Philippe gravatar image

updated 2013-06-19 03:08:36 -0600

Guanta gravatar image

Hi All.

I would like to connect 6 cameras to my PC. In OpenGL, I have no problems (used openframeworks in codeblocks). In Opencv I can connect to each camera sequentially, or even 2 simultaneously, however I cannot get a live feed from all 6 at the same time. 1 or 2 of the cameras may still display an image (after long delays), while the others remain blank. I suspect a bug in opencv. Anyone out there with a solution? I suspect that internally they buffers are clashing, the frames not updating or something similar. Code below.

#include <opencv2/opencv.hpp>

int main()
    //initialize and allocate memory to load the video stream from camera
    cv::VideoCapture camera0(0);
    cv::VideoCapture camera1(4);
    cv::VideoCapture camera2(5);

    if( !camera0.isOpened() ) return 1;
    if( !camera1.isOpened() ) return 1;
    if( !camera2.isOpened() ) return 1;

    while(true) {
        //grab and retrieve each frames of the video sequentially
        cv::Mat3b frame0;
        camera0 >> frame0;
        cv::Mat3b frame1;
        camera1 >> frame1;
        cv::Mat3b frame2;
        camera2 >> frame2;

        cv::imshow("Video0", frame0);
        cv::imshow("Video1", frame1);
        cv::imshow("Video2", frame2);

        //wait for 40 milliseconds
        int c = cvWaitKey(100);

        //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27)
        if(27 == char(c)) break;

    return 0;
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-09-27 06:27:47.549715