mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #13008 from dbudniko:dbudniko/gpu_opencl_backend
G-API GPU-OpenCL backend (#13008) * gpu/ocl backend core * accuracy tests added and adjusted + license headers * GPU perf. tests added; almost all adjusted to pass * all tests adjusted and passed - ready for pull request * missing license headers * fix warning (workaround RGB2Gray) * fix c++ magic * precompiled header * white spaces * try to fix warning and blur test * try to fix Blur perf tests * more alignments with the latest cpu backend * more gapi tests refactoring + 1 more UB issue fix + more informative tolerance exceed reports * white space fix * try workaround for SumTest * GAPI_EXPORTS instead CV_EXPORTS
This commit is contained in:
committed by
Alexander Alekhin
parent
ebc8015638
commit
5087ff0814
@@ -14,155 +14,36 @@
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
class AbsExactFluid : public Wrappable<AbsExactFluid>
|
||||
{
|
||||
public:
|
||||
AbsExactFluid() {}
|
||||
bool operator() (const cv::Mat& in1, const cv::Mat& in2) const { return cv::countNonZero(in1 != in2) == 0; }
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class AbsToleranceFluid : public Wrappable<AbsToleranceFluid>
|
||||
{
|
||||
public:
|
||||
AbsToleranceFluid(double tol) : _tol(tol) {}
|
||||
bool operator() (const cv::Mat& in1, const cv::Mat& in2) const
|
||||
{
|
||||
cv::Mat absDiff; cv::absdiff(in1, in2, absDiff);
|
||||
return cv::countNonZero(absDiff > _tol) == 0;
|
||||
}
|
||||
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:
|
||||
AbsTolerance32FFluid(double tol) : _tol(tol) {}
|
||||
bool operator() (const cv::Mat& in1, const cv::Mat& in2) const
|
||||
{
|
||||
if (CV_MAT_DEPTH(in1.type()) == CV_32F)
|
||||
return ((cv::countNonZero(cv::abs(in1 - in2) > (_tol)*cv::abs(in2))) ? false : true);
|
||||
else
|
||||
return ((cv::countNonZero(in1 != in2) <= (_tol * 100) * in2.total()) ? true : false);
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
};
|
||||
|
||||
class AbsToleranceSepFilterFluid : public Wrappable<AbsToleranceSepFilterFluid>
|
||||
{
|
||||
public:
|
||||
AbsToleranceSepFilterFluid(double tol) : _tol(tol) {}
|
||||
bool operator() (const cv::Mat& in1, const cv::Mat& in2) const
|
||||
{
|
||||
return ((cv::countNonZero(cv::abs(in1 - in2) > (_tol)* cv::abs(in2)) <= 0.01 * in2.total()) ? true : false);
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
};
|
||||
|
||||
class AbsToleranceGaussianBlurFluid : public Wrappable<AbsToleranceGaussianBlurFluid>
|
||||
{
|
||||
public:
|
||||
AbsToleranceGaussianBlurFluid(double tol) : _tol(tol) {}
|
||||
bool operator() (const cv::Mat& in1, const cv::Mat& in2) const
|
||||
{
|
||||
if (CV_MAT_DEPTH(in1.type()) == CV_32F || CV_MAT_DEPTH(in1.type()) == CV_64F)
|
||||
{
|
||||
return ((cv::countNonZero(cv::abs(in1 - in2) > (_tol)*cv::abs(in2))) ? false : true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CV_MAT_DEPTH(in1.type()) == CV_8U)
|
||||
{
|
||||
bool a = (cv::countNonZero(cv::abs(in1 - in2) > 1) <= _tol * in2.total());
|
||||
return ((a == 1 ? 0 : 1) && ((cv::countNonZero(cv::abs(in1 - in2) > 2) <= 0) == 1 ? 0 : 1)) == 1 ? false : true;
|
||||
}
|
||||
else return cv::countNonZero(in1 != in2)==0;
|
||||
}
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
};
|
||||
|
||||
class AbsToleranceRGBBGRFluid : public Wrappable<AbsToleranceRGBBGRFluid>
|
||||
{
|
||||
public:
|
||||
AbsToleranceRGBBGRFluid(double tol) : _tol(tol) {}
|
||||
bool operator() (const cv::Mat& in1, const cv::Mat& in2) const
|
||||
{
|
||||
bool a = (cv::countNonZero((in1 - in2) > 0) <= _tol * in2.total());
|
||||
return ((a == 1 ? 0 : 1) && ((cv::countNonZero((in1 - in2) > 1) <= 0) == 1 ? 0 : 1)) == 1 ? false : true;
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
};
|
||||
|
||||
class ToleranceTripleFluid : public Wrappable<ToleranceTripleFluid>
|
||||
{
|
||||
public:
|
||||
ToleranceTripleFluid(double tol1, double tol2, double tol3) : _tol1(tol1), _tol2(tol2), _tol3(tol3) {}
|
||||
bool operator() (const cv::Mat& in1, const cv::Mat& in2) const
|
||||
{
|
||||
bool a = (cv::countNonZero((in1 - in2) > 0) <= _tol1 * in2.total());
|
||||
return (((a == 1 ? 0 : 1) &&
|
||||
((cv::countNonZero((in1 - in2) > 1) <= _tol2 * in2.total()) == 1 ? 0 : 1) &&
|
||||
((cv::countNonZero((in1 - in2) > 2) <= _tol3 * in2.total()) == 1 ? 0 : 1))) == 1 ? false : true;
|
||||
}
|
||||
private:
|
||||
double _tol1, _tol2, _tol3;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(RGB2GrayTestFluid, RGB2GrayTest,
|
||||
Combine(Values(AbsToleranceRGBBGRFluid(0.001).to_compare_f()),
|
||||
Combine(Values(ToleranceRGBBGR(0.001).to_compare_f()),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(true, false),
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BGR2GrayTestFluid, BGR2GrayTest,
|
||||
Combine(Values(AbsToleranceRGBBGRFluid(0.001).to_compare_f()),
|
||||
Combine(Values(ToleranceRGBBGR(0.001).to_compare_f()),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(true, false),
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(RGB2YUVTestFluid, RGB2YUVTest,
|
||||
Combine(Values(AbsToleranceRGBBGRFluid(0.15*3).to_compare_f()),
|
||||
Combine(Values(ToleranceRGBBGR(0.15*3).to_compare_f()),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(true, false),
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(YUV2RGBTestFluid, YUV2RGBTest,
|
||||
Combine(Values(ToleranceTripleFluid(0.25 * 3, 0.01 * 3, 1e-5 * 3).to_compare_f()),
|
||||
Combine(Values(ToleranceTriple(0.25 * 3, 0.01 * 3, 1e-5 * 3).to_compare_f()),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(true, false),
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(RGB2LabTestFluid, RGB2LabTest,
|
||||
Combine(Values(ToleranceTripleFluid(0.25 * 3, 0.0, 1e-5 * 3).to_compare_f()),
|
||||
Combine(Values(ToleranceTriple(0.25 * 3, 0.0, 1e-5 * 3).to_compare_f()),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(true, false),
|
||||
@@ -170,14 +51,14 @@ INSTANTIATE_TEST_CASE_P(RGB2LabTestFluid, RGB2LabTest,
|
||||
|
||||
// FIXME: Not supported by Fluid yet (no kernel implemented)
|
||||
INSTANTIATE_TEST_CASE_P(BGR2LUVTestFluid, BGR2LUVTest,
|
||||
Combine(Values(ToleranceTripleFluid(0.25 * 3, 0.01 * 3, 0.0001 * 3).to_compare_f()),
|
||||
Combine(Values(ToleranceTriple(0.25 * 3, 0.01 * 3, 0.0001 * 3).to_compare_f()),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(true, false),
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(blurTestFluid, BlurTest,
|
||||
Combine(Values(AbsToleranceFluid(0.0).to_compare_f()),
|
||||
Combine(Values(AbsTolerance(0.0).to_compare_f()),
|
||||
Values(CV_8UC1, CV_16UC1, CV_16SC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -187,7 +68,7 @@ INSTANTIATE_TEST_CASE_P(blurTestFluid, BlurTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(gaussBlurTestFluid, GaussianBlurTest,
|
||||
Combine(Values(AbsToleranceGaussianBlurFluid(1e-6).to_compare_f()),
|
||||
Combine(Values(AbsToleranceGaussianBlur_Float_Int(1e-6, 1e-6).to_compare_f()),
|
||||
Values(CV_8UC1, CV_16UC1, CV_16SC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -196,7 +77,7 @@ INSTANTIATE_TEST_CASE_P(gaussBlurTestFluid, GaussianBlurTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(medianBlurTestFluid, MedianBlurTest,
|
||||
Combine(Values(AbsExactFluid().to_compare_f()),
|
||||
Combine(Values(AbsExact().to_compare_f()),
|
||||
Values(CV_8UC1, CV_16UC1, CV_16SC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -205,7 +86,7 @@ INSTANTIATE_TEST_CASE_P(medianBlurTestFluid, MedianBlurTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(erodeTestFluid, ErodeTest,
|
||||
Combine(Values(AbsExactFluid().to_compare_f()),
|
||||
Combine(Values(AbsExact().to_compare_f()),
|
||||
Values(CV_8UC1, CV_16UC1, CV_16SC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -217,7 +98,7 @@ INSTANTIATE_TEST_CASE_P(erodeTestFluid, ErodeTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(dilateTestFluid, DilateTest,
|
||||
Combine(Values(AbsExactFluid().to_compare_f()),
|
||||
Combine(Values(AbsExact().to_compare_f()),
|
||||
Values(CV_8UC1, CV_16UC1, CV_16SC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -229,7 +110,7 @@ INSTANTIATE_TEST_CASE_P(dilateTestFluid, DilateTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SobelTestFluid, SobelTest,
|
||||
Combine(Values(AbsExactFluid().to_compare_f()),
|
||||
Combine(Values(AbsExact().to_compare_f()),
|
||||
Values(CV_8UC1, CV_16UC1, CV_16SC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -241,7 +122,7 @@ INSTANTIATE_TEST_CASE_P(SobelTestFluid, SobelTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SobelTestFluid32F, SobelTest,
|
||||
Combine(Values(AbsToleranceSobelFluid(1e-3).to_compare_f()),
|
||||
Combine(Values(AbsToleranceSobel(1e-3).to_compare_f()),
|
||||
Values(CV_32FC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -253,7 +134,7 @@ INSTANTIATE_TEST_CASE_P(SobelTestFluid32F, SobelTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(boxFilterTestFluid32, BoxFilterTest,
|
||||
Combine(Values(AbsTolerance32FFluid(1e-6).to_compare_f()),
|
||||
Combine(Values(AbsTolerance_Float_Int(1e-6, 1e-4).to_compare_f()),
|
||||
Values(CV_8UC1, CV_16UC1, CV_16SC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -264,7 +145,7 @@ INSTANTIATE_TEST_CASE_P(boxFilterTestFluid32, BoxFilterTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(sepFilterTestFluid, SepFilterTest,
|
||||
Combine(Values(AbsToleranceSepFilterFluid(1e-5f).to_compare_f()),
|
||||
Combine(Values(AbsToleranceSepFilter(1e-5f).to_compare_f()),
|
||||
Values(CV_32FC1),
|
||||
Values(3), // add kernel size=5 when implementation is ready
|
||||
Values(cv::Size(1280, 720),
|
||||
@@ -274,7 +155,7 @@ INSTANTIATE_TEST_CASE_P(sepFilterTestFluid, SepFilterTest,
|
||||
Values(cv::compile_args(IMGPROC_FLUID))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(filter2DTestFluid, Filter2DTest,
|
||||
Combine(Values(AbsTolerance32FFluid(1e-6).to_compare_f()),
|
||||
Combine(Values(AbsTolerance_Float_Int(1e-6, 1e-4).to_compare_f()),
|
||||
Values(CV_8UC1, CV_16UC1, CV_16SC1),
|
||||
Values(3), // add kernel size=4,5,7 when implementation ready
|
||||
Values(cv::Size(1280, 720),
|
||||
|
||||
Reference in New Issue
Block a user