Merge pull request #14922 from andrey-golubev:operators_tests_update_clean

G-API: Align operators tests to new test model (#14922)

* Align operators tests to new test model

* Change init function in NotOperatorTest
pull/14932/head
Andrey Golubev 5 years ago committed by Alexander Alekhin
parent 8dd596b7ba
commit 1666195984
  1. 10
      modules/gapi/test/common/gapi_operators_tests.hpp
  2. 30
      modules/gapi/test/common/gapi_operators_tests_inl.hpp
  3. 57
      modules/gapi/test/cpu/gapi_operators_tests_cpu.cpp
  4. 54
      modules/gapi/test/cpu/gapi_operators_tests_fluid.cpp
  5. 57
      modules/gapi/test/gpu/gapi_operators_tests_gpu.cpp

@ -61,7 +61,6 @@ struct g_api_ocv_pair_mat_mat {
namespace
{
//declare test cases for matrix and scalar operators
g_api_ocv_pair_mat_scalar opPlus = {std::string{"operator+"},
[](cv::GMat in,cv::GScalar c){return in+c;},
@ -184,9 +183,12 @@ g_api_ocv_pair_mat_mat opXor = {std::string{"operator^"},
[](const cv::Mat& in1, const cv::Mat& in2, cv::Mat& out){cv::bitwise_xor(in1, in2, out);}};
} // anonymous namespace
struct MathOperatorMatScalarTest : public TestParams<std::tuple<compare_f, g_api_ocv_pair_mat_scalar,int,cv::Size,int,bool,cv::GCompileArgs>>{};
struct MathOperatorMatMatTest : public TestParams<std::tuple<compare_f, g_api_ocv_pair_mat_mat,int,cv::Size,int,bool,cv::GCompileArgs>>{};
struct NotOperatorTest : public TestParams<std::tuple<int,cv::Size,bool,cv::GCompileArgs>> {};
GAPI_TEST_FIXTURE(MathOperatorMatScalarTest, initMatsRandU,
FIXTURE_API(compare_f, g_api_ocv_pair_mat_scalar), 2, cmpF, op)
GAPI_TEST_FIXTURE(MathOperatorMatMatTest, initMatsRandU,
FIXTURE_API(compare_f, g_api_ocv_pair_mat_mat), 2, cmpF, op)
GAPI_TEST_FIXTURE(NotOperatorTest, initMatrixRandU, <>, 0)
} // opencv_test
#endif // OPENCV_GAPI_OPERATOR_TESTS_COMMON_HPP

@ -14,15 +14,6 @@ namespace opencv_test
{
TEST_P(MathOperatorMatScalarTest, OperatorAccuracyTest )
{
compare_f cmpF;
g_api_ocv_pair_mat_scalar op;
int type = 0, dtype = 0;
cv::Size sz;
bool initOutMatr = false;
cv::GCompileArgs compile_args;
std::tie(cmpF, op, type, sz, dtype, initOutMatr, compile_args) = GetParam();
initMatsRandU(type, sz, dtype, initOutMatr);
auto fun_gapi = op.g_api_function;
auto fun_ocv = op.ocv_function ;
@ -33,7 +24,7 @@ TEST_P(MathOperatorMatScalarTest, OperatorAccuracyTest )
auto out = fun_gapi(in1, in2);
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());
fun_ocv(in_mat1, sc, out_mat_ocv);
@ -46,15 +37,6 @@ TEST_P(MathOperatorMatScalarTest, OperatorAccuracyTest )
TEST_P(MathOperatorMatMatTest, OperatorAccuracyTest )
{
compare_f cmpF;
g_api_ocv_pair_mat_mat op;
int type = 0, dtype = 0;
cv::Size sz;
bool initOutMatr = false;
cv::GCompileArgs compile_args;
std::tie(cmpF, op, type, sz, dtype, initOutMatr, compile_args) = GetParam();
initMatsRandU(type, sz, dtype, initOutMatr);
auto fun_gapi = op.g_api_function;
auto fun_ocv = op.ocv_function ;
@ -65,7 +47,7 @@ TEST_P(MathOperatorMatMatTest, OperatorAccuracyTest )
auto out = fun_gapi(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());
fun_ocv(in_mat1, in_mat2, out_mat_ocv);
@ -78,16 +60,12 @@ TEST_P(MathOperatorMatMatTest, OperatorAccuracyTest )
TEST_P(NotOperatorTest, OperatorAccuracyTest)
{
cv::Size sz_in = std::get<1>(GetParam());
initMatrixRandU(std::get<0>(GetParam()), sz_in, std::get<0>(GetParam()), std::get<2>(GetParam()));
cv::GCompileArgs compile_args;
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in;
auto out = ~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 /////////////////////////////////////////////////////////////
{
@ -96,7 +74,7 @@ TEST_P(NotOperatorTest, OperatorAccuracyTest)
// 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);
}
}
} // opencv_test

@ -9,65 +9,68 @@
#include "../common/gapi_operators_tests.hpp"
#include <opencv2/gapi/cpu/core.hpp>
#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: CPU test runs are disabled since Fluid is an exclusive plugin now!
INSTANTIATE_TEST_CASE_P(MathOperatorTestCPU, MathOperatorMatMatTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq),
Values(CV_8UC1, CV_16SC1, CV_32FC1),
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_CPU))));
testing::Bool(),
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq)));
INSTANTIATE_TEST_CASE_P(MathOperatorTestCPU, MathOperatorMatScalarTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER),
Values(CV_8UC1, CV_16SC1, CV_32FC1),
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_CPU))));
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER)));
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestCPU, MathOperatorMatMatTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opAnd, opOr, opXor ),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_CPU))));
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values( opAnd, opOr, opXor )));
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestCPU, MathOperatorMatScalarTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR ),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_CPU))));
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR )));
INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestCPU, NotOperatorTest,
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)));
}

