0

I need to be able to zoom in and out of an image I show using cv2.imshow(). I read that this can be done by adding a flag that enables an expanded gui display.

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

However, running this does not seem to make a difference, and I don't see any buttons on the gui window I create. Is there anything I need to install and how should I run it? I'm not getting any errors.

Thank you.

  • Does this answer your question? [Zooming functionality in OpenCV imshow in Windows](https://stackoverflow.com/questions/50533775/zooming-functionality-in-opencv-imshow-in-windows) – Grillteller May 11 '20 at 12:24

1 Answers1

0

imshow zooming should work via built-in mouse events without WINDOW_GUI_EXPANDED.

For imshow or your particular use case, there are two requirements for zooming to work:

  • OpenCV is compiled with Qt library support
  • A thread is currently free to handle the window events (cv.waitKey(0) blocking in the main thread, or cv.startWindowThread() to spool up a background thread for window events)

I was never able to get QT support to work in windows with python. It works seamlessly in linux. And by building from source on windows with c++, it also works.

I believe that for python you need to install by copying the pyd file in C:\opencv\build\python\cv2\python-3 to your packages folder. Or you need to compile with the global python directories specified in the cmake config.

VoteCoffee
  • 4,692
  • 1
  • 41
  • 44