简体   繁体   中英

C++ waitKey Delay to Display Images in Loop

Within C++ (also using OpenCV) I'm creating a loop which displays a new image from file each iteration. To achieve this I've had to add in waitKey(1) otherwise only a blank window is displayed. I was just wondering why this millisecond delay must be included for the image to show each iteration and, if possible, if there is a method to display the image without requiring this delay.

Thanks in advance!

The function waitKey() waits for key event for a "delay" (here, 30 milliseconds). As explained in the OpenCV documentation, HighGui (imshow() is a function of HighGui) need a call of waitKey reguraly, in order to process its event loop.

Ie, if you don't call waitKey, HighGui cannot process windows events like redraw, resizing, input event etc. So just call it, even with a 1ms delay :)

what does waitKey (30) mean in OpenCV?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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