仅显示imshow

时间:2017-03-23 01:53:05

标签: matlab image-processing

我正在尝试使用前景检测将背景减法应用于我的视频。背景减法有效。但是imshow仅显示最终帧。任何帮助将不胜感激

foregroundDetector = vision.ForegroundDetector('NumGaussians', 3, ...'NumTrainingFrames', 100);

videoReader = vision.VideoFileReader('test1.mp4');

for i = 1:120
    frame = step(videoReader); % read the next video frame
%     imshow(frame);
    disp(i);
 foreground = step(foregroundDetector, frame);
    imshow(foreground);
end

1 个答案:

答案 0 :(得分:0)

为了防止不必要的图形处理,如果你在循环中不断更新图形对象,图形就不会被实际渲染,直到暂停执行显式>用于强制执行要刷新的事件队列。

drawnow

作为旁注,为了获得更好的性能,您应该更新现有的图像对象,而不是使用for k = 1:120 frame = step(videoReader); % read the next video frame foreground = step(foregroundDetector, frame); imshow(foreground); % Explicitly force the renderer to update the display drawnow end 不断创建新的图像对象。

imshow