From 75c567b6abecc2fa4a1ab36fa4ba4217841477aa Mon Sep 17 00:00:00 2001 From: Andrey Golubev Date: Fri, 28 Jun 2019 13:07:41 +0300 Subject: [PATCH] Merge pull request #14757 from andrey-golubev:core_tests_update G-API: Introduce new approach to write accuracy tests (#14757) * G-API: Introduce new common accuracy test fixture * Enable Range<> to Seq<> implicit conversion * Fix shadowing parameters * Update license headers * Rename ALIGNED_TYPE to SAME_TYPE * Move MkRange to tests * Fix TODO(agolubev) in test instantiations * Squash simple fixture declarations in one line * Remove unused line * Fix Windows issues with macro expansion * Choose between 1 or 2 matrix initialization * Redesign common class behavior Use "views" for GetParam() provided by GTest base class instead of doing segregation (with copy!) of common and specific parameters: request common or specific parameter directly by index from GetParam()-returned parameters * Refine user-level API and usage of new test model * Fix -fpermissive errors * Remove unnecessary init calls * Replace GCompileArgs member variable with func ptr * Rename initMatsRandN to make its behavior explicit Rename initMatsRandN to initMatrixRandN to eliminate confusion: initMatsRandN only initialized first matrix (similarly to initMatrixRandU) * Fix common of initNothing * Update copyright dates in missed files * Add check for specific parameters * Fix coment stlye --- .../common/gapi_imgproc_perf_tests_inl.hpp | 54 +- modules/gapi/test/common/gapi_core_tests.hpp | 138 +++--- .../gapi/test/common/gapi_core_tests_inl.hpp | 467 +++++------------- .../test/common/gapi_imgproc_tests_inl.hpp | 58 +-- .../gapi/test/common/gapi_tests_common.hpp | 137 ++++- .../gapi/test/common/gapi_tests_helpers.hpp | 73 +++ modules/gapi/test/cpu/gapi_core_tests_cpu.cpp | 292 ++++++----- .../gapi/test/cpu/gapi_core_tests_fluid.cpp | 164 +++--- modules/gapi/test/gpu/gapi_core_tests_gpu.cpp | 285 ++++++----- 9 files changed, 884 insertions(+), 784 deletions(-) create mode 100644 modules/gapi/test/common/gapi_tests_helpers.hpp diff --git a/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp b/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp index 0f92a8db58..3fea552ede 100644 --- a/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp +++ b/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // -// Copyright (C) 2018 Intel Corporation +// Copyright (C) 2018-2019 Intel Corporation #ifndef OPENCV_GAPI_IMGPROC_PERF_TESTS_INL_HPP @@ -68,7 +68,7 @@ PERF_TEST_P_(SepFilterPerfTest, TestPerformance) cv::Mat kernelY(kernSize, 1, CV_32F); randu(kernelX, -1, 1); randu(kernelY, -1, 1); - initMatsRandN(type, sz, dtype, false); + initMatrixRandN(type, sz, dtype, false); cv::Point anchor = cv::Point(-1, -1); @@ -110,7 +110,7 @@ PERF_TEST_P_(Filter2DPerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, borderType, dtype, compile_args) = GetParam(); - initMatsRandN(type, sz, dtype, false); + initMatrixRandN(type, sz, dtype, false); cv::Point anchor = {-1, -1}; double delta = 0; @@ -160,7 +160,7 @@ PERF_TEST_P_(BoxFilterPerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, filterSize, sz, borderType, dtype, compile_args) = GetParam(); - initMatsRandN(type, sz, dtype, false); + initMatrixRandN(type, sz, dtype, false); cv::Point anchor = {-1, -1}; bool normalize = true; @@ -204,7 +204,7 @@ PERF_TEST_P_(BlurPerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, filterSize, sz, borderType, compile_args) = GetParam(); - initMatsRandN(type, sz, type, false); + initMatrixRandN(type, sz, type, false); cv::Point anchor = {-1, -1}; @@ -250,7 +250,7 @@ PERF_TEST_P_(GaussianBlurPerfTest, TestPerformance) cv::Size kSize = cv::Size(kernSize, kernSize); auto& rng = cv::theRNG(); double sigmaX = rng(); - initMatsRandN(type, sz, type, false); + initMatrixRandN(type, sz, type, false); // OpenCV code /////////////////////////////////////////////////////////// cv::GaussianBlur(in_mat1, out_mat_ocv, kSize, sigmaX); @@ -289,7 +289,7 @@ PERF_TEST_P_(MedianBlurPerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, compile_args) = GetParam(); - initMatsRandN(type, sz, type, false); + initMatrixRandN(type, sz, type, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -330,7 +330,7 @@ PERF_TEST_P_(ErodePerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, kernType, compile_args) = GetParam(); - initMatsRandN(type, sz, type, false); + initMatrixRandN(type, sz, type, false); cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize)); @@ -373,7 +373,7 @@ PERF_TEST_P_(Erode3x3PerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, sz, numIters, compile_args) = GetParam(); - initMatsRandN(type, sz, type, false); + initMatrixRandN(type, sz, type, false); cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3, 3)); @@ -416,7 +416,7 @@ PERF_TEST_P_(DilatePerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, kernType, compile_args) = GetParam(); - initMatsRandN(type, sz, type, false); + initMatrixRandN(type, sz, type, false); cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize)); @@ -459,7 +459,7 @@ PERF_TEST_P_(Dilate3x3PerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, sz, numIters, compile_args) = GetParam(); - initMatsRandN(type, sz, type, false); + initMatrixRandN(type, sz, type, false); cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3, 3)); @@ -502,7 +502,7 @@ PERF_TEST_P_(SobelPerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, dtype, dx, dy, compile_args) = GetParam(); - initMatsRandN(type, sz, dtype, false); + initMatrixRandN(type, sz, dtype, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -545,7 +545,7 @@ PERF_TEST_P_(SobelXYPerfTest, TestPerformance) cv::Mat out_mat_ocv2; cv::Mat out_mat_gapi2; - initMatsRandN(type, sz, dtype, false); + initMatrixRandN(type, sz, dtype, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -590,7 +590,7 @@ PERF_TEST_P_(CannyPerfTest, TestPerformance) cv::GCompileArgs compile_args; std::tie(cmpF, type, sz, thrLow, thrUp, apSize, l2gr, compile_args) = GetParam(); - initMatsRandN(type, sz, CV_8UC1, false); + initMatrixRandN(type, sz, CV_8UC1, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -628,7 +628,7 @@ PERF_TEST_P_(EqHistPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC1, sz, CV_8UC1, false); + initMatrixRandN(CV_8UC1, sz, CV_8UC1, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -666,7 +666,7 @@ PERF_TEST_P_(RGB2GrayPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC1, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC1, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -704,7 +704,7 @@ PERF_TEST_P_(BGR2GrayPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC1, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC1, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -742,7 +742,7 @@ PERF_TEST_P_(RGB2YUVPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC3, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -780,7 +780,7 @@ PERF_TEST_P_(YUV2RGBPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC3, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -818,7 +818,7 @@ PERF_TEST_P_(RGB2LabPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC3, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -856,7 +856,7 @@ PERF_TEST_P_(BGR2LUVPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC3, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -894,7 +894,7 @@ PERF_TEST_P_(LUV2BGRPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC3, false); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -932,7 +932,7 @@ PERF_TEST_P_(BGR2YUVPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC3, false); cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2YUV); @@ -962,7 +962,7 @@ PERF_TEST_P_(YUV2BGRPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC3, false); cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2BGR); @@ -990,7 +990,7 @@ PERF_TEST_P_(BayerGR2RGBPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC1, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC1, sz, CV_8UC3, false); cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BayerGR2RGB); @@ -1018,7 +1018,7 @@ PERF_TEST_P_(RGB2HSVPerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC3, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC3, false); cv::cvtColor(in_mat1, in_mat1, cv::COLOR_BGR2RGB); cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2HSV); @@ -1047,7 +1047,7 @@ PERF_TEST_P_(RGB2YUV422PerfTest, TestPerformance) Size sz = get<1>(GetParam()); cv::GCompileArgs compile_args = get<2>(GetParam()); - initMatsRandN(CV_8UC3, sz, CV_8UC2, false); + initMatrixRandN(CV_8UC3, sz, CV_8UC2, false); cv::cvtColor(in_mat1, in_mat1, cv::COLOR_BGR2RGB); convertRGB2YUV422Ref(in_mat1, out_mat_ocv); diff --git a/modules/gapi/test/common/gapi_core_tests.hpp b/modules/gapi/test/common/gapi_core_tests.hpp index 38ebb3557a..be203810eb 100644 --- a/modules/gapi/test/common/gapi_core_tests.hpp +++ b/modules/gapi/test/common/gapi_core_tests.hpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // -// Copyright (C) 2018 Intel Corporation +// Copyright (C) 2018-2019 Intel Corporation #ifndef OPENCV_GAPI_CORE_TESTS_HPP @@ -46,16 +46,18 @@ struct PrintMathOpCoreParams std::string operator()(const ::testing::TestParamInfo& info) const { std::stringstream ss; - cv::Size sz = std::get<4>(info.param); - ss<(info.param)] - <<"_"<(info.param) - <<"_"<(info.param) - <<"_"<<(int)std::get<3>(info.param) + using AllParams = Params; + const AllParams::params_t& params = info.param; + cv::Size sz = AllParams::getCommon<1>(params); // size + ss<(params)] // mathOp + <<"_"<(params) // testWithScalar + <<"_"<(params) // type + <<"_"<<(int)AllParams::getSpecific<2>(params) // scale <<"_"<(info.param)+1) - <<"_"<(info.param) - <<"_"<(info.param); + <<"_"<<(AllParams::getCommon<2>(params)+1) // dtype + <<"_"<(params) // createOutputMatrices + <<"_"<(params); // doReverseOp return ss.str(); } }; @@ -66,13 +68,15 @@ struct PrintCmpCoreParams std::string operator()(const ::testing::TestParamInfo& info) const { std::stringstream ss; - cv::Size sz = std::get<3>(info.param); - ss<(info.param)] - <<"_"<(info.param) - <<"_"<(info.param) + using AllParams = Params; + const AllParams::params_t& params = info.param; + cv::Size sz = AllParams::getCommon<1>(params); // size + ss<(params)] // CmpType + <<"_"<(params) // testWithScalar + <<"_"<(params) // type <<"_"<(info.param); + <<"_"<(params); // createOutputMatrices return ss.str(); } }; @@ -83,12 +87,14 @@ struct PrintBWCoreParams std::string operator()(const ::testing::TestParamInfo& info) const { std::stringstream ss; - cv::Size sz = std::get<2>(info.param); - ss<(info.param)] - <<"_"<(info.param) + using AllParams = Params; + const AllParams::params_t& params = info.param; + cv::Size sz = AllParams::getCommon<1>(params); // size + ss<(params)] // bitwiseOp + <<"_"<(params) // type <<"_"<(info.param); + <<"_"<(params); // createOutputMatrices return ss.str(); } }; @@ -99,56 +105,64 @@ struct PrintNormCoreParams std::string operator()(const ::testing::TestParamInfo& info) const { std::stringstream ss; - cv::Size sz = std::get<2>(info.param); - ss<(info.param)] - <<"_"<(info.param) + using AllParams = Params; + const AllParams::params_t& params = info.param; + cv::Size sz = AllParams::getCommon<1>(params); // size + ss<(params)] // NormTypes + <<"_"<(params) // type <<"_"<>{}; -struct MulDoubleTest : public TestParams>{}; -struct DivTest : public TestParams>{}; -struct DivCTest : public TestParams>{}; -struct MeanTest : public TestParams> {}; -struct MaskTest : public TestParams> {}; -struct Polar2CartTest : public TestParams> {}; -struct Cart2PolarTest : public TestParams> {}; -struct CmpTest : public TestParams>{}; -struct BitwiseTest : public TestParams>{}; -struct NotTest : public TestParams> {}; -struct SelectTest : public TestParams> {}; -struct MinTest : public TestParams>{}; -struct MaxTest : public TestParams>{}; -struct AbsDiffTest : public TestParams>{}; -struct AbsDiffCTest : public TestParams> {}; -struct SumTest : public TestParams> {}; -struct AddWeightedTest : public TestParams>{}; -struct NormTest : public TestParams>{}; -struct IntegralTest : public TestWithParam> {}; -struct ThresholdTest : public TestParams> {}; -struct ThresholdOTTest : public TestParams> {}; -struct InRangeTest : public TestParams> {}; -struct Split3Test : public TestParams> {}; -struct Split4Test : public TestParams> {}; -struct ResizeTest : public TestWithParam> {}; -struct ResizeTestFxFy : public TestWithParam> {}; -struct Merge3Test : public TestParams> {}; -struct Merge4Test : public TestParams> {}; -struct RemapTest : public TestParams> {}; -struct FlipTest : public TestParams> {}; -struct CropTest : public TestParams> {}; -struct ConcatHorTest : public TestWithParam> {}; -struct ConcatVertTest : public TestWithParam> {}; -struct ConcatVertVecTest : public TestWithParam> {}; -struct ConcatHorVecTest : public TestWithParam> {}; -struct LUTTest : public TestParams> {}; -struct ConvertToTest : public TestParams> {}; -struct PhaseTest : public TestParams> {}; -struct SqrtTest : public TestParams> {}; -struct NormalizeTest : public TestParams> {}; +GAPI_TEST_FIXTURE(MathOpTest, initMatsRandU, FIXTURE_API(mathOp,bool,double,bool), 4, + opType, testWithScalar, scale, doReverseOp) +GAPI_TEST_FIXTURE(MulDoubleTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(DivTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(DivCTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(MeanTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(MaskTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(Polar2CartTest, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(Cart2PolarTest, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(CmpTest, initMatsRandU, FIXTURE_API(CmpTypes,bool), 2, opType, testWithScalar) +GAPI_TEST_FIXTURE(BitwiseTest, initMatsRandU, FIXTURE_API(bitwiseOp), 1, opType) +GAPI_TEST_FIXTURE(NotTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(SelectTest, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(MinTest, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(MaxTest, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(AbsDiffTest, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(AbsDiffCTest, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(SumTest, initMatrixRandU, FIXTURE_API(compare_scalar_f), 1, cmpF) +GAPI_TEST_FIXTURE(AddWeightedTest, initMatsRandU, FIXTURE_API(compare_f), 1, cmpF) +GAPI_TEST_FIXTURE(NormTest, initMatrixRandU, FIXTURE_API(compare_scalar_f,NormTypes), 2, + cmpF, opType) +GAPI_TEST_FIXTURE(IntegralTest, initNothing, <>, 0) +GAPI_TEST_FIXTURE(ThresholdTest, initMatrixRandU, FIXTURE_API(int), 1, tt) +GAPI_TEST_FIXTURE(ThresholdOTTest, initMatrixRandU, FIXTURE_API(int), 1, tt) +GAPI_TEST_FIXTURE(InRangeTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(Split3Test, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(Split4Test, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(ResizeTest, initNothing, FIXTURE_API(compare_f,int,cv::Size), 3, + cmpF, interp, sz_out) +GAPI_TEST_FIXTURE(ResizeTestFxFy, initNothing, FIXTURE_API(compare_f,int,double,double), 4, + cmpF, interp, fx, fy) +GAPI_TEST_FIXTURE(Merge3Test, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(Merge4Test, initMatsRandU, <>, 0) +GAPI_TEST_FIXTURE(RemapTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(FlipTest, initMatrixRandU, FIXTURE_API(int), 1, flipCode) +GAPI_TEST_FIXTURE(CropTest, initMatrixRandU, FIXTURE_API(cv::Rect), 1, rect_to) +GAPI_TEST_FIXTURE(ConcatHorTest, initNothing, <>, 0) +GAPI_TEST_FIXTURE(ConcatVertTest, initNothing, <>, 0) +GAPI_TEST_FIXTURE(ConcatVertVecTest, initNothing, <>, 0) +GAPI_TEST_FIXTURE(ConcatHorVecTest, initNothing, <>, 0) +GAPI_TEST_FIXTURE(LUTTest, initNothing, <>, 0) +GAPI_TEST_FIXTURE(ConvertToTest, initNothing, FIXTURE_API(compare_f, double, double), 3, + cmpF, alpha, beta) +GAPI_TEST_FIXTURE(PhaseTest, initMatsRandU, FIXTURE_API(bool), 1, angle_in_degrees) +GAPI_TEST_FIXTURE(SqrtTest, initMatrixRandU, <>, 0) +GAPI_TEST_FIXTURE(NormalizeTest, initNothing, FIXTURE_API(compare_f,double,double,int,MatType), 5, + cmpF, a, b, norm_type, ddepth) } // opencv_test #endif //OPENCV_GAPI_CORE_TESTS_HPP diff --git a/modules/gapi/test/common/gapi_core_tests_inl.hpp b/modules/gapi/test/common/gapi_core_tests_inl.hpp index 3fe1153b94..90ed202164 100644 --- a/modules/gapi/test/common/gapi_core_tests_inl.hpp +++ b/modules/gapi/test/common/gapi_core_tests_inl.hpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // -// Copyright (C) 2018 Intel Corporation +// Copyright (C) 2018-2019 Intel Corporation #ifndef OPENCV_GAPI_CORE_TESTS_INL_HPP @@ -16,15 +16,6 @@ namespace opencv_test TEST_P(MathOpTest, MatricesAccuracyTest ) { - mathOp opType = ADD; - int type = 0, dtype = 0; - cv::Size sz; - double scale = 1; // mul, div - bool testWithScalar = false, initOutMatr = false, doReverseOp = false; - cv::GCompileArgs compile_args; - std::tie(opType, testWithScalar, type, scale, sz, dtype, initOutMatr, doReverseOp, compile_args) = GetParam(); - initMatsRandU(type, sz, dtype, initOutMatr); - // G-API code & corresponding OpenCV code //////////////////////////////// cv::GMat in1, in2, out; if( testWithScalar ) @@ -82,7 +73,7 @@ TEST_P(MathOpTest, MatricesAccuracyTest ) } } cv::GComputation c(GIn(in1, sc1), GOut(out)); - c.apply(gin(in_mat1, sc), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, sc), gout(out_mat_gapi), getCompileArgs()); } else { @@ -118,7 +109,7 @@ TEST_P(MathOpTest, MatricesAccuracyTest ) FAIL() << "no such math operation type for matrix and matrix!"; }} cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), getCompileArgs()); } // Comparison ////////////////////////////////////////////////////////////// @@ -148,22 +139,14 @@ TEST_P(MathOpTest, MatricesAccuracyTest ) TEST_P(MulDoubleTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - int dtype = std::get<2>(param); - cv::Size sz_in = std::get<1>(param); - bool initOut = std::get<3>(param); - auto& rng = cv::theRNG(); double d = rng.uniform(0.0, 10.0); - auto compile_args = std::get<4>(param); - initMatrixRandU(type, sz_in, dtype, initOut); // G-API code //////////////////////////////////////////////////////////// cv::GMat in1, out; out = cv::gapi::mulC(in1, d, dtype); cv::GComputation c(in1, out); - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi, getCompileArgs()); // OpenCV code /////////////////////////////////////////////////////////// cv::multiply(in_mat1, d, out_mat_ocv, 1, dtype); @@ -187,26 +170,19 @@ TEST_P(MulDoubleTest, AccuracyTest) #else EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv)); #endif - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } TEST_P(DivTest, DISABLED_DivByZeroTest) // https://github.com/opencv/opencv/pull/12826 { - int type = 0, dtype = 0; - cv::Size sz_in; - bool initOut = false; - cv::GCompileArgs compile_args; - std::tie(type, sz_in, dtype, initOut, compile_args) = GetParam(); - - initMatrixRandU(type, sz_in, dtype, initOut); - in_mat2 = cv::Mat(sz_in, type); + in_mat2 = cv::Mat(sz, type); in_mat2.setTo(cv::Scalar::all(0)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, in2; auto out = cv::gapi::div(in1, in2, 1.0, dtype); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -216,19 +192,12 @@ TEST_P(DivTest, DISABLED_DivByZeroTest) // https://github.com/opencv/opencv/pul // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(DivCTest, DISABLED_DivByZeroTest) // https://github.com/opencv/opencv/pull/12826 { - int type = 0, dtype = 0; - cv::Size sz_in; - bool initOut = false; - cv::GCompileArgs compile_args; - std::tie(type, sz_in, dtype, initOut, compile_args) = GetParam(); - - initMatrixRandU(type, sz_in, dtype, initOut); sc = cv::Scalar::all(0); // G-API code ////////////////////////////////////////////////////////////// @@ -237,7 +206,7 @@ TEST_P(DivCTest, DISABLED_DivByZeroTest) // https://github.com/opencv/opencv/pu auto out = cv::gapi::divC(in1, sc1, dtype); cv::GComputation c(GIn(in1, sc1), GOut(out)); - c.apply(gin(in_mat1, sc), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, sc), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -247,19 +216,13 @@ TEST_P(DivCTest, DISABLED_DivByZeroTest) // https://github.com/opencv/opencv/pu // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi)); - cv::Mat zeros = cv::Mat::zeros(sz_in, type); + cv::Mat zeros = cv::Mat::zeros(sz, type); EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != zeros)); } } TEST_P(MeanTest, AccuracyTest) { - int type = 0; - bool initOut = false; - cv::Size sz_in; - cv::GCompileArgs compile_args; - std::tie(type, sz_in, initOut, compile_args) = GetParam(); - initMatrixRandU(type, sz_in, initOut); cv::Scalar out_norm; cv::Scalar out_norm_ocv; @@ -268,7 +231,7 @@ TEST_P(MeanTest, AccuracyTest) auto out = cv::gapi::mean(in); cv::GComputation c(cv::GIn(in), cv::GOut(out)); - c.apply(cv::gin(in_mat1), cv::gout(out_norm), std::move(compile_args)); + c.apply(cv::gin(in_mat1), cv::gout(out_norm), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { out_norm_ocv = cv::mean(in_mat1); @@ -281,14 +244,7 @@ TEST_P(MeanTest, AccuracyTest) TEST_P(MaskTest, AccuracyTest) { - int type = 0; - bool initOut = false; - cv::Size sz_in; - cv::GCompileArgs compile_args; - std::tie(type, sz_in, initOut, compile_args) = GetParam(); - initMatrixRandU(type, sz_in, type, initOut); - - in_mat2 = cv::Mat(sz_in, CV_8UC1); + in_mat2 = cv::Mat(sz, CV_8UC1); cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255)); in_mat2 = in_mat2 > 128; @@ -297,7 +253,7 @@ TEST_P(MaskTest, AccuracyTest) auto out = cv::gapi::mask(in, m); cv::GComputation c(cv::GIn(in, m), cv::GOut(out)); - c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi), std::move(compile_args)); + c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { out_mat_ocv = cv::Mat::zeros(in_mat1.size(), in_mat1.type()); @@ -311,17 +267,12 @@ TEST_P(MaskTest, AccuracyTest) TEST_P(Polar2CartTest, AccuracyTest) { - auto param = GetParam(); - cv::Size sz_in = std::get<0>(param); - auto compile_args = std::get<2>(param); - initMatsRandU(CV_32FC1, sz_in, CV_32FC1, std::get<1>(param)); - cv::Mat out_mat2; cv::Mat out_mat_ocv2; - if(std::get<1>(param) == true) + if(createOutputMatrices) { - out_mat2 = cv::Mat(sz_in, CV_32FC1); - out_mat_ocv2 = cv::Mat(sz_in, CV_32FC1); + out_mat2 = cv::Mat(sz, dtype); + out_mat_ocv2 = cv::Mat(sz, dtype); } // G-API code ////////////////////////////////////////////////////////////// @@ -329,7 +280,7 @@ TEST_P(Polar2CartTest, AccuracyTest) std::tie(out1, out2) = cv::gapi::polarToCart(in1, in2); cv::GComputation c(GIn(in1, in2), GOut(out1, out2)); - c.apply(gin(in_mat1,in_mat2), gout(out_mat_gapi, out_mat2), std::move(compile_args)); + c.apply(gin(in_mat1,in_mat2), gout(out_mat_gapi, out_mat2), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { cv::polarToCart(in_mat1, in_mat2, out_mat_ocv, out_mat_ocv2); @@ -361,19 +312,14 @@ TEST_P(Polar2CartTest, AccuracyTest) EXPECT_EQ(0, cv::countNonZero(difx > 1e-6*absx)); EXPECT_EQ(0, cv::countNonZero(dify > 1e-6*absy)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(Cart2PolarTest, AccuracyTest) { - auto param = GetParam(); - cv::Size sz_in = std::get<0>(param); - auto compile_args = std::get<2>(param); - initMatsRandU(CV_32FC1, sz_in, CV_32FC1, std::get<1>(param)); - - cv::Mat out_mat2(sz_in, CV_32FC1); - cv::Mat out_mat_ocv2(sz_in, CV_32FC1); + cv::Mat out_mat2(sz, dtype); + cv::Mat out_mat_ocv2(sz, dtype); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, in2, out1, out2; @@ -414,20 +360,12 @@ TEST_P(Cart2PolarTest, AccuracyTest) // (expected relative accuracy like 1e-6) EXPECT_EQ(0, cv::countNonZero(difm > 1e-6*absm)); EXPECT_EQ(0, cv::countNonZero(difa > 1e-3*absa)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(CmpTest, AccuracyTest) { - CmpTypes opType = CMP_EQ; - int type = 0; - cv::Size sz; - bool testWithScalar = false, initOutMatr = false; - cv::GCompileArgs compile_args; - std::tie(opType, testWithScalar, type, sz, initOutMatr, compile_args) = GetParam(); - initMatsRandU(type, sz, CV_8U, initOutMatr); - // G-API code & corresponding OpenCV code //////////////////////////////// cv::GMat in1, out; if( testWithScalar ) @@ -447,7 +385,7 @@ TEST_P(CmpTest, AccuracyTest) cv::compare(in_mat1, sc, out_mat_ocv, opType); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, sc), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, sc), gout(out_mat_gapi), getCompileArgs()); } else { @@ -466,7 +404,7 @@ TEST_P(CmpTest, AccuracyTest) cv::compare(in_mat1, in_mat2, out_mat_ocv, opType); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), getCompileArgs()); } // Comparison ////////////////////////////////////////////////////////////// @@ -478,14 +416,6 @@ TEST_P(CmpTest, AccuracyTest) TEST_P(BitwiseTest, AccuracyTest) { - bitwiseOp opType = AND; - int type = 0; - cv::Size sz; - bool initOutMatr = false; - cv::GCompileArgs compile_args; - std::tie(opType, type, sz, initOutMatr, compile_args) = GetParam(); - initMatsRandU(type, sz, type, initOutMatr); - // G-API code & corresponding OpenCV code //////////////////////////////// cv::GMat in1, in2, out; switch(opType) @@ -514,7 +444,7 @@ TEST_P(BitwiseTest, AccuracyTest) } } cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), getCompileArgs()); // Comparison ////////////////////////////////////////////////////////////// { @@ -525,17 +455,12 @@ TEST_P(BitwiseTest, AccuracyTest) TEST_P(NotTest, AccuracyTest) { - auto param = GetParam(); - cv::Size sz_in = std::get<1>(param); - auto compile_args = std::get<3>(param); - initMatrixRandU(std::get<0>(param), sz_in, std::get<0>(param), std::get<2>(param)); - // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; auto out = cv::gapi::bitwise_not(in); cv::GComputation c(in, out); - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi, getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -544,18 +469,13 @@ TEST_P(NotTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(SelectTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_in = std::get<1>(param); - auto compile_args = std::get<3>(param); - initMatsRandU(type, sz_in, type, std::get<2>(param)); - cv::Mat in_mask(sz_in, CV_8UC1); + cv::Mat in_mask(sz, CV_8UC1); cv::randu(in_mask, cv::Scalar::all(0), cv::Scalar::all(255)); // G-API code ////////////////////////////////////////////////////////////// @@ -563,7 +483,7 @@ TEST_P(SelectTest, AccuracyTest) auto out = cv::gapi::select(in1, in2, in3); cv::GComputation c(GIn(in1, in2, in3), GOut(out)); - c.apply(gin(in_mat1, in_mat2, in_mask), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2, in_mask), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -573,23 +493,18 @@ TEST_P(SelectTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(MinTest, AccuracyTest) { - auto param = GetParam(); - cv::Size sz_in = std::get<1>(param); - auto compile_args = std::get<3>(param); - initMatsRandU(std::get<0>(param), sz_in, std::get<0>(param), std::get<2>(param)); - // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, in2; auto out = cv::gapi::min(in1, in2); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -598,23 +513,18 @@ TEST_P(MinTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(MaxTest, AccuracyTest) { - auto param = GetParam(); - cv::Size sz_in = std::get<1>(param); - auto compile_args = std::get<3>(param); - initMatsRandU(std::get<0>(param), sz_in, std::get<0>(param), std::get<2>(param)); - // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, in2; auto out = cv::gapi::max(in1, in2); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -623,23 +533,18 @@ TEST_P(MaxTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(AbsDiffTest, AccuracyTest) { - auto param = GetParam(); - cv::Size sz_in = std::get<1>(param); - auto compile_args = std::get<3>(param); - initMatsRandU(std::get<0>(param), sz_in, std::get<0>(param), std::get<2>(param)); - // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, in2; auto out = cv::gapi::absDiff(in1, in2); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -648,24 +553,19 @@ TEST_P(AbsDiffTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(AbsDiffCTest, AccuracyTest) { - auto param = GetParam(); - cv::Size sz_in = std::get<1>(param); - auto compile_args = std::get<3>(param); - initMatsRandU(std::get<0>(param), sz_in, std::get<0>(param), std::get<2>(param)); - // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1; cv::GScalar sc1; auto out = cv::gapi::absDiffC(in1, sc1); cv::GComputation c(cv::GIn(in1, sc1), cv::GOut(out)); - c.apply(gin(in_mat1, sc), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, sc), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -674,20 +574,12 @@ TEST_P(AbsDiffCTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(SumTest, AccuracyTest) { - auto param = GetParam(); - compare_scalar_f cmpF = get<3>(GetParam()); - MatType type = std::get<0>(param); - cv::Size sz_in = std::get<1>(param); - auto compile_args = std::get<4>(param); - initMatrixRandU(type, sz_in, type, std::get<2>(param)); - - cv::Scalar out_sum; cv::Scalar out_sum_ocv; @@ -696,7 +588,7 @@ TEST_P(SumTest, AccuracyTest) auto out = cv::gapi::sum(in); cv::GComputation c(cv::GIn(in), cv::GOut(out)); - c.apply(cv::gin(in_mat1), cv::gout(out_sum), std::move(compile_args)); + c.apply(cv::gin(in_mat1), cv::gout(out_sum), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { out_sum_ocv = cv::sum(in_mat1); @@ -709,25 +601,17 @@ TEST_P(SumTest, AccuracyTest) TEST_P(AddWeightedTest, AccuracyTest) { - int type = 0, dtype = 0; - cv::Size sz_in; - bool initOut = false; - cv::GCompileArgs compile_args; - compare_f cmpF; - std::tie(type, sz_in, dtype, initOut, cmpF, compile_args) = GetParam(); - auto& rng = cv::theRNG(); double alpha = rng.uniform(0.0, 1.0); double beta = rng.uniform(0.0, 1.0); double gamma = rng.uniform(0.0, 1.0); - initMatsRandU(type, sz_in, dtype, initOut); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, in2; auto out = cv::gapi::addWeighted(in1, alpha, in2, beta, gamma, dtype); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -735,20 +619,11 @@ TEST_P(AddWeightedTest, AccuracyTest) } // Comparison ////////////////////////////////////////////////////////////// EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); - + EXPECT_EQ(out_mat_gapi.size(), sz); } TEST_P(NormTest, AccuracyTest) { - compare_scalar_f cmpF; - NormTypes opType = NORM_INF; - int type = 0; - cv::Size sz; - cv::GCompileArgs compile_args; - std::tie(opType, type, sz, cmpF, compile_args) = GetParam(); - initMatrixRandU(type, sz, type, false); - cv::Scalar out_norm; cv::Scalar out_norm_ocv; @@ -764,7 +639,7 @@ TEST_P(NormTest, AccuracyTest) } out_norm_ocv = cv::norm(in_mat1, opType); cv::GComputation c(GIn(in1), GOut(out)); - c.apply(gin(in_mat1), gout(out_norm), std::move(compile_args)); + c.apply(gin(in_mat1), gout(out_norm), getCompileArgs()); // Comparison ////////////////////////////////////////////////////////////// { @@ -774,16 +649,12 @@ TEST_P(NormTest, AccuracyTest) TEST_P(IntegralTest, AccuracyTest) { - int type = std::get<0>(GetParam()); - cv::Size sz_in = std::get<1>(GetParam()); - auto compile_args = std::get<2>(GetParam()); - int type_out = (type == CV_8U) ? CV_32SC1 : CV_64FC1; - cv::Mat in_mat1(sz_in, type); + in_mat1 = cv::Mat(sz, type); cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255)); - cv::Size sz_out = cv::Size(sz_in.width + 1, sz_in.height + 1); + cv::Size sz_out = cv::Size(sz.width + 1, sz.height + 1); cv::Mat out_mat1(sz_out, type_out); cv::Mat out_mat_ocv1(sz_out, type_out); @@ -795,7 +666,7 @@ TEST_P(IntegralTest, AccuracyTest) std::tie(out1, out2) = cv::gapi::integral(in1, type_out, CV_64FC1); cv::GComputation c(cv::GIn(in1), cv::GOut(out1, out2)); - c.apply(cv::gin(in_mat1), cv::gout(out_mat1, out_mat2), std::move(compile_args)); + c.apply(cv::gin(in_mat1), cv::gout(out_mat1, out_mat2), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -810,15 +681,8 @@ TEST_P(IntegralTest, AccuracyTest) TEST_P(ThresholdTest, AccuracyTestBinary) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_in = std::get<1>(param); - int tt = std::get<2>(param); - - auto compile_args = std::get<4>(param); cv::Scalar thr = initScalarRandU(50); cv::Scalar maxval = initScalarRandU(50) + cv::Scalar(50, 50, 50, 50); - initMatrixRandU(type, sz_in, type, std::get<3>(param)); cv::Scalar out_scalar; // G-API code ////////////////////////////////////////////////////////////// @@ -827,7 +691,7 @@ TEST_P(ThresholdTest, AccuracyTestBinary) out = cv::gapi::threshold(in1, th1, mv1, tt); cv::GComputation c(GIn(in1, th1, mv1), GOut(out)); - c.apply(gin(in_mat1, thr, maxval), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, thr, maxval), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -835,21 +699,14 @@ TEST_P(ThresholdTest, AccuracyTestBinary) } // Comparison ////////////////////////////////////////////////////////////// { - ASSERT_EQ(out_mat_gapi.size(), sz_in); + ASSERT_EQ(out_mat_gapi.size(), sz); EXPECT_EQ(0, cv::norm(out_mat_ocv, out_mat_gapi, NORM_L1)); } } TEST_P(ThresholdOTTest, AccuracyTestOtsu) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_in = std::get<1>(param); - int tt = std::get<2>(param); - - auto compile_args = std::get<4>(param); cv::Scalar maxval = initScalarRandU(50) + cv::Scalar(50, 50, 50, 50); - initMatrixRandU(type, sz_in, type, std::get<3>(param)); cv::Scalar out_gapi_scalar; double ocv_res; @@ -859,7 +716,7 @@ TEST_P(ThresholdOTTest, AccuracyTestOtsu) std::tie(out, scout) = cv::gapi::threshold(in1, mv1, tt); cv::GComputation c(cv::GIn(in1, mv1), cv::GOut(out, scout)); - c.apply(gin(in_mat1, maxval), gout(out_mat_gapi, out_gapi_scalar), std::move(compile_args)); + c.apply(gin(in_mat1, maxval), gout(out_mat_gapi, out_gapi_scalar), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -868,21 +725,15 @@ TEST_P(ThresholdOTTest, AccuracyTestOtsu) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); EXPECT_EQ(ocv_res, out_gapi_scalar.val[0]); } } TEST_P(InRangeTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_in = std::get<1>(param); - - auto compile_args = std::get<3>(param); cv::Scalar thrLow = initScalarRandU(100); cv::Scalar thrUp = initScalarRandU(100) + cv::Scalar(100, 100, 100, 100); - initMatrixRandU(type, sz_in, type, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1; @@ -890,7 +741,7 @@ TEST_P(InRangeTest, AccuracyTest) auto out = cv::gapi::inRange(in1, th1, mv1); cv::GComputation c(GIn(in1, th1, mv1), GOut(out)); - c.apply(gin(in_mat1, thrLow, thrUp), gout(out_mat_gapi), std::move(compile_args)); + c.apply(gin(in_mat1, thrLow, thrUp), gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -899,26 +750,22 @@ TEST_P(InRangeTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(Split3Test, AccuracyTest) { - cv::Size sz_in = std::get<0>(GetParam()); - auto compile_args = std::get<1>(GetParam()); - initMatrixRandU(CV_8UC3, sz_in, CV_8UC1); - - cv::Mat out_mat2 = cv::Mat(sz_in, CV_8UC1); - cv::Mat out_mat3 = cv::Mat(sz_in, CV_8UC1); - cv::Mat out_mat_ocv2 = cv::Mat(sz_in, CV_8UC1); - cv::Mat out_mat_ocv3 = cv::Mat(sz_in, CV_8UC1); + cv::Mat out_mat2 = cv::Mat(sz, dtype); + cv::Mat out_mat3 = cv::Mat(sz, dtype); + cv::Mat out_mat_ocv2 = cv::Mat(sz, dtype); + cv::Mat out_mat_ocv3 = cv::Mat(sz, dtype); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, out1, out2, out3; std::tie(out1, out2, out3) = cv::gapi::split3(in1); cv::GComputation c(cv::GIn(in1), cv::GOut(out1, out2, out3)); - c.apply(cv::gin(in_mat1), cv::gout(out_mat_gapi, out_mat2, out_mat3), std::move(compile_args)); + c.apply(cv::gin(in_mat1), cv::gout(out_mat_gapi, out_mat2, out_mat3), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { std::vector out_mats_ocv = {out_mat_ocv, out_mat_ocv2, out_mat_ocv3}; @@ -934,22 +781,19 @@ TEST_P(Split3Test, AccuracyTest) TEST_P(Split4Test, AccuracyTest) { - cv::Size sz_in = std::get<0>(GetParam()); - auto compile_args = std::get<1>(GetParam()); - initMatrixRandU(CV_8UC4, sz_in, CV_8UC1); - cv::Mat out_mat2 = cv::Mat(sz_in, CV_8UC1); - cv::Mat out_mat3 = cv::Mat(sz_in, CV_8UC1); - cv::Mat out_mat4 = cv::Mat(sz_in, CV_8UC1); - cv::Mat out_mat_ocv2 = cv::Mat(sz_in, CV_8UC1); - cv::Mat out_mat_ocv3 = cv::Mat(sz_in, CV_8UC1); - cv::Mat out_mat_ocv4 = cv::Mat(sz_in, CV_8UC1); + cv::Mat out_mat2 = cv::Mat(sz, dtype); + cv::Mat out_mat3 = cv::Mat(sz, dtype); + cv::Mat out_mat4 = cv::Mat(sz, dtype); + cv::Mat out_mat_ocv2 = cv::Mat(sz, dtype); + cv::Mat out_mat_ocv3 = cv::Mat(sz, dtype); + cv::Mat out_mat_ocv4 = cv::Mat(sz, dtype); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, out1, out2, out3, out4; std::tie(out1, out2, out3, out4) = cv::gapi::split4(in1); cv::GComputation c(cv::GIn(in1), cv::GOut(out1, out2, out3, out4)); - c.apply(cv::gin(in_mat1), cv::gout(out_mat_gapi, out_mat2, out_mat3, out_mat4), std::move(compile_args)); + c.apply(cv::gin(in_mat1), cv::gout(out_mat_gapi, out_mat2, out_mat3, out_mat4), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { std::vector out_mats_ocv = {out_mat_ocv, out_mat_ocv2, out_mat_ocv3, out_mat_ocv4}; @@ -996,31 +840,17 @@ static void ResizeAccuracyTest(compare_f cmpF, int type, int interp, cv::Size sz TEST_P(ResizeTest, AccuracyTest) { - compare_f cmpF; - int type = 0, interp = 0; - cv::Size sz_in, sz_out; - cv::GCompileArgs compile_args; - std::tie(cmpF, type, interp, sz_in, sz_out, compile_args) = GetParam(); - ResizeAccuracyTest(cmpF, type, interp, sz_in, sz_out, 0.0, 0.0, std::move(compile_args)); + ResizeAccuracyTest(cmpF, type, interp, sz, sz_out, 0.0, 0.0, getCompileArgs()); } TEST_P(ResizeTestFxFy, AccuracyTest) { - compare_f cmpF; - int type = 0, interp = 0; - cv::Size sz_in; - double fx = 0.0, fy = 0.0; - cv::GCompileArgs compile_args; - std::tie(cmpF, type, interp, sz_in, fx, fy, compile_args) = GetParam(); - ResizeAccuracyTest(cmpF, type, interp, sz_in, cv::Size{0, 0}, fx, fy, std::move(compile_args)); + ResizeAccuracyTest(cmpF, type, interp, sz, cv::Size{0, 0}, fx, fy, getCompileArgs()); } TEST_P(Merge3Test, AccuracyTest) { - cv::Size sz_in = std::get<0>(GetParam()); - initMatsRandU(CV_8UC1, sz_in, CV_8UC3); - auto compile_args = std::get<1>(GetParam()); - cv::Mat in_mat3(sz_in, CV_8UC1); + cv::Mat in_mat3(sz, type); cv::Scalar mean = cv::Scalar::all(127); cv::Scalar stddev = cv::Scalar::all(40.f); @@ -1031,7 +861,7 @@ TEST_P(Merge3Test, AccuracyTest) auto out = cv::gapi::merge3(in1, in2, in3); cv::GComputation c(cv::GIn(in1, in2, in3), cv::GOut(out)); - c.apply(cv::gin(in_mat1, in_mat2, in_mat3), cv::gout(out_mat_gapi), std::move(compile_args)); + c.apply(cv::gin(in_mat1, in_mat2, in_mat3), cv::gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { std::vector in_mats_ocv = {in_mat1, in_mat2, in_mat3}; @@ -1045,11 +875,8 @@ TEST_P(Merge3Test, AccuracyTest) TEST_P(Merge4Test, AccuracyTest) { - cv::Size sz_in = std::get<0>(GetParam()); - initMatsRandU(CV_8UC1, sz_in, CV_8UC4); - auto compile_args = std::get<1>(GetParam()); - cv::Mat in_mat3(sz_in, CV_8UC1); - cv::Mat in_mat4(sz_in, CV_8UC1); + cv::Mat in_mat3(sz, type); + cv::Mat in_mat4(sz, type); cv::Scalar mean = cv::Scalar::all(127); cv::Scalar stddev = cv::Scalar::all(40.f); @@ -1061,7 +888,7 @@ TEST_P(Merge4Test, AccuracyTest) auto out = cv::gapi::merge4(in1, in2, in3, in4); cv::GComputation c(cv::GIn(in1, in2, in3, in4), cv::GOut(out)); - c.apply(cv::gin(in_mat1, in_mat2, in_mat3, in_mat4), cv::gout(out_mat_gapi), std::move(compile_args)); + c.apply(cv::gin(in_mat1, in_mat2, in_mat3, in_mat4), cv::gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { std::vector in_mats_ocv = {in_mat1, in_mat2, in_mat3, in_mat4}; @@ -1075,12 +902,7 @@ TEST_P(Merge4Test, AccuracyTest) TEST_P(RemapTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_in = std::get<1>(param); - auto compile_args = std::get<3>(param); - initMatrixRandU(type, sz_in, type, std::get<2>(param)); - cv::Mat in_map1(sz_in, CV_16SC2); + cv::Mat in_map1(sz, CV_16SC2); cv::Mat in_map2 = cv::Mat(); cv::randu(in_map1, cv::Scalar::all(0), cv::Scalar::all(255)); cv::Scalar bv = cv::Scalar(); @@ -1090,7 +912,7 @@ TEST_P(RemapTest, AccuracyTest) auto out = cv::gapi::remap(in1, in_map1, in_map2, cv::INTER_NEAREST, cv::BORDER_REPLICATE, bv); cv::GComputation c(in1, out); - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi, getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -1099,25 +921,18 @@ TEST_P(RemapTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(FlipTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - int flipCode = std::get<1>(param); - cv::Size sz_in = std::get<2>(param); - initMatrixRandU(type, sz_in, type, false); - auto compile_args = std::get<4>(GetParam()); - // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; auto out = cv::gapi::flip(in, flipCode); cv::GComputation c(in, out); - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi, getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { cv::flip(in_mat1, out_mat_ocv, flipCode); @@ -1125,24 +940,17 @@ TEST_P(FlipTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(CropTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Rect rect_to = std::get<1>(param); - cv::Size sz_in = std::get<2>(param); - auto compile_args = std::get<4>(param); - - initMatrixRandU(type, sz_in, type, false); cv::Size sz_out = cv::Size(rect_to.width, rect_to.height); - if( std::get<3>(param) == true ) + if(createOutputMatrices) { - out_mat_gapi = cv::Mat(sz_out, type); - out_mat_ocv = cv::Mat(sz_out, type); + out_mat_gapi = cv::Mat(sz_out, dtype); + out_mat_ocv = cv::Mat(sz_out, dtype); } // G-API code ////////////////////////////////////////////////////////////// @@ -1150,7 +958,7 @@ TEST_P(CropTest, AccuracyTest) auto out = cv::gapi::crop(in, rect_to); cv::GComputation c(in, out); - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi, getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { cv::Mat(in_mat1, rect_to).copyTo(out_mat_ocv); @@ -1164,17 +972,14 @@ TEST_P(CropTest, AccuracyTest) TEST_P(ConcatHorTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_out = std::get<1>(param); - auto compile_args = std::get<2>(param); + cv::Size sz_out = sz; int wpart = sz_out.width / 4; cv::Size sz_in1 = cv::Size(wpart, sz_out.height); cv::Size sz_in2 = cv::Size(sz_out.width - wpart, sz_out.height); - cv::Mat in_mat1 (sz_in1, type ); - cv::Mat in_mat2 (sz_in2, type); + in_mat1 = cv::Mat(sz_in1, type ); + in_mat2 = cv::Mat(sz_in2, type); cv::Scalar mean = cv::Scalar::all(127); cv::Scalar stddev = cv::Scalar::all(40.f); @@ -1182,17 +987,17 @@ TEST_P(ConcatHorTest, AccuracyTest) cv::randn(in_mat2, mean, stddev); cv::Mat out_mat(sz_out, type); - cv::Mat out_mat_ocv(sz_out, type); + out_mat_ocv = cv::Mat(sz_out, type); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, in2; auto out = cv::gapi::concatHor(in1, in2); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { - cv::hconcat(in_mat1, in_mat2, out_mat_ocv ); + cv::hconcat(in_mat1, in_mat2, out_mat_ocv); } // Comparison ////////////////////////////////////////////////////////////// { @@ -1202,17 +1007,14 @@ TEST_P(ConcatHorTest, AccuracyTest) TEST_P(ConcatVertTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_out = std::get<1>(param); - auto compile_args = std::get<2>(param); + cv::Size sz_out = sz; int hpart = sz_out.height * 2/3; cv::Size sz_in1 = cv::Size(sz_out.width, hpart); cv::Size sz_in2 = cv::Size(sz_out.width, sz_out.height - hpart); - cv::Mat in_mat1 (sz_in1, type); - cv::Mat in_mat2 (sz_in2, type); + in_mat1 = cv::Mat(sz_in1, type); + in_mat2 = cv::Mat(sz_in2, type); cv::Scalar mean = cv::Scalar::all(127); cv::Scalar stddev = cv::Scalar::all(40.f); @@ -1220,14 +1022,14 @@ TEST_P(ConcatVertTest, AccuracyTest) cv::randn(in_mat2, mean, stddev); cv::Mat out_mat(sz_out, type); - cv::Mat out_mat_ocv(sz_out, type); + out_mat_ocv = cv::Mat(sz_out, type); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in1, in2; auto out = cv::gapi::concatVert(in1, in2); cv::GComputation c(GIn(in1, in2), GOut(out)); - c.apply(gin(in_mat1, in_mat2), gout(out_mat), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2), gout(out_mat), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { cv::vconcat(in_mat1, in_mat2, out_mat_ocv ); @@ -1240,10 +1042,7 @@ TEST_P(ConcatVertTest, AccuracyTest) TEST_P(ConcatVertVecTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_out = std::get<1>(param); - auto compile_args = std::get<2>(param); + cv::Size sz_out = sz; int hpart1 = sz_out.height * 2/5; int hpart2 = sz_out.height / 5; @@ -1251,9 +1050,9 @@ TEST_P(ConcatVertVecTest, AccuracyTest) cv::Size sz_in2 = cv::Size(sz_out.width, hpart2); cv::Size sz_in3 = cv::Size(sz_out.width, sz_out.height - hpart1 - hpart2); - cv::Mat in_mat1 (sz_in1, type); - cv::Mat in_mat2 (sz_in2, type); - cv::Mat in_mat3 (sz_in3, type); + in_mat1 = cv::Mat(sz_in1, type); + in_mat2 = cv::Mat(sz_in2, type); + cv::Mat in_mat3(sz_in3, type); cv::Scalar mean = cv::Scalar::all(127); cv::Scalar stddev = cv::Scalar::all(40.f); @@ -1262,7 +1061,7 @@ TEST_P(ConcatVertVecTest, AccuracyTest) cv::randn(in_mat3, mean, stddev); cv::Mat out_mat(sz_out, type); - cv::Mat out_mat_ocv(sz_out, type); + out_mat_ocv = cv::Mat(sz_out, type); // G-API code ////////////////////////////////////////////////////////////// std::vector mats(3); @@ -1271,7 +1070,7 @@ TEST_P(ConcatVertVecTest, AccuracyTest) std::vector cvmats = {in_mat1, in_mat2, in_mat3}; cv::GComputation c({mats[0], mats[1], mats[2]}, {out}); - c.apply(gin(in_mat1, in_mat2, in_mat3), gout(out_mat), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2, in_mat3), gout(out_mat), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -1285,10 +1084,7 @@ TEST_P(ConcatVertVecTest, AccuracyTest) TEST_P(ConcatHorVecTest, AccuracyTest) { - auto param = GetParam(); - int type = std::get<0>(param); - cv::Size sz_out = std::get<1>(param); - auto compile_args = std::get<2>(param); + cv::Size sz_out = sz; int wpart1 = sz_out.width / 3; int wpart2 = sz_out.width / 4; @@ -1296,8 +1092,8 @@ TEST_P(ConcatHorVecTest, AccuracyTest) cv::Size sz_in2 = cv::Size(wpart2, sz_out.height); cv::Size sz_in3 = cv::Size(sz_out.width - wpart1 - wpart2, sz_out.height); - cv::Mat in_mat1 (sz_in1, type); - cv::Mat in_mat2 (sz_in2, type); + in_mat1 = cv::Mat(sz_in1, type); + in_mat2 = cv::Mat(sz_in2, type); cv::Mat in_mat3 (sz_in3, type); cv::Scalar mean = cv::Scalar::all(127); cv::Scalar stddev = cv::Scalar::all(40.f); @@ -1307,7 +1103,7 @@ TEST_P(ConcatHorVecTest, AccuracyTest) cv::randn(in_mat3, mean, stddev); cv::Mat out_mat(sz_out, type); - cv::Mat out_mat_ocv(sz_out, type); + out_mat_ocv = cv::Mat(sz_out, type); // G-API code ////////////////////////////////////////////////////////////// std::vector mats(3); @@ -1316,7 +1112,7 @@ TEST_P(ConcatHorVecTest, AccuracyTest) std::vector cvmats = {in_mat1, in_mat2, in_mat3}; cv::GComputation c({mats[0], mats[1], mats[2]}, {out}); - c.apply(gin(in_mat1, in_mat2, in_mat3), gout(out_mat), std::move(compile_args)); + c.apply(gin(in_mat1, in_mat2, in_mat3), gout(out_mat), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { @@ -1330,14 +1126,11 @@ TEST_P(ConcatHorVecTest, AccuracyTest) TEST_P(LUTTest, AccuracyTest) { - auto param = GetParam(); - int type_mat = std::get<0>(param); - int type_lut = std::get<1>(param); + int type_mat = type; + int type_lut = dtype; int type_out = CV_MAKETYPE(CV_MAT_DEPTH(type_lut), CV_MAT_CN(type_mat)); - cv::Size sz_in = std::get<2>(param); - auto compile_args = std::get<4>(GetParam()); - initMatrixRandU(type_mat, sz_in, type_out); + initMatrixRandU(type_mat, sz, type_out); cv::Size sz_lut = cv::Size(1, 256); cv::Mat in_lut(sz_lut, type_lut); cv::randu(in_lut, cv::Scalar::all(0), cv::Scalar::all(255)); @@ -1347,7 +1140,7 @@ TEST_P(LUTTest, AccuracyTest) auto out = cv::gapi::LUT(in, in_lut); cv::GComputation c(in, out); - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi, getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { cv::LUT(in_mat1, in_lut, out_mat_ocv); @@ -1355,29 +1148,23 @@ TEST_P(LUTTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(ConvertToTest, AccuracyTest) { - int type_mat = -1, depth_to = -1; - double alpha = 1.0, beta = 0.0; - cv::Size sz_in; - cv::GCompileArgs compile_args; - compare_f cmpF; - - std::tie(type_mat, depth_to, sz_in, alpha, beta, cmpF, compile_args) = GetParam(); - + int type_mat = type; + int depth_to = dtype; int type_out = CV_MAKETYPE(depth_to, CV_MAT_CN(type_mat)); - initMatrixRandU(type_mat, sz_in, type_out); + initMatrixRandU(type_mat, sz, type_out); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; auto out = cv::gapi::convertTo(in, depth_to, alpha, beta); cv::GComputation c(in, out); - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi, getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { in_mat1.convertTo(out_mat_ocv, depth_to, alpha, beta); @@ -1385,25 +1172,18 @@ TEST_P(ConvertToTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv)); - EXPECT_EQ(out_mat_gapi.size(), sz_in); + EXPECT_EQ(out_mat_gapi.size(), sz); } } TEST_P(PhaseTest, AccuracyTest) { - int img_type = -1; - cv::Size img_size; - bool angle_in_degrees = false; - cv::GCompileArgs compile_args; - std::tie(img_type, img_size, angle_in_degrees, compile_args) = GetParam(); - initMatsRandU(img_type, img_size, img_type); - // G-API code ////////////////////////////////////////////////////////////// cv::GMat in_x, in_y; auto out = cv::gapi::phase(in_x, in_y, angle_in_degrees); cv::GComputation c(in_x, in_y, out); - c.apply(in_mat1, in_mat2, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, in_mat2, out_mat_gapi, getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// cv::phase(in_mat1, in_mat2, out_mat_ocv, angle_in_degrees); @@ -1417,18 +1197,12 @@ TEST_P(PhaseTest, AccuracyTest) TEST_P(SqrtTest, AccuracyTest) { - int img_type = -1; - cv::Size img_size; - cv::GCompileArgs compile_args; - std::tie(img_type, img_size, compile_args) = GetParam(); - initMatrixRandU(img_type, img_size, img_type); - // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; auto out = cv::gapi::sqrt(in); cv::GComputation c(in, out); - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi, getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// cv::sqrt(in_mat1, out_mat_ocv); @@ -1442,27 +1216,14 @@ TEST_P(SqrtTest, AccuracyTest) TEST_P(NormalizeTest, Test) { - auto param = GetParam(); - - compare_f cmpF; - MatType type, ddepth; - cv::Size sz; - double a = 0 , b = 0; - int norm_type = 0; - bool createOut = 0; - cv::GCompileArgs compile_args; - - std::tie(cmpF, type, sz, a, b, norm_type, ddepth, createOut, compile_args) = GetParam(); - int dtype = CV_MAKETYPE(ddepth, CV_MAT_CN(type)); - - initMatsRandN(type, sz, dtype, createOut); + initMatrixRandN(type, sz, CV_MAKETYPE(ddepth, CV_MAT_CN(type)), createOutputMatrices); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; auto out = cv::gapi::normalize(in, a, b, norm_type, ddepth); cv::GComputation c(cv::GIn(in), cv::GOut(out)); - c.apply(cv::gin(in_mat1), cv::gout(out_mat_gapi), std::move(compile_args)); + c.apply(cv::gin(in_mat1), cv::gout(out_mat_gapi), getCompileArgs()); // OpenCV code ///////////////////////////////////////////////////////////// { diff --git a/modules/gapi/test/common/gapi_imgproc_tests_inl.hpp b/modules/gapi/test/common/gapi_imgproc_tests_inl.hpp index e5d5154f23..bb707f9d46 100644 --- a/modules/gapi/test/common/gapi_imgproc_tests_inl.hpp +++ b/modules/gapi/test/common/gapi_imgproc_tests_inl.hpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // -// Copyright (C) 2018 Intel Corporation +// Copyright (C) 2018-2019 Intel Corporation #ifndef OPENCV_GAPI_IMGPROC_TESTS_INL_HPP @@ -61,7 +61,7 @@ TEST_P(Filter2DTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, borderType, dtype, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, dtype, initOut); + initMatrixRandN(type, sz, dtype, initOut); cv::Point anchor = {-1, -1}; double delta = 0; @@ -97,7 +97,7 @@ TEST_P(BoxFilterTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, filterSize, sz, borderType, dtype, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, dtype, initOut); + initMatrixRandN(type, sz, dtype, initOut); cv::Point anchor = {-1, -1}; bool normalize = true; @@ -133,7 +133,7 @@ TEST_P(SepFilterTest, AccuracyTest) cv::Mat kernelY(kernSize, 1, CV_32F); randu(kernelX, -1, 1); randu(kernelY, -1, 1); - initMatsRandN(type, sz, dtype, initOut); + initMatrixRandN(type, sz, dtype, initOut); cv::Point anchor = cv::Point(-1, -1); @@ -163,7 +163,7 @@ TEST_P(BlurTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, filterSize, sz, borderType, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, type, initOut); + initMatrixRandN(type, sz, type, initOut); cv::Point anchor = {-1, -1}; @@ -193,7 +193,7 @@ TEST_P(GaussianBlurTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF,type, kernSize, sz, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, type, initOut); + initMatrixRandN(type, sz, type, initOut); cv::Size kSize = cv::Size(kernSize, kernSize); double sigmaX = rand(); @@ -224,7 +224,7 @@ TEST_P(MedianBlurTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, type, initOut); + initMatrixRandN(type, sz, type, initOut); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -252,7 +252,7 @@ TEST_P(ErodeTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, kernType, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, type, initOut); + initMatrixRandN(type, sz, type, initOut); cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize)); @@ -282,7 +282,7 @@ TEST_P(Erode3x3Test, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, sz, initOut, numIters, compile_args) = GetParam(); - initMatsRandN(type, sz, type, initOut); + initMatrixRandN(type, sz, type, initOut); cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3,3)); @@ -312,7 +312,7 @@ TEST_P(DilateTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, kernType, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, type, initOut); + initMatrixRandN(type, sz, type, initOut); cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize)); @@ -342,7 +342,7 @@ TEST_P(Dilate3x3Test, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, sz, initOut, numIters, compile_args) = GetParam(); - initMatsRandN(type, sz, type, initOut); + initMatrixRandN(type, sz, type, initOut); cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3,3)); @@ -373,7 +373,7 @@ TEST_P(SobelTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, type, kernSize, sz, dtype, dx, dy, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, dtype, initOut); + initMatrixRandN(type, sz, dtype, initOut); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -404,7 +404,7 @@ TEST_P(SobelXYTest, AccuracyTest) cv::Mat out_mat_ocv2; cv::Mat out_mat_gapi2; - initMatsRandN(type, sz, dtype); + initMatrixRandN(type, sz, dtype); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -441,7 +441,7 @@ TEST_P(EqHistTest, AccuracyTest) bool initOut = false; cv::GCompileArgs compile_args; std::tie(cmpF, sz, initOut, compile_args) = GetParam(); - initMatsRandN(CV_8UC1, sz, CV_8UC1, initOut); + initMatrixRandN(CV_8UC1, sz, CV_8UC1, initOut); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -471,7 +471,7 @@ TEST_P(CannyTest, AccuracyTest) cv::GCompileArgs compile_args; std::tie(cmpF, type, sz, thrLow, thrUp, apSize, l2gr, initOut, compile_args) = GetParam(); - initMatsRandN(type, sz, CV_8UC1, initOut); + initMatrixRandN(type, sz, CV_8UC1, initOut); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -495,7 +495,7 @@ TEST_P(RGB2GrayTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC1, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC1, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -519,7 +519,7 @@ TEST_P(BGR2GrayTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC1, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC1, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -543,7 +543,7 @@ TEST_P(RGB2YUVTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -567,7 +567,7 @@ TEST_P(YUV2RGBTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// @@ -594,7 +594,7 @@ TEST_P(NV12toRGBTest, AccuracyTest) cv::GCompileArgs compile_args; std::tie(cmpF, sz, compile_args) = GetParam(); - initMatsRandN(CV_8UC1, sz, CV_8UC3); + initMatrixRandN(CV_8UC1, sz, CV_8UC3); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in_y; @@ -625,7 +625,7 @@ TEST_P(NV12toBGRTest, AccuracyTest) cv::GCompileArgs compile_args; std::tie(cmpF, sz, compile_args) = GetParam(); - initMatsRandN(CV_8UC1, sz, CV_8UC3); + initMatrixRandN(CV_8UC1, sz, CV_8UC3); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in_y; @@ -654,7 +654,7 @@ TEST_P(RGB2LabTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -678,7 +678,7 @@ TEST_P(BGR2LUVTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -702,7 +702,7 @@ TEST_P(LUV2BGRTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -726,7 +726,7 @@ TEST_P(BGR2YUVTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -750,7 +750,7 @@ TEST_P(YUV2BGRTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -774,7 +774,7 @@ TEST_P(RGB2HSVTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -798,7 +798,7 @@ TEST_P(BayerGR2RGBTest, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC1, std::get<1>(param), CV_8UC3, std::get<2>(param)); + initMatrixRandN(CV_8UC1, std::get<1>(param), CV_8UC3, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; @@ -822,7 +822,7 @@ TEST_P(RGB2YUV422Test, AccuracyTest) auto param = GetParam(); auto compile_args = std::get<3>(param); compare_f cmpF = std::get<0>(param); - initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC2, std::get<2>(param)); + initMatrixRandN(CV_8UC3, std::get<1>(param), CV_8UC2, std::get<2>(param)); // G-API code ////////////////////////////////////////////////////////////// cv::GMat in; diff --git a/modules/gapi/test/common/gapi_tests_common.hpp b/modules/gapi/test/common/gapi_tests_common.hpp index 35c4be3e47..9198a14536 100644 --- a/modules/gapi/test/common/gapi_tests_common.hpp +++ b/modules/gapi/test/common/gapi_tests_common.hpp @@ -2,13 +2,20 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // -// Copyright (C) 2018 Intel Corporation +// Copyright (C) 2018-2019 Intel Corporation +#ifndef OPENCV_GAPI_TESTS_COMMON_HPP +#define OPENCV_GAPI_TESTS_COMMON_HPP #include +#include +#include #include #include +#include + +#include "gapi_tests_helpers.hpp" namespace { @@ -41,6 +48,15 @@ public: return cv::Scalar(s1, s2, s3, s4); } + void initOutMats(cv::Size sz_in, int dtype) + { + if (dtype != -1) + { + out_mat_gapi = cv::Mat(sz_in, dtype); + out_mat_ocv = cv::Mat(sz_in, dtype); + } + } + void initMatsRandU(int type, cv::Size sz_in, int dtype, bool createOutputMatrices = true) { in_mat1 = cv::Mat(sz_in, type); @@ -50,10 +66,9 @@ public: cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255)); cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255)); - if (createOutputMatrices && dtype != -1) + if (createOutputMatrices) { - out_mat_gapi = cv::Mat (sz_in, dtype); - out_mat_ocv = cv::Mat (sz_in, dtype); + initOutMats(sz_in, dtype); } } @@ -62,28 +77,28 @@ public: in_mat1 = cv::Mat(sz_in, type); sc = initScalarRandU(100); - cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255)); - if (createOutputMatrices && dtype != -1) + if (createOutputMatrices) { - out_mat_gapi = cv::Mat (sz_in, dtype); - out_mat_ocv = cv::Mat (sz_in, dtype); + initOutMats(sz_in, dtype); } } - void initMatsRandN(int type, cv::Size sz_in, int dtype, bool createOutputMatrices = true) + void initMatrixRandN(int type, cv::Size sz_in, int dtype, bool createOutputMatrices = true) { - in_mat1 = cv::Mat(sz_in, type); + in_mat1 = cv::Mat(sz_in, type); cv::randn(in_mat1, cv::Scalar::all(127), cv::Scalar::all(40.f)); - if (createOutputMatrices && dtype != -1) + if (createOutputMatrices) { - out_mat_gapi = cv::Mat(sz_in, dtype); - out_mat_ocv = cv::Mat(sz_in, dtype); + initOutMats(sz_in, dtype); } } + // empty function intended to show that nothing is to be initialized via TestFunctional methods + void initNothing(int, cv::Size, int, bool = true) {} + static cv::Mat nonZeroPixels(const cv::Mat& mat) { int channels = mat.channels(); @@ -117,6 +132,100 @@ using compare_f = std::function; using compare_scalar_f = std::function; +// Universal parameter wrapper for common (pre-defined) and specific (user-defined) parameters +template +struct Params +{ + using gcomp_args_function_t = cv::GCompileArgs(*)(); + // TODO: delete bool (createOutputMatrices) from common parameters + using common_params_t = std::tuple; + using specific_params_t = std::tuple; + using params_t = std::tuple; + static constexpr const size_t common_params_size = std::tuple_size::value; + static constexpr const size_t specific_params_size = std::tuple_size::value; + + template + static const typename std::tuple_element::type& + getCommon(const params_t& t) + { + static_assert(I < common_params_size, "Index out of range"); + return std::get(t); + } + + template + static const typename std::tuple_element::type& + getSpecific(const params_t& t) + { + static_assert(specific_params_size > 0, + "Impossible to call this function: no specific parameters specified"); + static_assert(I < specific_params_size, "Index out of range"); + return std::get(t); + } +}; + +// Base class for test fixtures +template +struct TestWithParamBase : TestFunctional, + TestWithParam::params_t> +{ + using AllParams = Params; + + MatType type = getCommonParam<0>(); + cv::Size sz = getCommonParam<1>(); + MatType dtype = getCommonParam<2>(); + bool createOutputMatrices = getCommonParam<3>(); + + TestWithParamBase() + { + if (dtype == SAME_TYPE) { dtype = type; } + } + + // Get common (pre-defined) parameter value by index + template + inline auto getCommonParam() const + -> decltype(AllParams::template getCommon(this->GetParam())) + { + return AllParams::template getCommon(this->GetParam()); + } + + // Get specific (user-defined) parameter value by index + template + inline auto getSpecificParam() const + -> decltype(AllParams::template getSpecific(this->GetParam())) + { + return AllParams::template getSpecific(this->GetParam()); + } + + // Return G-API compile arguments specified for test fixture + inline cv::GCompileArgs getCompileArgs() const + { + return getCommonParam<4>()(); + } +}; + +/** + * @private + * @brief Create G-API test fixture with TestWithParamBase base class + * @param Fixture test fixture name + * @param InitF callable that will initialize default available members (from TestFunctional) + * @param API base class API. Specifies types of user-defined parameters. If there are no such + * parameters, empty angle brackets ("<>") must be specified. + * @param Number number of user-defined parameters (corresponds to the number of types in API). + * if there are no such parameters, 0 must be specified. + * @param ... list of names of user-defined parameters. if there are no parameters, the list + * must be empty. + */ +#define GAPI_TEST_FIXTURE(Fixture, InitF, API, Number, ...) \ + struct Fixture : public TestWithParamBase API { \ + static_assert(Number == AllParams::specific_params_size, \ + "Number of user-defined parameters doesn't match size of __VA_ARGS__"); \ + __WRAP_VAARGS(DEFINE_SPECIFIC_PARAMS_##Number(__VA_ARGS__)) \ + Fixture() { InitF(type, sz, dtype, createOutputMatrices); } \ + }; + +// Wrapper for test fixture API. Use to specify multiple types. +// Example: FIXTURE_API(int, bool) expands to +#define FIXTURE_API(...) <__VA_ARGS__> template struct Wrappable @@ -341,3 +450,5 @@ namespace return os << "compare_scalar_f"; } } + +#endif //OPENCV_GAPI_TESTS_COMMON_HPP diff --git a/modules/gapi/test/common/gapi_tests_helpers.hpp b/modules/gapi/test/common/gapi_tests_helpers.hpp new file mode 100644 index 0000000000..0d849c2b34 --- /dev/null +++ b/modules/gapi/test/common/gapi_tests_helpers.hpp @@ -0,0 +1,73 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_TESTS_HELPERS_HPP +#define OPENCV_GAPI_TESTS_HELPERS_HPP + +#include +#include + +namespace opencv_test +{ + +// out_type == in_type in matrices initialization if out_type is marked as SAME_TYPE +enum { + // TODO: why is it different from -1? + SAME_TYPE = std::numeric_limits::max() +}; + +// Ensure correct __VA_ARGS__ expansion on Windows +#define __WRAP_VAARGS(x) x + +#define __TUPLE_PARAM_TYPE(i) std::tuple_element::type + +// implementation of recursive in-class declaration and initialization of member variables +#define __DEFINE_PARAMS_IMPL1(index, param_name) \ + __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam(); + +#define __DEFINE_PARAMS_IMPL2(index, param_name, ...) \ + __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam(); \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL1(index+1, __VA_ARGS__)) + +#define __DEFINE_PARAMS_IMPL3(index, param_name, ...) \ + __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam(); \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL2(index+1, __VA_ARGS__)) + +#define __DEFINE_PARAMS_IMPL4(index, param_name, ...) \ + __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam(); \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL3(index+1, __VA_ARGS__)) + +#define __DEFINE_PARAMS_IMPL5(index, param_name, ...) \ + __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam(); \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL4(index+1, __VA_ARGS__)) + +#define __DEFINE_PARAMS_IMPL6(index, param_name, ...) \ + __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam(); \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL5(index+1, __VA_ARGS__)) + +// user interface to define member variables of specified names +#define DEFINE_SPECIFIC_PARAMS_0() + +#define DEFINE_SPECIFIC_PARAMS_1(...) \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL1(0, __VA_ARGS__)) + +#define DEFINE_SPECIFIC_PARAMS_2(...) \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL2(0, __VA_ARGS__)) + +#define DEFINE_SPECIFIC_PARAMS_3(...) \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL3(0, __VA_ARGS__)) + +#define DEFINE_SPECIFIC_PARAMS_4(...) \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL4(0, __VA_ARGS__)) + +#define DEFINE_SPECIFIC_PARAMS_5(...) \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL5(0, __VA_ARGS__)) + +#define DEFINE_SPECIFIC_PARAMS_6(...) \ + __WRAP_VAARGS(__DEFINE_PARAMS_IMPL6(0, __VA_ARGS__)) +} // namespace opencv_test + +#endif //OPENCV_GAPI_TESTS_HELPERS_HPP diff --git a/modules/gapi/test/cpu/gapi_core_tests_cpu.cpp b/modules/gapi/test/cpu/gapi_core_tests_cpu.cpp index 8b92179fc4..af27a199e4 100644 --- a/modules/gapi/test/cpu/gapi_core_tests_cpu.cpp +++ b/modules/gapi/test/cpu/gapi_core_tests_cpu.cpp @@ -2,74 +2,76 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // -// Copyright (C) 2018 Intel Corporation +// Copyright (C) 2018-2019 Intel Corporation #include "../test_precomp.hpp" #include "../common/gapi_core_tests.hpp" #include -#define CORE_CPU cv::gapi::core::cpu::kernels() +namespace +{ + #define CORE_CPU [] () { return cv::compile_args(cv::gapi::core::cpu::kernels()); } +} // anonymous namespace namespace opencv_test { - // FIXME: Wut? See MulTestCPU/MathOpTest below (duplicate?) INSTANTIATE_TEST_CASE_P(AddTestCPU, MathOpTest, - Combine(Values(ADD, MUL), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(1.0), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(false), - Values(cv::compile_args(CORE_CPU))), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU), + Values(ADD, MUL), + testing::Bool(), + Values(1.0), + Values(false)), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(MulTestCPU, MathOpTest, - Combine(Values(MUL), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(1.0, 0.5, 2.0), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(false), - Values(cv::compile_args(CORE_CPU))), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU), + Values(MUL), + testing::Bool(), + Values(1.0, 0.5, 2.0), + Values(false)), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(SubTestCPU, MathOpTest, - Combine(Values(SUB), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values (1.0), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU), + Values(SUB), testing::Bool(), - Values(cv::compile_args(CORE_CPU))), + Values (1.0), + testing::Bool()), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(DivTestCPU, MathOpTest, - Combine(Values(DIV), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values (1.0, 0.5, 2.0), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU), + Values(DIV), testing::Bool(), - Values(cv::compile_args(CORE_CPU))), + Values (1.0, 0.5, 2.0), + testing::Bool()), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(MulTestCPU, MulDoubleTest, @@ -78,8 +80,8 @@ INSTANTIATE_TEST_CASE_P(MulTestCPU, MulDoubleTest, cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(DivTestCPU, DivTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), @@ -87,8 +89,8 @@ INSTANTIATE_TEST_CASE_P(DivTestCPU, DivTest, cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(DivCTestCPU, DivCTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), @@ -96,81 +98,94 @@ INSTANTIATE_TEST_CASE_P(DivCTestCPU, DivCTest, cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(MeanTestCPU, MeanTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(-1, SAME_TYPE), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(MaskTestCPU, MaskTest, Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(SelectTestCPU, SelectTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(Polar2CartCPU, Polar2CartTest, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_32FC1), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(CV_32FC1), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(Cart2PolarCPU, Cart2PolarTest, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_32FC1), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(CV_32FC1), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(PhaseCPU, PhaseTest, Combine(Values(CV_32F, CV_32FC3), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), + Values(true), + Values(CORE_CPU), + testing::Bool())); INSTANTIATE_TEST_CASE_P(SqrtCPU, SqrtTest, Combine(Values(CV_32F, CV_32FC3), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), + Values(true), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(CompareTestCPU, CmpTest, - Combine(Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(CV_8U), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU))), + Values(CORE_CPU), + Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE), + testing::Bool()), opencv_test::PrintCmpCoreParams()); INSTANTIATE_TEST_CASE_P(BitwiseTestCPU, BitwiseTest, - Combine(Values(AND, OR, XOR), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU))), + Values(CORE_CPU), + Values(AND, OR, XOR)), opencv_test::PrintBWCoreParams()); INSTANTIATE_TEST_CASE_P(BitwiseNotTestCPU, NotTest, @@ -178,50 +193,56 @@ INSTANTIATE_TEST_CASE_P(BitwiseNotTestCPU, NotTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(MinTestCPU, MinTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(MaxTestCPU, MaxTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(SumTestCPU, SumTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), //Values(1e-5), - Values(AbsToleranceScalar(1e-5).to_compare_f()), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU), + Values(AbsToleranceScalar(1e-5).to_compare_f()))); INSTANTIATE_TEST_CASE_P(AbsDiffTestCPU, AbsDiffTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(AbsDiffCTestCPU, AbsDiffCTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(AddWeightedTestCPU, AddWeightedTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), @@ -230,18 +251,20 @@ INSTANTIATE_TEST_CASE_P(AddWeightedTestCPU, AddWeightedTest, cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), /*init output matrices or not*/ testing::Bool(), - Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU), + Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()))); INSTANTIATE_TEST_CASE_P(NormTestCPU, NormTest, - Combine(Values(NORM_INF, NORM_L1, NORM_L2), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), + Values(false), //Values(1e-5), + Values(CORE_CPU), Values(AbsToleranceScalar(1e-5).to_compare_f()), - Values(cv::compile_args(CORE_CPU))), + Values(NORM_INF, NORM_L1, NORM_L2)), opencv_test::PrintNormCoreParams()); INSTANTIATE_TEST_CASE_P(IntegralTestCPU, IntegralTest, @@ -249,25 +272,30 @@ INSTANTIATE_TEST_CASE_P(IntegralTestCPU, IntegralTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(-1), + Values(false), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(ThresholdTestCPU, ThresholdTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU), + Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, + cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV))); INSTANTIATE_TEST_CASE_P(ThresholdTestCPU, ThresholdOTTest, Combine(Values(CV_8UC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU), + Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE))); INSTANTIATE_TEST_CASE_P(InRangeTestCPU, InRangeTest, @@ -275,147 +303,177 @@ INSTANTIATE_TEST_CASE_P(InRangeTestCPU, InRangeTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(Split3TestCPU, Split3Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC3), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(CV_8UC1), + Values(true), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(Split4TestCPU, Split4Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC4), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(CV_8UC1), + Values(true), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(ResizeTestCPU, ResizeTest, - Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(-1), + Values(false), + Values(CORE_CPU), + Values(AbsSimilarPoints(2, 0.05).to_compare_f()), + Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), Values(cv::Size(64,64), - cv::Size(30,30)), - Values(cv::compile_args(CORE_CPU)))); + cv::Size(30,30)))); INSTANTIATE_TEST_CASE_P(ResizeTestCPU, ResizeTestFxFy, - Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(-1), + Values(false), + Values(CORE_CPU), + Values(AbsSimilarPoints(2, 0.05).to_compare_f()), + Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), Values(0.5, 0.1), - Values(0.5, 0.1), - Values(cv::compile_args(CORE_CPU)))); + Values(0.5, 0.1))); INSTANTIATE_TEST_CASE_P(Merge3TestCPU, Merge3Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC1), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(CV_8UC3), + Values(true), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(Merge4TestCPU, Merge4Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC1), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(CV_8UC4), + Values(true), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(RemapTestCPU, RemapTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(FlipTestCPU, FlipTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(0,1,-1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), +/*init output matrices or not*/ Values(false), + Values(CORE_CPU), + Values(0,1,-1))); INSTANTIATE_TEST_CASE_P(CropTestCPU, CropTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), +/*init output matrices or not*/ Values(false), + Values(CORE_CPU), + Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)))); INSTANTIATE_TEST_CASE_P(LUTTestCPU, LUTTest, Combine(Values(CV_8UC1, CV_8UC3), - Values(CV_8UC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CV_8UC1), +/*init output matrices or not*/ Values(true), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(LUTTestCustomCPU, LUTTest, Combine(Values(CV_8UC3), - Values(CV_8UC3), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(CV_8UC3), +/*init output matrices or not*/ Values(true), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(ConvertToCPU, ConvertToTest, - Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1), - Values(CV_8U, CV_16U, CV_16S, CV_32F), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(2.5, 1.0, -1.0), - Values(250.0, 0.0, -128.0), + Values(CV_8U, CV_16U, CV_16S, CV_32F), + Values(false), + Values(CORE_CPU), Values(AbsExact().to_compare_f()), - Values(cv::compile_args(CORE_CPU)))); + Values(2.5, 1.0, -1.0), + Values(250.0, 0.0, -128.0))); INSTANTIATE_TEST_CASE_P(ConcatHorTestCPU, ConcatHorTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), + Values(false), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(ConcatVertTestCPU, ConcatVertTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), + Values(false), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(ConcatVertVecTestCPU, ConcatVertVecTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), + Values(false), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(ConcatHorVecTestCPU, ConcatHorVecTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_CPU)))); + Values(SAME_TYPE), + Values(false), + Values(CORE_CPU))); INSTANTIATE_TEST_CASE_P(NormalizeTestCPU, NormalizeTest, - Combine(Values(AbsExact().to_compare_f()), - Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1), + Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1), Values(cv::Size(1280, 720), cv::Size(640, 480)), + Values(-1), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_CPU), + Values(AbsExact().to_compare_f()), Values(0.0, 15.0), Values(1.0, 120.0, 255.0), Values(NORM_MINMAX, NORM_INF, NORM_L1, NORM_L2), - Values(-1, CV_8U, CV_16U, CV_16S, CV_32F), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_CPU)))); + Values(-1, CV_8U, CV_16U, CV_16S, CV_32F))); } diff --git a/modules/gapi/test/cpu/gapi_core_tests_fluid.cpp b/modules/gapi/test/cpu/gapi_core_tests_fluid.cpp index e570c72ebc..e955651ead 100644 --- a/modules/gapi/test/cpu/gapi_core_tests_fluid.cpp +++ b/modules/gapi/test/cpu/gapi_core_tests_fluid.cpp @@ -2,32 +2,34 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // -// Copyright (C) 2018 Intel Corporation +// Copyright (C) 2018-2019 Intel Corporation #include "../test_precomp.hpp" #include "../common/gapi_core_tests.hpp" +namespace +{ + #define CORE_FLUID [] () { return cv::compile_args(cv::gapi::core::fluid::kernels()); } +} // anonymous namespace + namespace opencv_test { -#define CORE_FLUID cv::gapi::core::fluid::kernels() - - // FIXME: Windows accuracy problems after recent update! INSTANTIATE_TEST_CASE_P(MathOpTestFluid, MathOpTest, - Combine(Values(ADD, SUB, DIV, MUL), - testing::Bool(), - Values(CV_8UC3, CV_8UC1, CV_16SC1, CV_32FC1), - Values(1.0), + Combine(Values(CV_8UC3, CV_8UC1, CV_16SC1, CV_32FC1), Values(cv::Size(1920, 1080), cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values(-1, CV_8U, CV_32F), testing::Bool(), + Values(CORE_FLUID), + Values(ADD, SUB, DIV, MUL), testing::Bool(), - Values(cv::compile_args(CORE_FLUID))), + Values(1.0), + testing::Bool()), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(MulSTestFluid, MulDoubleTest, @@ -37,7 +39,7 @@ INSTANTIATE_TEST_CASE_P(MulSTestFluid, MulDoubleTest, cv::Size(128, 128)), Values(-1), // FIXME: extend with more types testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(DivCTestFluid, DivCTest, Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1), @@ -46,33 +48,36 @@ INSTANTIATE_TEST_CASE_P(DivCTestFluid, DivCTest, cv::Size(128, 128)), Values(CV_8U, CV_32F), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(AbsDiffTestFluid, AbsDiffTest, Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(AbsDiffCTestFluid, AbsDiffCTest, Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(BitwiseTestFluid, BitwiseTest, - Combine(Values(AND, OR, XOR), - Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1), + Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1), Values(cv::Size(1920, 1080), cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), testing::Bool(), - Values(cv::compile_args(CORE_FLUID))), + Values(CORE_FLUID), + Values(AND, OR, XOR)), opencv_test::PrintBWCoreParams()); INSTANTIATE_TEST_CASE_P(BitwiseNotTestFluid, NotTest, @@ -81,8 +86,9 @@ INSTANTIATE_TEST_CASE_P(BitwiseNotTestFluid, NotTest, cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(MinTestFluid, MinTest, Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1), @@ -90,8 +96,9 @@ INSTANTIATE_TEST_CASE_P(MinTestFluid, MinTest, cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(MaxTestFluid, MaxTest, Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1), @@ -99,19 +106,21 @@ INSTANTIATE_TEST_CASE_P(MaxTestFluid, MaxTest, cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(CompareTestFluid, CmpTest, - Combine(Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE), - testing::Bool(), - Values(CV_8UC3, CV_8UC1, CV_16SC1, CV_32FC1), + Combine(Values(CV_8UC3, CV_8UC1, CV_16SC1, CV_32FC1), Values(cv::Size(1920, 1080), cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(CV_8U), testing::Bool(), - Values(cv::compile_args(CORE_FLUID))), + Values(CORE_FLUID), + Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE), + testing::Bool()), opencv_test::PrintCmpCoreParams()); INSTANTIATE_TEST_CASE_P(AddWeightedTestFluid, AddWeightedTest, @@ -121,57 +130,70 @@ INSTANTIATE_TEST_CASE_P(AddWeightedTestFluid, AddWeightedTest, cv::Size(128, 128)), Values(-1, CV_8U, CV_32F), testing::Bool(), - Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()), //Values(0.5000005), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID), + Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()))); INSTANTIATE_TEST_CASE_P(LUTTestFluid, LUTTest, Combine(Values(CV_8UC1, CV_8UC3), - Values(CV_8UC1), Values(cv::Size(1920, 1080), cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CV_8UC1), +/*init output matrices or not*/ Values(true), + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(ConvertToFluid, ConvertToTest, Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_32FC1), - Values(CV_8U, CV_16U, CV_32F), Values(cv::Size(1920, 1080), cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(2.5, 1.0, -1.0), - Values(250.0, 0.0, -128.0), + Values(CV_8U, CV_16U, CV_32F), + Values(true), + Values(CORE_FLUID), Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()), - Values(cv::compile_args(CORE_FLUID)))); + Values(2.5, 1.0, -1.0), + Values(250.0, 0.0, -128.0))); INSTANTIATE_TEST_CASE_P(Split3TestFluid, Split3Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC3), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_FLUID)))); + Values(CV_8UC1), + Values(true), + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(Split4TestFluid, Split4Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC4), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_FLUID)))); + Values(CV_8UC1), + Values(true), + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(Merge3TestFluid, Merge3Test, - Combine(Values(cv::Size(1920, 1080), + Combine(Values(CV_8UC1), + Values(cv::Size(1920, 1080), cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_FLUID)))); + Values(CV_8UC3), + Values(true), + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(Merge4TestFluid, Merge4Test, - Combine(Values(cv::Size(1920, 1080), + Combine(Values(CV_8UC1), + Values(cv::Size(1920, 1080), cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_FLUID)))); + Values(CV_8UC4), + Values(true), + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(SelectTestFluid, SelectTest, Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1), @@ -179,37 +201,46 @@ INSTANTIATE_TEST_CASE_P(SelectTestFluid, SelectTest, cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(Polar2CartFluid, Polar2CartTest, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_32FC1), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(CV_32FC1), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(Cart2PolarFluid, Cart2PolarTest, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_32FC1), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(CV_32FC1), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(PhaseFluid, PhaseTest, Combine(Values(CV_32F, CV_32FC3), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(SAME_TYPE), + Values(true), + Values(CORE_FLUID), + testing::Bool())); INSTANTIATE_TEST_CASE_P(SqrtFluid, SqrtTest, Combine(Values(CV_32F, CV_32FC3), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_FLUID)))); + Values(SAME_TYPE), + Values(true), + Values(CORE_FLUID))); INSTANTIATE_TEST_CASE_P(ThresholdTestFluid, ThresholdTest, Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1), @@ -217,11 +248,12 @@ INSTANTIATE_TEST_CASE_P(ThresholdTestFluid, ThresholdTest, cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), + testing::Bool(), + Values(CORE_FLUID), Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, - cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV), - testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV))); INSTANTIATE_TEST_CASE_P(InRangeTestFluid, InRangeTest, Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1), @@ -229,25 +261,27 @@ INSTANTIATE_TEST_CASE_P(InRangeTestFluid, InRangeTest, cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), testing::Bool(), - Values(cv::compile_args(CORE_FLUID)))); + Values(CORE_FLUID))); -INSTANTIATE_TEST_CASE_P( - ResizeTestFluid, ResizeTest, - Combine(Values(AbsExact().to_compare_f()), - Values(CV_8UC3/*CV_8UC1, CV_16UC1, CV_16SC1*/), +INSTANTIATE_TEST_CASE_P(ResizeTestFluid, ResizeTest, + Combine(Values(CV_8UC3/*CV_8UC1, CV_16UC1, CV_16SC1*/), + Values(cv::Size(1280, 720), + cv::Size(640, 480), + cv::Size(128, 128), + cv::Size(64, 64), + cv::Size(30, 30)), + Values(-1), + Values(false), + Values(CORE_FLUID), + Values(AbsExact().to_compare_f()), Values(/*cv::INTER_NEAREST,*/ cv::INTER_LINEAR/*, cv::INTER_AREA*/), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128), cv::Size(64, 64), - cv::Size(30, 30)), - Values(cv::Size(1280, 720), - cv::Size(640, 480), - cv::Size(128, 128), - cv::Size(64, 64), - cv::Size(30, 30)), - Values(cv::compile_args(CORE_FLUID)))); + cv::Size(30, 30)))); //---------------------------------------------------------------------- // FIXME: Clean-up test configurations which are enabled already @@ -476,7 +510,7 @@ INSTANTIATE_TEST_CASE_P(LUTTestCPU, LUTTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool())); +/*init output matrices or not*/ Values(true))); INSTANTIATE_TEST_CASE_P(LUTTestCustomCPU, LUTTest, Combine(Values(CV_8UC3), @@ -484,7 +518,7 @@ INSTANTIATE_TEST_CASE_P(LUTTestCustomCPU, LUTTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool())); +/*init output matrices or not*/ Values(true))); INSTANTIATE_TEST_CASE_P(ConvertToCPU, ConvertToTest, Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_32FC1), diff --git a/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp b/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp index 8bfc93d920..03289781d2 100644 --- a/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp +++ b/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp @@ -2,72 +2,75 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // -// Copyright (C) 2018 Intel Corporation +// Copyright (C) 2018-2019 Intel Corporation #include "../test_precomp.hpp" #include "../common/gapi_core_tests.hpp" -#define CORE_GPU cv::gapi::core::gpu::kernels() +namespace +{ + #define CORE_GPU [] () { return cv::compile_args(cv::gapi::core::gpu::kernels()); } +} // anonymous namespace namespace opencv_test { // FIXME: Wut? See MulTestGPU/MathOpTest below (duplicate?) INSTANTIATE_TEST_CASE_P(AddTestGPU, MathOpTest, - Combine(Values(ADD, MUL), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(1.0), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(false), - Values(cv::compile_args(CORE_GPU))), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU), + Values(ADD, MUL), + testing::Bool(), + Values(1.0), + Values(false)), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(MulTestGPU, MathOpTest, - Combine(Values(MUL), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(1.0, 0.5, 2.0), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(false), - Values(cv::compile_args(CORE_GPU))), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU), + Values(MUL), + testing::Bool(), + Values(1.0, 0.5, 2.0), + Values(false)), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(SubTestGPU, MathOpTest, - Combine(Values(SUB), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values (1.0), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU), + Values(SUB), testing::Bool(), - Values(cv::compile_args(CORE_GPU))), + Values (1.0), + testing::Bool()), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(DivTestGPU, MathOpTest, - Combine(Values(DIV), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values (1.0, 0.5, 2.0), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU), + Values(DIV), testing::Bool(), - Values(cv::compile_args(CORE_GPU))), + Values (1.0, 0.5, 2.0), + testing::Bool()), opencv_test::PrintMathOpCoreParams()); INSTANTIATE_TEST_CASE_P(MulTestGPU, MulDoubleTest, @@ -76,8 +79,8 @@ INSTANTIATE_TEST_CASE_P(MulTestGPU, MulDoubleTest, cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(DivTestGPU, DivTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), @@ -85,8 +88,8 @@ INSTANTIATE_TEST_CASE_P(DivTestGPU, DivTest, cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(DivCTestGPU, DivCTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), @@ -94,16 +97,17 @@ INSTANTIATE_TEST_CASE_P(DivCTestGPU, DivCTest, cv::Size(640, 480), cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(MeanTestGPU, MeanTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(SAME_TYPE), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU))); //TODO: mask test doesn't work #if 0 @@ -113,7 +117,7 @@ INSTANTIATE_TEST_CASE_P(MaskTestGPU, MaskTest, cv::Size(640, 480), cv::Size(128, 128)), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); #endif INSTANTIATE_TEST_CASE_P(SelectTestGPU, SelectTest, @@ -121,42 +125,49 @@ INSTANTIATE_TEST_CASE_P(SelectTestGPU, SelectTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(Polar2CartGPU, Polar2CartTest, - Combine(Values(cv::Size(1280, 720), - cv::Size(640, 480), - cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); - -INSTANTIATE_TEST_CASE_P(Cart2PolarGPU, Cart2PolarTest, - Combine(Values(cv::Size(1280, 720), - cv::Size(640, 480), - cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); - -INSTANTIATE_TEST_CASE_P(CompareTestGPU, CmpTest, - Combine(Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE), - testing::Bool(), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), + Combine(Values(CV_32FC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(CV_32FC1), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU))), + Values(CORE_GPU))); + +INSTANTIATE_TEST_CASE_P(Cart2PolarGPU, Cart2PolarTest, + Combine(Values(CV_32FC1), + Values(cv::Size(1280, 720), + cv::Size(640, 480), + cv::Size(128, 128)), + Values(CV_32FC1), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU))); + +INSTANTIATE_TEST_CASE_P(CompareTestGPU, CmpTest, + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), + Values(cv::Size(1280, 720), + cv::Size(640, 480), + cv::Size(128, 128)), + Values(CV_8U), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU), + Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE), + testing::Bool()), opencv_test::PrintCmpCoreParams()); INSTANTIATE_TEST_CASE_P(BitwiseTestGPU, BitwiseTest, - Combine(Values(AND, OR, XOR), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU))), + Values(CORE_GPU), + Values(AND, OR, XOR)), opencv_test::PrintBWCoreParams()); INSTANTIATE_TEST_CASE_P(BitwiseNotTestGPU, NotTest, @@ -164,49 +175,55 @@ INSTANTIATE_TEST_CASE_P(BitwiseNotTestGPU, NotTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(SAME_TYPE), +/*init output matrices or not*/ testing::Bool(), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(MinTestGPU, MinTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(MaxTestGPU, MaxTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(SumTestGPU, SumTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(AbsToleranceScalar(1e-3).to_compare_f()),//TODO: too relaxed? - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU), + Values(AbsToleranceScalar(1e-3).to_compare_f())));//TODO: too relaxed? INSTANTIATE_TEST_CASE_P(AbsDiffTestGPU, AbsDiffTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(AbsDiffCTestGPU, AbsDiffCTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(AddWeightedTestGPU, AddWeightedTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), @@ -215,17 +232,19 @@ INSTANTIATE_TEST_CASE_P(AddWeightedTestGPU, AddWeightedTest, cv::Size(128, 128)), Values( -1, CV_8U, CV_16U, CV_32F ), /*init output matrices or not*/ testing::Bool(), - Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU), + Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()))); INSTANTIATE_TEST_CASE_P(NormTestGPU, NormTest, - Combine(Values(NORM_INF, NORM_L1, NORM_L2), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), + Values(false), + Values(CORE_GPU), Values(AbsToleranceScalar(1e-3).to_compare_f()), //TODO: too relaxed? - Values(cv::compile_args(CORE_GPU))), + Values(NORM_INF, NORM_L1, NORM_L2)), opencv_test::PrintNormCoreParams()); INSTANTIATE_TEST_CASE_P(IntegralTestGPU, IntegralTest, @@ -233,25 +252,30 @@ INSTANTIATE_TEST_CASE_P(IntegralTestGPU, IntegralTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(-1), + Values(false), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(ThresholdTestGPU, ThresholdTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU), + Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, + cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV))); INSTANTIATE_TEST_CASE_P(ThresholdTestGPU, ThresholdOTTest, Combine(Values(CV_8UC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU), + Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE))); INSTANTIATE_TEST_CASE_P(InRangeTestGPU, InRangeTest, @@ -259,123 +283,148 @@ INSTANTIATE_TEST_CASE_P(InRangeTestGPU, InRangeTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(Split3TestGPU, Split3Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC3), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(CV_8UC1), + Values(true), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(Split4TestGPU, Split4Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC4), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(CV_8UC1), + Values(true), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(ResizeTestGPU, ResizeTest, - Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(-1), + Values(false), + Values(CORE_GPU), + Values(AbsSimilarPoints(2, 0.05).to_compare_f()), + Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), Values(cv::Size(64,64), - cv::Size(30,30)), - Values(cv::compile_args(CORE_GPU)))); + cv::Size(30,30)))); INSTANTIATE_TEST_CASE_P(ResizeTestGPU, ResizeTestFxFy, - Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()), - Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(-1), + Values(false), + Values(CORE_GPU), + Values(AbsSimilarPoints(2, 0.05).to_compare_f()), + Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), Values(0.5, 0.1), - Values(0.5, 0.1), - Values(cv::compile_args(CORE_GPU)))); + Values(0.5, 0.1))); INSTANTIATE_TEST_CASE_P(Merge3TestGPU, Merge3Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC1), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(CV_8UC3), + Values(true), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(Merge4TestGPU, Merge4Test, - Combine(Values(cv::Size(1280, 720), + Combine(Values(CV_8UC1), + Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(CV_8UC4), + Values(true), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(RemapTestGPU, RemapTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), + Values(SAME_TYPE), /*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(FlipTestGPU, FlipTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(0,1,-1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(SAME_TYPE), +/*init output matrices or not*/ Values(false), + Values(CORE_GPU), + Values(0,1,-1))); INSTANTIATE_TEST_CASE_P(CropTestGPU, CropTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), - Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(SAME_TYPE), +/*init output matrices or not*/ Values(false), + Values(CORE_GPU), + Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50)))); INSTANTIATE_TEST_CASE_P(LUTTestGPU, LUTTest, Combine(Values(CV_8UC1, CV_8UC3), - Values(CV_8UC1), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CV_8UC1), +/*init output matrices or not*/ Values(true), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(LUTTestCustomGPU, LUTTest, Combine(Values(CV_8UC3), - Values(CV_8UC3), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), -/*init output matrices or not*/ testing::Bool(), - Values(cv::compile_args(CORE_GPU)))); + Values(CV_8UC3), +/*init output matrices or not*/ Values(true), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(ConvertToGPU, ConvertToTest, - Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1), - Values(CV_8U, CV_16U, CV_16S, CV_32F), + Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(2.5, 1.0, -1.0), - Values(250.0, 0.0, -128.0), + Values(CV_8U, CV_16U, CV_16S, CV_32F), + Values(false), + Values(CORE_GPU), Values(AbsExact().to_compare_f()), - Values(cv::compile_args(CORE_GPU)))); + Values(2.5, 1.0, -1.0), + Values(250.0, 0.0, -128.0))); INSTANTIATE_TEST_CASE_P(ConcatHorTestGPU, ConcatHorTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(SAME_TYPE), + Values(false), + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(ConcatVertTestGPU, ConcatVertTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(SAME_TYPE), + Values(false), + Values(CORE_GPU))); //TODO: fix this backend to allow ConcatVertVec ConcatHorVec #if 0 @@ -384,13 +433,13 @@ INSTANTIATE_TEST_CASE_P(ConcatVertVecTestGPU, ConcatVertVecTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); INSTANTIATE_TEST_CASE_P(ConcatHorVecTestGPU, ConcatHorVecTest, Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ), Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(cv::compile_args(CORE_GPU)))); + Values(CORE_GPU))); #endif }