Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

imshow() shows the image after scanf_s()

Hello,

I would like to get some user input after I show an image. But even though imshow() is being executed, it waits till the user input to show the image. I get an empty window until scanf_s() is done. Why is this happening?

I am using Visual Studio 2013, and OpenCV 2.4.11.

Here is a little demo:

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main()
{   
    char in[15];
    namedWindow("Source", 1);

    Mat src = imread("toy.png");

    imshow("Source", src);

    scanf_s("%s", in, sizeof in);

    waitKey();
    return 0;
}

toy.png: toy

imshow() shows the image after scanf_s()

Hello,

I would like to get some user input after I show an image. But even though imshow() is being executed, it waits till the user input to show the image. I get an empty window until scanf_s() is done. Why is this happening?

I am using Visual Studio 2013, and OpenCV 2.4.11.

Here is a little demo:

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main()
{   
    char in[15];
    namedWindow("Source", 1);

    Mat src = imread("toy.png");

    imshow("Source", src);

    scanf_s("%s", in, sizeof in);

    waitKey();
    return 0;
}

toy.png: toy