huangbiubiu
huangbiubiu

Reputation: 1271

Why add a small number on the bounding box?

I found that on the implementation of Fast(er) RCNN, there is always a small value added to the width and height of the bounding box. Why add a small number to the width and height?

For example, in Fast RCNN, cfg.EPS (default is 1e-14) is added:

ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + cfg.EPS
ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + cfg.EPS
ex_ctr_x = ex_rois[:, 0] + 0.5 * ex_widths
ex_ctr_y = ex_rois[:, 1] + 0.5 * ex_heights

gt_widths = gt_rois[:, 2] - gt_rois[:, 0] + cfg.EPS
gt_heights = gt_rois[:, 3] - gt_rois[:, 1] + cfg.EPS
gt_ctr_x = gt_rois[:, 0] + 0.5 * gt_widths
gt_ctr_y = gt_rois[:, 1] + 0.5 * gt_heights

In Faster-RCNN, 1.0 is added to widths and heights.

ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + 1.0
ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + 1.0
ex_ctr_x = ex_rois[:, 0] + 0.5 * ex_widths
ex_ctr_y = ex_rois[:, 1] + 0.5 * ex_heights

gt_widths = gt_rois[:, 2] - gt_rois[:, 0] + 1.0
gt_heights = gt_rois[:, 3] - gt_rois[:, 1] + 1.0
gt_ctr_x = gt_rois[:, 0] + 0.5 * gt_widths
gt_ctr_y = gt_rois[:, 1] + 0.5 * gt_heights

Upvotes: 0

Views: 55

Answers (3)

user9467593
user9467593

Reputation: 1

My opinion.Actually,The pixels on the "bounding box border" are need to be calculated.SO you need to exclude them(by add 1).

Upvotes: 0

Gergely Papp
Gergely Papp

Reputation: 900

I have a strong feeling the code will continue with the areas of the boxes and use those for calculating the IoU. If so, you need to be sure the bounding box actually has some non-zero area.

Upvotes: 0

Cris Luengo
Cris Luengo

Reputation: 60695

I don’t know what is happening in the first case, but in the second case looks like the left and right locations are both inside the bounding box. The number of pixels spanned must therefore include both left and right locations. This is why 1 is added.

Upvotes: 1

Related Questions