I am semantically segmenting images within a video sequence and displaying the result within a display window in real-time. However, my code is "dropping frames" by not updating the display window with each call to imshow
.
Below is a code extract that demonstrates my problem:
for (int i = 0; i < images->size(); i++)
{
Mat frame = images->getImage(i);
// semantic segmentation code (omitted)
Mat frame_overlay = ...
// problem: the window "seg result" does not always update
imshow("seg result", frame_overlay);
int key = waitKey(1);
if (key == 27)
break;
}
As a work around I can increase the wait time from 1 ms to 10 ms in the call to waitKey
, but surely there has to be a better way of doing this.
How can I force the "seg result"
window to update with the new frame_overlay
image?