Zooming functionality in OpenCV imshow in Windows

2020-05-08 00:42发布

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?

1条回答
再贱就再见
2楼-- · 2020-05-08 01:24

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)
查看更多
登录 后发表回答