Ask Your Question

Revision history [back]

Minimizing the FaceRecognizer loading time

I'm following the example here: http://docs.opencv.org/2.4/modules/contrib/doc/facerec/tutorial/facerec_save_load.html

Ptr<FaceRecognizer> model0 = createFisherFaceRecognizer();
model0->train(images, labels);
model0->save("faces_at.yml");    // save the model to faces_at.yaml

The issue is that the size of the saved file is big and it increases as the number inputs(which I train my model on) increases. Is there ANY way that I could reduce the file size? Because of the nature of my application, I need to load my predictor repeatedly which makes everything very slow. Once I've saved the file, I'm not doing any training and I'm using my loaded faceRecognizer for prediction only.

When I look into the YAML file, it seems that one of the things the model saves, is the following:

eigenvectors: !!opencv-matrix
   rows: 10304
   cols: 29

Where 29 is the number of inputs and 10304 =92x112 the resolution of the images. Does the algorithm need this data for its prediction?

Can I modify what is being saved and what is being loaded so that I could reduce the amount of data required to be saved? If so, what do need to save and where should I change?