kmeans-anchor-boxes icon indicating copy to clipboard operation
kmeans-anchor-boxes copied to clipboard

Incorrect interaction area calculation

Open kangskii opened this issue 6 years ago • 2 comments
trafficstars

Hi, In yout iou() function, you cannot calculate the interaction AREA by the following equation: (Line16) intersection = x * y

In my opinion, we cannot calculate the overlap if we only know the width and heights of the two boxes. Please help to double check and iou() function.

kangskii avatar Jan 26 '19 08:01 kangskii

Hi, let's look at the original IoU formula in the numerator (intersection): (min(x_A2, x_B2) - max(x_A1, x_B1))(min(y_A2, y_B2) - max(y_A1, y_B1)). Now we shift all boxes to the origin. Then (min(x_A2', x_B2') - max(0, 0))(min(y_A2', y_B2') - max(0, 0)) = min(x_A2', x_B2') * min(y_A2', y_B2'), which is line 16.

So we are actually considering both coordinates, but the lower point of each box is (0, 0) and the upper point is (x2, y2). I hope this makes sense.

lars76 avatar Jan 26 '19 15:01 lars76

Now it is clear for me. Thanks for your answer.

kangskii avatar Jan 30 '19 02:01 kangskii