Commit e329c84d authored by Alexey Smirnov's avatar Alexey Smirnov Committed by Alexander Alekhin

Merge pull request #14684 from smirnov-alexey:as/convert2_test_extension

G-API: Add parameters alpha and beta in tests on ConvertTo kernel (#14684)

* Add parameters alpha and beta in tests on ConvertTo kernel

* Change tolerance function

* Reduce number of test cases
parent 03a3be08
...@@ -145,7 +145,7 @@ struct ConcatVertTest : public TestWithParam<std::tuple<int, cv::Size, cv::GC ...@@ -145,7 +145,7 @@ struct ConcatVertTest : public TestWithParam<std::tuple<int, cv::Size, cv::GC
struct ConcatVertVecTest : public TestWithParam<std::tuple<int, cv::Size, cv::GCompileArgs>> {}; struct ConcatVertVecTest : public TestWithParam<std::tuple<int, cv::Size, cv::GCompileArgs>> {};
struct ConcatHorVecTest : public TestWithParam<std::tuple<int, cv::Size, cv::GCompileArgs>> {}; struct ConcatHorVecTest : public TestWithParam<std::tuple<int, cv::Size, cv::GCompileArgs>> {};
struct LUTTest : public TestParams<std::tuple<int, int, cv::Size,bool, cv::GCompileArgs>> {}; struct LUTTest : public TestParams<std::tuple<int, int, cv::Size,bool, cv::GCompileArgs>> {};
struct ConvertToTest : public TestParams<std::tuple<int, int, cv::Size, cv::GCompileArgs>> {}; struct ConvertToTest : public TestParams<std::tuple<int, int, cv::Size, double, double, compare_f, cv::GCompileArgs>> {};
struct PhaseTest : public TestParams<std::tuple<int, cv::Size, bool, cv::GCompileArgs>> {}; struct PhaseTest : public TestParams<std::tuple<int, cv::Size, bool, cv::GCompileArgs>> {};
struct SqrtTest : public TestParams<std::tuple<int, cv::Size, cv::GCompileArgs>> {}; struct SqrtTest : public TestParams<std::tuple<int, cv::Size, cv::GCompileArgs>> {};
struct NormalizeTest : public TestParams<std::tuple<compare_f,MatType,cv::Size,double,double,int,MatType,bool,cv::GCompileArgs>> {}; struct NormalizeTest : public TestParams<std::tuple<compare_f,MatType,cv::Size,double,double,int,MatType,bool,cv::GCompileArgs>> {};
......
...@@ -1361,27 +1361,30 @@ TEST_P(LUTTest, AccuracyTest) ...@@ -1361,27 +1361,30 @@ TEST_P(LUTTest, AccuracyTest)
TEST_P(ConvertToTest, AccuracyTest) TEST_P(ConvertToTest, AccuracyTest)
{ {
auto param = GetParam(); int type_mat = -1, depth_to = -1;
int type_mat = std::get<0>(param); double alpha = 1.0, beta = 0.0;
int depth_to = std::get<1>(param); cv::Size sz_in;
cv::Size sz_in = std::get<2>(param); cv::GCompileArgs compile_args;
compare_f cmpF;
std::tie(type_mat, depth_to, sz_in, alpha, beta, cmpF, compile_args) = GetParam();
int type_out = CV_MAKETYPE(depth_to, CV_MAT_CN(type_mat)); int type_out = CV_MAKETYPE(depth_to, CV_MAT_CN(type_mat));
initMatrixRandU(type_mat, sz_in, type_out); initMatrixRandU(type_mat, sz_in, type_out);
auto compile_args = std::get<3>(GetParam());
// G-API code ////////////////////////////////////////////////////////////// // G-API code //////////////////////////////////////////////////////////////
cv::GMat in; cv::GMat in;
auto out = cv::gapi::convertTo(in, depth_to); auto out = cv::gapi::convertTo(in, depth_to, alpha, beta);
cv::GComputation c(in, out); cv::GComputation c(in, out);
c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
// OpenCV code ///////////////////////////////////////////////////////////// // OpenCV code /////////////////////////////////////////////////////////////
{ {
in_mat1.convertTo(out_mat_ocv, depth_to); in_mat1.convertTo(out_mat_ocv, depth_to, alpha, beta);
} }
// Comparison ////////////////////////////////////////////////////////////// // Comparison //////////////////////////////////////////////////////////////
{ {
EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi)); EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
EXPECT_EQ(out_mat_gapi.size(), sz_in); EXPECT_EQ(out_mat_gapi.size(), sz_in);
} }
} }
......
...@@ -369,11 +369,14 @@ INSTANTIATE_TEST_CASE_P(LUTTestCustomCPU, LUTTest, ...@@ -369,11 +369,14 @@ INSTANTIATE_TEST_CASE_P(LUTTestCustomCPU, LUTTest,
Values(cv::compile_args(CORE_CPU)))); Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ConvertToCPU, ConvertToTest, INSTANTIATE_TEST_CASE_P(ConvertToCPU, ConvertToTest,
Combine(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_8U, CV_16U, CV_16S, CV_32F), Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(cv::Size(1280, 720), Values(cv::Size(1280, 720),
cv::Size(640, 480), cv::Size(640, 480),
cv::Size(128, 128)), cv::Size(128, 128)),
Values(2.5, 1.0, -1.0),
Values(250.0, 0.0, -128.0),
Values(AbsExact().to_compare_f()),
Values(cv::compile_args(CORE_CPU)))); Values(cv::compile_args(CORE_CPU))));
INSTANTIATE_TEST_CASE_P(ConcatHorTestCPU, ConcatHorTest, INSTANTIATE_TEST_CASE_P(ConcatHorTestCPU, ConcatHorTest,
......
...@@ -142,6 +142,9 @@ INSTANTIATE_TEST_CASE_P(ConvertToFluid, ConvertToTest, ...@@ -142,6 +142,9 @@ INSTANTIATE_TEST_CASE_P(ConvertToFluid, ConvertToTest,
cv::Size(1280, 720), cv::Size(1280, 720),
cv::Size(640, 480), cv::Size(640, 480),
cv::Size(128, 128)), cv::Size(128, 128)),
Values(2.5, 1.0, -1.0),
Values(250.0, 0.0, -128.0),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values(cv::compile_args(CORE_FLUID)))); Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(Split3TestFluid, Split3Test, INSTANTIATE_TEST_CASE_P(Split3TestFluid, Split3Test,
......
...@@ -353,11 +353,14 @@ INSTANTIATE_TEST_CASE_P(LUTTestCustomGPU, LUTTest, ...@@ -353,11 +353,14 @@ INSTANTIATE_TEST_CASE_P(LUTTestCustomGPU, LUTTest,
Values(cv::compile_args(CORE_GPU)))); Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ConvertToGPU, ConvertToTest, INSTANTIATE_TEST_CASE_P(ConvertToGPU, ConvertToTest,
Combine(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_8U, CV_16U, CV_16S, CV_32F), Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(cv::Size(1280, 720), Values(cv::Size(1280, 720),
cv::Size(640, 480), cv::Size(640, 480),
cv::Size(128, 128)), cv::Size(128, 128)),
Values(2.5, 1.0, -1.0),
Values(250.0, 0.0, -128.0),
Values(AbsExact().to_compare_f()),
Values(cv::compile_args(CORE_GPU)))); Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ConcatHorTestGPU, ConcatHorTest, INSTANTIATE_TEST_CASE_P(ConcatHorTestGPU, ConcatHorTest,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment