本文介紹了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)
做了兩件事:
- 它等待 x 毫秒以等待 OpenCV 窗口(即從
cv::imshow()
創建)上的按鍵.請注意,它不會在 stdin 上偵聽控制臺輸入.如果在此期間按下某個鍵,則返回該鍵的 ASCII 代碼.否則,它返回-1
.(如果 x 為零,它會無限期地等待按鍵.) - 它處理任何窗口事件,例如使用
cv::namedWindow()
創建窗口,或使用cv::imshow()
顯示圖像.
- 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.) - It handles any windowing events, such as creating windows with
cv::namedWindow()
, or showing images withcv::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() 函數有什么作用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!