@ -8,65 +8,69 @@
#include "../test_precomp.hpp"
#include "../common/gapi_operators_tests.hpp"
#define CORE_FLUID cv::gapi::core::fluid::kernels()
namespace
{
#define CORE_FLUID [] () { return cv::compile_args(cv::gapi::core::fluid::kernels()); }
} // anonymous namespace
namespace opencv_test
{
INSTANTIATE_TEST_CASE_P(MathOperatorTestFluid, MathOperatorMatMatTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq),
Values(CV_8UC1, CV_16SC1, CV_32FC1),
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_FLUID))));
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq)));
//FIXME: Some Mat/Scalar Fluid kernels are not there yet!
INSTANTIATE_TEST_CASE_P(DISABLED_MathOperatorTestFluid, MathOperatorMatScalarTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER),
Values(CV_8UC1, CV_16SC1, CV_32FC1),
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_FLUID))));
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER)));
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestFluid, MathOperatorMatMatTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opAnd, opOr, opXor ),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_FLUID))));
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values( opAnd, opOr, opXor )));
//FIXME: Some Mat/Scalar Fluid kernels are not there yet!
INSTANTIATE_TEST_CASE_P(DISABLED_BitwiseOperatorTestFluid, MathOperatorMatScalarTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR ),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_FLUID))));
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR )));
INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestFluid, NotOperatorTest,
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_FLUID))));
Values(CORE_FLUID)));
}

@ -8,64 +8,67 @@
#include "../test_precomp.hpp"
#include "../common/gapi_operators_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
{
INSTANTIATE_TEST_CASE_P(MathOperatorTestGPU, MathOperatorMatMatTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq),
Values(CV_8UC1, CV_16SC1, CV_32FC1),
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_GPU))));
testing::Bool(),
Values(CORE_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq)));
INSTANTIATE_TEST_CASE_P(MathOperatorTestGPU, MathOperatorMatScalarTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_f()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER),
Values(CV_8UC1, CV_16SC1, CV_32FC1),
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_GPU))));
Values(CORE_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_f()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER)));
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestGPU, MathOperatorMatMatTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opAnd, opOr, opXor ),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_GPU))));
Values(CORE_GPU),
Values(AbsExact().to_compare_f()),
Values( opAnd, opOr, opXor )));
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestGPU, MathOperatorMatScalarTest,
Combine(Values(AbsExact().to_compare_f()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR ),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(cv::compile_args(CORE_GPU))));
Values(CORE_GPU),
Values(AbsExact().to_compare_f()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR )));
INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestGPU, NotOperatorTest,
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_GPU))));
Values(CORE_GPU)));
}

Loading…
Cancel
Save