使用Python在opencv中的imshow不是交互式的 [英] imshow in opencv with python is not interactive
问题描述
imshow()面临一些问题.我正在使用以下代码显示图像:
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()
但是窗口仅显示图像,不显示RGB信息或坐标,也不放大/缩小.我看过教程,似乎人们可以在窗口弹出后立即查看所有这些内容.我尝试搜索是否有人遇到类似问题,但只找到一个答案,说我应该检查我的OpenCV版本是否为3.4+.我的版本是3.4.1,因此应该可以正常工作,但事实并非如此.有人可以帮我吗?
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?
谢谢.
推荐答案
或者,您也可以简单地使用matplotlib库来具有缩放/坐标/RGB功能:
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()
使用Jupyter,您可以尝试:
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.
这篇关于使用Python在opencv中的imshow不是交互式的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!