Merge pull request #13052 from elatkin:yl/gapi_sobel3x3_f32_v2
authorEvgeny Latkin <evgeny.latkin@intel.com>
Tue, 6 Nov 2018 20:08:50 +0000 (23:08 +0300)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Tue, 6 Nov 2018 20:08:50 +0000 (23:08 +0300)
* GAPI: Sobel 3x3 with FP32 input

* GAPI: Sobel 3x3 with FP32 input, v2

modules/gapi/src/backends/fluid/gfluidimgproc.cpp
modules/gapi/test/cpu/gapi_imgproc_tests_fluid.cpp

index 58321f3..c35d16b 100644 (file)
@@ -817,6 +817,7 @@ GAPI_FLUID_KERNEL(GFluidSobel, cv::gapi::imgproc::GSobel, true)
         UNARY_( float, uchar , run_sobel, dst, src, kx, ky, ksize, scale, delta);
         UNARY_( float, ushort, run_sobel, dst, src, kx, ky, ksize, scale, delta);
         UNARY_( float,  short, run_sobel, dst, src, kx, ky, ksize, scale, delta);
+        UNARY_( float,  float, run_sobel, dst, src, kx, ky, ksize, scale, delta);
 
         CV_Error(cv::Error::StsBadArg, "unsupported combination of types");
     }
index dd78c08..ffebac4 100644 (file)
@@ -36,6 +36,24 @@ private:
     double _tol;
 };
 
+class AbsToleranceSobelFluid : public Wrappable<AbsToleranceSobelFluid>
+{
+public:
+    AbsToleranceSobelFluid(double tol) : tolerance(tol) {}
+    bool operator() (const cv::Mat& in1, const cv::Mat& in2) const
+    {
+        cv::Mat diff, a1, a2, b, base;
+        cv::absdiff(in1, in2, diff);
+        a1 = cv::abs(in1);
+        a2 = cv::abs(in2);
+        cv::max(a1, a2, b);
+        cv::max(1, b, base);  // base = max{1, |in1|, |in2|}
+        return cv::countNonZero(diff > tolerance*base) == 0;
+    }
+private:
+    double tolerance;
+};
+
 class AbsTolerance32FFluid : public Wrappable<AbsTolerance32FFluid>
 {
 public:
@@ -222,6 +240,18 @@ INSTANTIATE_TEST_CASE_P(SobelTestFluid, SobelTest,
                                 Values(true, false),
                                 Values(cv::compile_args(IMGPROC_FLUID))));
 
+INSTANTIATE_TEST_CASE_P(SobelTestFluid32F, SobelTest,
+                        Combine(Values(AbsToleranceSobelFluid(1e-3).to_compare_f()),
+                                Values(CV_32FC1),
+                                Values(3), // add kernel size=5 when implementation is ready
+                                Values(cv::Size(1280, 720),
+                                       cv::Size(640, 480)),
+                                Values(CV_32F),
+                                Values(0, 1),
+                                Values(1, 2),
+                                Values(true, false),
+                                Values(cv::compile_args(IMGPROC_FLUID))));
+
 INSTANTIATE_TEST_CASE_P(boxFilterTestFluid32, BoxFilterTest,
                         Combine(Values(AbsTolerance32FFluid(1e-6).to_compare_f()),
                                 Values(CV_8UC1, CV_16UC1, CV_16SC1),