Problem with getframe with trisurf when making movie
Mostrar comentarios más antiguos
I want to make a movie use getframe and VideoWriter to view a 3D dataset at different view angle. First, i use scatter3 to plot 3D dataset, and use getframe and VideoWriter. It works perfect. However, when i use trisurf to plot the surface of dataset,and use exactly the same code to as above. But i found the the frame in this movie does not change over time, and it is a 2D image instead of 3D.
Are there some meet the same problem? Many thanks.
writerObj = VideoWriter('ColorGamutDTri.avi');
writerObj.FrameRate = 80;
open(writerObj);
n=-180;
while(n<180)
view(n,10);
n=n+1;
pause(0.1);
frame = getframe(gcf);
writeVideo(writerObj, frame);
end
close(writerObj);
8 comentarios
Geoff Hayes
el 16 de Sept. de 2014
Renbo - I used the example from trisurf to create a surface plot, and then ran your code. When I viewed the movie, the frames did rotate and so appeared as expected. When you viewed your video, are you sure that there is more than one frame in it?
Renbo
el 19 de Sept. de 2014
Geoff Hayes
el 19 de Sept. de 2014
Renbo - please clarify I indeed got the same result as you got. No rotation in movie at all because I did see the rotation when I ran the example from the trisurf link with your above code.
[x,y] = meshgrid(1:15,1:15);
tri = delaunay(x,y);
z = peaks(15);
trisurf(tri,x,y,z);
writerObj = VideoWriter('ColorGamutDTri.avi');
writerObj.FrameRate = 80;
open(writerObj);
n=-180;
while(n<180)
view(n,10);
n=n+1;
pause(0.1);
frame = getframe(gcf);
writeVideo(writerObj, frame);
end
close(writerObj);
On the video that you have created, type the following in the Command Window
obj = VideoReader('ColorGamutDTri.avi');
get(obj)
which will return information like
General Settings:
Duration = 4.5
Name = ColorGamutDTri.avi
Path = /Users/geoff/Development/bitbucket_repos/matlab/testing
Tag =
Type = VideoReader
UserData = []
Video Settings:
BitsPerPixel = 24
FrameRate = 80
Height = 420
NumberOfFrames = 360
VideoFormat = RGB24
Width = 560
What do you see for the NumberOfFrames for your video? (The above output was taken from the above code pasted in this comment.)
Geoff Hayes
el 21 de Sept. de 2014
Hi Renbo - I ran the GamtTest.m script (as is) and it worked fine - the video was rotating. I then uncommented your code so that it would read from file, and again the video showed the big blue and small red "structures" rotate around each other, just at a faster rate than the MATLAB plot. You've added a pause of 0.1 seconds after every view change (frame), so I changed the frame rate of the video to 6, replacing
writerObj.FrameRate = 80;
with
writerObj.FrameRate = 6;
I don't know why you are not seeing the rotation. Try changing the frame rate (as above) and see what happens again.
Geoff Hayes
el 22 de Sept. de 2014
Glad that you got it tow work, Renbo!
Renbo
el 22 de Sept. de 2014
Respuestas (0)
Categorías
Más información sobre Lighting, Transparency, and Shading en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!