File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ namespace cv
57
57
{
58
58
namespace dnn
59
59
{
60
+ static inline int scaleAndRoundRoi (float f, float scale)
61
+ {
62
+ return (int )(f * scale + (f >= 0 .f ? 0 .5f : -0 .5f ));
63
+ }
60
64
61
65
class PoolingLayerImpl : public PoolingLayer
62
66
{
@@ -296,16 +300,16 @@ class PoolingLayerImpl : public PoolingLayer
296
300
if (poolingType == ROI)
297
301
{
298
302
const float *roisData = rois->ptr <float >(n);
299
- int ystartROI = round (roisData[2 ] * spatialScale);
300
- int yendROI = round (roisData[4 ] * spatialScale);
303
+ int ystartROI = scaleAndRoundRoi (roisData[2 ], spatialScale);
304
+ int yendROI = scaleAndRoundRoi (roisData[4 ], spatialScale);
301
305
int roiHeight = std::max (yendROI - ystartROI + 1 , 1 );
302
306
roiRatio = (float )roiHeight / height;
303
307
304
308
ystart = ystartROI + y0 * roiRatio;
305
309
yend = ystartROI + std::ceil ((y0 + 1 ) * roiRatio);
306
310
307
- xstartROI = round (roisData[1 ] * spatialScale);
308
- int xendROI = round (roisData[3 ] * spatialScale);
311
+ xstartROI = scaleAndRoundRoi (roisData[1 ], spatialScale);
312
+ int xendROI = scaleAndRoundRoi (roisData[3 ], spatialScale);
309
313
int roiWidth = std::max (xendROI - xstartROI + 1 , 1 );
310
314
roiRatio = (float )roiWidth / width;
311
315
You can’t perform that action at this time.
0 commit comments