Merge pull request #15638 from AsyaPronina:asyadev/gapi_filter2d_test

This commit is contained in:
Alexander Alekhin 2019-10-05 11:22:11 +00:00
commit c54753c185
5 changed files with 29 additions and 8 deletions

View File

@ -29,8 +29,8 @@ namespace opencv_test
// - created (and initialized) automatically
// - available in test body
// Note: all parameter _values_ (e.g. type CV_8UC3) are set via INSTANTIATE_TEST_CASE_P macro
GAPI_TEST_FIXTURE(Filter2DTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
cmpF, kernSize, borderType)
GAPI_TEST_FIXTURE(Filter2DTest, initMatrixRandN, FIXTURE_API(CompareMats,cv::Size,int), 3,
cmpF, filterSize, borderType)
GAPI_TEST_FIXTURE(BoxFilterTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
cmpF, filterSize, borderType)
GAPI_TEST_FIXTURE(SepFilterTest, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, kernSize)

View File

@ -57,9 +57,23 @@ TEST_P(Filter2DTest, AccuracyTest)
cv::Point anchor = {-1, -1};
double delta = 0;
cv::Mat kernel = cv::Mat(kernSize, kernSize, CV_32FC1);
cv::Scalar kernMean = cv::Scalar(1.0);
cv::Scalar kernStddev = cv::Scalar(2.0/3);
cv::Mat kernel = cv::Mat(filterSize, CV_32FC1);
cv::Scalar kernMean, kernStddev;
const auto kernSize = filterSize.width * filterSize.height;
const auto bigKernSize = 49;
if (kernSize < bigKernSize)
{
kernMean = cv::Scalar(0.3);
kernStddev = cv::Scalar(0.5);
}
else
{
kernMean = cv::Scalar(0.008);
kernStddev = cv::Scalar(0.008);
}
randn(kernel, kernMean, kernStddev);
// G-API code //////////////////////////////////////////////////////////////
@ -67,6 +81,7 @@ TEST_P(Filter2DTest, AccuracyTest)
auto out = cv::gapi::filter2D(in, dtype, kernel, anchor, delta, borderType);
cv::GComputation c(in, out);
c.apply(in_mat1, out_mat_gapi, getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
{

View File

@ -26,7 +26,10 @@ INSTANTIATE_TEST_CASE_P(Filter2DTestCPU, Filter2DTest,
Values(-1, CV_32F),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_obj()),
Values(3, 4, 5, 7),
Values(cv::Size(3, 3),
cv::Size(4, 4),
cv::Size(5, 5),
cv::Size(7, 7)),
Values(cv::BORDER_DEFAULT)));
INSTANTIATE_TEST_CASE_P(BoxFilterTestCPU, BoxFilterTest,

View File

@ -214,7 +214,7 @@ INSTANTIATE_TEST_CASE_P(filter2DTestFluid, Filter2DTest,
Values(-1, CV_32F),
Values(IMGPROC_FLUID),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3), // add kernel size=4,5,7 when implementation ready
Values(cv::Size(3, 3)), // add kernel size=4x4,5x5,7x7 when implementation ready
Values(cv::BORDER_DEFAULT)));
} // opencv_test

View File

@ -25,7 +25,10 @@ INSTANTIATE_TEST_CASE_P(Filter2DTestGPU, Filter2DTest,
Values(-1, CV_32F),
Values(IMGPROC_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_obj()),
Values(3, 4, 5, 7),
Values(cv::Size(3, 3),
cv::Size(4, 4),
cv::Size(5, 5),
cv::Size(7, 7)),
Values(cv::BORDER_DEFAULT)));
INSTANTIATE_TEST_CASE_P(BoxFilterTestCPU, BoxFilterTest,