Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Avinash S
Avinash S le 19 Fév 2016
Commenté : Avinash S le 19 Fév 2016
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

Réponse acceptée

Jan
Jan le 19 Fév 2016
Try to insert a drawnow command to instruct Matlab to update the display.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by