Commit 220b2785 authored by Dmitry Budnikov's avatar Dmitry Budnikov Committed by Alexander Alekhin

Merge pull request #12944 from dbudniko:dbudniko/tests_thresholds

* added threshold to g-api imgproc tests

* trailing spaces remove

* try to fix warnings

* fix license header

* fix random numbers issue

* fix Sobel test

* license headers + precompiled headers included
parent 853f5111
// 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) 2018 Intel Corporation
#include "perf_precomp.hpp"
#include "gapi_core_perf_tests_inl.hpp"
This diff is collapsed.
// 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) 2018 Intel Corporation
#include "perf_precomp.hpp"
#include "gapi_imgproc_perf_tests_inl.hpp"
This diff is collapsed.
...@@ -878,8 +878,7 @@ TEST_P(ThresholdOTTest, AccuracyTestOtsu) ...@@ -878,8 +878,7 @@ TEST_P(ThresholdOTTest, AccuracyTestOtsu)
int tt = std::get<2>(param); int tt = std::get<2>(param);
auto compile_args = std::get<4>(param); auto compile_args = std::get<4>(param);
auto& rng = cv::theRNG(); cv::Scalar maxval = initScalarRandU(50) + cv::Scalar(50, 50, 50, 50);
cv::Scalar maxval = cv::Scalar(50 + rng(50),50 + rng(50),50 + rng(50),50 + rng(50));
initMatrixRandU(type, sz_in, type, std::get<3>(param)); initMatrixRandU(type, sz_in, type, std::get<3>(param));
cv::Scalar out_gapi_scalar; cv::Scalar out_gapi_scalar;
double ocv_res; double ocv_res;
...@@ -911,9 +910,8 @@ TEST_P(InRangeTest, AccuracyTest) ...@@ -911,9 +910,8 @@ TEST_P(InRangeTest, AccuracyTest)
cv::Size sz_in = std::get<1>(param); cv::Size sz_in = std::get<1>(param);
auto compile_args = std::get<3>(param); auto compile_args = std::get<3>(param);
auto& rng = cv::theRNG(); cv::Scalar thrLow = initScalarRandU(100);
cv::Scalar thrLow = cv::Scalar(rng(100),rng(100),rng(100),rng(100)); cv::Scalar thrUp = initScalarRandU(100) + cv::Scalar(100, 100, 100, 100);
cv::Scalar thrUp = cv::Scalar(100 + rng(100),100 + rng(100),100 + rng(100),100 + rng(100));
initMatrixRandU(type, sz_in, type, std::get<2>(param)); initMatrixRandU(type, sz_in, type, std::get<2>(param));
// G-API code ////////////////////////////////////////////////////////////// // G-API code //////////////////////////////////////////////////////////////
......
...@@ -14,28 +14,29 @@ ...@@ -14,28 +14,29 @@
namespace opencv_test namespace opencv_test
{ {
struct Filter2DTest : public TestParams <std::tuple<MatType,int,cv::Size,int,int,bool,cv::GCompileArgs>> {};
struct BoxFilterTest : public TestParams <std::tuple<MatType,int,cv::Size,int,int,double,bool,cv::GCompileArgs>> {}; struct Filter2DTest : public TestParams <std::tuple<compare_f, MatType,int,cv::Size,int,int,bool,cv::GCompileArgs>> {};
struct SepFilterTest : public TestParams <std::tuple<MatType,int,cv::Size,int,bool,cv::GCompileArgs>> {}; struct BoxFilterTest : public TestParams <std::tuple<compare_f,MatType,int,cv::Size,int,int,bool,cv::GCompileArgs>> {};
struct BlurTest : public TestParams <std::tuple<MatType,int,cv::Size,int,double,bool,cv::GCompileArgs>> {}; struct SepFilterTest : public TestParams <std::tuple<compare_f,MatType,int,cv::Size,int,bool,cv::GCompileArgs>> {};
struct GaussianBlurTest : public TestParams <std::tuple<MatType,int,cv::Size,bool,cv::GCompileArgs>> {}; struct BlurTest : public TestParams <std::tuple<compare_f,MatType,int,cv::Size,int,bool,cv::GCompileArgs>> {};
struct MedianBlurTest : public TestParams <std::tuple<MatType,int,cv::Size,bool,cv::GCompileArgs>> {}; struct GaussianBlurTest : public TestParams <std::tuple<compare_f,MatType,int,cv::Size,bool,cv::GCompileArgs>> {};
struct ErodeTest : public TestParams <std::tuple<MatType,int,cv::Size,int,bool,cv::GCompileArgs>> {}; struct MedianBlurTest : public TestParams <std::tuple<compare_f,MatType,int,cv::Size,bool,cv::GCompileArgs>> {};
struct Erode3x3Test : public TestParams <std::tuple<MatType,cv::Size,bool,int,cv::GCompileArgs>> {}; struct ErodeTest : public TestParams <std::tuple<compare_f,MatType,int,cv::Size,int,bool,cv::GCompileArgs>> {};
struct DilateTest : public TestParams <std::tuple<MatType,int,cv::Size,int,bool,cv::GCompileArgs>> {}; struct Erode3x3Test : public TestParams <std::tuple<compare_f,MatType,cv::Size,bool,int,cv::GCompileArgs>> {};
struct Dilate3x3Test : public TestParams <std::tuple<MatType,cv::Size,bool,int,cv::GCompileArgs>> {}; struct DilateTest : public TestParams <std::tuple<compare_f,MatType,int,cv::Size,int,bool,cv::GCompileArgs>> {};
struct SobelTest : public TestParams <std::tuple<MatType,int,cv::Size,int,int,int,bool,cv::GCompileArgs>> {}; struct Dilate3x3Test : public TestParams <std::tuple<compare_f,MatType,cv::Size,bool,int,cv::GCompileArgs>> {};
struct EqHistTest : public TestParams <std::tuple<cv::Size,bool, cv::GCompileArgs>> {}; struct SobelTest : public TestParams <std::tuple<compare_f,MatType,int,cv::Size,int,int,int,bool,cv::GCompileArgs>> {};
struct CannyTest : public TestParams <std::tuple<MatType,cv::Size,double,double,int,bool,bool,cv::GCompileArgs>> {}; struct EqHistTest : public TestParams <std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct RGB2GrayTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct CannyTest : public TestParams <std::tuple<compare_f,MatType,cv::Size,double,double,int,bool,bool,cv::GCompileArgs>> {};
struct BGR2GrayTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct RGB2GrayTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct RGB2YUVTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct BGR2GrayTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct YUV2RGBTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct RGB2YUVTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct RGB2LabTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct YUV2RGBTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct BGR2LUVTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct RGB2LabTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct LUV2BGRTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct BGR2LUVTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct BGR2YUVTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct LUV2BGRTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct YUV2BGRTest : public TestParams<std::tuple<cv::Size,bool,cv::GCompileArgs>> {}; struct BGR2YUVTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
struct YUV2BGRTest : public TestParams<std::tuple<compare_f,cv::Size,bool,cv::GCompileArgs>> {};
} // opencv_test } // opencv_test
#endif //OPENCV_GAPI_IMGPROC_TESTS_HPP #endif //OPENCV_GAPI_IMGPROC_TESTS_HPP
...@@ -31,13 +31,22 @@ public: ...@@ -31,13 +31,22 @@ public:
cv::Scalar sc; cv::Scalar sc;
cv::Scalar initScalarRandU(unsigned upper)
{
auto& rng = cv::theRNG();
double s1 = rng(upper);
double s2 = rng(upper);
double s3 = rng(upper);
double s4 = rng(upper);
return cv::Scalar(s1, s2, s3, s4);
}
void initMatsRandU(int type, cv::Size sz_in, int dtype, bool createOutputMatrices = true) void initMatsRandU(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);
in_mat2 = cv::Mat(sz_in, type); in_mat2 = cv::Mat(sz_in, type);
auto& rng = cv::theRNG(); sc = initScalarRandU(100);
sc = cv::Scalar(rng(100),rng(100),rng(100),rng(100));
cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255)); cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255));
cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255)); cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255));
...@@ -52,8 +61,7 @@ public: ...@@ -52,8 +61,7 @@ public:
{ {
in_mat1 = cv::Mat(sz_in, type); in_mat1 = cv::Mat(sz_in, type);
auto& rng = cv::theRNG(); sc = initScalarRandU(100);
sc = cv::Scalar(rng(100),rng(100),rng(100),rng(100));
cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255)); cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255));
...@@ -105,4 +113,19 @@ class TestParams: public TestFunctional, public TestWithParam<T>{}; ...@@ -105,4 +113,19 @@ class TestParams: public TestFunctional, public TestWithParam<T>{};
template<class T> template<class T>
class TestPerfParams: public TestFunctional, public perf::TestBaseWithParam<T>{}; class TestPerfParams: public TestFunctional, public perf::TestBaseWithParam<T>{};
using compare_f = std::function<bool(const cv::Mat &a, const cv::Mat &b)>;
template<typename T>
struct Wrappable
{
compare_f to_compare_f()
{
T t = *static_cast<T*const>(this);
return [t](const cv::Mat &a, const cv::Mat &b)
{
return t(a, b);
};
}
};
} }
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