Ask Your Question

Revision history [back]

Stereo Camera Code: Both are on but only one capture window

Hello, I am trying out some projects to learn how to program and in addition gain some knowledge about computer vision. I am currently in the stage of setting up the stereo vision but am only getting one capture window... the code is below. I want two windows open with a recording from the different camera. Any help is appreciated!!

#include "opencv\cv.h";
#include "opencv2\highgui\highgui.hpp";
#include "opencv2\imgproc\imgproc.hpp";

#include <iostream>;

using namespace cv;
using namespace std;



int main()
{
    VideoCapture stream1(0); //camera 1
    VideoCapture stream2(1); // camera 2

    if (!stream1.isOpened()) { //check if video device 0 has been initialised
        cout << "cannot open camera";
    };

    if (!stream2.isOpened()) { //check if video device 1 has been initialised
        cout << "cannot open camera";
    };


    for (;;){
        Mat cameraFrame1;
        Mat cameraFrame2;

        stream1.read(cameraFrame1);
        stream2.read(cameraFrame2);

        imshow("RedCamera 1", cameraFrame1);
        imshow("BlackCamera 2", cameraFrame2);

        if (waitKey(30) >= 0) break;

    }
    return 0;

}