You could potentially add a command-line-based method that processes input files and saves them to disk, or even perform face detection, face preprocessing, and/or face recognition as a web service. For these types of projects, it is quite easy to add the desired functionality by using the save and load functions of the FaceRecognizer class. You may also want to save the trained data, and then load it on program startup.
Saving the trained model to an XML or YML file is very easy, and is shown as follows:
model->save("trainedModel.yml");
You may also want to save the array of preprocessed faces and labels, if you want to add more data to the training set later.
For example, here is some sample code for loading the trained model from a file. Note that you must specify the face recognition algorithm (for example, FaceRecognizer.Eigenfaces or FaceRecognizer.Fisherfaces) that was originally used to create the trained model:
string facerecAlgorithm = "FaceRecognizer.Fisherfaces";
model = Algorithm::create<FaceRecognizer>(facerecAlgorithm);
Mat labels;
try {
model->load("trainedModel.yml");
labels = model->get<Mat>("labels");
} catch (cv::Exception &e) {}
if (labels.rows <= 0) {
cerr << "ERROR: Couldn't load trained data from "
"[trainedModel.yml]!" << endl;
exit(1);
}