2016-04-28 19:40:36 +00:00
|
|
|
clear
|
|
|
|
|
|
|
|
curr_dir = cd('.');
|
|
|
|
|
|
|
|
% Replace this with your downloaded 300-W train data
|
|
|
|
if(exist([getenv('USERPROFILE') '/Dropbox/AAM/eye_clm/mpii_data/'], 'file'))
|
|
|
|
database_root = [getenv('USERPROFILE') '/Dropbox/AAM/eye_clm/mpii_data/'];
|
2016-07-22 13:35:50 +00:00
|
|
|
elseif(exist('D:\Dropbox/Dropbox/AAM/eye_clm/mpii_data/', 'file'))
|
|
|
|
database_root = 'D:\Dropbox/Dropbox/AAM/eye_clm/mpii_data/';
|
2017-09-19 09:18:57 +00:00
|
|
|
elseif(exist('F:\Dropbox/AAM/eye_clm/mpii_data/', 'file'))
|
|
|
|
database_root = 'F:\Dropbox/AAM/eye_clm/mpii_data/';
|
2017-01-04 22:32:38 +00:00
|
|
|
elseif(exist('/multicomp/datasets/mpii_gaze/mpii_data/', 'file'))
|
|
|
|
database_root = '/multicomp/datasets/mpii_gaze/mpii_data/';
|
2016-04-28 19:40:36 +00:00
|
|
|
else
|
|
|
|
fprintf('MPII gaze dataset not found\n');
|
|
|
|
end
|
2017-01-04 22:32:38 +00:00
|
|
|
|
2016-04-28 19:40:36 +00:00
|
|
|
output_loc = './gaze_estimates_MPII/';
|
|
|
|
if(~exist(output_loc, 'dir'))
|
|
|
|
mkdir(output_loc);
|
|
|
|
end
|
|
|
|
|
|
|
|
output = './mpii_out/';
|
|
|
|
|
|
|
|
%% Perform actual gaze predictions
|
2017-01-04 22:32:38 +00:00
|
|
|
if(isunix)
|
|
|
|
executable = '"../../build/bin/FaceLandmarkImg"';
|
|
|
|
else
|
|
|
|
executable = '"../../x64/Release/FaceLandmarkImg.exe"';
|
|
|
|
end
|
|
|
|
|
2017-12-10 10:55:34 +00:00
|
|
|
command = sprintf('%s -fx 1028 -fy 1028 ', executable);
|
2016-04-28 19:40:36 +00:00
|
|
|
p_dirs = dir([database_root, 'p*']);
|
|
|
|
|
|
|
|
parfor p=1:numel(p_dirs)
|
|
|
|
tic
|
|
|
|
|
2017-12-10 10:55:34 +00:00
|
|
|
input_loc = ['-gaze -fdir "', [database_root, p_dirs(p).name], '" '];
|
|
|
|
out_img_loc = ['-out_dir "', [output, p_dirs(p).name], '" '];
|
|
|
|
command_c = cat(2, command, input_loc, out_img_loc);
|
2016-04-28 19:40:36 +00:00
|
|
|
|
2017-01-04 22:32:38 +00:00
|
|
|
if(isunix)
|
|
|
|
unix(command_c, '-echo');
|
|
|
|
else
|
|
|
|
dos(command_c);
|
2017-12-10 10:55:34 +00:00
|
|
|
end
|
2016-04-28 19:40:36 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
%%
|
|
|
|
|
|
|
|
% Extract the results
|
|
|
|
predictions_l = zeros(750, 3);
|
|
|
|
predictions_r = zeros(750, 3);
|
|
|
|
gt_l = zeros(750, 3);
|
|
|
|
gt_r = zeros(750, 3);
|
|
|
|
|
|
|
|
angle_err_l = zeros(750,1);
|
|
|
|
angle_err_r = zeros(750,1);
|
|
|
|
|
|
|
|
p_dirs = dir([database_root, 'p*']);
|
|
|
|
curr = 1;
|
|
|
|
for p=1:numel(p_dirs)
|
|
|
|
load([database_root, p_dirs(p).name, '/Data.mat']);
|
|
|
|
|
|
|
|
for i=1:size(filenames, 1)
|
|
|
|
|
2017-12-10 10:55:34 +00:00
|
|
|
fname = sprintf('%s/%s/%d_%d_%d_%d_%d_%d_%d.csv', output, p_dirs(p).name,...
|
2016-04-28 19:40:36 +00:00
|
|
|
filenames(i,1), filenames(i,2), filenames(i,3), filenames(i,4),...
|
|
|
|
filenames(i,5), filenames(i,6), filenames(i,7));
|
2017-12-10 10:55:34 +00:00
|
|
|
|
|
|
|
if(p==1 && i==1)
|
|
|
|
% First read in the column names
|
|
|
|
tab = readtable(fname);
|
|
|
|
column_names = tab.Properties.VariableNames;
|
2016-04-28 19:40:36 +00:00
|
|
|
|
2017-12-10 10:55:34 +00:00
|
|
|
gaze_0_ids = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'gaze_0_'));
|
|
|
|
gaze_1_ids = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'gaze_1_'));
|
|
|
|
end
|
|
|
|
|
|
|
|
if(exist(fname, 'file'))
|
|
|
|
all_params = dlmread(fname, ',', 1, 0);
|
|
|
|
else
|
|
|
|
all_params = [];
|
|
|
|
end
|
2016-04-28 19:40:36 +00:00
|
|
|
|
2017-12-10 10:55:34 +00:00
|
|
|
% If there was a face detected
|
|
|
|
if(size(all_params,1)>0)
|
|
|
|
predictions_r(curr,:) = all_params(1,gaze_0_ids);
|
|
|
|
predictions_l(curr,:) = all_params(1,gaze_1_ids);
|
|
|
|
else
|
2016-04-28 19:40:36 +00:00
|
|
|
predictions_r(curr,:) = [0,0,-1];
|
2017-12-10 10:55:34 +00:00
|
|
|
predictions_l(curr,:) = [0,0,-1];
|
2016-04-28 19:40:36 +00:00
|
|
|
end
|
2017-12-10 10:55:34 +00:00
|
|
|
|
|
|
|
head_rot = headpose(i,1:3);
|
|
|
|
|
2016-04-28 19:40:36 +00:00
|
|
|
gt_r(curr,:) = data.right.gaze(i,:)';
|
|
|
|
gt_r(curr,:) = gt_r(curr,:) / norm(gt_r(curr,:));
|
|
|
|
gt_l(curr,:) = data.left.gaze(i,:)';
|
|
|
|
gt_l(curr,:) = gt_l(curr,:) / norm(gt_l(curr,:));
|
|
|
|
|
|
|
|
angle_err_l(curr) = acos(predictions_l(curr,:) * gt_l(curr,:)') * 180/pi;
|
|
|
|
angle_err_r(curr) = acos(predictions_r(curr,:) * gt_r(curr,:)') * 180/pi;
|
|
|
|
|
|
|
|
curr = curr + 1;
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
all_errors = cat(1, angle_err_l, angle_err_r);
|
|
|
|
mean_error = mean(all_errors);
|
|
|
|
median_error = median(all_errors);
|
|
|
|
save('mpii_1500_errs.mat', 'all_errors', 'mean_error', 'median_error');
|
|
|
|
|
|
|
|
f = fopen('mpii_1500_errs.txt', 'w');
|
|
|
|
fprintf(f, 'Mean error, median error\n');
|
|
|
|
fprintf(f, '%.3f, %.3f\n', mean_error, median_error);
|
|
|
|
fclose(f);
|