loading and saving a facerecognizer model

asked 2016-10-05 09:15:56 -0500

atv gravatar image

Is the code listed here still valid: https://books.google.co.uk/books?id=U...

It says to specify model::Algorithm but i think this is old opencv2 syntax.

For example could i do something like this (i know model returns void, i'll use a try { construct like in the google link):

Ptr<BasicFaceRecognizer> model = createFisherFaceRecognizer(0,200.0);
if(model->load("eigenfaces_at.yml")) { // Train
Ptr<BasicFaceRecognizer> model = createFisherFaceRecognizer(0,200.0);
for( int i = 0; i < nlabels; i++ )
model->setLabelInfo(i, labelsInfo[i]);
model->train(images, labels);
model->save("eigenfaces_at.yml"); // Save our model

I'm asking because in the past (and i haven't played with it for a while now) i would get:

 OpenCV Error: Bad argument (This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?) in       predict, file /tmp/opencv-20160502-20452-13c59z2/opencv-2.4.12/modules/contrib/src/facerec.cpp, line 620

Thanks all.

edit retag flag offensive close merge delete