How to record video file via m-code from vrworld which is displayed on vr.canvas
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a simulation which uses Simulink 3D Animation through Matlab interface to display an animation in a GUI window. Now I need a button to record the view as a video file.
I show the 3D view in the GUI window like this:
myWorld = vrworld('mainWorld.wrl');
open(myWorld);
myCanvas = vr.canvas(myWorld, gcf, [10 10 500 500]);
And during the simulation I update the view like this
myWorld.MYOBJECT.point = [ new_x new_y new_z ];
and also change the view point etc. How can I write a code to record the view as a movie file? I tried to read the documentation, but the options I have seem very cumbersome. It seems the vrworld should be linked to a Simulink model (I have no Simulink in my simulation) and the Simulink model should be running to record a video. Do I need to make a dummy Simulink model and somehow synchronize it with my Matlab simulation?
0 commentaires
Réponses (2)
Jan Danek
le 13 Juil 2012
Hi Antti,
Please look at the "MATLAB Animation Recording of Virtual Worlds Not Associated with Simulink Models" chapter of the Simulink 3D Animation documentation:
Basically, you need to set the time in the scene to be controlled by you:
set(virtual_world,'TimeSource', 'external')
An then do something like this in a loop:
for time=StartTime:Step:StopTime
% advance the time in the virtual scene set(virtual_world,'Time',time);
% here we change VRML nodes properties
virtual_world.Car.translation = [ time*speed 0 0 ];
% render the changed position
vrdrawnow;
end
Hope this helps,
Jan
0 commentaires
Antti
le 16 Juil 2012
1 commentaire
Jan Danek
le 23 Juil 2012
Hi Antti,
You are right, vr.canvas doesn't have the "Record2D" property that governs the 2D animation recording to a video file in vrfigure. You can do one of the following:
1. Combine the use of vr.canvas/capture method with VideoWriter to achieve the same effect. This will allow you to have complete control on when to capture the scene (you don't have to set world / figure properties to achieve the recording, you just do the capture when you need it and save the image to the output video file.)
2. Use the 3D animation recording. If you can accept that the result will be not an AVI file, but "VRML Animation File", this is connected to the underlying virtual world, and IMHO provides even more comfort when exploring the animation later using the "vrplay". Try this:
vrplay octavia_scene_anim
Another positive effect of this 3D animation is that its recording doesn't slow you down during your work with your GUI (writing text values is far less demanding than creating an AVI file).
All the best,
Jan
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!