0

I am new to open CV so currently struggling with it. I have extracted HOG features using following definition:

HOGDescriptor hog(Size(16,16), Size(16,16), Size(16,16), Size(8,8), 9);

It returns 36 dimensional feature vector / pixel. Now I want to separate all these 36 values in a row and save it in text file. I don't know how to do it. Please do guide me.

Thanks in advance.

herohuyongtao
  • 49,413
  • 29
  • 133
  • 174
user3319734
  • 67
  • 2
  • 9

1 Answers1

0

After you compute the features, i.e. descriptors by cv::HOGDescriptor::compute, it's a vector<float>, so just access it like normal vector<float>s.

And if you want to split them into 36-by-36 style, you can do like this:

for (int i=0; i<descriptors.size()/36; i++)
{
    // ... handle 36 values here
    for (int j=0; j<36; j++)
    {
        if (36*i+j < descriptors.size()) // make sure not out-of-bound
        {
            float temp = descriptors[36*i+j];
            ...
        }
    }   
}
herohuyongtao
  • 49,413
  • 29
  • 133
  • 174