Ask Your Question

Revision history [back]

imshow ignores window opened by namedWindow

Im new to opencv and im using opencv 3.4 in c++ VS2017. I have problem with displaying image. My code looks like:

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


using namespace std;
using namespace cv;

int main(int argc, char** argv) {

    Mat img;

img = imread("image.bmp", IMREAD_GRAYSCALE);

namedWindow("Original", WINDOW_AUTOSIZE);
imshow("Original", img);

waitKey(0);

img.release();
destroyWindow("Original");

    return 0;
}

When i run code, it opens two windows, one by namedWindow, which is blank(gray) and one by imshow, where the image is diplayed. Waitkey works only with one opened by named named Window function. I have no idea why is imshow craeting new window?