필터 지우기
필터 지우기

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

조회 수: 1 (최근 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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by