Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

loading and saving a facerecognizer model

Is the code listed here still valid: https://books.google.co.uk/books?id=UjWoIFHcr58C&pg=PT446&lpg=PT446&dq=how+do+i+use+model-%3Eload+facerecognizer&source=bl&ots=S9i2zxkw6w&sig=LoQ6IdwdH0C6_07h1sCSFXJs8Jg&hl=en&sa=X&ved=0ahUKEwjAwZuGy9fMAhXmCcAKHVf_Boo4ChDoAQgbMAA#v=onepage&q&f=false

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.