Nour
Nour

Reputation: 307

imshow in opencv with python is not interactive

I am facing a bit of an issue with imshow(). I am displaying an image using the following code:

cv2.namedWindow("image", cv2.WINDOW_GUI_EXPANDED)
cv2.imshow("image", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

(displayed window)

But the window only displays the image, it does not show RGB information or coordinates, and it does not zoom in/out. I have watched tutorials and it seems that people can view all of these things as soon as the window pops up. I tried searching to see if anyone else had a similar problem, and I only found an answer saying that I should check if my OpenCV version is 3.4+. My version is 3.4.1, so it should work fine, but it isn't. Can someone help me with this?

Thanks.

Upvotes: 1

Views: 4243

Answers (1)

Dinesh
Dinesh

Reputation: 1565

Alternatively, you can also simply use matplotlib library to have zoom/coordinates/RGB features:

import cv2
from matplotlib import pyplot as plt

img = cv2.imread('lena.png')
plt.imshow(img)
plt.xticks([]), plt.yticks([])
plt.show()

With Jupyter, you can try:

import cv2
from matplotlib import pyplot as plt

img = cv2.imread('lena.png')
%matplotlib qt
plt.imshow(img)
plt.xticks([]), plt.yticks([])
plt.show()

You may need few dependencies.

Upvotes: 3

Related Questions