# How can i make a zoom box on opencv window

**URL:** https://forum.opencv.org/t/how-can-i-make-a-zoom-box-on-opencv-window/5442
**Category:** Python
**Created:** [October 2, 2021, 5:42am UTC](https://forum.opencv.org/t/how-can-i-make-a-zoom-box-on-opencv-window/5442 "2021-10-02T05:42:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![payam\_mohammadi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/payam_mohammadi/32/3335_2.png) [@payam\_mohammadi](https://forum.opencv.org/u/payam_mohammadi)
#### Post date: [October 2, 2021, 5:42am UTC](https://forum.opencv.org/t/how-can-i-make-a-zoom-box-on-opencv-window/5442/1 "2021-10-02T05:42:53Z")

</div>

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](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/2/2ad88f8e191e0a2de60a6a8eb75ee4b791ba8988.jpeg)  
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

---

<div class="post-metadata">

### Author: ![Alejandro\_Silvestri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alejandro_silvestri/32/357_2.png) [@Alejandro\_Silvestri](https://forum.opencv.org/u/Alejandro_Silvestri)
#### Post date: [October 3, 2021, 2:29pm UTC](https://forum.opencv.org/t/how-can-i-make-a-zoom-box-on-opencv-window/5442/2 "2021-10-03T14:29:21Z")

</div>

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.
