Merge pull request #13052 from elatkin:yl/gapi_sobel3x3_f32_v2

* GAPI: Sobel 3x3 with FP32 input

* GAPI: Sobel 3x3 with FP32 input, v2
pull/13059/head
Evgeny Latkin 6 years ago committed by Alexander Alekhin
parent 7a686a0c43
commit 000110e760
  1. 1
      modules/gapi/src/backends/fluid/gfluidimgproc.cpp
  2. 30
      modules/gapi/test/cpu/gapi_imgproc_tests_fluid.cpp

@ -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");
}

@ -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),

Loading…
Cancel
Save