From 363976694eead3f1637fed1d22a3d6b7e39ea740 Mon Sep 17 00:00:00 2001 From: Anna Khakimova Date: Fri, 8 Nov 2019 16:45:10 +0300 Subject: [PATCH] GAPI Fluid: The run_sepfilter() has logic error into handler for 5x5 and larger kernels --- .../perf/cpu/gapi_imgproc_perf_tests_fluid.cpp | 2 +- .../gapi/src/backends/fluid/gfluidimgproc.cpp | 16 ++++++++++------ .../gapi/test/cpu/gapi_imgproc_tests_fluid.cpp | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/gapi/perf/cpu/gapi_imgproc_perf_tests_fluid.cpp b/modules/gapi/perf/cpu/gapi_imgproc_perf_tests_fluid.cpp index 6414a81a25..1ccd763099 100644 --- a/modules/gapi/perf/cpu/gapi_imgproc_perf_tests_fluid.cpp +++ b/modules/gapi/perf/cpu/gapi_imgproc_perf_tests_fluid.cpp @@ -58,7 +58,7 @@ INSTANTIATE_TEST_CASE_P(BlurPerfTestFluid, BlurPerfTest, INSTANTIATE_TEST_CASE_P(GaussianBlurPerfTestFluid, GaussianBlurPerfTest, Combine(Values(ToleranceFilter(1e-3f, 0.01).to_compare_f()), Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1), - Values(3), // TODO: add size=5, when kernel is ready + Values(3, 5), Values(szVGA, sz720p, sz1080p), Values(cv::compile_args(IMGPROC_FLUID)))); diff --git a/modules/gapi/src/backends/fluid/gfluidimgproc.cpp b/modules/gapi/src/backends/fluid/gfluidimgproc.cpp index 1db0ba5b49..ba70954476 100644 --- a/modules/gapi/src/backends/fluid/gfluidimgproc.cpp +++ b/modules/gapi/src/backends/fluid/gfluidimgproc.cpp @@ -628,7 +628,7 @@ static void run_sepfilter(Buffer& dst, const View& src, else { int length = chan * width; - int xshift = chan * xborder; + int xshift = chan; // horizontal pass @@ -788,8 +788,6 @@ GAPI_FLUID_KERNEL(GFluidGaussBlur, cv::gapi::imgproc::GGaussBlur, true) Buffer& dst, Buffer& scratch) { - GAPI_Assert(ksize.height == 3); - int kxsize = ksize.width; int kysize = ksize.height; @@ -800,10 +798,16 @@ GAPI_FLUID_KERNEL(GFluidGaussBlur, cv::gapi::imgproc::GGaussBlur, true) int chan = src.meta().chan; int length = width * chan; - float *buf[3]; + constexpr int buffSize = 5; + GAPI_Assert(ksize.height <= buffSize); + + float *buf[buffSize]{}; + buf[0] = ky + kysize; - buf[1] = buf[0] + length; - buf[2] = buf[1] + length; + for (int i = 1; i < ksize.height; ++i) + { + buf[i] = buf[i - 1] + length; + } auto anchor = cv::Point(-1, -1); diff --git a/modules/gapi/test/cpu/gapi_imgproc_tests_fluid.cpp b/modules/gapi/test/cpu/gapi_imgproc_tests_fluid.cpp index dfc7ee8d76..282241fe1e 100644 --- a/modules/gapi/test/cpu/gapi_imgproc_tests_fluid.cpp +++ b/modules/gapi/test/cpu/gapi_imgproc_tests_fluid.cpp @@ -106,7 +106,7 @@ INSTANTIATE_TEST_CASE_P(gaussBlurTestFluid, GaussianBlurTest, Values(-1), Values(IMGPROC_FLUID), Values(ToleranceFilter(1e-3f, 0.01).to_compare_obj()), - Values(3))); // add kernel size=5 when implementation is ready + Values(3, 5))); INSTANTIATE_TEST_CASE_P(medianBlurTestFluid, MedianBlurTest, Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),