Difference in hog descriptor computed on color images in Python and C++

Viewed 1266

I've computed the HOGDescriptor on a color image and found different results in Python and C++, the opencv version, HOG parameters and image being the same on both. There is a startling difference between the HOG descriptors computed in C++ and Python on the default BGR image

First 100 values of BGR HOG Descriptor in C++ First 100 values of BGR HOG Descriptor in Python

There is again, a startling difference between the HOG descriptors computed in C++ and Python on the default BGR2RBG image. However, C++ seems to follow the recommended (by Dalal, Triggs) way of computing the HOG as the max of all three channels, as is proved by the fact that BGR and RGB image has the same HOG descriptor, but Python does not

First 100 values of RGB HOG Descriptor in C++ First 100 values of RGB HOG Descriptor in Python

The grayscale versions of the image, however, show similar (but not same) descriptor values.

First 100 values of GRAY HOG Descriptor in C++ and Python

HOG parameters:

cv::HOGDescriptor hogDescriptor;
hogDescriptor.blockSize = cv::Size(8, 8);
hogDescriptor.cellSize = cv::Size(4, 4);
hogDescriptor.blockStride = cv::Size(4, 4);
hogDescriptor.nbins = 9;
hogDescriptor.signedGradient = true;
hogDescriptor.winSize = cv::Size(72, 72);

My question is, why is there such a large difference between the C++ and Python implementations even though Python is just a wrapper for the C++ version?

1 Answers
Related