Ask Your Question
0

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

asked 2014-11-07 16:28:16 -0500

Nimble_Ninja gravatar image

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;

}
edit retag flag offensive close merge delete

Comments

1

please triple-check the opencv libs your program is linking. do not use debug libs with a release build, or the other way round.

"gibberrish" strings are mostly a result of linking to different models of the c++stdlib.

berak gravatar imageberak ( 2014-11-08 00:22:45 -0500 )edit
1

yes you are right berak... I added the files to a global property sheet and not to the debug sheet... have fixed issue and works perfect... Thank you for getting me pointed in the right direction!!!!

Nimble_Ninja gravatar imageNimble_Ninja ( 2014-11-08 10:14:22 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-11-07 16:47:05 -0500

wolfram79 gravatar image

Hi Ninja,

try to initialize named windows first

(...)

cv::namedWindow("RedCamera"); cv::namedWindow("BlackCamera");

for (;;){

(...)

cv::imshow("RedCamera", cameraFrame1); cv::imshow("BlackCamera", cameraFrame2);

(...)

(see also:)

http://stackoverflow.com/questions/19565262/opencv-imshow-does-not-work

edit flag offensive delete link more

Comments

Thanks for the response... I tried the code you posted and it did not work. A small blank screen did appear and then another one with the stream from camera2. It seems like it dumps the image from camera 1 and does not hold on to it. BTW the name on the window was gibberish and has been that way for all my applications...

Nimble_Ninja gravatar imageNimble_Ninja ( 2014-11-07 17:46:47 -0500 )edit

looks like I had lib files in a global property sheet instead of a local one... code runs!!! thanks for all the help!

Nimble_Ninja gravatar imageNimble_Ninja ( 2014-11-08 10:23:01 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-11-07 16:28:16 -0500

Seen: 376 times

Last updated: Nov 07 '14