In OpenCV, I have seen many instances of namedWindow() preceding imshow(); such as:
namedWindow( imageName, CV_WINDOW_AUTOSIZE );
namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );
imshow( imageName, image );
imshow( "Gray image", gray_image );
The above code is from OpenCV documentation.
In one of the posts a user mentions that namedWindow() is not necessary. I myself have never used namedWindow().
From the namedWindow documentation it seems that namedWindow() might be useful with imshow() when the flag is not WINDOW_AUTOSIZE. But is there any use of namedWindow() with WINDOW_AUTOSIZE before imshow()?
Python OpenCV namedWindow() method is used to create a window with a suitable name and size to display images and videos on the screen. The image by default is displayed in its original size, so we may need to resize the image for it to fit our screen.
waitKey() and cv2. destroyAllWindows(). Inside the cv2. waitKey() function, you can provide any value to close the image and continue with further lines of code.
from the documentation to which you refer:
namedWindow creates a window that can be used as a placeholder for images and trackbars. Created windows are referred to by their names.
The fuction namedWindow just makes sure that if you wish to do something with that same window afterwards (eg move, resize, close that window), you can do it by referencing it with the same name.
So if you just want to show it; you don't need to use namedWindow()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With