Exemplo n.º 1
0
void Classifier::SaveClassifierToFile(string fileName)
{
	if (em_model.isTrained() == false)
		return;

	FileStorage fs = FileStorage(fileName, FileStorage::WRITE);
	em_model.write(fs);

	fs.release();
}
Exemplo n.º 2
0
//Learn classifier
bool Classifier::Train(Mat sample)
{
	cout << "Training classfication model...";
		clock_t startTime_train = clock();
		em_model.train(sample);		
		clock_t endTime_train = clock();
		double timeSec_train = (endTime_train - startTime_train) / static_cast<double>(CLOCKS_PER_SEC);
		cout << " train time = " << timeSec_train << "secs\n";	

		SaveClassifierToFile("em" + to_string(i) + ".xml");
		i++;

	return em_model.isTrained();
}