Life2Coding
Resize the OpenCV Window According to the Screen Resolution

This post will be helpful in learning OpenCV using Python programming. Here I will show how to implement OpenCV functions and apply it in various aspects using some examples. Then the output will be shown with some comparisons as well.

Requirements:

First, you need to setup your Python Environment with OpenCV. You can easily do it by following Life2Coding’s tutorial on YouTube: Linking OpenCV 3 with Python 3

Goals:

In this tutorial, I will show you how to resize the input image according to the screen resolution.

Documentation:

Python: cv2.resizeWindow(winname, width, height) → None

Resizes window to the specified size

Parameters: 

  • winname – Window name
  • width – The new window width
  • height – The new window height

Note

  • The specified window size is for the image area. Toolbars are not counted.
  • Only windows created without CV_WINDOW_AUTOSIZE flag i.e with CV_WINDOW_NORMAL flag can be resized.

 Steps:

  • Load Image using cv2.imread()
  • Create window using cv2.namedWindow()
  • Resize the window using cv2.resizeWindow()
  • Display Image using cv2.imshow()
  • Wait for keyboard button press using cv2.waitKey()
  • Exit window and destroy all windows using cv2.destroyAllWindows()

Example Code:

Output:

1.-210x250 Resize the OpenCV Window According to the Screen Resolution resize-114x250 Resize the OpenCV Window According to the Screen Resolution

life2coding_icon [] Resize the OpenCV Window According to the Screen Resolution

Life2Coding

Technology Related Blog at Life2Coding
Feel free to contact us for your any kind of technical problems. We are here to help you.
life2coding_icon [] Resize the OpenCV Window According to the Screen Resolution

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.