Open jpjodoin opened 10 years ago
How you test the correctness of the classifier with your specific modification?
To test it, I have used my training data as my test data in order to make sure I was getting the correct result for the known case of the classifier. With the previous implementation, I was getting poor results even when using my training data as test data.
As found here: https://github.com/DaHoC/trainHOG/issues/2
"The first value (Index 0) of the vector being generated in function getSingleDetectingVector() being always 0 due to the way SVMlight handles indices, as well as the last value (Index 3780) being overwritten by -b. An indexshift does not fix this issue because the positions/indices of the detecting vector components do matter for HOG."
I think I've found the solution to solve this issue if you want to try. You have to shift the indice by -1, remove the last line with the -model->b, and rescale the output to 3780.
We then use -model->b as the detection threshold.
Example: void getSingleDetectingVector(std::vector& singleDetectorVector, std::vector& singleDetectorVectorIndices) {
// Now we use the trained svm to retrieve the single detector vector
DOC* supveclist = model->supvec;
printf("Calculating single descriptor vector out of support vectors (may take some time)\n");
// Retrieve single detecting vector (v1 | b) from returned ones by calculating vec1 = sum_1_n (alpha_yx_i). (vec1 is a n x1 column vector. n = feature vector length )
singleDetectorVector.clear();
singleDetectorVector.resize(model->totwords, 0.);
printf("Resulting vector size %lu\n", singleDetectorVector.size());
float getThreshold() const { return model->b; }
And when you want to detect, you can use something like this: hogdetector.detect(im, ptList, svm.getThreshold(), cv::Size(8, 8),cv::Size(0, 0));