Ask Your Question

fnhdx's profile - activity

2019-04-11 21:55:28 -0600 received badge  Popular Question (source)
2015-08-14 14:05:22 -0600 commented answer how to write two dimensional vector to file

@theodore I noticed that loading YML file is very slow. My file is about 180000*10 int (<6Mb on disk). It takes less than 1 sec to write to disk, but more than 20sec to load from disk. Any idea about that?

2015-08-12 14:04:42 -0600 commented answer how to write two dimensional vector to file

This is exactly what I want. Thanks a lot!

2015-08-12 14:03:57 -0600 received badge  Scholar (source)
2015-08-12 14:03:55 -0600 received badge  Supporter (source)
2015-08-12 09:48:46 -0600 asked a question how to write two dimensional vector to file

I have two dimensional vector vector<vector<int> > test; I want to save it to file and read it back. I tried to write it to a FileStorage, but after I read it back, it became one dimension vector. Does anybody have an idea? Thanks.

2014-11-15 12:03:09 -0600 received badge  Student (source)
2014-11-14 09:27:34 -0600 asked a question svm weights question

I have simple question about svm weights. I am doing a binary classification. I want to set different weights for different classes. My code is like this

Mat weights = (Mat_<double>(2,1)<<1,2);
CvMat weight = weights;
param.class_weights = &weight;

I am wondering which weight is for which class(negative/positive)? I didn't it from opencv document. thanks.

2014-11-13 15:49:22 -0600 asked a question svm weights

I have simple question about svm weights. I am doing a binary classification. I want to set different weights for different classes. My code is like this

Mat weights = (Mat_<double>(2,1)<<1,2);
CvMat weight = weights;
param.class_weights = &weight;

I am wondering which weight is for which class(negative/positive)? I didn't it from opencv document. thanks.

2014-10-13 07:56:02 -0600 commented question unexpected performance using SVM with RBF kernel

Sorry for the confusion. The input should be normalized lbp histogram. Also, it's two class svm.

2014-10-12 18:54:54 -0600 received badge  Editor (source)
2014-10-12 15:17:26 -0600 asked a question unexpected performance using SVM with RBF kernel

I am kind of new to svm classification. I am trying to use opencv svm classifier to do some face recognition. The input feature parameters are normalized Local binary pattern. So all values are from 0-1. I first tried linear kernel to train the classifier and then use the training data set to test set. I got 100% accuracy ( I know it means nothing). However, when I changed kernel to RBF (all other parameters are default) and re-test the training set, all cases are classified to one class which means they are not separable. I tried different gamma values from 0.000001 to 10. Does anyone have idea about this issue? Thanks.

CvSVMParams param;
param.svm_type = CvSVM::C_SVC;
param.kernel_type = CvSVM::RBF; //CvSVM::RBF, CvSVM::LINEAR ...
param.degree = 2; // for poly
param.gamma = 0.000000001; // for poly/rbf/sigmoid
param.coef0 = 1; // for poly/sigmoid

param.C = 0.5; // for CV_SVM_C_SVC, CV_SVM_EPS_SVR and CV_SVM_NU_SVR
param.term_crit.type = CV_TERMCRIT_EPS;//CV_TERMCRIT_ITER +CV_TERMCRIT_EPS;
param.term_crit.max_iter = 1000000;
param.term_crit.epsilon = 1e-9;
SVM.train(trainingDataMat, labelMat, Mat(), Mat(), param);

for(int i=0; i<trainingDataMat.rows; i++){
    Mat sampleMat = trainingDataMat(Range(i,i+1), Range::all());
    double response = SVM.predict(sampleMat);
    cout<<"test"<<i<<"=  "<<response<<endl;
}