Displaying Images
cv2.imshow() method is used to display an image in a window. The window automatically fits the image size.
Example: Python OpenCV Display Images
Python3
# Python code to read image import cv2 # To read image from disk, we use # cv2.imread function, in below method, img = cv2.imread( "geeks.png" , cv2.IMREAD_COLOR) # Creating GUI window to display an image on screen # first Parameter is windows title (should be in string format) # Second Parameter is image array cv2.imshow( "w3wiki" , img) # To hold the window on screen, we use cv2.waitKey method # Once it detected the close input, it will release the control # To the next line # First Parameter is for holding screen for specified milliseconds # It should be positive integer. If 0 pass an parameter, then it will # hold the screen until user close it. cv2.waitKey( 0 ) # It is for removing/deleting created GUI window from screen # and memory cv2.destroyAllWindows() |
Output:
Getting Started with Python OpenCV
Computer Vision is one of the techniques from which we can understand images and videos and can extract information from them. It is a subset of artificial intelligence that collects information from digital images or videos.
Python OpenCV is the most popular computer vision library. By using it, one can process images and videos to identify objects, faces, or even handwriting of a human. When it is integrated with various libraries, such as NumPy, python is capable of processing the OpenCV array structure for analysis.
In this article, we will discuss Python OpenCV in detail along with some common operations like resizing, cropping, reading, saving images, etc with the help of good examples.