Skip to content

Instantly share code, notes, and snippets.

@pppoe
Created February 13, 2017 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pppoe/785a7e69e8f9334af2af1c2b5d27245e to your computer and use it in GitHub Desktop.
Save pppoe/785a7e69e8f9334af2af1c2b5d27245e to your computer and use it in GitHub Desktop.
export out data from 3DDFA
output_root = 'extracted';
mkdir(output_root);
num_lms = 68;
lines = textread('flist', '%s');
num_lines = length(lines);
for ff = 1:num_lines
fpath = lines{ff};
[froot, fname, fext] = fileparts(fpath);
out_root = [output_root '/' froot];
fimg = [froot '/' fname '.jpg'];
out_img = [out_root '/' fname '.jpg'];
out_info = [out_root '/' fname '.info'];
out_lms = [out_root '/' fname '.lms'];
P = load(fpath);
sprintf('%d %s + %s -> [%s] %s %s %s', ff, fpath, fimg, out_root, out_img, out_info, out_lms)
%% Copy Image
copyfile(fimg, out_img);
%% Dump Landmarks
fp = fopen(out_lms, 'w');
for l = 1:num_lms
fprintf(fp, '%f %f\n', P.pt2d(1,l), P.pt2d(2,l));
end
fclose(fp);
%% Dump Parameters
fp = fopen(out_info, 'w');
for l = 1:7
fprintf(fp, '%f\n', P.Pose_Para(l));
end
for l = 1:199
fprintf(fp, '%f\n', P.Shape_Para(l));
end
for l = 1:29
fprintf(fp, '%f\n', P.Exp_Para(l));
end
fclose(fp);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment