1 | initial version |
That is because of two things 1) You are using the old C - syle API 2) Once a namedWindow has been made, the container keeps existing, however, you should give it the parameter autosize.
What I suggest is using the newer C++ API and the following code
Mat img = imread("jpgTest.jpg");
// show source image
namedWindow("Image", WINDOW_AUTOSIZE);
imshow("Image",img);
// wait on keystroke to close down
waitKey(0);