open source pkg v1
This commit is contained in:
59
pkg/OpenFace/matlab_runners/Demos/Read_HOG_file.m
Normal file
59
pkg/OpenFace/matlab_runners/Demos/Read_HOG_file.m
Normal file
@@ -0,0 +1,59 @@
|
||||
function [hog_data, valid_inds] = Read_HOG_file(hog_file)
|
||||
|
||||
valid_inds = [];
|
||||
|
||||
f = fopen(hog_file, 'r');
|
||||
|
||||
% Pre-allocated data
|
||||
curr_data = [];
|
||||
curr_ind = 0;
|
||||
|
||||
while(~feof(f))
|
||||
|
||||
if(curr_ind == 0)
|
||||
num_cols = fread(f, 1, 'int32');
|
||||
if(isempty(num_cols))
|
||||
break;
|
||||
end
|
||||
|
||||
num_rows = fread(f, 1, 'int32');
|
||||
num_chan = fread(f, 1, 'int32');
|
||||
|
||||
curr_ind = curr_ind + 1;
|
||||
|
||||
% preallocate some space
|
||||
if(curr_ind == 1)
|
||||
curr_data = zeros(1000, 1 + num_rows * num_cols * num_chan);
|
||||
num_feats = 1 + num_rows * num_cols * num_chan;
|
||||
end
|
||||
|
||||
if(curr_ind > size(curr_data,1))
|
||||
curr_data = cat(1, curr_data, zeros(1000, 1 + num_rows * num_cols * num_chan));
|
||||
end
|
||||
feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32');
|
||||
curr_data(curr_ind, :) = feature_vec;
|
||||
else
|
||||
|
||||
% Reading in batches of 5000
|
||||
|
||||
feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32');
|
||||
feature_vec = feature_vec(4:end,:)';
|
||||
|
||||
num_rows_read = size(feature_vec,1);
|
||||
|
||||
if(~isempty(feature_vec))
|
||||
curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec;
|
||||
curr_ind = curr_ind + size(feature_vec,1);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
fclose(f);
|
||||
|
||||
% Do some cleanup, remove un-allocated data
|
||||
if(~isempty(curr_data))
|
||||
valid_inds = curr_data(1:curr_ind,1);
|
||||
hog_data = curr_data(1:curr_ind,2:end);
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,179 @@
|
||||
% A demo script that demonstrates how to process a single video file using
|
||||
% OpenFace and extract and visualize all of the features
|
||||
|
||||
clear
|
||||
|
||||
% The location executable will depend on the OS
|
||||
if(isunix)
|
||||
executable = '"../../build/bin/FeatureExtraction"';
|
||||
else
|
||||
executable = '"../../x64/Release/FeatureExtraction.exe"';
|
||||
end
|
||||
|
||||
% Input file
|
||||
in_dir = '../../samples/image_sequence';
|
||||
|
||||
% Where to store the output
|
||||
output_dir = './processed_features/';
|
||||
|
||||
% This will take directory after -fdir and output all the features to directory
|
||||
% after -out_dir
|
||||
command = sprintf('%s -fdir "%s" -out_dir "%s" -verbose', executable, in_dir, output_dir);
|
||||
|
||||
if(isunix)
|
||||
unix(command);
|
||||
else
|
||||
dos(command);
|
||||
end
|
||||
|
||||
%% Demonstrating reading the output files
|
||||
|
||||
% 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_dir);
|
||||
output_csv = sprintf('%s/%s.csv', output_dir, name);
|
||||
|
||||
% First read in the column names, to know which columns to read for
|
||||
% particular features
|
||||
tab = readtable(output_csv);
|
||||
column_names = tab.Properties.VariableNames;
|
||||
|
||||
% Read all of the data
|
||||
all_params = dlmread(output_csv, ',', 1, 0);
|
||||
|
||||
% This indicates which frames were succesfully tracked
|
||||
|
||||
% Find which column contains success of tracking data and timestamp data
|
||||
valid_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'success'));
|
||||
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
|
||||
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_'));
|
||||
|
||||
% Output rigid (first 6) and non-rigid shape parameters
|
||||
shape_params = all_params(valid_frames, shape_inds);
|
||||
|
||||
figure
|
||||
plot(frame_nums, shape_params);
|
||||
title('Shape parameters');
|
||||
xlabel('Frame');
|
||||
|
||||
%% Demonstrate 2D landmarks
|
||||
landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'x_'));
|
||||
landmark_inds_y = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'y_'));
|
||||
|
||||
xs = all_params(valid_frames, landmark_inds_x);
|
||||
ys = all_params(valid_frames, landmark_inds_y);
|
||||
|
||||
eye_landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_x_'));
|
||||
eye_landmark_inds_y = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_y_'));
|
||||
|
||||
eye_xs = all_params(valid_frames, eye_landmark_inds_x);
|
||||
eye_ys = all_params(valid_frames, eye_landmark_inds_y);
|
||||
|
||||
figure
|
||||
|
||||
for j = 1:size(xs,1)
|
||||
plot(xs(j,:), -ys(j,:), '.');
|
||||
hold on;
|
||||
plot(eye_xs(j,:), -eye_ys(j,:), '.r');
|
||||
hold off;
|
||||
|
||||
xlim([min(xs(1,:)) * 0.5, max(xs(2,:))*1.4]);
|
||||
ylim([min(-ys(1,:)) * 1.4, max(-ys(2,:))*0.5]);
|
||||
xlabel('x (px)');
|
||||
ylabel('y (px)');
|
||||
drawnow
|
||||
end
|
||||
|
||||
|
||||
%% Demonstrate 3D landmarks
|
||||
landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'X_'));
|
||||
landmark_inds_y = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'Y_'));
|
||||
landmark_inds_z = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'Z_'));
|
||||
|
||||
xs = all_params(valid_frames, landmark_inds_x);
|
||||
ys = all_params(valid_frames, landmark_inds_y);
|
||||
zs = all_params(valid_frames, landmark_inds_z);
|
||||
|
||||
eye_landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_X_'));
|
||||
eye_landmark_inds_y = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_Y_'));
|
||||
eye_landmark_inds_z = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_Z_'));
|
||||
|
||||
eye_xs = all_params(valid_frames, eye_landmark_inds_x);
|
||||
eye_ys = all_params(valid_frames, eye_landmark_inds_y);
|
||||
eye_zs = all_params(valid_frames, eye_landmark_inds_z);
|
||||
|
||||
figure
|
||||
for j = 1:size(xs,1)
|
||||
plot3(xs(j,:), ys(j,:), zs(j,:), '.');axis equal;
|
||||
hold on;
|
||||
plot3(eye_xs(j,:), eye_ys(j,:), eye_zs(j,:), '.r');
|
||||
hold off;
|
||||
xlabel('X (mm)');
|
||||
ylabel('Y (mm)');
|
||||
zlabel('Z (mm)');
|
||||
drawnow
|
||||
end
|
||||
|
||||
%% Demonstrate AUs
|
||||
au_reg_inds = cellfun(@(x) ~isempty(x) && x==5, strfind(column_names, '_r'));
|
||||
|
||||
aus = all_params(valid_frames, au_reg_inds);
|
||||
figure
|
||||
plot(frame_nums, aus);
|
||||
title('Facial Action Units (intensity)');
|
||||
xlabel('Time (s)');
|
||||
ylabel('Intensity');
|
||||
ylim([0,6]);
|
||||
|
||||
au_class_inds = cellfun(@(x) ~isempty(x) && x==5, strfind(column_names, '_c'));
|
||||
|
||||
aus = all_params(valid_frames, au_class_inds);
|
||||
figure
|
||||
plot(frame_nums, aus);
|
||||
title('Facial Action Units (presense)');
|
||||
xlabel('Time (s)');
|
||||
ylim([0,2]);
|
||||
%% Demo pose
|
||||
pose_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'pose_'));
|
||||
|
||||
pose = all_params(valid_frames, pose_inds);
|
||||
figure
|
||||
plot(frame_nums, pose);
|
||||
title('Pose (rotation and translation)');
|
||||
xlabel('Frame number');
|
||||
|
||||
%% Demo gaze
|
||||
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(frame_nums, gaze(:,1), 'DisplayName', 'Left - right');
|
||||
hold on;
|
||||
plot(frame_nums, gaze(:,2), 'DisplayName', 'Up - down');
|
||||
xlabel('Frame number') % x-axis label
|
||||
ylabel('Angle radians') % y-axis label
|
||||
legend('show');
|
||||
hold off;
|
||||
|
||||
%% Output HOG files
|
||||
output_hog_file = sprintf('%s/%s.hog', output_dir, name);
|
||||
[hog_data, valid_inds] = Read_HOG_file(output_hog_file);
|
||||
|
||||
%% Output aligned images
|
||||
output_aligned_dir = sprintf('%s/%s_aligned/', output_dir, name);
|
||||
img_files = dir([output_aligned_dir, '/*.bmp']);
|
||||
imgs = cell(numel(img_files, 1));
|
||||
for i=1:numel(img_files)
|
||||
imgs{i} = imread([ output_aligned_dir, '/', img_files(i).name]);
|
||||
imshow(imgs{i})
|
||||
drawnow
|
||||
end
|
||||
179
pkg/OpenFace/matlab_runners/Demos/feature_extraction_demo_vid.m
Normal file
179
pkg/OpenFace/matlab_runners/Demos/feature_extraction_demo_vid.m
Normal file
@@ -0,0 +1,179 @@
|
||||
% A demo script that demonstrates how to process a single video file using
|
||||
% OpenFace and extract and visualize all of the features
|
||||
|
||||
clear
|
||||
|
||||
% The location executable will depend on the OS
|
||||
if(isunix)
|
||||
executable = '"../../build/bin/FeatureExtraction"';
|
||||
else
|
||||
executable = '"../../x64/Release/FeatureExtraction.exe"';
|
||||
end
|
||||
|
||||
% Input file
|
||||
in_file = '../../samples/default.wmv';
|
||||
|
||||
% Where to store the output
|
||||
output_dir = './processed_features/';
|
||||
|
||||
% This will take file after -f and output all the features to directory
|
||||
% after -out_dir
|
||||
command = sprintf('%s -f "%s" -out_dir "%s" -verbose', executable, in_file, output_dir);
|
||||
|
||||
if(isunix)
|
||||
unix(command);
|
||||
else
|
||||
dos(command);
|
||||
end
|
||||
|
||||
%% Demonstrating reading the output files
|
||||
|
||||
% 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);
|
||||
output_csv = sprintf('%s/%s.csv', output_dir, name);
|
||||
|
||||
% First read in the column names, to know which columns to read for
|
||||
% particular features
|
||||
tab = readtable(output_csv);
|
||||
column_names = tab.Properties.VariableNames;
|
||||
|
||||
% Read all of the data
|
||||
all_params = dlmread(output_csv, ',', 1, 0);
|
||||
|
||||
% This indicates which frames were succesfully tracked
|
||||
|
||||
% 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'));
|
||||
|
||||
% 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);
|
||||
|
||||
%% Finding which header line starts with p_ (basically model params)
|
||||
shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_'));
|
||||
|
||||
% Output rigid (first 6) and non-rigid shape parameters
|
||||
shape_params = all_params(valid_frames, shape_inds);
|
||||
|
||||
figure
|
||||
plot(time_stamps, shape_params);
|
||||
title('Shape parameters');
|
||||
xlabel('Time (s)');
|
||||
|
||||
%% Demonstrate 2D landmarks
|
||||
landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'x_'));
|
||||
landmark_inds_y = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'y_'));
|
||||
|
||||
xs = all_params(valid_frames, landmark_inds_x);
|
||||
ys = all_params(valid_frames, landmark_inds_y);
|
||||
|
||||
eye_landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_x_'));
|
||||
eye_landmark_inds_y = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_y_'));
|
||||
|
||||
eye_xs = all_params(valid_frames, eye_landmark_inds_x);
|
||||
eye_ys = all_params(valid_frames, eye_landmark_inds_y);
|
||||
|
||||
figure
|
||||
|
||||
for j = 1:size(xs,1)
|
||||
plot(xs(j,:), -ys(j,:), '.');
|
||||
hold on;
|
||||
plot(eye_xs(j,:), -eye_ys(j,:), '.r');
|
||||
hold off;
|
||||
|
||||
xlim([min(xs(1,:)) * 0.5, max(xs(2,:))*1.4]);
|
||||
ylim([min(-ys(1,:)) * 1.4, max(-ys(2,:))*0.5]);
|
||||
xlabel('x (px)');
|
||||
ylabel('y (px)');
|
||||
drawnow
|
||||
end
|
||||
|
||||
|
||||
%% Demonstrate 3D landmarks
|
||||
landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'X_'));
|
||||
landmark_inds_y = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'Y_'));
|
||||
landmark_inds_z = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'Z_'));
|
||||
|
||||
xs = all_params(valid_frames, landmark_inds_x);
|
||||
ys = all_params(valid_frames, landmark_inds_y);
|
||||
zs = all_params(valid_frames, landmark_inds_z);
|
||||
|
||||
eye_landmark_inds_x = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_X_'));
|
||||
eye_landmark_inds_y = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_Y_'));
|
||||
eye_landmark_inds_z = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'eye_lmk_Z_'));
|
||||
|
||||
eye_xs = all_params(valid_frames, eye_landmark_inds_x);
|
||||
eye_ys = all_params(valid_frames, eye_landmark_inds_y);
|
||||
eye_zs = all_params(valid_frames, eye_landmark_inds_z);
|
||||
|
||||
figure
|
||||
for j = 1:size(xs,1)
|
||||
plot3(xs(j,:), ys(j,:), zs(j,:), '.');axis equal;
|
||||
hold on;
|
||||
plot3(eye_xs(j,:), eye_ys(j,:), eye_zs(j,:), '.r');
|
||||
hold off;
|
||||
xlabel('X (mm)');
|
||||
ylabel('Y (mm)');
|
||||
zlabel('Z (mm)');
|
||||
drawnow
|
||||
end
|
||||
|
||||
%% Demonstrate AUs
|
||||
au_reg_inds = cellfun(@(x) ~isempty(x) && x==5, strfind(column_names, '_r'));
|
||||
|
||||
aus = all_params(valid_frames, au_reg_inds);
|
||||
figure
|
||||
plot(time_stamps, aus);
|
||||
title('Facial Action Units (intensity)');
|
||||
xlabel('Time (s)');
|
||||
ylabel('Intensity');
|
||||
ylim([0,6]);
|
||||
|
||||
au_class_inds = cellfun(@(x) ~isempty(x) && x==5, strfind(column_names, '_c'));
|
||||
|
||||
aus = all_params(valid_frames, au_class_inds);
|
||||
figure
|
||||
plot(time_stamps, aus);
|
||||
title('Facial Action Units (presense)');
|
||||
xlabel('Time (s)');
|
||||
ylim([0,2]);
|
||||
%% Demo pose
|
||||
pose_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'pose_'));
|
||||
|
||||
pose = all_params(valid_frames, pose_inds);
|
||||
figure
|
||||
plot(time_stamps, pose);
|
||||
title('Pose (rotation and translation)');
|
||||
xlabel('Time (s)');
|
||||
|
||||
%% Demo gaze
|
||||
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_stamps, gaze(:,1), 'DisplayName', 'Left - right');
|
||||
hold on;
|
||||
plot(time_stamps, gaze(:,2), 'DisplayName', 'Up - down');
|
||||
xlabel('Time(s)') % x-axis label
|
||||
ylabel('Angle radians') % y-axis label
|
||||
legend('show');
|
||||
hold off;
|
||||
|
||||
%% Output HOG files
|
||||
output_hog_file = sprintf('%s/%s.hog', output_dir, name);
|
||||
[hog_data, valid_inds] = Read_HOG_file(output_hog_file);
|
||||
|
||||
%% Output aligned images
|
||||
output_aligned_dir = sprintf('%s/%s_aligned/', output_dir, name);
|
||||
img_files = dir([output_aligned_dir, '/*.bmp']);
|
||||
imgs = cell(numel(img_files, 1));
|
||||
for i=1:numel(img_files)
|
||||
imgs{i} = imread([ output_aligned_dir, '/', img_files(i).name]);
|
||||
imshow(imgs{i})
|
||||
drawnow
|
||||
end
|
||||
41
pkg/OpenFace/matlab_runners/Demos/gaze_extraction_demo_vid.m
Normal file
41
pkg/OpenFace/matlab_runners/Demos/gaze_extraction_demo_vid.m
Normal file
@@ -0,0 +1,41 @@
|
||||
clear
|
||||
|
||||
if(isunix)
|
||||
executable = '"../../build/bin/FeatureExtraction"';
|
||||
else
|
||||
executable = '"../../x64/Release/FeatureExtraction.exe"';
|
||||
end
|
||||
|
||||
output = './processed_features/';
|
||||
|
||||
in_file = '../../samples/2015-10-15-15-14.avi';
|
||||
|
||||
command = sprintf('%s -f "%s" -out_dir "%s" -gaze -verbose', executable, in_file, output);
|
||||
|
||||
if(isunix)
|
||||
unix(command);
|
||||
else
|
||||
dos(command);
|
||||
end
|
||||
|
||||
%% Demonstrating reading the output files
|
||||
[~, out_filename,~] = fileparts(in_file);
|
||||
out_filename = sprintf('%s/%s.csv', output, out_filename);
|
||||
|
||||
% First read in the column names
|
||||
tab = readtable(out_filename);
|
||||
column_names = tab.Properties.VariableNames;
|
||||
|
||||
all_params = dlmread(out_filename, ',', 1, 0);
|
||||
|
||||
gaze_angle_ids = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'gaze_angle_'));
|
||||
|
||||
gaze = all_params(:,gaze_angle_ids);
|
||||
|
||||
plot(gaze(:,1), 'DisplayName', 'Left - right');
|
||||
hold on;
|
||||
plot(gaze(:,2), 'DisplayName', 'Up - down');
|
||||
xlabel('Frame') % x-axis label
|
||||
ylabel('Angle in radians') % y-axis label
|
||||
legend('show');
|
||||
hold off;
|
||||
47
pkg/OpenFace/matlab_runners/Demos/run_demo_align_size.m
Normal file
47
pkg/OpenFace/matlab_runners/Demos/run_demo_align_size.m
Normal file
@@ -0,0 +1,47 @@
|
||||
% A demo script that demonstrates how to extract aligned faces from a sequence,
|
||||
% also shows how to extract different sized aligned faces
|
||||
|
||||
clear
|
||||
|
||||
% The location executable will depend on the OS
|
||||
if(isunix)
|
||||
executable = '"../../build/bin/FeatureExtraction"';
|
||||
else
|
||||
executable = '"../../x64/Release/FeatureExtraction.exe"';
|
||||
end
|
||||
|
||||
% Input file
|
||||
in_file = '../../samples/default.wmv';
|
||||
|
||||
% Where to store the output
|
||||
output_dir = './processed_features/';
|
||||
|
||||
img_sizes = [64, 112, 224];
|
||||
|
||||
for s=1:numel(img_sizes)
|
||||
% This will take file after -f and output all the features to directory
|
||||
% after -out_dir, with name after -of
|
||||
command = sprintf('%s -f "%s" -out_dir "%s" -simalign -simsize %d -of sample_%d', executable, in_file, output_dir, img_sizes(s), img_sizes(s) );
|
||||
|
||||
if(isunix)
|
||||
unix(command);
|
||||
else
|
||||
dos(command);
|
||||
end
|
||||
|
||||
%% Output aligned images
|
||||
output_aligned_dir = sprintf('%s/sample_%d_aligned/', output_dir, img_sizes(s));
|
||||
img_files = dir([output_aligned_dir, '/*.bmp']);
|
||||
imgs = cell(numel(img_files), 1);
|
||||
|
||||
assert(numel(imgs) > 0);
|
||||
|
||||
for i=1:numel(img_files)
|
||||
imgs{i} = imread([ output_aligned_dir, '/', img_files(i).name]);
|
||||
|
||||
assert(size(imgs{i},1) == img_sizes(s) && size(imgs{i},2) == img_sizes(s));
|
||||
|
||||
imshow(imgs{i})
|
||||
drawnow
|
||||
end
|
||||
end
|
||||
34
pkg/OpenFace/matlab_runners/Demos/run_demo_images.m
Normal file
34
pkg/OpenFace/matlab_runners/Demos/run_demo_images.m
Normal file
@@ -0,0 +1,34 @@
|
||||
clear
|
||||
if(isunix)
|
||||
executable = '"../../build/bin/FaceLandmarkImg"';
|
||||
else
|
||||
executable = '"../../x64/Release/FaceLandmarkImg.exe"';
|
||||
end
|
||||
|
||||
in_dir = '../../samples/';
|
||||
out_dir = './demo_img/';
|
||||
|
||||
model = 'model/main_ceclm_general.txt'; % Trained on in the wild, menpo and multi-pie data (a CE-CLM model)
|
||||
|
||||
% Uncomment the below models if you want to try them
|
||||
%model = 'model/main_clnf_general.txt'; % Trained on in the wild and multi-pie data (a CLNF model)
|
||||
|
||||
%model = 'model/main_clnf_wild.txt'; % Trained on in-the-wild data only
|
||||
|
||||
%model = 'model/main_clm_general.txt'; % Trained on in the wild and multi-pie data (less accurate SVR/CLM model)
|
||||
%model = 'model/main_clm_wild.txt'; % Trained on in-the-wild
|
||||
|
||||
% Load images (-fdir), output images and all the features (-out_dir), use a
|
||||
% user specified model (-mloc), and visualize everything (-verbose)
|
||||
command = sprintf('%s -fdir "%s" -out_dir "%s" -verbose -mloc "%s" ', executable, in_dir, out_dir, model);
|
||||
|
||||
% Demonstrates the multi-hypothesis slow landmark detection (more accurate
|
||||
% when dealing with non-frontal faces and less accurate face detections)
|
||||
% Comment to skip this functionality
|
||||
command = cat(2, command, ' -wild -multi_view 1');
|
||||
|
||||
if(isunix)
|
||||
unix(command);
|
||||
else
|
||||
dos(command);
|
||||
end
|
||||
39
pkg/OpenFace/matlab_runners/Demos/run_demo_video_multi.m
Normal file
39
pkg/OpenFace/matlab_runners/Demos/run_demo_video_multi.m
Normal file
@@ -0,0 +1,39 @@
|
||||
% A demo how to run a multi-face face tracker
|
||||
|
||||
clear;
|
||||
|
||||
if(isunix)
|
||||
executable = '"../../build/bin/FaceLandmarkVidMulti"';
|
||||
else
|
||||
executable = '"../../x64/Release/FaceLandmarkVidMulti.exe"';
|
||||
end
|
||||
|
||||
in_files = dir('../../samples/multi_face.avi');
|
||||
|
||||
model = 'model/main_ceclm_general.txt'; % Trained on in the wild, menpo and multi-pie data (a CE-CLM model)
|
||||
|
||||
% Uncomment the below models if you want to try them
|
||||
%model = 'model/main_clnf_general.txt'; % Trained on in the wild and multi-pie data (a CLNF model)
|
||||
|
||||
% Uncomment the below models if you want to try them
|
||||
%model = 'model/main_clnf_wild.txt'; % Trained on in-the-wild data only
|
||||
|
||||
%model = 'model/main_clm_general.txt'; % Trained on in the wild and multi-pie data (less accurate SVR/CLM model)
|
||||
%model = 'model/main_clm_wild.txt'; % Trained on in-the-wild
|
||||
|
||||
% Create a command that will run the tracker on set of videos and display the output
|
||||
command = sprintf('%s -mloc "%s" -verbose ', executable, model);
|
||||
|
||||
% add all videos to single argument list (so as not to load the model anew
|
||||
% for every video)
|
||||
for i=1:numel(in_files)
|
||||
inputFile = ['../../samples/', in_files(i).name];
|
||||
command = cat(2, command, [' -f "' inputFile '" ']);
|
||||
end
|
||||
|
||||
% Call the executable
|
||||
if(isunix)
|
||||
unix(command);
|
||||
else
|
||||
dos(command);
|
||||
end
|
||||
40
pkg/OpenFace/matlab_runners/Demos/run_demo_videos.m
Normal file
40
pkg/OpenFace/matlab_runners/Demos/run_demo_videos.m
Normal file
@@ -0,0 +1,40 @@
|
||||
% A demo how to run a single-face face tracker
|
||||
|
||||
clear
|
||||
|
||||
if(isunix)
|
||||
executable = '"../../build/bin/FaceLandmarkVid"';
|
||||
else
|
||||
executable = '"../../x64/Release/FaceLandmarkVid.exe"';
|
||||
end
|
||||
|
||||
in_files = dir('../../samples/*.wmv');
|
||||
in_files = cat(1, in_files, dir('../../samples/*.avi'));
|
||||
|
||||
model = 'model/main_ceclm_general.txt'; % Trained on in the wild, menpo and multi-pie data (a CE-CLM model)
|
||||
|
||||
% Uncomment the below models if you want to try them
|
||||
%model = 'model/main_clnf_general.txt'; % Trained on in the wild and multi-pie data (a CLNF model)
|
||||
|
||||
% Uncomment the below models if you want to try them
|
||||
%model = 'model/main_clnf_wild.txt'; % Trained on in-the-wild data only
|
||||
|
||||
%model = 'model/main_clm_general.txt'; % Trained on in the wild and multi-pie data (less accurate SVR/CLM model)
|
||||
%model = 'model/main_clm_wild.txt'; % Trained on in-the-wild
|
||||
|
||||
% Create a command that will run the tracker on set of videos and display the output
|
||||
command = sprintf('%s -mloc "%s" ', executable, model);
|
||||
|
||||
% add all videos to single argument list by appending -f comments
|
||||
% so as not to load the model anew for every video)
|
||||
for i=1:numel(in_files)
|
||||
inputFile = ['../../samples/', in_files(i).name];
|
||||
command = cat(2, command, [' -f "' inputFile '" ']);
|
||||
end
|
||||
|
||||
% Call the executable
|
||||
if(isunix)
|
||||
unix(command);
|
||||
else
|
||||
dos(command);
|
||||
end
|
||||
29
pkg/OpenFace/matlab_runners/Demos/run_test_img_seq.m
Normal file
29
pkg/OpenFace/matlab_runners/Demos/run_test_img_seq.m
Normal file
@@ -0,0 +1,29 @@
|
||||
% A test script on image sequences, making sure grayscale and 16 bit
|
||||
% sequences work
|
||||
|
||||
clear
|
||||
|
||||
% The location executable will depend on the OS
|
||||
if(isunix)
|
||||
executable = '"../../build/bin/FeatureExtraction"';
|
||||
else
|
||||
executable = '"../../x64/Release/FeatureExtraction.exe"';
|
||||
end
|
||||
|
||||
% Input file
|
||||
in_dirs = {'../../samples/image_sequence',...
|
||||
'../../samples/image_sequence_gray', ...
|
||||
'../../samples/image_sequence_16bit'};
|
||||
|
||||
% Where to store the output
|
||||
output_dir = './processed_features/';
|
||||
|
||||
for i=1:numel(in_dirs)
|
||||
command = sprintf('%s -fdir "%s" -out_dir "%s" -verbose', executable, in_dirs{i}, output_dir);
|
||||
|
||||
if(isunix)
|
||||
unix(command);
|
||||
else
|
||||
dos(command);
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user