Zooming functionality in OpenCV imshow in Windows

13,818

Solution 1

see https://gist.github.com/BartG95/1ce8ba1e9c25ec3698d1

appears to be a longer procedure though, so you could instead switch to matplotlib's pyplot function (uses Qt). you need to apply this oneliner before (see Extracting a region from an image using slicing in Python, OpenCV for details):

import cv2
import matplotlib.pyplot as plt

image = cv2.imread("~\\imagedir\\image.jpg")
plt_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
imgplot = plt.imshow(plt_image)

Solution 2

A detour, by PIL:

import cv2
from PIL import Image

img = cv2.imread('lena.jpg')
img2 = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
im_pil = Image.fromarray(img2)
im_pil.show()
Share:
13,818
Atul Balaji
Author by

Atul Balaji

Interested in Deep Learning and Data Science.

Updated on June 09, 2022

Comments

  • Atul Balaji
    Atul Balaji almost 2 years

    In Ubuntu, OpenCV's imshow function has a window where different options such as zoom in, zoom out, pan window, etc, are available, like this:

    enter image description here

    However, in Windows, these features are absent. I have a particular case where I need to deploy my OpenCV code on Windows, where the user needs to zoom into parts of the image.

    Is there any way to access/add these functionalities in Windows also?