1

System information (version)

  • OpenCV => python-opencv/bionic-updates,bionic-security,now 3.2.0+dfsg-4ubuntu0.1 amd64 [installed]
  • Operating System / Platform => Ubuntu 18.04
  • EDIT: GTK backend, I use Xubuntu.
  • EDIT: I didn't build opencv, I just installed the python-opencv package through APT.

Detailed description

WINDOW_NORMAL does not work when image is higher than display resolution.

I have two images: the big one is 2560x2048, the small one is 750x600. My display is set to 1920x1080 resolution.

When I load the small one using the code below, everything works as expected: I can resize and maximize the window, and image "scales" to window size.

Now I load the big one (which is exactly the same image, just bigger). Resize doesn't work (it just moves the window instead). Maximize sets the window and the image to the original resolution, which is much bigger than my display resolution, and can't see the whole image on my screen.

One thing that I noticed is that in version 2.4 I could resize the window to a size lower than the image resolution. This doesn't work anymore in version 3.2 and might be key to the problem.

Note: This seems a similar issue, but is not. I can't resize the image because I'm interested in the coordinates of the user when he clicks on the image.

Steps to reproduce

import cv2

path="/tmp/img.jpg" # or small_img.jpg

img = cv2.imread(path, 1)
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
ferranrigual
  • 329
  • 1
  • 7
  • Maybe edit in the [bug report](https://github.com/opencv/opencv/issues/13995) you created... I was already going to suggest you go and post it there :) | Any change to try with a more recent version? What HighGUI backend does this build use (one of gtk or qt... maybe dump out the buildinformation) – Dan Mašek Mar 07 '19 at 14:28
  • Thanks Dan! I edited the post with answers to your questions. Is there any more information that I can provide? – ferranrigual Mar 07 '19 at 17:17
  • you can try cv2.WINDOW_FREERATIO instead. – Gopiraj Mar 08 '19 at 06:17
  • Thanks! We tried all of them just in case, without success. – ferranrigual Mar 08 '19 at 10:26

1 Answers1

0

another possibility is resizing the image for output displaying, if its only for debugging purposes.

try imutils.resize

Peter F
  • 420
  • 4
  • 12
  • This is for a desktop application that needs to run in multiple desktops. I could ask the system about the screen resolution, but would like to avoid it. – ferranrigual Nov 15 '19 at 14:34