Python OpenCV - namedWindow() Function Last Updated : 03 Jan, 2023 Comments Improve Suggest changes Like Article Like Report 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. Created windows are referred by their names and can also be used as a placeholder. The function does nothing If a window exists with the same name. Syntax: cv2.namedWindow(window_name, flag) Parameters: window_name: Name of the window that will display image/videoflag: Represents if window size is automatically set or adjustable. Some of the flag values are: WINDOW_NORMAL - Allows to manually change window sizeWINDOW_AUTOSIZE(Default) - Automatically sets the window sizeWINDOW_FULLSCREEN - Changes the window size to fullscreen Return Value: It doesn't return anything Image used for all the below examples: Example 1: Working of namedWindow() method with automatically sets the window size Python3 # Python program to explain cv2.namedWindow() method # Importing OpenCV import cv2 # Path to image in local directory path = 'C:/Users/art/OneDrive/Desktop/geeks.png' # Using cv2.imread() to read an image in default mode image = cv2.imread(path) # Using namedWindow() # A window with 'Display' name is created # with WINDOW_AUTOSIZE, window size is set automatically cv2.namedWindow("Display", cv2.WINDOW_AUTOSIZE) # using cv2.imshow() to display the image cv2.imshow('Display', image) # Waiting 0ms for user to press any key cv2.waitKey(0) # Using cv2.destroyAllWindows() to destroy # all created windows open on screen cv2.destroyAllWindows() Output: Explanation: In this code, in order to use namedWindow function OpenCV python library is imported. Then by using cv2.imread, a file from a particular location(path) is loaded into 'image' variable in default mode. Now to create a window with 'Display' name and automatic size for image namedWindow is used. By using cv2.imshow, the custom window is displayed on the screen. After waiting for 0ms user can destroy all windows by pressing any key from the keyboard. Example 2: Manually change the window size Python3 # Python Program to explain namedWindow() method # Importing OpenCV import cv2 # Path to image in local directory path = 'C:/Users/art/OneDrive/Desktop/geeks.png' # Using cv2.imread() to read an image in grayscale mode image = cv2.imread(path, 0) # Using namedWindow() # A window with 'Display_Image' name is created # with WINDOW_NORMAL allowing us to have random size cv2.namedWindow("Display_Image", cv2.WINDOW_NORMAL) # Using cv2.imshow() to display the image cv2.imshow('Display_Image', image) # Waiting 0ms for user to press any key cv2.waitKey(0) # Using cv2.destroyAllWindows() to destroy # all created windows open on screen cv2.destroyAllWindows() Output: Note: When a user randomly changes size, the window size is changed dimensions of the image remain unchanged. Comment More infoAdvertise with us Next Article Python OpenCV - namedWindow() Function vibhutijain99 Follow Improve Article Tags : Python OpenCV Python-OpenCV Practice Tags : python Similar Reads Python OpenCV - moveWindow() Function When we show the image using the imshow() function output window will open at the center or default position of a computer screen. Even if there are multiple image windows all windows will be displayed at the same position and we have to move windows manually. If we want to show image windows at a s 2 min read Python OpenCV - getWindowImageRect() Function Python OpenCV getWindowImageRect() Function returns the client screen coordinates, along with the width and height of the window containing the picture. Syntax of cv2.getWindowImageRect() Syntax: cv2.getWindowImageRect(window_name) Parameter: window_name - Name of the window displaying image/video 3 min read Python OpenCV - waitKey() Function waitkey() function of Python OpenCV allows users to display a window for given milliseconds or until any key is pressed. It takes time in milliseconds as a parameter and waits for the given time to destroy the window, if 0 is passed in the argument it waits till any key is pressed. Example: Pythonim 2 min read Python OpenCV - waitKeyEx() Function Python OpenCv waitKeyEx() method is similar to waitKey() method but it also returns the full key code. The key code which is returned is implementation-specific and depends on the used backend: QT/GTK/Win32/etc. Syntax: cv2.waitKey(delay) Parameters: delay: The time in milliseconds after which windo 2 min read Python - Move() function in wxPython In this particular article we will learn, how can we move our window to a particular point. This can be achieved using Move() function in wx.Window class of wxPython. Move() takes x and y points to move window to a particularx, y point. Syntax : wx.Move(self, x, y, flags=SIZE_USE_EXISTING) Parameter 1 min read Python OpenCV | cv2.imshow() method OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.imshow() method is used to display an image in a window. The window automatically fits the image size. Syntax: cv2.imshow(window_name, image)Parameters: window_name: A string representing the name of the wi 3 min read Python | How to get function name ? One of the most prominent styles of coding is following the OOP paradigm. For this, nowadays, stress has been to write code with modularity, increase debugging, and create a more robust, reusable code. This all encouraged the use of different functions for different tasks, and hence we are bound to 3 min read Python OpenCV - resizeWindow() Function resizeWindow() method in Python OpenCV is used to resize window displaying images/videos to a specific size. The specified window size is for images excluding toolbars. This only works for created windows having flags other than CV_WINDOW_AUTOSIZE. Syntax: cv2.resizeWindow(window_name, width, height 1 min read Python OpenCV - destroyWindow() Function Python Opencv destroyWindow() function is used to close particular windows. This function takes one parameter that is window name which you want to close or destroy and it doesn't return anything. Syntax: cv2.destroyWindow(window_name) Parameter: window_name: name of the window which you want to des 1 min read Handle mouse events in Python - OpenCV OpenCV is one of the most popular computer vision libraries. If you want to start your journey in the field of computer vision, then a thorough understanding of the concepts of OpenCV is of paramount importance. Note: For more information, refer to Introduction to OpenCV Handling Mouse Evenets OpenC 2 min read Like