I have an image that is 6400 × 3200, while my screen is 1280 x 800. Therefore, the image needs to be resized for display only. I am using Python and OpenCV 2.4.9. According to OpenCV Documentation,
If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow.
That is what I am doing, but the image is not fitted to the screen, only a portion is shown because it's too big. I've also tried with cv2.resizeWindow, but it doesn't make any difference.
import cv2 cv2.namedWindow("output", cv2.WINDOW_NORMAL) # Create window with freedom of dimensions # cv2.resizeWindow("output", 400, 300) # Resize window to specified dimensions im = cv2.imread("earth.jpg") # Read image cv2.imshow("output", im) # Show image cv2.waitKey(0) # Display the image infinitely until any keypress
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products.
Python-OpenCV is just a wrapper around the original C/C++ code. It is normally used for combining best features of both the languages, Performance of C/C++ & Simplicity of Python. So when you call a function in OpenCV from Python, what actually run is underlying C/C++ source.
OpenCV-Python is a library of Python bindings designed to solve computer vision problems. Python is a general purpose programming language started by Guido van Rossum that became very popular very quickly, mainly because of its simplicity and code readability.
Although I was expecting an automatic solution (fitting to the screen automatically), resizing solves the problem as well.
import cv2 cv2.namedWindow("output", cv2.WINDOW_NORMAL) # Create window with freedom of dimensions im = cv2.imread("earth.jpg") # Read image imS = cv2.resize(im, (960, 540)) # Resize image cv2.imshow("output", imS) # Show image cv2.waitKey(0) # Display the image infinitely until any keypress
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With