【发布时间】:2014-05-06 01:43:44
【问题描述】:
我有 64 位的 ubuntu 系统。我在idel中运行代码。 我正面临 opencv 挂起问题,图像显示但我必须强制终止图像窗口。所以参考了这个帖子——Using other keys for the waitKey() function of opencv
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)的问题。