Ask Your Question
1

cv::HOGDescriptor::compute crashes in 2.4.9 (not in 2.4.6)

asked 2014-07-01 14:43:30 -0600

brice gravatar image

updated 2014-07-01 15:03:15 -0600

Hi

in some code that I am maintaining, we call cv::HOGDescriptor::compute. After ROS opencv package upgraded to 2.4.9 from 2.4.6 it started to crash. Nothing else has changed in my code. I am not familiar at all with HOG descriptors, so I'm not sure how to go about this, so I'm hoping somebody can tell me what has changed lately in this function.

here is the error that I get: opencv2/core/core.hpp:345: size_t cv::alignSize(size_t, int): Assertion `(n & (n - 1)) == 0' failed. (this is checking that n is power of 2)

and here is some of my code (hopefully enough of it to give you a sense of what's going on):

this is how I construct the HOGDescriptor:

hog_ = new cv::HOGDescriptor(win_size_, block_size_, block_stride_,
                             cell_size_, num_bins_,
                             1, -1, 0, 0.2, false);

where win_size_ is (30,30), block_size_ is (30,30), block_stride_ is (10,10), cell_size is (5,5), and num_bins_ is 6.

And this is how I call compute:

hog_->compute(img, cv_result_, cv::Size(), cv::Size(), coords_);

where img is a cv::Mat1b of 60x60, and coords_ contains 4 elements: {(0,30),(15,0),(15,15),(30,30)}

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-07-02 06:41:55 -0600

Guanta gravatar image

I guess, they just added an assert that you should use sizes which are of the power of 2 (i.e. 2,4,8,16,32, etc). Afaik before that it just implicitly converted it to the closest numbers anyways (maybe I'm wrong here).

edit flag offensive delete link more
1

answered 2014-07-17 06:09:07 -0600

Abai gravatar image

There was a bug fix to this function:

http://docs.opencv.org/modules/core/doc/utility_and_system_functions_and_macros.html#alignsize

https://github.com/Itseez/opencv/commit/f1b5cbc8fe734b25220d2b4a1e7156b2017375e5

Instead of fixing the function to align by any n bytes, an assert was added that so that it only accepts n that is a power of two. Since this function is used inside HOGDescriptor::compute detect and detectROI to provide padding for input, this has effectively restricted these functions to cell and block sizes that are a power of two. Quite a limitation in my eyes since the parameters as you describe them should be perfectly valid.

I haven't gotten around to submitting a bug report regarding this problem, perhaps you could do it?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-07-01 14:43:30 -0600

Seen: 2,466 times

Last updated: Jul 17 '14