From 57ebf069c36c0bca66911e8f945a7eacac6e6136 Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Wed, 20 Dec 2017 07:08:14 +0000 Subject: [PATCH 1/2] Bug fix Bosphorus script. --- .../Action Unit Experiments/run_AU_prediction_Bosphorus.m | 4 ++-- matlab_runners/Gaze Experiments/mpii_1500_errs.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/matlab_runners/Action Unit Experiments/run_AU_prediction_Bosphorus.m b/matlab_runners/Action Unit Experiments/run_AU_prediction_Bosphorus.m index 4c34dbc..b60e3bf 100644 --- a/matlab_runners/Action Unit Experiments/run_AU_prediction_Bosphorus.m +++ b/matlab_runners/Action Unit Experiments/run_AU_prediction_Bosphorus.m @@ -9,9 +9,9 @@ out_loc = './out_bosph/'; %% if(isunix) - executable = '"../../build/bin/FeatureExtraction"'; + executable = '"../../build/bin/FaceLandmarkImg"'; else - executable = '"../../x64/Release/FeatureExtraction.exe"'; + executable = '"../../x64/Release/FaceLandmarkImg.exe"'; end bosph_dirs = dir([Bosphorus_dir, '/BosphorusDB/BosphorusDB/bs*']); diff --git a/matlab_runners/Gaze Experiments/mpii_1500_errs.txt b/matlab_runners/Gaze Experiments/mpii_1500_errs.txt index 4a203b7..99b3432 100644 --- a/matlab_runners/Gaze Experiments/mpii_1500_errs.txt +++ b/matlab_runners/Gaze Experiments/mpii_1500_errs.txt @@ -1,2 +1,2 @@ Mean error, median error -9.438, 8.611 +9.428, 8.611 From 1e1a44c61faa2c0051fe8bd83b416ef6447f993e Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Sat, 23 Dec 2017 10:13:07 +0000 Subject: [PATCH 2/2] Removing no longer needed functions. --- .../include/LandmarkDetectorUtils.h | 9 - .../src/LandmarkDetectorUtils.cpp | 330 ------------------ 2 files changed, 339 deletions(-) diff --git a/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h b/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h index a28bdcd..a716dda 100644 --- a/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h +++ b/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h @@ -48,15 +48,6 @@ namespace LandmarkDetector //=========================================================================== // Defining a set of useful utility functions to be used within CLNF - - //============================================================================================= - // Helper functions for parsing the inputs - //============================================================================================= - void get_video_input_output_params(vector &input_video_file, vector &output_files, string &output_codec, vector &arguments); - - void get_image_input_output_params(vector &input_image_files, vector &output_feature_files, vector &output_pose_files, vector &output_image_files, - vector> &input_bounding_boxes, vector &arguments); - //=========================================================================== // Fast patch expert response computation (linear model across a ROI) using normalised cross-correlation //=========================================================================== diff --git a/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp b/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp index 80133ff..0f2ba56 100644 --- a/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp +++ b/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp @@ -40,341 +40,11 @@ #include #include -// Boost includes -#include -#include - -using namespace boost::filesystem; - using namespace std; namespace LandmarkDetector { - -// Useful utility for creating directories for storing the output files -void create_directory_from_file(string output_path) -{ - - // Creating the right directory structure - - // First get rid of the file - auto p = path(path(output_path).parent_path()); - - if(!p.empty() && !boost::filesystem::exists(p)) - { - bool success = boost::filesystem::create_directories(p); - if(!success) - { - cout << "Failed to create a directory... " << p.string() << endl; - } - } -} - -// Useful utility for creating directories for storing the output files -void create_directories(string output_path) -{ - - // Creating the right directory structure - - // First get rid of the file - auto p = path(output_path); - - if(!p.empty() && !boost::filesystem::exists(p)) - { - bool success = boost::filesystem::create_directories(p); - if(!success) - { - cout << "Failed to create a directory... " << p.string() << endl; - } - } -} - -// Extracting the following command line arguments -f, -op, -of, -ov (and possible ordered repetitions) -void get_video_input_output_params(vector &input_video_files, vector &output_files, string& output_codec, vector &arguments) -{ - bool* valid = new bool[arguments.size()]; - - for(size_t i = 0; i < arguments.size(); ++i) - { - valid[i] = true; - } - - // By default use DIVX codec - output_codec = "DIVX"; - - string input_root = ""; - string output_root = ""; - - string separator = string(1, boost::filesystem::path::preferred_separator); - - // First check if there is a root argument (so that videos and outputs could be defined more easilly) - for(size_t i = 0; i < arguments.size(); ++i) - { - if (arguments[i].compare("-root") == 0) - { - input_root = arguments[i + 1] + separator; - output_root = arguments[i + 1] + separator; - - // Add the / or \ to the directory - i++; - } - if (arguments[i].compare("-inroot") == 0) - { - input_root = arguments[i + 1] + separator; - i++; - } - if (arguments[i].compare("-outroot") == 0) - { - output_root = arguments[i + 1] + separator; - i++; - } - } - - for(size_t i = 0; i < arguments.size(); ++i) - { - if (arguments[i].compare("-f") == 0) - { - input_video_files.push_back(input_root + arguments[i + 1]); - valid[i] = false; - valid[i+1] = false; - i++; - } - else if (arguments[i].compare("-of") == 0) - { - output_files.push_back(output_root + arguments[i + 1]); - create_directory_from_file(output_root + arguments[i + 1]); - valid[i] = false; - valid[i+1] = false; - i++; - } - else if (arguments[i].compare("-oc") == 0) - { - if(arguments[i + 1].length() == 4) - output_codec = arguments[i + 1]; - } - } - - for(int i=arguments.size()-1; i >= 0; --i) - { - if(!valid[i]) - { - arguments.erase(arguments.begin()+i); - } - } - -} - -void get_image_input_output_params(vector &input_image_files, vector &output_feature_files, vector &output_pose_files, vector &output_image_files, - vector> &input_bounding_boxes, vector &arguments) -{ - bool* valid = new bool[arguments.size()]; - - string out_pts_dir, out_pose_dir, out_img_dir; - - string input_root = ""; - string output_root = ""; - - string separator = string(1, boost::filesystem::path::preferred_separator); - - // First check if there is a root argument (so that videos and outputs could be defined more easilly) - for (size_t i = 0; i < arguments.size(); ++i) - { - if (arguments[i].compare("-root") == 0) - { - input_root = arguments[i + 1] + separator; - output_root = arguments[i + 1] + separator; - i++; - } - if (arguments[i].compare("-inroot") == 0) - { - input_root = arguments[i + 1] + separator; - i++; - } - if (arguments[i].compare("-outroot") == 0) - { - output_root = arguments[i + 1] + separator; - i++; - } - } - - for(size_t i = 0; i < arguments.size(); ++i) - { - valid[i] = true; - if (arguments[i].compare("-f") == 0) - { - input_image_files.push_back(input_root + arguments[i + 1]); - valid[i] = false; - valid[i+1] = false; - i++; - } - else if (arguments[i].compare("-fdir") == 0) - { - - // parse the -fdir directory by reading in all of the .png and .jpg files in it - path image_directory (arguments[i+1]); - - try - { - // does the file exist and is it a directory - if (exists(image_directory) && is_directory(image_directory)) - { - - vector file_in_directory; - copy(directory_iterator(image_directory), directory_iterator(), back_inserter(file_in_directory)); - - // Sort the images in the directory first - sort(file_in_directory.begin(), file_in_directory.end()); - - for (vector::const_iterator file_iterator (file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator) - { - // Possible image extension .jpg and .png - if(file_iterator->extension().string().compare(".jpg") == 0 || file_iterator->extension().string().compare(".png") == 0 || file_iterator->extension().string().compare(".bmp") == 0) - { - - - input_image_files.push_back(file_iterator->string()); - - // If there exists a .txt file corresponding to the image, it is assumed that it contains a bounding box definition for a face - // [minx, miny, maxx, maxy] - path current_file = *file_iterator; - path bbox = current_file.replace_extension("txt"); - - // If there is a bounding box file push it to the list of bounding boxes - if(exists(bbox)) - { - - std::ifstream in_bbox(bbox.string().c_str(), ios_base::in); - - double min_x, min_y, max_x, max_y; - - in_bbox >> min_x >> min_y >> max_x >> max_y; - - in_bbox.close(); - - input_bounding_boxes.push_back(cv::Rect_(min_x, min_y, max_x - min_x, max_y - min_y)); - } - } - } - } - } - catch (const filesystem_error& ex) - { - cout << ex.what() << '\n'; - } - - valid[i] = false; - valid[i+1] = false; - i++; - } - else if (arguments[i].compare("-ofdir") == 0) - { - out_pts_dir = arguments[i + 1]; - create_directories(out_pts_dir); - valid[i] = false; - valid[i+1] = false; - i++; - } - else if (arguments[i].compare("-opdir") == 0) - { - out_pose_dir = arguments[i + 1]; - create_directories(out_pose_dir); - valid[i] = false; - valid[i + 1] = false; - i++; - } - else if (arguments[i].compare("-oidir") == 0) - { - out_img_dir = arguments[i + 1]; - create_directories(out_img_dir); - valid[i] = false; - valid[i+1] = false; - i++; - } - else if (arguments[i].compare("-op") == 0) - { - output_pose_files.push_back(output_root + arguments[i + 1]); - valid[i] = false; - valid[i + 1] = false; - i++; - } - else if (arguments[i].compare("-of") == 0) - { - output_feature_files.push_back(output_root + arguments[i + 1]); - valid[i] = false; - valid[i+1] = false; - i++; - } - else if (arguments[i].compare("-oi") == 0) - { - output_image_files.push_back(output_root + arguments[i + 1]); - valid[i] = false; - valid[i+1] = false; - i++; - } - } - - // If any output directories are defined populate them based on image names - if(!out_img_dir.empty()) - { - for(size_t i=0; i < input_image_files.size(); ++i) - { - path image_loc(input_image_files[i]); - - path fname = image_loc.filename(); - fname = fname.replace_extension("bmp"); - output_image_files.push_back(out_img_dir + "/" + fname.string()); - - } - if(!input_image_files.empty()) - { - create_directory_from_file(output_image_files[0]); - } - } - - if(!out_pts_dir.empty()) - { - for(size_t i=0; i < input_image_files.size(); ++i) - { - path image_loc(input_image_files[i]); - - path fname = image_loc.filename(); - fname = fname.replace_extension("pts"); - output_feature_files.push_back(out_pts_dir + "/" + fname.string()); - } - create_directory_from_file(output_feature_files[0]); - } - - if (!out_pose_dir.empty()) - { - for (size_t i = 0; i < input_image_files.size(); ++i) - { - path image_loc(input_image_files[i]); - - path fname = image_loc.filename(); - fname = fname.replace_extension("pose"); - output_pose_files.push_back(out_pose_dir + "/" + fname.string()); - } - create_directory_from_file(output_pose_files[0]); - } - - // Make sure the same number of images and bounding boxes is present, if any bounding boxes are defined - if(input_bounding_boxes.size() > 0) - { - assert(input_bounding_boxes.size() == input_image_files.size()); - } - - // Clear up the argument list - for(int i=arguments.size()-1; i >= 0; --i) - { - if(!valid[i]) - { - arguments.erase(arguments.begin()+i); - } - } - -} - //=========================================================================== // Fast patch expert response computation (linear model across a ROI) using normalised cross-correlation //===========================================================================