Merge pull request #11315 from tomoaki0705:featureComparePixelCount
This commit is contained in:
@@ -304,14 +304,9 @@ PARAM_TEST_CASE(Resize, MatType, double, double, Interpolation, bool, int)
|
||||
UMAT_UPLOAD_INPUT_PARAMETER(src);
|
||||
UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.0)
|
||||
{
|
||||
OCL_EXPECT_MATS_NEAR(dst, threshold);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#if defined(__aarch64__) || defined(__arm__)
|
||||
const int integerEps = 3;
|
||||
#else
|
||||
const int integerEps = 1;
|
||||
@@ -328,7 +323,7 @@ OCL_TEST_P(Resize, Mat)
|
||||
OCL_OFF(cv::resize(src_roi, dst_roi, Size(), fx, fy, interpolation));
|
||||
OCL_ON(cv::resize(usrc_roi, udst_roi, Size(), fx, fy, interpolation));
|
||||
|
||||
Near(eps);
|
||||
OCL_EXPECT_MAT_N_DIFF(dst, eps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,11 +383,6 @@ PARAM_TEST_CASE(Remap, MatDepth, Channels, std::pair<MatType, MatType>, BorderTy
|
||||
if (noType != map2Type)
|
||||
UMAT_UPLOAD_INPUT_PARAMETER(map2);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.0)
|
||||
{
|
||||
OCL_EXPECT_MATS_NEAR(dst, threshold);
|
||||
}
|
||||
};
|
||||
|
||||
typedef Remap Remap_INTER_NEAREST;
|
||||
@@ -406,7 +396,7 @@ OCL_TEST_P(Remap_INTER_NEAREST, Mat)
|
||||
OCL_OFF(cv::remap(src_roi, dst_roi, map1_roi, map2_roi, INTER_NEAREST, borderType, val));
|
||||
OCL_ON(cv::remap(usrc_roi, udst_roi, umap1_roi, umap2_roi, INTER_NEAREST, borderType, val));
|
||||
|
||||
Near(1.0);
|
||||
OCL_EXPECT_MAT_N_DIFF(dst, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,12 +413,14 @@ OCL_TEST_P(Remap_INTER_LINEAR, Mat)
|
||||
// TODO investigate accuracy
|
||||
if (cv::ocl::Device::getDefault().isNVidia())
|
||||
eps = 8.0;
|
||||
#elif defined(__arm__)
|
||||
eps = 8.0;
|
||||
#endif
|
||||
|
||||
OCL_OFF(cv::remap(src_roi, dst_roi, map1_roi, map2_roi, INTER_LINEAR, borderType, val));
|
||||
OCL_ON(cv::remap(usrc_roi, udst_roi, umap1_roi, umap2_roi, INTER_LINEAR, borderType, val));
|
||||
|
||||
Near(eps);
|
||||
OCL_EXPECT_MAT_N_DIFF(dst, eps);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,25 @@ do \
|
||||
<< "Size: " << mat1.size() << std::endl; \
|
||||
} while ((void)0, 0)
|
||||
|
||||
#define OCL_EXPECT_MAT_N_DIFF(name, eps) \
|
||||
do \
|
||||
{ \
|
||||
ASSERT_EQ(name ## _roi.type(), u ## name ## _roi.type()); \
|
||||
ASSERT_EQ(name ## _roi.size(), u ## name ## _roi.size()); \
|
||||
Mat diff, binary, binary_8; \
|
||||
absdiff(name ## _roi, u ## name ## _roi, diff); \
|
||||
Mat mask(diff.size(), CV_8UC(dst.channels()), cv::Scalar::all(255)); \
|
||||
if (mask.cols > 2 && mask.rows > 2) \
|
||||
mask(cv::Rect(1, 1, mask.cols - 2, mask.rows - 2)).setTo(0); \
|
||||
cv::threshold(diff, binary, (double)eps, 255, cv::THRESH_BINARY); \
|
||||
EXPECT_LE(countNonZero(binary.reshape(1)), (int)(binary.cols*binary.rows*5/1000)) \
|
||||
<< "Size: " << name ## _roi.size() << std::endl; \
|
||||
binary.convertTo(binary_8, mask.type()); \
|
||||
binary_8 = binary_8 & mask; \
|
||||
EXPECT_LE(countNonZero(binary_8.reshape(1)), (int)((binary_8.cols+binary_8.rows)/100)) \
|
||||
<< "Size: " << name ## _roi.size() << std::endl; \
|
||||
} while ((void)0, 0)
|
||||
|
||||
#define OCL_EXPECT_MATS_NEAR(name, eps) \
|
||||
do \
|
||||
{ \
|
||||
|
||||
Reference in New Issue
Block a user