Python OpenCV - waitKeyEx() Function Last Updated : 03 Jan, 2023 Comments Improve Suggest changes Like Article Like Report 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 windows needs to destroyed. If given 0 it waits for infinite till any key is pressed to destroy window. Return : This method return the full key code of the key which is pressed. If no key is pressed it return -1. Example 1: In the below example we have implemented the waitKeyEx() method we have made a window that has an image named "gfg_logo.png" and then we display it and using waitKeyEx() method we delay the closing of the window and then press a key to close it. We store the returned value in the full_key_code variable and print it. Python # importing cv2 module import cv2 # read the image img = cv2.imread("gfg_logo.png") # showing the image cv2.imshow('gfg', img) # waiting using waitKeyEX method and storing # the returned value in full_key_code full_key_code = cv2.waitKeyEx(0) # printing the variable print("The key code is:"+str(full_key_code)) Output: The key code is:13 In the output, the value of full_key_code will be printed according to the key pressed When we press enter the value that is printed is as follows. Example 2: Another Example we can see is where we don't press any key and wait for the window to destroy automatically after the delay that is given. We will pass 5000 as a parameter to wait for 5 seconds and then a window will close automatically without the need of pressing any key. In this case the function will return -1 as no key was pressed. Python # importing cv2 module import cv2 # read the image img = cv2.imread("gfg_logo.png") # showing the image cv2.imshow('gfg', img) # waiting using waitKeyEX method and # storing the returned value in full_key_code full_key_code = cv2.waitKeyEx(5000) # printing the variable print("The key code is:"+str(full_key_code)) Output: The key code is:-1 Comment More infoAdvertise with us Next Article Python OpenCV - waitKeyEx() Function Y yashgupta0524 Follow Improve Article Tags : Python OpenCV Python-OpenCV Practice Tags : python Similar Reads 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 - setWindowTitle() Function Python OpenCV setWindowTitle() method used for giving the title of the windows. It takes 2 parameters that are windows name and the title that needs to be given. Both the parameters are expected to be of string type. Syntax: cv2.setWindowTitle( winname, title ) Parameters: winname: windows nametitl 1 min read Python OpenCV - startWindowThread() Function This article will discuss how to use the python OpenCV startWindowThread() function. Do you want to display images and videos using a simplified interface through an OpenCV code? Then, you must check out the OpenCV startWindowsThread() function, which lets you use the high GUI windows, i.e., a simpl 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 - 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 - namedWindow() Function 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 3 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 Python OpenCV - haveImageReader() function In this article, we are going to learn about the haveImageReader() function of the OpenCV library. The haveImageReader() function is used to check whether specified images can be decoded or read successfully by OpenCV or not. Sometimes we need to detect if the specified image file is being correctl 1 min read Python OpenCV - haveImageWriter() function In this article, we are going to learn about the haveImageWriter() function of the OpenCV library. haveImageWriter() function Sometimes we need to detect if the specified image file is being correctly written or not before continuing further, In such a case we can use OpenCV which helps us to proces 2 min read Python OpenCV - destroyAllWindows() Function Python Opencv destroyAllWindows() function allows users to destroy or close all windows at any time after exiting the script. If you have multiple windows open at the same time and you want to close then you would use this function. It doesn't take any parameters and doesn't return anything. It is s 2 min read Like