mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #13251 from dbudniko:dbudniko/gapi_more_fixes_for_tests
More fixes for G-API tests (#13251) * scalar comparator and more fixes for tests * add weighted aligned * white space * more white space * Add weighted test accuracy check enabled
This commit is contained in:
committed by
Alexander Alekhin
parent
8f4e5c2fb8
commit
51cc78b2a2
@@ -50,9 +50,9 @@ namespace opencv_test
|
||||
class MaxPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
|
||||
class AbsDiffPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
|
||||
class AbsDiffCPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
|
||||
class SumPerfTest : public TestPerfParams<tuple<cv::Size, MatType, double, cv::GCompileArgs>> {};
|
||||
class AddWeightedPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, double, cv::GCompileArgs>> {};
|
||||
class NormPerfTest : public TestPerfParams<tuple<NormTypes, cv::Size, MatType, double, cv::GCompileArgs>> {};
|
||||
class SumPerfTest : public TestPerfParams<tuple<compare_scalar_f, cv::Size, MatType, cv::GCompileArgs>> {};
|
||||
class AddWeightedPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, int, cv::GCompileArgs>> {};
|
||||
class NormPerfTest : public TestPerfParams<tuple<compare_scalar_f, NormTypes, cv::Size, MatType, cv::GCompileArgs>> {};
|
||||
class IntegralPerfTest : public TestPerfParams<tuple<cv::Size, MatType, cv::GCompileArgs>> {};
|
||||
class ThresholdPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
|
||||
class ThresholdOTPerfTest : public TestPerfParams<tuple<cv::Size, MatType, int, cv::GCompileArgs>> {};
|
||||
|
||||
@@ -900,13 +900,13 @@ PERF_TEST_P_(AbsDiffCPerfTest, TestPerformance)
|
||||
|
||||
PERF_TEST_P_(SumPerfTest, TestPerformance)
|
||||
{
|
||||
cv::Size sz_in = get<0>(GetParam());
|
||||
MatType type = get<1>(GetParam());
|
||||
double tolerance = get<2>(GetParam());
|
||||
compare_scalar_f cmpF = get<0>(GetParam());
|
||||
cv::Size sz_in = get<1>(GetParam());
|
||||
MatType type = get<2>(GetParam());
|
||||
cv::GCompileArgs compile_args = get<3>(GetParam());
|
||||
|
||||
|
||||
initMatrixRandU(type, sz_in, false);
|
||||
initMatrixRandU(type, sz_in, type, false);
|
||||
cv::Scalar out_sum;
|
||||
cv::Scalar out_sum_ocv;
|
||||
|
||||
@@ -928,8 +928,7 @@ PERF_TEST_P_(SumPerfTest, TestPerformance)
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_LE(std::abs(out_sum[0] - out_sum_ocv[0]) / std::max(1.0, std::abs(out_sum_ocv[0])), tolerance)
|
||||
<< "OCV=" << out_sum_ocv[0] << " GAPI=" << out_sum[0];
|
||||
EXPECT_TRUE(cmpF(out_sum, out_sum_ocv));
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
@@ -939,10 +938,10 @@ PERF_TEST_P_(SumPerfTest, TestPerformance)
|
||||
|
||||
PERF_TEST_P_(AddWeightedPerfTest, TestPerformance)
|
||||
{
|
||||
cv::Size sz_in = get<0>(GetParam());
|
||||
MatType type = get<1>(GetParam());
|
||||
int dtype = get<2>(GetParam());
|
||||
double tolerance = get<3>(GetParam());
|
||||
compare_f cmpF = get<0>(GetParam());
|
||||
cv::Size sz_in = get<1>(GetParam());
|
||||
MatType type = get<2>(GetParam());
|
||||
int dtype = get<3>(GetParam());
|
||||
cv::GCompileArgs compile_args = get<4>(GetParam());
|
||||
|
||||
auto& rng = cv::theRNG();
|
||||
@@ -968,45 +967,9 @@ PERF_TEST_P_(AddWeightedPerfTest, TestPerformance)
|
||||
}
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
// FIXIT unrealiable check
|
||||
if (0)
|
||||
{
|
||||
// Note, that we cannot expect bitwise results for add-weighted:
|
||||
//
|
||||
// tmp = src1*alpha + src2*beta + gamma;
|
||||
// dst = saturate<DST>( round(tmp) );
|
||||
//
|
||||
// Because tmp is floating-point, dst depends on compiler optimizations
|
||||
//
|
||||
// However, we must expect good accuracy of tmp, and rounding correctly
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz_in);
|
||||
|
||||
cv::Mat failures;
|
||||
|
||||
if (out_mat_ocv.type() == CV_32FC1)
|
||||
{
|
||||
// result: float - may vary in 7th decimal digit
|
||||
failures = abs(out_mat_gapi - out_mat_ocv) > abs(out_mat_ocv) * 1e-6;
|
||||
}
|
||||
else
|
||||
{
|
||||
// result: integral - rounding may vary if fractional part of tmp
|
||||
// is nearly 0.5
|
||||
|
||||
cv::Mat inexact, incorrect, diff, tmp;
|
||||
|
||||
inexact = out_mat_gapi != out_mat_ocv;
|
||||
|
||||
// even if rounded differently, check if still rounded correctly
|
||||
cv::addWeighted(in_mat1, alpha, in_mat2, beta, gamma, tmp, CV_32F);
|
||||
cv::subtract(out_mat_gapi, tmp, diff, cv::noArray(), CV_32F);
|
||||
incorrect = abs(diff) >= tolerance;// 0.5000005f; // relative to 6 digits
|
||||
|
||||
failures = inexact & incorrect;
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(failures));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz_in);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
@@ -1015,10 +978,10 @@ PERF_TEST_P_(AddWeightedPerfTest, TestPerformance)
|
||||
|
||||
PERF_TEST_P_(NormPerfTest, TestPerformance)
|
||||
{
|
||||
NormTypes opType = get<0>(GetParam());
|
||||
cv::Size sz = get<1>(GetParam());
|
||||
MatType type = get<2>(GetParam());
|
||||
double tolerance = get<3>(GetParam());
|
||||
compare_scalar_f cmpF = get<0>(GetParam());
|
||||
NormTypes opType = get<1>(GetParam());
|
||||
cv::Size sz = get<2>(GetParam());
|
||||
MatType type = get<3>(GetParam());
|
||||
cv::GCompileArgs compile_args = get<4>(GetParam());
|
||||
|
||||
|
||||
@@ -1051,8 +1014,7 @@ PERF_TEST_P_(NormPerfTest, TestPerformance)
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_LE(std::abs(out_norm[0] - out_norm_ocv[0]) / std::max(1.0, std::abs(out_norm_ocv[0])), tolerance)
|
||||
<< "OCV=" << out_norm_ocv[0] << " GAPI=" << out_norm[0];
|
||||
EXPECT_TRUE(cmpF(out_norm, out_norm_ocv));
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
|
||||
@@ -152,24 +152,24 @@ INSTANTIATE_TEST_CASE_P(AbsDiffCPerfTestCPU, AbsDiffCPerfTest,
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SumPerfTestCPU, SumPerfTest,
|
||||
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
|
||||
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
|
||||
Values(szSmall128, szVGA, sz720p, sz1080p),
|
||||
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
|
||||
Values(0.0),
|
||||
//Values(0.0),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
// FIXME: Comparison introduced by YL doesn't work with C3
|
||||
INSTANTIATE_TEST_CASE_P(AddWeightedPerfTestCPU, AddWeightedPerfTest,
|
||||
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
|
||||
Values(CV_8UC1, /*CV_8UC3,*/ CV_16UC1, CV_16SC1, CV_32FC1),
|
||||
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
|
||||
Values(szSmall128, szVGA, sz720p, sz1080p),
|
||||
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
|
||||
Values(-1, CV_8U, CV_16U, CV_32F),
|
||||
Values(0.5000005),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NormPerfTestCPU, NormPerfTest,
|
||||
Combine(Values(NORM_INF, NORM_L1, NORM_L2),
|
||||
Combine(Values(AbsToleranceScalar(0.0).to_compare_f()),
|
||||
Values(NORM_INF, NORM_L1, NORM_L2),
|
||||
Values(szSmall128, szVGA, sz720p, sz1080p),
|
||||
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
|
||||
Values(0.0),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(IntegralPerfTestCPU, IntegralPerfTest,
|
||||
|
||||
@@ -153,24 +153,23 @@ INSTANTIATE_TEST_CASE_P(AbsDiffCPerfTestGPU, AbsDiffCPerfTest,
|
||||
Values(cv::compile_args(CORE_GPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SumPerfTestGPU, SumPerfTest,
|
||||
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
|
||||
Combine(Values(AbsToleranceScalar(1e-5).to_compare_f()),
|
||||
Values( szSmall128, szVGA, sz720p, sz1080p ),
|
||||
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
|
||||
Values(4.0), //TODO: too relaxed?
|
||||
Values(cv::compile_args(CORE_GPU))));
|
||||
|
||||
// FIXME: Comparison introduced by YL doesn't work with C3
|
||||
INSTANTIATE_TEST_CASE_P(AddWeightedPerfTestGPU, AddWeightedPerfTest,
|
||||
Combine(Values( szSmall128, szVGA, sz720p, sz1080p ),
|
||||
Values( CV_8UC1, /*CV_8UC3,*/ CV_16UC1, CV_16SC1, CV_32FC1 ),
|
||||
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
|
||||
Values( szSmall128, szVGA, sz720p, sz1080p ),
|
||||
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
|
||||
Values( -1, CV_8U, CV_16U, CV_32F ),
|
||||
Values(0.50005),
|
||||
Values(cv::compile_args(CORE_GPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NormPerfTestGPU, NormPerfTest,
|
||||
Combine(Values(NORM_INF, NORM_L1, NORM_L2),
|
||||
Combine(Values(AbsToleranceScalar(1e-5).to_compare_f()),
|
||||
Values(NORM_INF, NORM_L1, NORM_L2),
|
||||
Values( szSmall128, szVGA, sz720p, sz1080p ),
|
||||
Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
|
||||
Values(4.0), //TODO: too relaxed?
|
||||
Values(cv::compile_args(CORE_GPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(IntegralPerfTestGPU, IntegralPerfTest,
|
||||
|
||||
@@ -109,10 +109,20 @@ INSTANTIATE_TEST_CASE_P(Dilate3x3PerfTestGPU, Dilate3x3PerfTest,
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SobelPerfTestGPU, SobelPerfTest,
|
||||
Combine(Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
|
||||
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1/*, CV_32FC1*/), //TODO: CV_32FC1 fails accuracy
|
||||
Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
|
||||
Values(3, 5),
|
||||
Values(szVGA, sz720p, sz1080p),
|
||||
Values(-1, CV_32F),
|
||||
Values(-1, CV_16S, CV_32F),
|
||||
Values(0, 1),
|
||||
Values(1, 2),
|
||||
Values(cv::compile_args(IMGPROC_GPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SobelPerfTestGPU32F, SobelPerfTest,
|
||||
Combine(Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
|
||||
Values(CV_32FC1),
|
||||
Values(3, 5),
|
||||
Values(szVGA, sz720p, sz1080p),
|
||||
Values(CV_32F),
|
||||
Values(0, 1),
|
||||
Values(1, 2),
|
||||
Values(cv::compile_args(IMGPROC_GPU))));
|
||||
|
||||
Reference in New Issue
Block a user