mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
implementation of pollKey, companion to waitKey
w32 backend: implemented other backends: stubbed or fallback to waitKey documentation: cross-linked and more precise in some places
This commit is contained in:
@@ -347,23 +347,34 @@ The function waitKey waits for a key event infinitely (when \f$\texttt{delay}\le
|
||||
milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the
|
||||
function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is
|
||||
running on your computer at that time. It returns the code of the pressed key or -1 if no key was
|
||||
pressed before the specified time had elapsed.
|
||||
pressed before the specified time had elapsed. To check for a key press but not wait for it, use
|
||||
#pollKey.
|
||||
|
||||
@note
|
||||
@note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle
|
||||
GUI events, so one of them needs to be called periodically for normal event processing unless
|
||||
HighGUI is used within an environment that takes care of event processing.
|
||||
|
||||
This function is the only method in HighGUI that can fetch and handle events, so it needs to be
|
||||
called periodically for normal event processing unless HighGUI is used within an environment that
|
||||
takes care of event processing.
|
||||
|
||||
@note
|
||||
|
||||
The function only works if there is at least one HighGUI window created and the window is active.
|
||||
If there are several HighGUI windows, any of them can be active.
|
||||
@note The function only works if there is at least one HighGUI window created and the window is
|
||||
active. If there are several HighGUI windows, any of them can be active.
|
||||
|
||||
@param delay Delay in milliseconds. 0 is the special value that means "forever".
|
||||
*/
|
||||
CV_EXPORTS_W int waitKey(int delay = 0);
|
||||
|
||||
/** @brief Polls for a pressed key.
|
||||
|
||||
The function pollKey polls for a key event without waiting. It returns the code of the pressed key
|
||||
or -1 if no key was pressed since the last invocation. To wait until a key was pressed, use #waitKey.
|
||||
|
||||
@note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle
|
||||
GUI events, so one of them needs to be called periodically for normal event processing unless
|
||||
HighGUI is used within an environment that takes care of event processing.
|
||||
|
||||
@note The function only works if there is at least one HighGUI window created and the window is
|
||||
active. If there are several HighGUI windows, any of them can be active.
|
||||
*/
|
||||
CV_EXPORTS_W int pollKey();
|
||||
|
||||
/** @brief Displays an image in the specified window.
|
||||
|
||||
The function imshow displays an image in the specified window. If the window was created with the
|
||||
@@ -383,11 +394,12 @@ If the window was not created before this function, it is assumed creating a win
|
||||
|
||||
If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow.
|
||||
|
||||
@note This function should be followed by cv::waitKey function which displays the image for specified
|
||||
milliseconds. Otherwise, it won't display the image. For example, **waitKey(0)** will display the window
|
||||
infinitely until any keypress (it is suitable for image display). **waitKey(25)** will display a frame
|
||||
for 25 ms, after which display will be automatically closed. (If you put it in a loop to read
|
||||
videos, it will display the video frame-by-frame)
|
||||
@note This function should be followed by a call to cv::waitKey or cv::pollKey to perform GUI
|
||||
housekeeping tasks that are necessary to actually show the given image and make the window respond
|
||||
to mouse and keyboard events. Otherwise, it won't display the image and the window might lock up.
|
||||
For example, **waitKey(0)** will display the window infinitely until any keypress (it is suitable
|
||||
for image display). **waitKey(25)** will display a frame and wait approximately 25 ms for a key
|
||||
press (suitable for displaying a video frame-by-frame). To remove the window, use cv::destroyWindow.
|
||||
|
||||
@note
|
||||
|
||||
|
||||
Reference in New Issue
Block a user