Generate a movie silently

16 vues (au cours des 30 derniers jours)
ConvexHull
ConvexHull le 24 Mai 2020
Modifié(e) : ConvexHull le 27 Juil 2020
Dear all,
I am familiar with the standard procedure to create an animation/video in MATLAB with e.g.:
vidObj = VideoWriter('video.avi');
vidObj.FrameRate = 20;
vidObj.Quality = 100;
open(vidObj);
figure(Figure_Video)
currFrame=getframe(gcf);
writeVideo(vidObj,currFrame);
close(vidObj);
However, suppose if the creation of the animation takes few hours (one frame each minute) and i want to do some other work (writing texts, emails) with the same computer. Each minute MATLAB captures the display/mouse and makes it even unpossible to do some other work.
Therefore my question:
Is there an easy way to create an animation silently in the background?
Thank you!
  6 commentaires
Ameer Hamza
Ameer Hamza le 24 Mai 2020
Which command are you using which grab the mouse attention from other applications? Using the code in your question does not result in grabbing the mouse attention. For example, run the following code. You can continue to work on your other applications (at least this works in macOS)
v = VideoWriter('temp.mp4', 'MPEG-4');
open(v)
x = linspace(1,10);
y = sin(x);
fig = figure();
for i=1:numel(x)
plot(x(1:i), y(1:i));
currFrame = getframe(fig);
writeVideo(v, currFrame);
end
close(v);
Although you can avoid multiple calls to plot(), I just write it like this to show even this does not grab attention. You are probably writing so another command which grabs attention. My guess is that you have written the line
figure(Figure_Video)
inside the loop.
Image Analyst
Image Analyst le 24 Mai 2020
Also, switching to a particular axes will steal focus:
axes(handles.axesImage); % This call steals focus.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 24 Mai 2020
  1 commentaire
ConvexHull
ConvexHull le 27 Juil 2020
Modifié(e) : ConvexHull le 27 Juil 2020
Thanks for your answer and sorry for my late response.
The most important command is the
set(0, 'CurrentFigure', fig_A);
instead of
figure(fig_A);
With this it is even possible to call
  • getframe or
  • multiple figures inside a loop or
  • copy subplots from fig_A to fig_B
without any troubles.
Regards

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by