-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcanimate.m
63 lines (55 loc) · 2.12 KB
/
mcanimate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function p = mcanimate(d, p, proj)
% Creates animation of mocap data and saves it to file (.avi or .mpeg-4) or as consecutive
% frames (.png). Matlab's VideoWriter function is used to create the video
% file.
% COMPATIBILITY NOTES (v. 1.5): The 'folder'-field (animpar structure, v. 1.4) has been changed to
% 'output' and is used as file name for the animation (and stored to the current directory)
% or as folder name in case frames are to be plotted.
% Please use the function without the projection input argument, but specify
% it in the animation structure instead.
%
% syntax
% p = mcanimate(d);
% p = mcanimate(d, p);
%
% input parameters
% d: MoCap data structure
% p: animpar structure (optional)
% [depricated: proj: projection used: 0 = orthographic (default), 1 = perspective
% this flag is supposed to be set in the animation parameter stucture instead]
%
% output
% p: animpar structure used for plotting the frames
%
% examples
% mcanimate(d, par);
%
% comments
% If the animpar structure is not given as input argument, the function
% creates it by calling the function mcinitanimpar and setting the .limits field
% of the animpar structure automatically so that all the markers fit into all frames.
% If the par.pers field (perspective projection) is not given, it is created internally for backwards
% compatibility. For explanation of the par.pers field, see help mcinitanimpar
%
% see also
% mcplotframe, mcinitanimpar
%
% Adaptation of the native Motion Capture Toolbox function to work with 3D frame plotting
% Download the MoCap Toolbox from
% https://www.jyu.fi/hytk/fi/laitokset/mutku/en/research/materials/mocaptoolbox
%
if nargin>2
disp([10, 'Please note that, from MCT version 1.5, the perspective projection flag is set in the field "perspective" in the animation parameters. Please adapt your code accordingly.', 10])
p.perspective=proj;
end
if nargin<2
p = mcinitanimpar;
end
% resample for p.fps fps movie
d2 = mcresample(d, p.fps);
p.animate = 1;
if isfield(p,'par3D')
p = mcplot3Dframe(d2,1:d2.nFrames,p);
else
p = mcplotframe(d2,1:d2.nFrames,p); % output parameter added 240608
end