livestream closing with 0 entering

asked 2018-05-18 08:34:31 -0600

Hi,

my problem is that I cannot enter any letter or number. Actually I want to close the live stream with entering 0.

What did i do wrong?

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

using namespace cv;
using namespace std;

int live()
{
    int eingabe;

    VideoCapture cam1(0);
    if (!cam1.isOpened()) cout << "Cam1 doesn't work" << endl;

    VideoCapture cam2(1);
    if (!cam2.isOpened()) cout << "R doesn't work" << endl;

    /*
    VideoCapture cam3(2);
    if (!cam3.isOpened()) cout << "R doesn't work" << endl;
    */

    Mat src1, src2, src3;

    while (1)
    {
        scanf("%d", &eingabe);

        cam1 >> src1;
        cam2 >> src2;
        // cam3 >> src3;
        imshow("Cam1", src1);
        imshow("Cam2", src2);
        // imshow("Cam3", src3);
        waitKey(1);

        if (eingabe == 0)
            break;
    }

    src1.release();
    src2.release();
    // src3.release();

    return 0;
}
edit retag flag offensive close merge delete

Comments

scanf will only take input if the console window has focus. waitKey() will ony react, if the highgui windw has focus. it seems, you confuse that.

berak gravatar imageberak ( 2018-05-18 09:25:13 -0600 )edit