opencv-python namedWindow() can't resize window

Viewed 9137

I am using namedWindow() function in my code to resize the image's window. The mouse cursor showing i can resize the windows, but it actually can't. Here is my code

import numpy as np
import cv2

img=cv2.imread('/home/jeff/Downloads/iphone.png', 1)
cv2.namedWindow('image',cv2.WINDOW_NORMAL)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

Please assist. Thanks.

2 Answers

Replace code line cv2.namedWindow('image',cv2.WINDOW_NORMAL) with following:

cv2.namedWindow('image',cv2.WINDOW_AUTOSIZE)

There is a bug (at least in v3.2.0) that the resizing does not work if the image is bigger than the screen resolution. See the issue on GitHub.

Related