我使用 surf 和 bow 训练 svm ,现在我预测图像时它总是返回我 1 ,即使我选择负图像时它也返回我 1 作为输出
这是 svm 的参数:
CvSVMParams Params;
Params.svm_type=CvSVM::C_SVC;
Params.kernel_type=CvSVM::LINEAR;
Params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);
Params.gamma=3;
CvSVM svm;
svm.train(training_mat,labels,cv::Mat(),cv::Mat(),Params);
这是我的预测代码:
predict_img = cvLoadImage("ss.jpg",0);
detector.detect(predict_img, keypoint2);
RetainBestKeypoints(keypoint2, 20);
dextract.compute( predict_img, keypoint2, descriptors_2);
Mat my_img_3 = descriptors_2.reshape(1,1);
float response = svm.predict(my_img_3);
cout<<response;
这是初始化:
BOWImgDescriptorExtractor dextract(extractor,matcher);
SurfFeatureDetector detector(500);