imshow ignores window opened by namedWindow

asked 2018-04-05 07:45:39 -0600

mobert gravatar image

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?

edit retag flag offensive close merge delete

Comments

  • make sure, the window names are really the same
  • double-check your linker settings. use opencv debug libs (with trailing 'd') for DEBUG build only nad also release libs for RELEASE build ONLY , don't mix, or use both !
berak gravatar imageberak ( 2018-04-05 07:53:32 -0600 )edit