//load some class_1 samples into matrix //load the associated SVM parameter file into SVM //test (predict) Mat test_samples; CvSVM classifier; FileStorage fs ("train_sample/training_samples-1000.yaml.gz" , FileStorage::READ) ; if ( !fs.isOpened() ){ cerr << "Cannot open file " << endl ; return ; } classifier.load("SVM_parameter_files/svm_1000_auto/SVM_classifier_class_1.yaml") ; string class_= "class_"; for ( size_t i = 1 ; i <= 24; i++ ){ stringstream ss ; ss << class_ <<i ; fs[ss.str()] >>test_samples; size_t positive = 0 ; size_t negative = 0 ; //test svm classifier that classify class_1 as positive and others as negative for ( int i = 0 ; i < test_samples.rows ; i++ ){ float res = classifier.predict(test_samples.row(i),false ) ; ( (res == 1) ? (positive++):(negative++) ); } cout << ss.str() << " positive examples = " <<positive <<" , negative examples =" << negative << endl ; } fs.release();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)