Python OpenCV – resizeWindow() Function
Last Updated :
03 Jan, 2023
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)
Parameters:
- window_name: Name of the window that will display image/video
- width: New window width (integer type)
- height: New window height (integer type)
Return Value: It doesn’t return anything
Image used for below examples:
Example 1:
Python3
import cv2
path = 'C:/Users/art/OneDrive/Desktop/geeks.png'
image = cv2.imread(path)
cv2.namedWindow( "Resized_Window" , cv2.WINDOW_NORMAL)
cv2.resizeWindow( "Resized_Window" , 300 , 700 )
cv2.imshow( "Resized_Window" , image)
cv2.waitKey( 0 )
|
Output:
Example 2:
Python3
import cv2
path = 'C:/Users/art/OneDrive/Desktop/geeks.png'
image = cv2.imread(path, 0 )
cv2.namedWindow( "Resize" , cv2.WINDOW_NORMAL)
cv2.resizeWindow( "Resize" , 700 , 200 )
cv2.imshow( "Resize" , image)
cv2.waitKey( 0 )
|
Output:
Share your thoughts in the comments
Please Login to comment...