Ask Your Question
0

Strange assert in surf_gpu.cpp

asked 2013-07-23 14:46:21 -0600

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-07-24 01:40:27 -0600

Vladislav Vinogradov gravatar image

updated 2013-07-24 03:59:37 -0600

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
edit flag offensive delete link more

Comments

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

Grigory Velmozhin gravatar imageGrigory Velmozhin ( 2013-07-24 02:35:33 -0600 )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 ( 2013-07-24 04:22:11 -0600 )edit

Question Tools

Stats

Asked: 2013-07-23 14:46:21 -0600

Seen: 932 times

Last updated: Jul 24 '13