First time here? Check out the FAQ!

Ask Your Question
0

Strange assert in surf_gpu.cpp

asked Jul 23 '13

I get very strange asserts in my code, changing the size of the input image.

        CV_Assert(img_rows - min_size >= 0);
        CV_Assert(img_cols - min_size >= 0);

       or

        CV_Assert(layer_rows - 2 * min_margin > 0);
        CV_Assert(layer_cols - 2 * min_margin > 0);

Line 125 surf_gpu.cpp opencv 2.4.5

I decided to read the code and came across a black magic

Code (line 131):

const int min_margin = ((calcSize((surf_.nOctaves - 1), 2) >> 1) >> (surf_.nOctaves - 1)) + 1;

gives always 11

proof:

image description

this is bug or not?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Jul 24 '13

Vladislav Vinogradov gravatar image

updated Jul 24 '13

It is not a bug. GPU SURF doesn't support small image size. This assert checks that input image has proper size.

UPDATE

Why min_margin is always 11?

sizeo(oct, layer) = (9 + 6*layer) << oct = (9 + 6*layer)*(2^oct)
sizeo(oct - 1, 2) = (9 + 6*2)*(2^(oct - 1)) = 21 * (2^(oct - 1))
sizeo(oct - 1, 2) >> 1 = sizeo(oct - 1, 2) / 2 = 21 * (2^(oct - 2))
(sizeo(oct - 1, 2) >> 1) >> (oct - 1) = (sizeo(oct - 1, 2) >> 1) * (2^(1 - oct)) = 21 * (2^(oct - 2)) * (2^(1 - oct)) = 21/2 === 10
getsd(oct) = ((sizeo(oct - 1, 2) >> 1) >> (oct - 1)) + 1 === 11
Preview: (hide)

Comments

I solved the problem with the small image size. But why line 131 returns always 11? =)

Grigory Velmozhin gravatar imageGrigory Velmozhin (Jul 24 '13)edit
1

Thanks for the proof. Then maybe we should change the line 131 to const int min_margin = 11;

Grigory Velmozhin gravatar imageGrigory Velmozhin (Jul 24 '13)edit

Question Tools

Stats

Asked: Jul 23 '13

Seen: 1,044 times

Last updated: Jul 24 '13