Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Loading a saved yml file for LBPH Algorithm

I've saved the model in .yml extension and tried to load it later. But unfortunately, I'm getting exception when loading the .yml file.

When I tried to recognize the face through predict function,

model->predict(preprocessedFace, identity, confidenceRatio);

it gives me the following exception:

Program has stopped working. 

Windows can check online for a solution bla bla bla...

So, someone please suggest how should I proceed to overcome the problem. Thanks.

My save code:

Ptr<FaceRecognizer> model;
cout << "Learning the collected faces using the [" << facerecAlgorithm << "] algorithm ..." << endl;

bool haveContribModule = initModule_contrib();
if (!haveContribModule) {
    cerr << "ERROR: The 'contrib' module is needed for FaceRecognizer but has not been loaded into OpenCV!" << endl;
    exit(1);
}

model = Algorithm::create<FaceRecognizer>(facerecAlgorithm);
if (model.empty()) {
    cerr << "ERROR: The FaceRecognizer algorithm [" << facerecAlgorithm << "] is not available in your version of OpenCV. Please update to OpenCV v2.4.1 or newer." << endl;
    exit(1);
}

model->train(preprocessedFaces, faceLabels);
model->save("lbph_trained_data1.yml");

My load code:

Ptr<FaceRecognizer> model;

cout << "Loading the file ..." << endl;

bool haveContribModule = initModule_contrib();
if (!haveContribModule) {
    cerr << "ERROR: The 'contrib' module is needed for FaceRecognizer but has not been loaded into OpenCV!" << endl;
    exit(1);
}

model = Algorithm::create<FaceRecognizer>("FaceRecognizer.LBPH");
if (model.empty()) {
    cerr << "ERROR: The FaceRecognizer algorithm [FaceRecognizer.LBPH] is not available in your version of OpenCV. Please update to OpenCV v2.4.1 or newer." << endl;
    exit(1);
}

model->load("H:\\Face\\lbph_trained_data1.yml");
cout << "file loaded successfully" << endl;

Loading a saved yml file for LBPH Algorithm

I've saved the model in .yml extension and tried to load it later. But unfortunately, I'm getting exception when loading the .yml file.

When I tried to recognize the face through predict function,

model->predict(preprocessedFace, identity, confidenceRatio);

it gives me the following exception:

Program has stopped working. 

Windows can check online for a solution bla bla bla...

So, someone please suggest how should I proceed to overcome the problem. Thanks.

My save code:

Ptr<FaceRecognizer> model;
cout << "Learning the collected faces using the [" << facerecAlgorithm << "] algorithm ..." << endl;

bool haveContribModule = initModule_contrib();
if (!haveContribModule) {
    cerr << "ERROR: The 'contrib' module is needed for FaceRecognizer but has not been loaded into OpenCV!" << endl;
    exit(1);
}

model = Algorithm::create<FaceRecognizer>(facerecAlgorithm);
if (model.empty()) {
    cerr << "ERROR: The FaceRecognizer algorithm [" << facerecAlgorithm << "] is not available in your version of OpenCV. Please update to OpenCV v2.4.1 or newer." << endl;
    exit(1);
}

model->train(preprocessedFaces, faceLabels);
model->save("lbph_trained_data1.yml");

My load code:

Ptr<FaceRecognizer> model;

cout << "Loading the file ..." << endl;

bool haveContribModule = initModule_contrib();
if (!haveContribModule) {
    cerr << "ERROR: The 'contrib' module is needed for FaceRecognizer but has not been loaded into OpenCV!" << endl;
    exit(1);
}

model = Algorithm::create<FaceRecognizer>("FaceRecognizer.LBPH");
if (model.empty()) {
    cerr << "ERROR: The FaceRecognizer algorithm [FaceRecognizer.LBPH] is not available in your version of OpenCV. Please update to OpenCV v2.4.1 or newer." << endl;
    exit(1);
}

model->load("H:\\Face\\lbph_trained_data1.yml");
cout << "file loaded successfully" << endl;