I'm using OpenCV to evaluate some algorithms for face recognition, at the moment I'm using HoG ( Histogram of Oriented Gradients)
我正在使用OpenCV来评估一些人脸识别算法,目前我正在使用HoG(方向梯度直方图)
I wish to store descriptors, from several images, in a vector, for later comparison.
我希望将几个图像中的描述符存储在一个向量中,以便以后进行比较。
For each image it stores X descriptors in a vector of floats usually initialized like this:
对于每个图像,它将X描述符存储在通常初始化为浮动的向量中,如下所示:
vector <float> descriptors;
So, in order to store many, I thought the initialization would be something like this:
所以,为了存储很多,我认为初始化将是这样的:
vector <vector <float> > descriptors;
Although the program compiles ok, it stops at hog.compute
without any warning or error.
虽然程序编译正常,但它在hog.compute处停止,没有任何警告或错误。
for (i = 0; i < images.size(); i++){
hog.compute(images[i], descriptors[i], Size(16,16), Size(4,4), locs);
}
Any tip or suggestion?
任何提示或建议?
Thank you in advance!
先谢谢你!
1 个解决方案
#1
1
You should allocate enough space for descriptors
before calling it. There's only a empty container by vector <vector <float> > descriptors;
, it will crash if you trying to access its elements, i.e. descriptors[0]
, because descriptors.size()==0
currently.
在调用之前,您应该为描述符分配足够的空间。 vector
You can simply change
你可以简单地改变
vector <vector <float> > descriptors;
to
至
vector <vector <float> > descriptors(images.size());
or
要么
vector <vector <float> > descriptors;
descriptors.resize(images.size());
#1
1
You should allocate enough space for descriptors
before calling it. There's only a empty container by vector <vector <float> > descriptors;
, it will crash if you trying to access its elements, i.e. descriptors[0]
, because descriptors.size()==0
currently.
在调用之前,您应该为描述符分配足够的空间。 vector
You can simply change
你可以简单地改变
vector <vector <float> > descriptors;
to
至
vector <vector <float> > descriptors(images.size());
or
要么
vector <vector <float> > descriptors;
descriptors.resize(images.size());