Unpredictable behaviour from cv::HOGDescriptor::detectMultiScale, depending on input.
Hi,
I am trying to implement a HOG SVM detector using my own training data and have had trouble getting it to work reliably. I am using OpenCV 2.4 in visual studio.
I am using the SVMlight library which generates a descriptor vector and a hit threshold for the HOGDescriptor object. I set the HOG object using this descriptor vector and run detectMultiscale using the hit threshold generated by SVMlight. What will happen is my program will stall on this function indefinitely. However if I change the descriptor vector to the default people detector provided by OpenCV then I begin to get detections again.
The default people descriptor vector is 1981 values in length with hit threshold 0. My SVMlight trained descriptor vector is 3781 values in length with hit threshold -0.6566.
If I change the hit threshold to from -0.6566 to zero, I also start to get detections, although they are often false positives since this is the incorrect threshold.
Another issue I have is if I try to set a custom window size (48x48) for example, I get an assertion error: checkDetectorSize() with no more feedback to help me understand the problem.
My question is, does anyone know what I could do to work around these problems? Could it be SVMlight? Is there another SVM library I can use to train the detector? Are these bugs inherent to the HOG class in OpenCV 2.4?
Thanks for the help, I can provide more detailed information if required.
Comments
- If you change the window size, you're changing the vector length. You can't use a window size that produces a vector whose length is different from that used for training the classifier
- I'm not familiar with SVMlight, but the hit threshold param is a detection param, independent of the training. It controls the minimum required confidence to output a positive detection. Thus, afaik, there's no hit threshold associated with a particular trained model (I don't know how you assure -0.6566 is the right threshold - why? in what conditions?). Moreover, are you sure that the hit threshold means the same in both libraries?
- You can always use the SVM implementation of the ml module to train your own classifier, although you'll need to use your our multiscale sliding-window mechanism for HOG