I need to form HOGDescriptor::setSVMDetector()
input.
I compute descriptors with openCV then use libSVM to get model file. To form input i know that i need
Ok, it seems things are clear now. Alphas are the first column in my case. Since i had all of them equal to -1 or 1 (dunno why) in my test model, i thought these were labels.
Anyway, here is my parser (but you need to leave only SVs in file):
std::ifstream ifs("cars_model.model");
const int nsv = 90;
const int nfeatures = 144;
float rho = 12.5459;
char ts[4000] = ""; // !
std::vector res(nfeatures,0);
std::vector alphas;
Mat_ temp(nsv, nfeatures);
int c = 0;
std::cout << "Loading model file...\n";
for (int i=0; i> al;
alphas.push_back(al);
for (int j=0; j> ind >> junk >> s;
temp.at(c, j) = s;
//std::cout << f << ' ' << s << '\n';
}
c++;
}
ifs.close();
std::cout << "Computing primal form...\n";
for (int i=0; i(i,j) * alpha);
}
}
//res.push_back(-rho);
std::ofstream ofs("primal.txt");
for (int i=0; i
And you know, it works. You can set rho as threshold of the detector.