我有64bit的ubuntu系统。我在idel中运行代码。 我正面临opencv挂起问题,图像显示,但我必须强制杀死图像窗口。因此,下文称此主题 - Using other keys for the waitKey() function of opencvopencv cv2.destroyAllWindows()不响应
import cv2
img = cv2.imread('sof.jpg') # load a dummy image
while(1):
cv2.imshow('img',img)
k = cv2.waitKey(3000) & 0xff
if k==32: # SpaceBar key to stop
break
elif k==-1: # normally -1 returned,so don't print it
continue
else:
print k # else print its value
不过它不工作形象挂起,我必须手动关闭它。
您的代码适合我。你可以从命令行shell而不是从空闲中尝试它吗?很久以前,我有空闲和GUI(我认为它是tkinter)的问题。 – KobeJohn