Ask Your Question
2

Loading a saved yml file for LBPH Algorithm

asked 2014-01-06 04:49:56 -0600

sarwar026 gravatar image

updated 2014-01-06 04:51:20 -0600

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;
edit retag flag offensive close merge delete

Comments

did you try to debug it ?

model->load has a return value, check it !

berak gravatar imageberak ( 2014-01-06 14:16:27 -0600 )edit

@berak: It shows void as Load() return value. My openCV version is 2.4.7

sarwar026 gravatar imagesarwar026 ( 2014-01-06 21:26:30 -0600 )edit

oh, sorry, you're right, i confused something.

berak gravatar imageberak ( 2014-01-07 03:00:57 -0600 )edit

can you give me a direction plz? You solved my previous problem http://answers.opencv.org/question/25564/opencv-recognition-throws-exception-lbph-algorithm/

sarwar026 gravatar imagesarwar026 ( 2014-01-07 21:37:09 -0600 )edit

i am facing the same problem. so i updated opencv from 2.4.7 to 2.4.8, but the problem remains. it shows parsing error and missing , between elements in icvYMLParseValue. i am stuck. i debugged my code and found the exception is only because of model->load. plz help.

AndroidXtreme gravatar imageAndroidXtreme ( 2014-02-16 00:42:54 -0600 )edit

@AndroidXtreme: The problem is in the version 2.4.7. I forgot to give an answer here. I just update the version to 2.4.9 and it resolved. Plz try it. Thanks

sarwar026 gravatar imagesarwar026 ( 2014-02-22 22:14:23 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-02-22 22:15:53 -0600

sarwar026 gravatar image

My OpenCV version is 2.4.7 which has the bug I guess. After I updated my version to 2.4.9 it works!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-06 04:49:56 -0600

Seen: 1,104 times

Last updated: Feb 22 '14