From 01368270be7404312908dde40ad0db1cff2c682e Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Thu, 23 Nov 2017 18:33:10 +0000 Subject: [PATCH] Dealing in a better way with frame numbers --- .gitignore | 3 +++ .../Demos/feature_extraction_demo_img_seq.m | 24 +++++++++---------- .../Demos/feature_extraction_demo_vid.m | 6 ++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 5167503..aa07b45 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,6 @@ matlab_version/face_validation/trained/intermediate/ lib/local/GazeAnalyser/x64/ lib/local/Utilities/x64/ exe/FeatureExtraction/processed/ +exe/FaceLandmarkImg/processed/ +exe/FeatureExtraction/processed_features/ +matlab_runners/Demos/processed_features/ diff --git a/matlab_runners/Demos/feature_extraction_demo_img_seq.m b/matlab_runners/Demos/feature_extraction_demo_img_seq.m index a652645..ebf6be8 100644 --- a/matlab_runners/Demos/feature_extraction_demo_img_seq.m +++ b/matlab_runners/Demos/feature_extraction_demo_img_seq.m @@ -30,7 +30,7 @@ end % Most of the features will be in the csv file in the output directory with % the same name as the input file -[~,name,~] = fileparts(in_file); +[~,name,~] = fileparts(in_dir); output_csv = sprintf('%s/%s.csv', output_dir, name); % First read in the column names, to know which columns to read for @@ -45,13 +45,13 @@ all_params = dlmread(output_csv, ',', 1, 0); % Find which column contains success of tracking data and timestamp data valid_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'success')); -time_stamp_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'timestamp')); +frame_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'frame')); % Extract tracking success data and only read those frame valid_frames = logical(all_params(:,valid_ind)); % Get the timestamp data -time_stamps = all_params(valid_frames, time_stamp_ind); +frame_nums = all_params(valid_frames, frame_ind); %% Finding which header line starts with p_ (basically model params) shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_')); @@ -60,9 +60,9 @@ shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_')); shape_params = all_params(valid_frames, shape_inds); figure -plot(time_stamps, shape_params); +plot(frame_nums, shape_params); title('Shape parameters'); -xlabel('Time (s)'); +xlabel('Frame'); %% Demonstrate 2D landmarks landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'x_')); @@ -127,7 +127,7 @@ au_reg_inds = cellfun(@(x) ~isempty(x) && x==5, strfind(column_names, '_r')); aus = all_params(valid_frames, au_reg_inds); figure -plot(time, aus); +plot(frame_nums, aus); title('Facial Action Units (intensity)'); xlabel('Time (s)'); ylabel('Intensity'); @@ -137,7 +137,7 @@ au_class_inds = cellfun(@(x) ~isempty(x) && x==5, strfind(column_names, '_c')); aus = all_params(valid_frames, au_class_inds); figure -plot(time, aus); +plot(frame_nums, aus); title('Facial Action Units (presense)'); xlabel('Time (s)'); ylim([0,2]); @@ -146,9 +146,9 @@ pose_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'pose_')); pose = all_params(valid_frames, pose_inds); figure -plot(pose); +plot(frame_nums, pose); title('Pose (rotation and translation)'); -xlabel('Time (s)'); +xlabel('Frame number'); %% Demo gaze gaze_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'gaze_angle')); @@ -156,10 +156,10 @@ gaze_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'gaze_angle' % Read gaze (x,y,z) for one eye and (x,y,z) for another gaze = all_params(valid_frames, gaze_inds); -plot(time, gaze(:,1), 'DisplayName', 'Left - right'); +plot(frame_nums, gaze(:,1), 'DisplayName', 'Left - right'); hold on; -plot(time, gaze(:,2), 'DisplayName', 'Up - down'); -xlabel('Time(s)') % x-axis label +plot(frame_nums, gaze(:,2), 'DisplayName', 'Up - down'); +xlabel('Frame number') % x-axis label ylabel('Angle radians') % y-axis label legend('show'); hold off; diff --git a/matlab_runners/Demos/feature_extraction_demo_vid.m b/matlab_runners/Demos/feature_extraction_demo_vid.m index aa37739..0f01c5f 100644 --- a/matlab_runners/Demos/feature_extraction_demo_vid.m +++ b/matlab_runners/Demos/feature_extraction_demo_vid.m @@ -137,7 +137,7 @@ au_class_inds = cellfun(@(x) ~isempty(x) && x==5, strfind(column_names, '_c')); aus = all_params(valid_frames, au_class_inds); figure -plot(time, aus); +plot(time_stamps, aus); title('Facial Action Units (presense)'); xlabel('Time (s)'); ylim([0,2]); @@ -146,7 +146,7 @@ pose_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'pose_')); pose = all_params(valid_frames, pose_inds); figure -plot(pose); +plot(time_stamps, pose); title('Pose (rotation and translation)'); xlabel('Time (s)'); @@ -158,7 +158,7 @@ gaze = all_params(valid_frames, gaze_inds); plot(time, gaze(:,1), 'DisplayName', 'Left - right'); hold on; -plot(time, gaze(:,2), 'DisplayName', 'Up - down'); +plot(time_stamps, gaze(:,2), 'DisplayName', 'Up - down'); xlabel('Time(s)') % x-axis label ylabel('Angle radians') % y-axis label legend('show');