3

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?

Josh
  • 1,357
  • 2
  • 23
  • 45
  • Run in release maybe? – Miki Dec 12 '15 at 01:28
  • I am running in release. – Josh Dec 12 '15 at 01:36
  • 1
    If your semantic segmentation code is fast (<10ms or so) then what might be happening is that you draw faster than your monitor refresh speed and the frames get "lost" – mirosval Dec 13 '15 at 08:59
  • 1
    No, this cannot be the case here, as simply playing back the images without any intermediary processing (i.e. a faster frame rate) does not result in dropped frames. – Josh Dec 16 '15 at 02:50
  • https://stackoverflow.com/questions/37038606/opencv-imshow-freezes-when-updating – user202729 Feb 12 '19 at 11:52

0 Answers0