2

When I am calculating the HOG features of eye image of size 25*125. then getting the error message terminate called after throwing an instance of 'std::length_error' what(): vector::_M_fill_insert

HOGDescriptor hog;
vector<float> ders;
vector<Point>locs;
hog.compute(img,ders,Size(4,4),Size(0,0),locs);
Mat Hogfeat;
Hogfeat.create(ders.size(),1,CV_32FC1);

for(int i=0;i<ders.size();i++)
{
Hogfeat.at<float>(i,0)=ders.at(i);

}

Can any one tell me the solution?

4

2 回答 2

4

图像的一侧小于描述符,因此计算失败。

如果我使用以下行,则计算对我有用:

hog.compute(img,ders,Size(3,3),Size(0,0),locs);

块的大小是 8。所以3 * 8 = 24 <= 25但是 4 * 8 = 32 > 25

解决方案取决于您想要实现的目标以及您愿意做出的妥协。您可以只使用较小的描述符,这可能会导致其他图像的描述性有所损失。或者您可以缩放或填充太小的图像,这可能会使它们的描述符不那么有用,但不会影响其他的。

于 2013-01-14T09:43:51.733 回答
2

我遇到了同样的问题,我通过将图像大小调整为(64 x 128)或更大来解决它;任何小于此的大小都会返回该错误。所以你应该做

resize(img, dst, Size(64, 128))¶

在你打电话之前hog.compute(....)

于 2013-03-27T17:13:26.717 回答