Rotate 3d mesh by using videowriter (change camera angle)

5 vues (au cours des 30 derniers jours)
Justina Ghebryal
Justina Ghebryal le 17 Oct 2020
Purpose:
While playing an .avi movie, manually change the camera angle (have the option to rotate 3D).
Question:
How can I add an option to rotate the mesh during playing an .avi movie?
The code:
I created a 3D mesh.
All vertices have their own signal value. vq_list is a matrix that contains all signal values for different time steps.
%% Create first figure
p = patch('Faces',FV_refined.faces,'Vertices',FV_refined.vertices,'FaceVertexCData', vq_list(:,1),'FaceColor','interp');
After creating the first figure with the signal values for the first time point, I do this for all time points. So that I have a video in time that shows how all signal values change over time.
%% Create figures with data for all time steps
for i = 1:length(vq_list)
p.FaceVertexCData = vq_list(:,i);
pause(1);
axis vis3d
rotate3d on
%view(90,1) Movie2.avi
caxis([-100 100])
frame(i) = getframe(gcf);
end
Each figure is a frame (which contains data in 3 dimensions) that I can later use to write my video by using VideoWriter:
v = VideoWriter('Movie.avi');
open(v)
writeVideo(v, frame);
close(v)
By using implay I can play the video:
implay('Movie.avi')
The problem:
The video is in 2D and I cannot rotate it. The first figure does have the option to rotate it and all separate frames have this option too. But when making a video of it, this option is not shown in Movie Player.

Réponses (1)

Ameer Hamza
Ameer Hamza le 17 Oct 2020
Modifié(e) : Ameer Hamza le 17 Oct 2020
I am not sure if such an interaction is even possible with .avi files (or other commonly known video container formats). getframe() returns a rasterized image, which is just pixels and does not contain any information about 3D structure of your scene. If you want such interaction, then you need to use a 3D CG software package, such as Blender, but even in those cases, the interaction is only possible inside the software; the exported video does not have such capability.
  1 commentaire
Justina Ghebryal
Justina Ghebryal le 17 Oct 2020
Thanks for your reply, I will look into these type of solutions

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by