使用openCV提取HOG功能 [英] Extracting HOG features using openCV
问题描述
我是OpenCV的新人。以前,我使用Matlab从9x9像素的图像计算HOG特征。在Matlab中我得到9值的特征向量,因为我使用9 bin直方图。但在OpenCV中,第一个问题是我无法运行:
d.compute(imROI,descriptorsValues,Size(9, 9),Size(0,0),locs);
看起来9x9的图片小于允许的最小尺寸,是真的吗?
其次,请解释一下我所有的输入参数:
compute(const Mat& img,vector< float>& descriptor,
Size winStride,Size padding,
const vector< Point>& locations)const
非常感谢。
解决方案
看起来9x9图片小于允许的最小尺寸,是真的吗?
这不是真的。
对于
compute
,第三个参数是Size winStride
,您可以使用最小值Size(1,1)
。
我想你没有正确初始化
HOGDescriptor hog
,导致你无法运行。
如果您只想获取8个值,即imROI的大小是9x9?
hog特征的大小可以计算为
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);
因此为了得到
8
hog功能,您可以设置参数如下:HOGDescriptor * hog = new HOGDescriptor(cvSize(9,9),cvSize (9,9),
cvSize(9,9),cvSize(9,9),8);
vector< float>描述符;
hog-> compute(imROI,descriptors,Size(1,1),Size(0,0));
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.
解决方案It seems 9x9 image is less than minimum allowed size, is it true?
It's not true.
For
compute
, the third parameter isSize winStride
, you can use smaller values up toSize(1,1)
.I guess you didn't initialize
HOGDescriptor hog
correctly that caused you not able to run.
If you want to only get 8 values for Size of imROI is 9x9?
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));
这篇关于使用openCV提取HOG功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!