mirror of
https://github.com/opencv/opencv.git
synced 2025-06-08 01:53:19 +08:00
fix build error on Visual Studio 2012
* round doesn't exists in standard library of Visual Studio 2012 * apply the correct computation of ROI
This commit is contained in:
parent
f2070c9f5d
commit
ecb6bcf2e0
@ -57,6 +57,10 @@ namespace cv
|
|||||||
{
|
{
|
||||||
namespace dnn
|
namespace dnn
|
||||||
{
|
{
|
||||||
|
static inline int scaleAndRoundRoi(float f, float scale)
|
||||||
|
{
|
||||||
|
return (int)(f * scale + (f >= 0.f ? 0.5f : -0.5f));
|
||||||
|
}
|
||||||
|
|
||||||
class PoolingLayerImpl : public PoolingLayer
|
class PoolingLayerImpl : public PoolingLayer
|
||||||
{
|
{
|
||||||
@ -296,16 +300,16 @@ public:
|
|||||||
if (poolingType == ROI)
|
if (poolingType == ROI)
|
||||||
{
|
{
|
||||||
const float *roisData = rois->ptr<float>(n);
|
const float *roisData = rois->ptr<float>(n);
|
||||||
int ystartROI = round(roisData[2] * spatialScale);
|
int ystartROI = scaleAndRoundRoi(roisData[2], spatialScale);
|
||||||
int yendROI = round(roisData[4] * spatialScale);
|
int yendROI = scaleAndRoundRoi(roisData[4], spatialScale);
|
||||||
int roiHeight = std::max(yendROI - ystartROI + 1, 1);
|
int roiHeight = std::max(yendROI - ystartROI + 1, 1);
|
||||||
roiRatio = (float)roiHeight / height;
|
roiRatio = (float)roiHeight / height;
|
||||||
|
|
||||||
ystart = ystartROI + y0 * roiRatio;
|
ystart = ystartROI + y0 * roiRatio;
|
||||||
yend = ystartROI + std::ceil((y0 + 1) * roiRatio);
|
yend = ystartROI + std::ceil((y0 + 1) * roiRatio);
|
||||||
|
|
||||||
xstartROI = round(roisData[1] * spatialScale);
|
xstartROI = scaleAndRoundRoi(roisData[1], spatialScale);
|
||||||
int xendROI = round(roisData[3] * spatialScale);
|
int xendROI = scaleAndRoundRoi(roisData[3], spatialScale);
|
||||||
int roiWidth = std::max(xendROI - xstartROI + 1, 1);
|
int roiWidth = std::max(xendROI - xstartROI + 1, 1);
|
||||||
roiRatio = (float)roiWidth / width;
|
roiRatio = (float)roiWidth / width;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user