SVM::Params params;
params.svmType = SVM::C_SVC;
params.kernelType = SVM::LINEAR;
params.C=options.svm_c;
params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
params.termCrit.maxCount =options.svm_iter;
params.termCrit.epsilon = options.svm_eps;
Ptr<TrainData> svm1;
Ptr<SVM> svm;
svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);
svm=ml::SVM::create(params);
svm->train(svm1,0);
This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:
void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
const float* another, Qfloat* results,
double alpha, double beta )
{
int j, k;
for( j = 0; j < vcount; j++ )
{
const float* sample = &vecs[j*var_count];
double s = 0;
for( k = 0; k <= var_count - 4; k += 4 )
s += sample[k]*another[k] + sample[k+1]*another[k+1] +
sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
for( ; k < var_count; k++ )
s += sample[k]*another[k];
results[j] = (Qfloat)(s*alpha + beta); // this is line 173
}
}
The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".
Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.
Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64.