Reputation: 77
I am new in OpenCV. Previously I used Matlab to compute HOG features from an image of 9x9 pixels. In Matlab I was getting feature vector of 9 values as I was using 9 bin histogram. But in OpenCV, first problem is that I am unable to run:
d.compute(imROI, descriptorsValues,Size(9,9),Size(0,0),locs);
It seems 9x9 image is less than minimum allowed size, is it true?
Secondly, can some one please explain me all the input parameters of:
compute(const Mat& img, vector<float>& descriptors,
Size winStride, Size padding,
const vector<Point>& locations) const
Thanks a lot.
Upvotes: 2
Views: 8787
Reputation: 50667
It's not true.
For compute
, the third parameter is Size winStride
, you can use smaller values up to Size(1,1)
.
I guess you didn't initialize HOGDescriptor hog
correctly that caused you not able to run.
The size of hog features can be computed as
num_of_hog_features = (size_t)nbins * ( blockSize.width/cellSize.width)
* (blockSize.height/cellSize.height) * ((winSize.width
- blockSize.width)/blockStride.width + 1)
* ((winSize.height - blockSize.height)
/ blockStride.height + 1);
So in order to get 8
values of hog feature, you can setup the parameters as follows:
HOGDescriptor *hog=new HOGDescriptor(cvSize(9,9),cvSize(9,9),
cvSize(9,9),cvSize(9,9),8);
vector<float> descriptors;
hog->compute(imROI, descriptors,Size(1,1), Size(0,0));
Upvotes: 4