简体   繁体   English

cv2.waitKey(0) 不要等待

[英]cv2.waitKey(0) doen't wait

key = cv2.waitKey(0)
print(key)
>>>-1

I have known that "cv2.waitKey(0)" wait and code does nothing until any key is pressed.我知道“cv2.waitKey(0)”等待并且代码在按下任何键之前什么都不做。

how can I make "cv2.waitKey(0)" work??我怎样才能使“cv2.waitKey(0)”工作?

from the doc cv2.waitKey(delay) waits for delay milliseconds and also, The function only works if there is at least one HighGUI window created and the window is active.来自文档cv2.waitKey(delay) 等待delay毫秒,此外,function 仅在至少创建一个 HighGUI window 且 Z05B8C74CBD96FBF2DE4C1A352702FBF 处于活动状态时才有效。

It returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed.如果在指定时间过去之前没有按下任何键,则返回被按下键的代码或 -1。

You didn't press anything.你什么都没按。 that's why you get the -1这就是为什么你得到 -1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM