mirror of
https://gitcode.com/gh_mirrors/ope/OpenFace.git
synced 2025-12-30 04:52:29 +00:00
Better reporting if model loading failed, better sample image.
This commit is contained in:
@@ -109,6 +109,13 @@ int main(int argc, char **argv)
|
||||
// The modules that are being used for tracking
|
||||
cout << "Loading the model" << endl;
|
||||
LandmarkDetector::CLNF face_model(det_parameters.model_location);
|
||||
|
||||
if (!face_model.loaded_successfully)
|
||||
{
|
||||
cout << "ERROR: Could not load the landmark detector" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
cout << "Model loaded" << endl;
|
||||
|
||||
// Load facial feature extractor and AU analyser (make sure it is static)
|
||||
|
||||
@@ -103,6 +103,11 @@ int main(int argc, char **argv)
|
||||
|
||||
// The modules that are being used for tracking
|
||||
LandmarkDetector::CLNF face_model(det_parameters.model_location);
|
||||
if (!face_model.loaded_successfully)
|
||||
{
|
||||
cout << "ERROR: Could not load the landmark detector" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!face_model.eye_model)
|
||||
{
|
||||
|
||||
@@ -139,6 +139,12 @@ int main(int argc, char **argv)
|
||||
|
||||
LandmarkDetector::CLNF face_model(det_parameters[0].model_location);
|
||||
|
||||
if (!face_model.loaded_successfully)
|
||||
{
|
||||
cout << "ERROR: Could not load the landmark detector" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Loading the face detectors
|
||||
face_model.face_detector_HAAR.load(det_parameters[0].haar_face_detector_location);
|
||||
face_model.haar_face_detector_location = det_parameters[0].haar_face_detector_location;
|
||||
|
||||
@@ -117,6 +117,12 @@ int main(int argc, char **argv)
|
||||
// Always track gaze in feature extraction
|
||||
LandmarkDetector::CLNF face_model(det_parameters.model_location);
|
||||
|
||||
if (!face_model.loaded_successfully)
|
||||
{
|
||||
cout << "ERROR: Could not load the landmark detector" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Load facial feature extractor and AU analyser
|
||||
FaceAnalysis::FaceAnalyserParameters face_analysis_params(arguments);
|
||||
FaceAnalysis::FaceAnalyser face_analyser(face_analysis_params);
|
||||
|
||||
@@ -139,6 +139,9 @@ public:
|
||||
// Tracking which view was used last
|
||||
int view_used;
|
||||
|
||||
// See if the model was read in correctly
|
||||
bool loaded_successfully;
|
||||
|
||||
// A default constructor
|
||||
CLNF();
|
||||
|
||||
@@ -181,12 +184,12 @@ public:
|
||||
|
||||
// Reading the model in
|
||||
void Read(string name);
|
||||
|
||||
// Helper reading function
|
||||
void Read_CLNF(string clnf_location);
|
||||
|
||||
private:
|
||||
|
||||
// Helper reading function
|
||||
bool Read_CLNF(string clnf_location);
|
||||
|
||||
// the speedup of RLMS using precalculated KDE responses (described in Saragih 2011 RLMS paper)
|
||||
map<int, cv::Mat_<float> > kde_resp_precalc;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class PDM{
|
||||
// A copy constructor
|
||||
PDM(const PDM& other);
|
||||
|
||||
void Read(string location);
|
||||
bool Read(string location);
|
||||
|
||||
// Number of vertices
|
||||
inline int NumberOfPoints() const {return mean_shape.rows/3;}
|
||||
|
||||
@@ -108,13 +108,13 @@ public:
|
||||
inline int nViews(size_t scale = 0) const { return (int)centers[scale].size(); };
|
||||
|
||||
// Reading in all of the patch experts
|
||||
void Read(vector<string> intensity_svr_expert_locations, vector<string> intensity_ccnf_expert_locations, vector<string> intensity_cen_expert_locations, string early_term_loc = "");
|
||||
bool Read(vector<string> intensity_svr_expert_locations, vector<string> intensity_ccnf_expert_locations, vector<string> intensity_cen_expert_locations, string early_term_loc = "");
|
||||
|
||||
|
||||
private:
|
||||
void Read_SVR_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<Multi_SVR_patch_expert> >& patches, double& scale);
|
||||
void Read_CCNF_patch_experts(string patchesFileLocation, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CCNF_patch_expert> >& patches, double& patchScaling);
|
||||
void Read_CEN_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CEN_patch_expert> >& patches, double& scale);
|
||||
bool Read_SVR_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<Multi_SVR_patch_expert> >& patches, double& scale);
|
||||
bool Read_CCNF_patch_experts(string patchesFileLocation, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CCNF_patch_expert> >& patches, double& patchScaling);
|
||||
bool Read_CEN_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CEN_patch_expert> >& patches, double& scale);
|
||||
|
||||
// Helper for collecting visibilities
|
||||
std::vector<int> Collect_visible_landmarks(vector<vector<cv::Mat_<int> > > visibilities, int scale, int view_id, int n);
|
||||
|
||||
@@ -61,12 +61,19 @@ using namespace LandmarkDetector;
|
||||
CLNF::CLNF()
|
||||
{
|
||||
FaceModelParameters parameters;
|
||||
|
||||
// A successful read wil set this to true
|
||||
loaded_successfully = false;
|
||||
|
||||
this->Read(parameters.model_location);
|
||||
}
|
||||
|
||||
// Constructor from a model file
|
||||
CLNF::CLNF(string fname)
|
||||
{
|
||||
// A successful read wil set this to true
|
||||
loaded_successfully = false;
|
||||
|
||||
this->Read(fname);
|
||||
}
|
||||
|
||||
@@ -74,7 +81,7 @@ CLNF::CLNF(string fname)
|
||||
CLNF::CLNF(const CLNF& other): pdm(other.pdm), params_local(other.params_local.clone()), params_global(other.params_global), detected_landmarks(other.detected_landmarks.clone()),
|
||||
landmark_likelihoods(other.landmark_likelihoods.clone()), patch_experts(other.patch_experts), landmark_validator(other.landmark_validator), haar_face_detector_location(other.haar_face_detector_location),
|
||||
mtcnn_face_detector_location(other.mtcnn_face_detector_location), hierarchical_mapping(other.hierarchical_mapping), hierarchical_models(other.hierarchical_models), hierarchical_model_names(other.hierarchical_model_names),
|
||||
hierarchical_params(other.hierarchical_params), eye_model(other.eye_model), face_detector_MTCNN(other.face_detector_MTCNN), preference_det(other.preference_det)
|
||||
hierarchical_params(other.hierarchical_params), eye_model(other.eye_model), face_detector_MTCNN(other.face_detector_MTCNN), preference_det(other.preference_det), loaded_successfully(other.loaded_successfully)
|
||||
{
|
||||
this->detection_success = other.detection_success;
|
||||
this->tracking_initialised = other.tracking_initialised;
|
||||
@@ -158,6 +165,8 @@ CLNF & CLNF::operator= (const CLNF& other)
|
||||
|
||||
mtcnn_face_detector_location = other.mtcnn_face_detector_location;
|
||||
face_detector_MTCNN = other.face_detector_MTCNN;
|
||||
|
||||
loaded_successfully = other.loaded_successfully;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -199,6 +208,8 @@ CLNF::CLNF(const CLNF&& other)
|
||||
|
||||
this->preference_det = other.preference_det;
|
||||
|
||||
this->loaded_successfully = other.loaded_successfully;
|
||||
|
||||
}
|
||||
|
||||
// Assignment operator for rvalues
|
||||
@@ -237,11 +248,13 @@ CLNF & CLNF::operator= (const CLNF&& other)
|
||||
|
||||
this->preference_det = other.preference_det;
|
||||
|
||||
this->loaded_successfully = other.loaded_successfully;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void CLNF::Read_CLNF(string clnf_location)
|
||||
bool CLNF::Read_CLNF(string clnf_location)
|
||||
{
|
||||
// Location of modules
|
||||
ifstream locations(clnf_location.c_str(), ios_base::in);
|
||||
@@ -250,7 +263,7 @@ void CLNF::Read_CLNF(string clnf_location)
|
||||
{
|
||||
cout << "Couldn't open the CLNF model file aborting" << endl;
|
||||
cout.flush();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
string line;
|
||||
@@ -294,7 +307,12 @@ void CLNF::Read_CLNF(string clnf_location)
|
||||
if (module.compare("PDM") == 0)
|
||||
{
|
||||
cout << "Reading the PDM module from: " << location << "....";
|
||||
pdm.Read(location);
|
||||
bool read_success = pdm.Read(location);
|
||||
|
||||
if (!read_success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
cout << "Done" << endl;
|
||||
}
|
||||
@@ -303,6 +321,11 @@ void CLNF::Read_CLNF(string clnf_location)
|
||||
cout << "Reading the Triangulations module from: " << location << "....";
|
||||
ifstream triangulationFile(location.c_str(), ios_base::in);
|
||||
|
||||
if(!triangulationFile.is_open())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LandmarkDetector::SkipComments(triangulationFile);
|
||||
|
||||
int numViews;
|
||||
@@ -337,8 +360,15 @@ void CLNF::Read_CLNF(string clnf_location)
|
||||
}
|
||||
|
||||
// Initialise the patch experts
|
||||
patch_experts.Read(intensity_expert_locations, ccnf_expert_locations, cen_expert_locations, early_term_loc);
|
||||
bool read_success = patch_experts.Read(intensity_expert_locations, ccnf_expert_locations, cen_expert_locations, early_term_loc);
|
||||
|
||||
if(!read_success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void CLNF::Read(string main_location)
|
||||
@@ -350,6 +380,7 @@ void CLNF::Read(string main_location)
|
||||
if(!locations.is_open())
|
||||
{
|
||||
cout << "Couldn't open the model file, aborting" << endl;
|
||||
loaded_successfully = false;
|
||||
return;
|
||||
}
|
||||
string line;
|
||||
@@ -389,7 +420,13 @@ void CLNF::Read(string main_location)
|
||||
cout << "Reading the landmark detector module from: " << location << endl;
|
||||
|
||||
// The CLNF module includes the PDM and the patch experts
|
||||
Read_CLNF(location);
|
||||
bool read_success = Read_CLNF(location);
|
||||
|
||||
if(!read_success)
|
||||
{
|
||||
loaded_successfully = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(module.compare("LandmarkDetector_part") == 0)
|
||||
{
|
||||
@@ -412,6 +449,12 @@ void CLNF::Read(string main_location)
|
||||
|
||||
CLNF part_model(location);
|
||||
|
||||
if (!part_model.loaded_successfully)
|
||||
{
|
||||
loaded_successfully = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this->hierarchical_models.push_back(part_model);
|
||||
|
||||
this->hierarchical_model_names.push_back(part_name);
|
||||
@@ -546,6 +589,8 @@ void CLNF::Read(string main_location)
|
||||
preference_det.x = -1;
|
||||
preference_det.y = -1;
|
||||
|
||||
loaded_successfully = true;
|
||||
|
||||
}
|
||||
|
||||
// Resetting the model (for a new video, or complet reinitialisation
|
||||
|
||||
@@ -695,10 +695,14 @@ void PDM::CalcParams(cv::Vec6f& out_params_global, cv::Mat_<float>& out_params_l
|
||||
|
||||
}
|
||||
|
||||
void PDM::Read(string location)
|
||||
bool PDM::Read(string location)
|
||||
{
|
||||
|
||||
|
||||
ifstream pdmLoc(location, ios_base::in);
|
||||
if (!pdmLoc.is_open())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LandmarkDetector::SkipComments(pdmLoc);
|
||||
|
||||
@@ -720,4 +724,6 @@ void PDM::Read(string location)
|
||||
cv::Mat_<double> eigen_values_d;
|
||||
LandmarkDetector::ReadMat(pdmLoc, eigen_values_d);
|
||||
eigen_values_d.convertTo(eigen_values, CV_32F);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ int Patch_experts::GetViewIdx(const cv::Vec6f& params_global, int scale) const
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void Patch_experts::Read(vector<string> intensity_svr_expert_locations, vector<string> intensity_ccnf_expert_locations, vector<string> intensity_cen_expert_locations, string early_term_loc)
|
||||
bool Patch_experts::Read(vector<string> intensity_svr_expert_locations, vector<string> intensity_ccnf_expert_locations, vector<string> intensity_cen_expert_locations, string early_term_loc)
|
||||
{
|
||||
|
||||
// initialise the SVR intensity patch expert parameters
|
||||
@@ -390,7 +390,11 @@ void Patch_experts::Read(vector<string> intensity_svr_expert_locations, vector<s
|
||||
{
|
||||
string location = intensity_svr_expert_locations[scale];
|
||||
cout << "Reading the intensity SVR patch experts from: " << location << "....";
|
||||
Read_SVR_patch_experts(location, centers[scale], visibilities[scale], svr_expert_intensity[scale], patch_scaling[scale]);
|
||||
bool success_read = Read_SVR_patch_experts(location, centers[scale], visibilities[scale], svr_expert_intensity[scale], patch_scaling[scale]);
|
||||
if (!success_read)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise and read CCNF patch experts (currently only intensity based),
|
||||
@@ -409,7 +413,12 @@ void Patch_experts::Read(vector<string> intensity_svr_expert_locations, vector<s
|
||||
{
|
||||
string location = intensity_ccnf_expert_locations[scale];
|
||||
cout << "Reading the intensity CCNF patch experts from: " << location << "....";
|
||||
Read_CCNF_patch_experts(location, centers[scale], visibilities[scale], ccnf_expert_intensity[scale], patch_scaling[scale]);
|
||||
bool success_read = Read_CCNF_patch_experts(location, centers[scale], visibilities[scale], ccnf_expert_intensity[scale], patch_scaling[scale]);
|
||||
|
||||
if (!success_read)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (scale == 0)
|
||||
{
|
||||
@@ -433,7 +442,11 @@ void Patch_experts::Read(vector<string> intensity_svr_expert_locations, vector<s
|
||||
{
|
||||
string location = intensity_cen_expert_locations[scale];
|
||||
cout << "Reading the intensity CEN patch experts from: " << location << "....";
|
||||
Read_CEN_patch_experts(location, centers[scale], visibilities[scale], cen_expert_intensity[scale], patch_scaling[scale]);
|
||||
bool success_read = Read_CEN_patch_experts(location, centers[scale], visibilities[scale], cen_expert_intensity[scale], patch_scaling[scale]);
|
||||
if (!success_read)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (scale == 0)
|
||||
{
|
||||
@@ -448,6 +461,11 @@ void Patch_experts::Read(vector<string> intensity_svr_expert_locations, vector<s
|
||||
{
|
||||
ifstream earlyTermFile(early_term_loc.c_str(), ios_base::in);
|
||||
|
||||
if (!earlyTermFile.is_open())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reading in weights/biases/cutoffs
|
||||
for (int i = 0; i < centers[0].size(); ++i)
|
||||
{
|
||||
@@ -470,10 +488,10 @@ void Patch_experts::Read(vector<string> intensity_svr_expert_locations, vector<s
|
||||
early_term_cutoffs.push_back(cutoff);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//======================= Reading the SVR patch experts =========================================//
|
||||
void Patch_experts::Read_SVR_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<Multi_SVR_patch_expert> >& patches, double& scale)
|
||||
bool Patch_experts::Read_SVR_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<Multi_SVR_patch_expert> >& patches, double& scale)
|
||||
{
|
||||
|
||||
ifstream patchesFile(expert_location.c_str(), ios_base::in);
|
||||
@@ -532,15 +550,17 @@ void Patch_experts::Read_SVR_patch_experts(string expert_location, std::vector<c
|
||||
}
|
||||
|
||||
cout << "Done" << endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Can't find/open the patches file" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//======================= Reading the CCNF patch experts =========================================//
|
||||
void Patch_experts::Read_CCNF_patch_experts(string patchesFileLocation, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CCNF_patch_expert> >& patches, double& patchScaling)
|
||||
bool Patch_experts::Read_CCNF_patch_experts(string patchesFileLocation, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CCNF_patch_expert> >& patches, double& patchScaling)
|
||||
{
|
||||
|
||||
ifstream patchesFile(patchesFileLocation.c_str(), ios::in | ios::binary);
|
||||
@@ -613,15 +633,17 @@ void Patch_experts::Read_CCNF_patch_experts(string patchesFileLocation, std::vec
|
||||
}
|
||||
}
|
||||
cout << "Done" << endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Can't find/open the patches file" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//======================= Reading the CEN patch experts =========================================//
|
||||
void Patch_experts::Read_CEN_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CEN_patch_expert> >& patches, double& scale)
|
||||
bool Patch_experts::Read_CEN_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CEN_patch_expert> >& patches, double& scale)
|
||||
{
|
||||
|
||||
ifstream patchesFile(expert_location.c_str(), ios::in | ios::binary);
|
||||
@@ -670,9 +692,11 @@ void Patch_experts::Read_CEN_patch_experts(string expert_location, std::vector<c
|
||||
}
|
||||
}
|
||||
cout << "Done" << endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Can't find/open the patches file" << endl;
|
||||
cout << "Could not find CEN patch experts, for instructions of how to download them, see https://github.com/TadasBaltrusaitis/OpenFace/wiki/Model-download \n" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ https://www.flickr.com/photos/58842866@N08/5388143519/in/photolist-9d8Dmc-gw5bm6
|
||||
https://www.flickr.com/photos/phild41/8374763064/in/photolist-dL3RhC-66N7as-7dotLe-7cWKR5-614Znb-qtmFFa-9d8ApH-3rDKJ1-7dAJqB-9dbHLo-7cSSSv-7bYXwd-7cChJ3-76qadC-nJV7d4-8icrgY-TZXhp3-r6CqQo-7ZxYAM-c8d8ow-NzZybL-4Yc23a-9yKTpR-rLggYN-JP6Vt-9GE7Yr-4Yc3iK-q2BAZF-9dbLs9-aM48vi-7R8pUS-aEKRnZ-spZQv3-7d7tBM-nGtg3X-mueqda-6JnkB7-muehBN-aEPGau-jrTTpy-pBcvLR-62my1e-du9wzk-mudYkt-Kuizzp-c8d8eC-wEbB9G-give5v-x3tNus-7dAKev
|
||||
https://www.flickr.com/photos/leinadsimpson/18571168/
|
||||
https://www.flickr.com/photos/58842866@N08/5388135593/in/photolist-9d8AZx-ykVZn-745C1V-fsnZ-9d8C9r-745C4P-czkJEw-cVyqM-dFpoGg-cVyGg-5cxqSd-haQUE-QGCbMa-5NN7zB-dGPKw-cVyBo-745C8R-cVysh-cVyB7-cVyoR-cVys6-9d8GnB-cVyDA-haQHJ-cVypm-abUokh-6JhVvz-6ZdA8C-ucatk-cVyot-9d8B8c-9d8DUP-cVyH6-mueBcx-6Jnb2j-dGPJh-9dbL4C-61TYrz-haRdB-eRwkeK-wUU8Z-h9puXH-9PYeL-5hFAFb-2HrU6a-2HJCk-9dbGmh-s1RVE-9d8D9r-72eKHx
|
||||
https://www.flickr.com/photos/montclairfilmfest/26915909057/
|
||||
https://www.flickr.com/photos/montclairfilmfest/26915909057/
|
||||
https://www.flickr.com/photos/zedzap/15358021401/in/photolist-pp8SGr-NePm-sgvh1w-5NXxDK-8CMzWu-rqrhcG-pBCCod-bfUZeX-4ZPaTe-4rpdwL-5Cd1wR-rB3CNB-5NXB1B-2EnmHW-E64P-5nUvot-mHBwo-9WSExP-6BRTxK-jnqZVV-r719qs-WeAicd-4JJbg9-bdhFKv-4Tfp8A-o8R2q5-5N6TRb-5P5yDQ-qkYTv-78vbm7-8X7VjC-dnNVuP-2wXRcE-489YHS-63Tvfh-gmgGjU-7DjTFv-anhffU-bU2cGc-aneqPg-4TbbRk-Qp9eN-68wU8T-5Xie5o-qspVC-9fX3mY-7sNBTX-gmgSLV-joZg27-d6REe
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 129 KiB |
Reference in New Issue
Block a user