How can i make a zoom box on opencv window

hi guys
i am showing an image on opencv window
with
img = cv2.imread(c:/35.jpg")
cv2.imshow(“field”, img)
in python
i would like my app work like below image
now i dont know how can i zoom on image same this image >
4656456456
i need to when i press a key for example (“Z” key) on my keyboard
appear a little square box on up and left place on image that (zoomed 2x) that it show curser mouse place
and then hide this zoom box by a key for example “X”
thanks in advance
any help is great

Hi @payam_mohammadi

OpenCV has a very limited GUI for debugging purposes. You can use QT or any GUI library to add buttons, menus, subwindows, but they are not part of OpenCV.

If you want to show a zoom subwindow with OpenCV HighGUI, you must compose an image and show it with imshow. So, there isn’t a subwindow, it is the image with the zoom pasted on it.

When you press Z you must read x,y mouse coordinate, grab a roi around it, zoom it and paste it wherever you want, let’s say on top left of the background image. Then imshow the composed image. When you press X, imshow the original image.

I hope it helps.

1 Like