Fix AU and triangulation loading for FaceLandmarkImg and FeatureExtraction

This commit is contained in:
Chris Watts 2016-12-29 23:40:03 +00:00
parent d21921efdd
commit 4260f6a20e
2 changed files with 68 additions and 49 deletions

View File

@ -317,6 +317,10 @@ int main (int argc, char **argv)
//Convert arguments to more convenient vector form //Convert arguments to more convenient vector form
vector<string> arguments = get_arguments(argc, argv); vector<string> arguments = get_arguments(argc, argv);
// Search paths
boost::filesystem::path config_path = boost::filesystem::path(CONFIG_DIR);
boost::filesystem::path parent_path = boost::filesystem::path(arguments[0]).parent_path();
// Some initial parameters that can be overriden from command line // Some initial parameters that can be overriden from command line
vector<string> files, depth_files, output_images, output_landmark_locations, output_pose_locations; vector<string> files, depth_files, output_images, output_landmark_locations, output_pose_locations;
@ -356,38 +360,44 @@ int main (int argc, char **argv)
// Loading the AU prediction models // Loading the AU prediction models
string au_loc = "AU_predictors/AU_all_static.txt"; string au_loc = "AU_predictors/AU_all_static.txt";
if (!boost::filesystem::exists(boost::filesystem::path(au_loc))) boost::filesystem::path au_loc_path = boost::filesystem::path(au_loc);
if (boost::filesystem::exists(au_loc_path))
{ {
boost::filesystem::path loc = boost::filesystem::path(arguments[0]).parent_path() / au_loc; au_loc = au_loc_path.string();
}
if (boost::filesystem::exists(loc)) else if (boost::filesystem::exists(parent_path/au_loc_path))
{ {
au_loc = loc.string(); au_loc = (parent_path/au_loc_path).string();
} }
else else if (boost::filesystem::exists(config_path/au_loc_path))
{ {
cout << "Can't find AU prediction files, exiting" << endl; au_loc = (config_path/au_loc_path).string();
return 1; }
} else
{
cout << "Can't find AU prediction files, exiting" << endl;
return 1;
} }
// Used for image masking for AUs // Used for image masking for AUs
string tri_loc; string tri_loc;
if (boost::filesystem::exists(boost::filesystem::path("model/tris_68_full.txt"))) boost::filesystem::path tri_loc_path = boost::filesystem::path("model/tris_68_full.txt");
if (boost::filesystem::exists(tri_loc_path))
{ {
std::ifstream triangulation_file("model/tris_68_full.txt"); tri_loc = tri_loc_path.string();
tri_loc = "model/tris_68_full.txt"; }
else if (boost::filesystem::exists(parent_path/tri_loc_path))
{
tri_loc = (parent_path/tri_loc_path).string();
}
else if (boost::filesystem::exists(config_path/tri_loc_path))
{
tri_loc = (config_path/tri_loc_path).string();
} }
else else
{ {
boost::filesystem::path loc = boost::filesystem::path(arguments[0]).parent_path() / "model/tris_68_full.txt"; cout << "Can't find triangulation files, exiting" << endl;
tri_loc = loc.string(); return 1;
if (!exists(loc))
{
cout << "Can't find triangulation files, exiting" << endl;
return 1;
}
} }
FaceAnalysis::FaceAnalyser face_analyser(vector<cv::Vec3d>(), 0.7, 112, 112, au_loc, tri_loc); FaceAnalysis::FaceAnalyser face_analyser(vector<cv::Vec3d>(), 0.7, 112, 112, au_loc, tri_loc);

View File

@ -81,6 +81,9 @@
#include <FaceAnalyser.h> #include <FaceAnalyser.h>
#include <GazeEstimation.h> #include <GazeEstimation.h>
#ifndef CONFIG_DIR
#define CONFIG_DIR "~"
#endif
#define INFO_STREAM( stream ) \ #define INFO_STREAM( stream ) \
std::cout << stream << std::endl std::cout << stream << std::endl
@ -242,6 +245,10 @@ int main (int argc, char **argv)
vector<string> arguments = get_arguments(argc, argv); vector<string> arguments = get_arguments(argc, argv);
// Search paths
boost::filesystem::path config_path = boost::filesystem::path(CONFIG_DIR);
boost::filesystem::path parent_path = boost::filesystem::path(arguments[0]).parent_path();
// Some initial parameters that can be overriden from command line // Some initial parameters that can be overriden from command line
vector<string> input_files, depth_directories, output_files, tracked_videos_output; vector<string> input_files, depth_directories, output_files, tracked_videos_output;
@ -322,22 +329,24 @@ int main (int argc, char **argv)
output_2D_landmarks, output_3D_landmarks, output_model_params, output_pose, output_AUs, output_gaze, arguments); output_2D_landmarks, output_3D_landmarks, output_model_params, output_pose, output_AUs, output_gaze, arguments);
// Used for image masking // Used for image masking
string tri_loc; string tri_loc;
if(boost::filesystem::exists(path("model/tris_68_full.txt"))) boost::filesystem::path tri_loc_path = boost::filesystem::path("model/tris_68_full.txt");
if (boost::filesystem::exists(tri_loc_path))
{ {
tri_loc = "model/tris_68_full.txt"; tri_loc = tri_loc_path.string();
}
else if (boost::filesystem::exists(parent_path/tri_loc_path))
{
tri_loc = (parent_path/tri_loc_path).string();
}
else if (boost::filesystem::exists(config_path/tri_loc_path))
{
tri_loc = (config_path/tri_loc_path).string();
} }
else else
{ {
path loc = path(arguments[0]).parent_path() / "model/tris_68_full.txt"; cout << "Can't find triangulation files, exiting" << endl;
tri_loc = loc.string(); return 1;
if(!exists(loc))
{
cout << "Can't find triangulation files, exiting" << endl;
return 1;
}
} }
// Will warp to scaled mean shape // Will warp to scaled mean shape
@ -362,23 +371,23 @@ int main (int argc, char **argv)
au_loc_local = "AU_predictors/AU_all_static.txt"; au_loc_local = "AU_predictors/AU_all_static.txt";
} }
if(boost::filesystem::exists(path(au_loc_local))) boost::filesystem::path au_loc_path = boost::filesystem::path(au_loc_local);
if (boost::filesystem::exists(au_loc_path))
{ {
au_loc = au_loc_local; au_loc = au_loc_path.string();
}
else if (boost::filesystem::exists(parent_path/au_loc_path))
{
au_loc = (parent_path/au_loc_path).string();
}
else if (boost::filesystem::exists(config_path/au_loc_path))
{
au_loc = (config_path/au_loc_path).string();
} }
else else
{ {
path loc = path(arguments[0]).parent_path() / au_loc_local; cout << "Can't find AU prediction files, exiting" << endl;
return 1;
if(exists(loc))
{
au_loc = loc.string();
}
else
{
cout << "Can't find AU prediction files, exiting" << endl;
return 1;
}
} }
// Creating a face analyser that will be used for AU extraction // Creating a face analyser that will be used for AU extraction