Ejemplo n.º 1
0
int train(float* src,char *filename,int N)
{
    EM* myGMM = new EM(5);
	FileStorage tmp(filename,cv::FileStorage::WRITE);
    Mat train_32F(N,3,CV_32FC1,src);
    train_32F.convertTo(train_32F,CV_32F,1/255.);
    myGMM->train(train_32F);
    tmp<<"model";
	myGMM->write(tmp);
	tmp.release();
	
    return 0;
}
Ejemplo 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();
}