Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

std::length_error at HOGDetector::compute()

Hi, I am trying to create my own HOG detector (using a svm). The tutorial with INRIA-dataset worked fine. Now I want to use pictures of size 80x80 as training set.

However, when calling this line with the 80x80-grayscale image:

hog.compute(image, detections, Size(8,8), Size(0,0));

I get the following error:

terminate called after throwing an instance of 'std::length_error' what(): vector::_M_fill_insert

I am using OpenCV 3.1. Does anybody know how I can solve this problem?

std::length_error at HOGDetector::compute()

Hi, I am trying to create my own HOG detector (using a svm). The tutorial with INRIA-dataset worked fine. Now I want to use pictures of size 80x80 as training set. set (one picture is included at the end of this post as reference).

However, when calling this line with the 80x80-grayscale image:

hog.compute(image, detections, Size(8,8), Size(0,0));

I get the following error:

terminate called after throwing an instance of 'std::length_error' what(): vector::_M_fill_insert

I am using OpenCV 3.1. Does anybody know how I can solve this problem?

Edit: The colour image is read, then transformed to grayscale and then the compute() fails:

cv::Mat img = cv::imread("path/to/picture.png");
cv::HOGDescriptor hog;
cv::Rect r = cv::Rect( 0, 0, 80, 80 );
cv::Mat gray;
std::vector< float > descriptors;
r.x += ( img.cols - r.width ) / 2;
r.y += ( img.rows - r.height ) / 2;
cv::cvtColor(img(r), gray, cv::COLOR_BGR2GRAY);
std::clog << "[DEB] img-size: " << gray.size().width << "x" << gray.size().height << std::endl; // outputs 80x80, as expected
hog.compute(gray, descriptors, cv::Size(8, 8), cv::Size(0, 0)); // this fails and gives me the mentioned error

C:\fakepath\36.png