0
votes

I am converting digits.py into a c++ sample from OpenCV. Digits.py is found under the python2 samples folder. It is an application that uses SVMs to recognize characters.

During a preprocessing step, HOG (histogram of gradients is calculated). In order to do this with C++ it is more convenient to use cv::HOGDescriptor::compute() to get a HOG value for each image bin.

https://github.com/Itseez/opencv/blob/5f590ebed084a5002c9013e11c519dcb139d47e9/samples/python2/digits.py

Line 126.

In python, they use the Hellinger Kernel that improves sample discrimination. However, i cannot see this occurring in HOG.cpp under compute().

https://github.com/Itseez/opencv/blob/5f590ebed084a5002c9013e11c519dcb139d47e9/modules/objdetect/src/hog.cpp

How do we apply this to a cv::Mat recovered from cv::HOGDescriptor.compute?

1

1 Answers

0
votes

why not try the same thing as in the python example ?

Mat img = ...
Mat descr;
hog.compute(img, descr, ...);

float eps = 1e-7f;
descr /= sum(descr)[0] + eps; // same as: normalize(descr,descr,1,eps,NORM_L1);
sqrt(descr,descr);
descr /= norm(descr) + eps;  

// ... feed to svm