私は 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);