1

I have an SVM RBF Model that was trained using libsvm. I have a feature extractor that is now developed in OpenCV and rather than re-training the model in OpenCV, I want to use the libsvm model directly. I am loading the model using libsvm using svm_load_model. I now want to use svm_predict(model,x) but the test data is to be loaded into svm_node x. How do I convert OpenCV Mat feature to svm_node or for that matter a C++ vector feature to svm_node x?

struct svm_node
{
int index;
double value;
};
4

2 回答 2

2

http://book.caltech.edu/bookforum/archive/index.php/t-4065.html

看看这个。这与您(和我)面临的类似问题。

于 2013-11-20T20:28:13.203 回答
-3

此链接教程 OpenCV 中的 SVM。
http://docs.opencv.org/doc/tutorials/ml/introduction_to_svm/introduction_to_svm.html

您可以设置 SVM 参数。即 C 和 G.
CvSVMParams 参数;
params.svm_type = CvSVM::C_SVC;
params.kernel_type = CvSVM::LINEAR;
params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);

在 OpenCV
CvSVM SVM 中训练 SVM 模型;
SVM.train(trainingDataMat, labelsMat, Mat(), Mat(), params);

最后,您可以在 SVM 模型中预测数据。
浮动响应 = SVM.predict(sampleMat);

于 2013-06-12T07:27:27.137 回答