I'm trying to use OpenCV's HOG descriptor, but the feature vector computed from it seems far too long. Here is a snippet that demonstrates the problem:
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <stdlib.h>
#include <vector>
int main()
{
cv::Mat image = cv::imread("1.jpg");
std::vector<float> features;
cv::HOGDescriptor hogdis;
hogdis.compute(image, features);
printf("HOG feature's length is %zu %zu\n", hogdis.getDescriptorSize(), features.size());
return 0;
}
The output is
HOG feature's length is 3780 1606500
The latter value seems absurd. The image 1.jpg
has dimension 256x256x3, which has much less pixels than the feature vector. Why does OpenCV fills the feature vector with so many values? How do I obtain the 3780 long vector to feed to my SVM trainer?