按键时,焦点落在窗户上,不能落在cmd窗户上。
此外,imshow ) )之后的waitKey ) ),以便在绘制图像时保留时间。 否则,窗口将没有响应,图像将不再显示。
intwaitkey(intdelay=0) ) ) )。
-对于延迟延迟delay=0函数,延迟时间无限长,需要按键才能继续运行。
-延迟delay 0函数返回所按键的ASCII码值,超时时返回-1。
opencv :等待密钥
等待键
Waits for a pressed key。
c:intwaitkey(intdelay=0) )。
python:cv2.waitkey([Delay] ) retval
parameters :戴尔? dlayinmilliseconds.0 isthespecialvaluethatmeans“forever”。
thefunctionwaitkeywaitsforakeyeventinfinitely (when (文本TT ) delay ) leq0) or for delay milliseconds, whenitispositive.sincetheoshasaminimumtimebetweenswitchingthreads,thefunctionwillnotwaitexactlydelayms,it will wait at at at leat lat lat least dependingonwhatelseisrunningonyourcomputeratthattime.itreturnsthecodeofthepressedkeyor-1 ifnokeywaspressedbeforethespecifiecifieyor
笔记
thisfunctionistheonlymethodinhighguithatcanfetchandhandleevents,soitneedstobecalledperiodicallyfornormaleventprocessingunlesiongunlelested
笔记
thefunctiononlyworksifthereisatleastonehighguiwindowcreatedandthewindowisactive.ifthereareseveralhighghguiwindows,anyofthememchthemc
也就是说,waitKey仅在显示窗口时工作,否则无效。
例如,调用cv.waitkey(0),如果此时没有活动窗口,则此函数立即返回-1
以上,就cv.waitKey在python上没有反应的理由和解决方法,编辑向大家介绍了所有共享的内容。 希望您能参考。 另外,我想支持编剧。