フィルターのクリア

Figure gets displayed only after terminating the program. What to do?

2 ビュー (過去 30 日間)
Avinash S
Avinash S 2016 年 2 月 19 日
コメント済み: Avinash S 2016 年 2 月 19 日
im using subplots with imshow in my program which reads frames from a video file. Output figure is not getting displayed. If i terminate the program using Ctrl+C, the figure shows up. However instead of video file if I read input from webcam with videoinput, I get the output figure normally as usual. Code:
foregroundDetector = vision.ForegroundDetector('NumGaussians',3,'NumTrainingFrames',10,'LearningRate',0.000001);
foregroundDetector1 = vision.ForegroundDetector('NumGaussians',3,'NumTrainingFrames',10,'LearningRate',0.000001);
%vid = videoinput('winvideo', 1); %select input device
vid = vision.VideoFileReader('daria_walk.avi');
i=1;
DlgH = figure;
H = uicontrol('Style', 'PushButton', ...
'String', 'Close', ...
'Callback', 'delete(gcbf)');
while (ishandle(H))
frame = step(vid);
%frame = getsnapshot(vid);
YCBCR = rgb2ycbcr(frame);
rgbForeground = step(foregroundDetector, frame);
ycbcrForeground = step(foregroundDetector1, YCBCR(:,:,3));
se = strel('square', 3);
filteredForeground = imopen(rgbForeground, se);
subplot(1,2,1);
imshow(filteredForeground);
title('RGB Foreground');
subplot(1,2,2);
imshow(ycbcrForeground);
title('YCBCR Foreground');
end
close

採用された回答

Jan
Jan 2016 年 2 月 19 日
Try to insert a drawnow command to instruct Matlab to update the display.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by