Merge pull request #382 from severin-lemaignan/landmark_detector_ctor

Make sure model paths are checked even when using FaceModelParameters default ctor
This commit is contained in:
Tadas Baltrusaitis 2018-03-25 11:42:03 +01:00 committed by GitHub
commit 23f8793731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -108,6 +108,7 @@ struct FaceModelParameters
private:
void init();
void check_model_path(const std::string& root="/");
};
}

View File

@ -57,6 +57,7 @@ FaceModelParameters::FaceModelParameters()
{
// initialise the default values
init();
check_model_path();
}
FaceModelParameters::FaceModelParameters(vector<string> &arguments)
@ -182,17 +183,24 @@ FaceModelParameters::FaceModelParameters(vector<string> &arguments)
}
}
check_model_path(root.string());
}
void FaceModelParameters::check_model_path(const std::string& root)
{
// Make sure model_location is valid
// First check working directory, then the executable's directory, then the config path set by the build process.
boost::filesystem::path config_path = boost::filesystem::path(CONFIG_DIR);
boost::filesystem::path model_path = boost::filesystem::path(model_location);
boost::filesystem::path root_path = boost::filesystem::path(root);
if (boost::filesystem::exists(model_path))
{
model_location = model_path.string();
}
else if (boost::filesystem::exists(root/model_path))
else if (boost::filesystem::exists(root_path/model_path))
{
model_location = (root/model_path).string();
model_location = (root_path/model_path).string();
}
else if (boost::filesystem::exists(config_path/model_path))
{