2017-01-04 23:32:38 +01:00
|
|
|
clear
|
|
|
|
|
|
|
|
if(isunix)
|
|
|
|
executable = '"../../build/bin/FeatureExtraction"';
|
|
|
|
else
|
|
|
|
executable = '"../../x64/Release/FeatureExtraction.exe"';
|
|
|
|
end
|
2016-04-28 21:40:36 +02:00
|
|
|
|
|
|
|
output = './output_features_vid/';
|
|
|
|
|
|
|
|
if(~exist(output, 'file'))
|
|
|
|
mkdir(output)
|
|
|
|
end
|
|
|
|
|
2017-05-09 18:20:10 +02:00
|
|
|
in_files = dir('../../samples/2015-10-15-15-14.avi');
|
2016-04-28 21:40:36 +02:00
|
|
|
% some parameters
|
|
|
|
verbose = true;
|
|
|
|
|
2017-01-04 23:32:38 +01:00
|
|
|
command = executable;
|
2016-04-28 21:40:36 +02:00
|
|
|
command = cat(2, command, ' -verbose -no2Dfp -no3Dfp -noMparams -noPose -noAUs ');
|
|
|
|
|
|
|
|
% add all videos to single argument list (so as not to load the model anew
|
|
|
|
% for every video)
|
|
|
|
for i=1:numel(in_files)
|
|
|
|
|
2017-05-09 18:20:10 +02:00
|
|
|
inputFile = ['../../samples/', in_files(i).name];
|
2016-04-28 21:40:36 +02:00
|
|
|
[~, name, ~] = fileparts(inputFile);
|
|
|
|
|
|
|
|
% where to output tracking results
|
|
|
|
outputFile_gaze = [output name '_gaze.txt'];
|
|
|
|
|
|
|
|
if(~exist([output name], 'file'))
|
|
|
|
mkdir([output name]);
|
|
|
|
end
|
|
|
|
|
|
|
|
command = cat(2, command, ['-fx 700 -fy 700 -f "' inputFile '" -of "' outputFile_gaze '"']);
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2017-01-04 23:32:38 +01:00
|
|
|
if(isunix)
|
|
|
|
unix(command);
|
|
|
|
else
|
|
|
|
dos(command);
|
|
|
|
end
|
2016-04-28 21:40:36 +02:00
|
|
|
|
|
|
|
%% Demonstrating reading the output files
|
|
|
|
filename = [output name];
|
|
|
|
|
|
|
|
% Read gaze (x,y,z) for one eye and (x,y,z) for another
|
|
|
|
gaze = dlmread([filename, '_gaze.txt'], ',', 1, 0);
|
|
|
|
|
|
|
|
% This indicates which frames were succesfully tracked
|
|
|
|
valid_frames = gaze(:,4);
|
|
|
|
|
|
|
|
% only picking left, right and up down views for visualisation
|
2016-12-02 20:21:24 +01:00
|
|
|
|
|
|
|
% These are gaze angles with respect to head pose
|
|
|
|
gaze_angle = gaze(:,[11,12]);
|
|
|
|
|
|
|
|
figure;
|
|
|
|
plot(smooth(gaze_angle(:,1)), 'DisplayName', 'Left - right');
|
|
|
|
hold on;
|
|
|
|
plot(smooth(gaze_angle(:,2)), 'DisplayName', 'Up - down');
|
|
|
|
xlabel('Frame') % x-axis label
|
|
|
|
ylabel('Radians') % y-axis label
|
|
|
|
legend('show');
|
|
|
|
hold off;
|
|
|
|
|
|
|
|
% These are gaze direction vectors
|
2016-04-28 21:40:36 +02:00
|
|
|
gaze = gaze(:,[5,6,7,8,9,10]);
|
2016-12-02 20:21:24 +01:00
|
|
|
|
2016-04-28 21:40:36 +02:00
|
|
|
gaze = (gaze(:,[1,2,3]) + gaze(:,[4,5,6]))/2;
|
|
|
|
gaze(:,1) = smooth(gaze(:,1));
|
|
|
|
gaze(:,2) = smooth(gaze(:,2));
|
|
|
|
gaze(:,3) = smooth(gaze(:,3));
|
|
|
|
|
2016-12-02 20:21:24 +01:00
|
|
|
figure;
|
2016-04-28 21:40:36 +02:00
|
|
|
plot(gaze(:,1), 'DisplayName', 'Left - right');
|
|
|
|
hold on;
|
|
|
|
plot(gaze(:,2), 'DisplayName', 'Up - down');
|
|
|
|
xlabel('Frame') % x-axis label
|
|
|
|
ylabel('Gaze vector size') % y-axis label
|
|
|
|
legend('show');
|
|
|
|
hold off;
|