Effacer les filtres
Effacer les filtres

capturing the same frame

2 vues (au cours des 30 derniers jours)
Osita Onyejekwe
Osita Onyejekwe le 7 Avr 2017
Commenté : Osita Onyejekwe le 10 Avr 2017
My frame is capturing the same beginning video frame in multiple figures. I want the multiple figure to be images of the video as it progrosses, not the same figure for multiple figures. Here is my code. Please fix it
obj = VideoReader('Climate.mp4');
for k = 1 : 5 %fill in the appropriate number
this_frame = read(obj, k);
thisfig = figure();
%thisfig = gcf;
thisax = axes('Parent', thisfig);
image(this_frame, 'Parent', thisax);
title(thisax, sprintf('Frame #%d', k));
end

Réponse acceptée

Image Analyst
Image Analyst le 7 Avr 2017
So don't create a new figure each frame. How does this work:
obj = VideoReader('Climate.mp4');
for k = 1 : obj.NumberOfFrames
this_frame = read(obj, k);
imshow(this_frame);
title(sprintf('Frame #%d', k), 'FontSize', 14);
drawnow; % Force immediate repaint of screen.
pause(0.1); % Increase number to slow it down more.
end
  11 commentaires
Osita Onyejekwe
Osita Onyejekwe le 7 Avr 2017
obj = VideoReader('Climate.mp4'); for k = 1 : obj.NumberOfFrames this_frame = read(obj, k); imshow(this_frame); title(sprintf('Frame #%d', k), 'FontSize', 14); drawnow; % Force immediate repaint of screen. pause(0.1); % Increase number to slow it down more. promptMessage = sprintf('Showing Frame #%d.\nDo you want to Continue processing,\nor Quit processing?', k); titleBarCaption = 'Continue?'; buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue'); if strcmpi(buttonText, 'Quit') break; if rem(k, 5) == 0 % Ask every fifth frame buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue'); end end end
i put the if in but now it underlines everything...
Image Analyst
Image Analyst le 7 Avr 2017
You need to think about the logic flow. This works just fine.
obj = VideoReader('Climate.mp4');
for k = 1 : obj.NumberOfFrames
this_frame = read(obj, k);
imshow(this_frame);
title(sprintf('Frame #%d', k), 'FontSize', 14);
drawnow; % Force immediate repaint of screen.
pause(0.1); % Increase number to slow it down more.
if rem(k, 5) == 0 % Ask every fifth frame
promptMessage = sprintf('Showing Frame #%d.\nDo you want to Continue processing,\nor Quit processing?', k);
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if strcmpi(buttonText, 'Quit')
break;
end
end
end

Connectez-vous pour commenter.

Plus de réponses (1)

Osita Onyejekwe
Osita Onyejekwe le 7 Avr 2017
Here is another look
  4 commentaires
Osita Onyejekwe
Osita Onyejekwe le 10 Avr 2017
Thank you so much. All is perfect now!!!
Osita Onyejekwe
Osita Onyejekwe le 10 Avr 2017
Final Final Final question.
Given this code, is there a way I can save all the frames into a folder as image files as I run the code?
obj = VideoReader('Climate.mp4'); for k = 1 : obj.NumberOfFrames this_frame = read(obj, k); imshow(this_frame); title(sprintf('Frame #%d', k), 'FontSize', 14); drawnow; % Force immediate repaint of screen. pause(0.1); % Increase number to slow it down more. if rem(k, 5) == 0 % Ask every fifth frame promptMessage = sprintf('Showing Frame #%d.\nDo you want to Continue processing,\nor Quit processing?', k); titleBarCaption = 'Continue?'; buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue'); if strcmpi(buttonText, 'Quit') break; end end end
thank you!!!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Animation 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