OpenCV 的 cvWaitKey() 函数有什么作用?

What does OpenCV#39;s cvWaitKey( ) function do?(OpenCV 的 cvWaitKey() 函数有什么作用?)
本文介绍了OpenCV 的 cvWaitKey() 函数有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

cvWaitKey() 执行过程中会发生什么?有哪些典型的用例?我在 OpenCV 参考中看到了它,但文档并不清楚其确切用途.

What happens during the execution of cvWaitKey()? What are some typical use cases? I saw it in OpenCV reference but the documentation isn't clear on its exact purpose.

推荐答案

cvWaitKey(x)/cv::waitKey(x) 做了两件事:

  1. 它等待 x 毫秒以等待 OpenCV 窗口(即从 cv::imshow() 创建)上的按键.请注意,它不会在 stdin 上侦听控制台输入.如果在此期间按下某个键,则返回该键的 ASCII 代码.否则,它返回 -1.(如果 x 为零,它会无限期地等待按键.)
  2. 它处理任何窗口事件,例如使用 cv::namedWindow() 创建窗口,或使用 cv::imshow() 显示图像.
  1. It waits for x milliseconds for a key press on a OpenCV window (i.e. created from cv::imshow()). Note that it does not listen on stdin for console input. If a key was pressed during that time, it returns the key's ASCII code. Otherwise, it returns -1. (If x is zero, it waits indefinitely for the key press.)
  2. It handles any windowing events, such as creating windows with cv::namedWindow(), or showing images with cv::imshow().

opencv 新手的一个常见错误是通过视频帧循环调用 cv::imshow(),而不用 cv::waitKey(30) 跟踪每次绘制代码>.在这种情况下,屏幕上不会显示任何内容,因为 highgui 从来没有时间处理来自 cv::imshow() 的绘制请求.

A common mistake for opencv newcomers is to call cv::imshow() in a loop through video frames, without following up each draw with cv::waitKey(30). In this case, nothing appears on screen, because highgui is never given time to process the draw requests from cv::imshow().

这篇关于OpenCV 的 cvWaitKey() 函数有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Bring window to front -gt; raise(),show(),activateWindow() don’t work(把窗户放在前面 -raise(),show(),activateWindow() 不起作用)
How to get a list video capture devices NAMES (web cameras) using Qt (crossplatform)? (C++)(如何使用 Qt(跨平台)获取列表视频捕获设备名称(网络摄像机)?(C++))
How to compile Qt as static(如何将 Qt 编译为静态)
C++ over Qt : Controlling transparency of Labels and Buttons(C++ over Qt:控制标签和按钮的透明度)
How to know when a new USB storage device is connected in Qt?(Qt如何知道新的USB存储设备何时连接?)
What is an event loop in Qt?(Qt 中的事件循环是什么?)