Merge pull request #14945 from andrey-golubev:delete_bool
G-API: clean up accuracy tests (#14945) * Delete createOutputMatrices flag Update the way compile args function is created Fix instantiation suffix print function * Update comment (NB) * Make printable comparison functions * Use defines instead of objects for compile args * Remove custom printers, use operator<< overload * Remove SAME_TYPE and use -1 instead * Delete createOutputMatrices flag in new tests * Fix GetParam() printed values * Update Resize tests: use CompareF object * Address code review feedback * Add default cases for operator<< overloads * change throw to GAPI_Assert
This commit is contained in:
committed by
Alexander Alekhin
parent
c11423df1e
commit
c9bd43c0f6
@@ -30,91 +30,37 @@ enum bitwiseOp
|
||||
NOT = 3
|
||||
};
|
||||
|
||||
namespace
|
||||
// Note: namespace must match the namespace of the type of the printed object
|
||||
inline std::ostream& operator<<(std::ostream& os, mathOp op)
|
||||
{
|
||||
const char *MathOperations[] = {"ADD", "SUB", "MUL", "DIV"};
|
||||
const char *BitwiseOperations[] = {"And", "Or", "Xor"};
|
||||
const char *CompareOperations[] = {"CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE"};
|
||||
//corresponds to OpenCV
|
||||
const char *NormOperations[] = {"", "NORM_INF", "NORM_L1", "","NORM_L2"};
|
||||
#define CASE(v) case mathOp::v: os << #v; break
|
||||
switch (op)
|
||||
{
|
||||
CASE(ADD);
|
||||
CASE(SUB);
|
||||
CASE(MUL);
|
||||
CASE(DIV);
|
||||
default: GAPI_Assert(false && "unknown mathOp value");
|
||||
}
|
||||
#undef CASE
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
struct PrintMathOpCoreParams
|
||||
// Note: namespace must match the namespace of the type of the printed object
|
||||
inline std::ostream& operator<<(std::ostream& os, bitwiseOp op)
|
||||
{
|
||||
template <class TestParams>
|
||||
std::string operator()(const ::testing::TestParamInfo<TestParams>& info) const
|
||||
#define CASE(v) case bitwiseOp::v: os << #v; break
|
||||
switch (op)
|
||||
{
|
||||
std::stringstream ss;
|
||||
using AllParams = Params<mathOp,bool,double,bool>;
|
||||
const AllParams::params_t& params = info.param;
|
||||
cv::Size sz = AllParams::getCommon<1>(params); // size
|
||||
ss<<MathOperations[AllParams::getSpecific<0>(params)] // mathOp
|
||||
<<"_"<<AllParams::getSpecific<1>(params) // testWithScalar
|
||||
<<"_"<<AllParams::getCommon<0>(params) // type
|
||||
<<"_"<<(int)AllParams::getSpecific<2>(params) // scale
|
||||
<<"_"<<sz.width
|
||||
<<"x"<<sz.height
|
||||
<<"_"<<(AllParams::getCommon<2>(params)+1) // dtype
|
||||
<<"_"<<AllParams::getCommon<3>(params) // createOutputMatrices
|
||||
<<"_"<<AllParams::getSpecific<3>(params); // doReverseOp
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
struct PrintCmpCoreParams
|
||||
{
|
||||
template <class TestParams>
|
||||
std::string operator()(const ::testing::TestParamInfo<TestParams>& info) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
using AllParams = Params<CmpTypes,bool>;
|
||||
const AllParams::params_t& params = info.param;
|
||||
cv::Size sz = AllParams::getCommon<1>(params); // size
|
||||
ss<<CompareOperations[AllParams::getSpecific<0>(params)] // CmpType
|
||||
<<"_"<<AllParams::getSpecific<1>(params) // testWithScalar
|
||||
<<"_"<<AllParams::getCommon<0>(params) // type
|
||||
<<"_"<<sz.width
|
||||
<<"x"<<sz.height
|
||||
<<"_"<<AllParams::getCommon<3>(params); // createOutputMatrices
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
struct PrintBWCoreParams
|
||||
{
|
||||
template <class TestParams>
|
||||
std::string operator()(const ::testing::TestParamInfo<TestParams>& info) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
using AllParams = Params<bitwiseOp>;
|
||||
const AllParams::params_t& params = info.param;
|
||||
cv::Size sz = AllParams::getCommon<1>(params); // size
|
||||
ss<<BitwiseOperations[AllParams::getSpecific<0>(params)] // bitwiseOp
|
||||
<<"_"<<AllParams::getCommon<0>(params) // type
|
||||
<<"_"<<sz.width
|
||||
<<"x"<<sz.height
|
||||
<<"_"<<AllParams::getCommon<3>(params); // createOutputMatrices
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
struct PrintNormCoreParams
|
||||
{
|
||||
template <class TestParams>
|
||||
std::string operator()(const ::testing::TestParamInfo<TestParams>& info) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
using AllParams = Params<compare_scalar_f,NormTypes>;
|
||||
const AllParams::params_t& params = info.param;
|
||||
cv::Size sz = AllParams::getCommon<1>(params); // size
|
||||
ss<<NormOperations[AllParams::getSpecific<1>(params)] // NormTypes
|
||||
<<"_"<<AllParams::getCommon<0>(params) // type
|
||||
<<"_"<<sz.width
|
||||
<<"x"<<sz.height;
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
CASE(AND);
|
||||
CASE(OR);
|
||||
CASE(XOR);
|
||||
CASE(NOT);
|
||||
default: GAPI_Assert(false && "unknown bitwiseOp value");
|
||||
}
|
||||
#undef CASE
|
||||
return os;
|
||||
}
|
||||
|
||||
GAPI_TEST_FIXTURE(MathOpTest, initMatsRandU, FIXTURE_API(mathOp,bool,double,bool), 4,
|
||||
opType, testWithScalar, scale, doReverseOp)
|
||||
@@ -133,9 +79,9 @@ 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,
|
||||
GAPI_TEST_FIXTURE(SumTest, initMatrixRandU, FIXTURE_API(CompareScalars), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(AddWeightedTest, initMatsRandU, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NormTest, initMatrixRandU, FIXTURE_API(CompareScalars,NormTypes), 2,
|
||||
cmpF, opType)
|
||||
GAPI_TEST_FIXTURE(IntegralTest, initNothing, <>, 0)
|
||||
GAPI_TEST_FIXTURE(ThresholdTest, initMatrixRandU, FIXTURE_API(int), 1, tt)
|
||||
@@ -143,11 +89,11 @@ 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,
|
||||
GAPI_TEST_FIXTURE(ResizeTest, initNothing, FIXTURE_API(CompareMats,int,cv::Size), 3,
|
||||
cmpF, interp, sz_out)
|
||||
GAPI_TEST_FIXTURE(ResizePTest, initNothing, FIXTURE_API(compare_f,int,cv::Size), 3,
|
||||
GAPI_TEST_FIXTURE(ResizePTest, initNothing, FIXTURE_API(CompareMats,int,cv::Size), 3,
|
||||
cmpF, interp, sz_out)
|
||||
GAPI_TEST_FIXTURE(ResizeTestFxFy, initNothing, FIXTURE_API(compare_f,int,double,double), 4,
|
||||
GAPI_TEST_FIXTURE(ResizeTestFxFy, initNothing, FIXTURE_API(CompareMats,int,double,double), 4,
|
||||
cmpF, interp, fx, fy)
|
||||
GAPI_TEST_FIXTURE(Merge3Test, initMatsRandU, <>, 0)
|
||||
GAPI_TEST_FIXTURE(Merge4Test, initMatsRandU, <>, 0)
|
||||
@@ -159,11 +105,11 @@ 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,
|
||||
GAPI_TEST_FIXTURE(ConvertToTest, initNothing, FIXTURE_API(CompareMats, 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,
|
||||
GAPI_TEST_FIXTURE(NormalizeTest, initNothing, FIXTURE_API(CompareMats,double,double,int,MatType2), 5,
|
||||
cmpF, a, b, norm_type, ddepth)
|
||||
struct BackendOutputAllocationTest : TestWithParamBase<>
|
||||
{
|
||||
|
||||
@@ -269,7 +269,7 @@ TEST_P(Polar2CartTest, AccuracyTest)
|
||||
{
|
||||
cv::Mat out_mat2;
|
||||
cv::Mat out_mat_ocv2;
|
||||
if(createOutputMatrices)
|
||||
if (dtype != -1)
|
||||
{
|
||||
out_mat2 = cv::Mat(sz, dtype);
|
||||
out_mat_ocv2 = cv::Mat(sz, dtype);
|
||||
@@ -808,7 +808,8 @@ TEST_P(Split4Test, AccuracyTest)
|
||||
}
|
||||
}
|
||||
|
||||
static void ResizeAccuracyTest(compare_f cmpF, int type, int interp, cv::Size sz_in, cv::Size sz_out, double fx, double fy, cv::GCompileArgs&& compile_args)
|
||||
static void ResizeAccuracyTest(const CompareMats& cmpF, int type, int interp, cv::Size sz_in,
|
||||
cv::Size sz_out, double fx, double fy, cv::GCompileArgs&& compile_args)
|
||||
{
|
||||
cv::Mat in_mat1 (sz_in, type );
|
||||
cv::Scalar mean = cv::Scalar::all(127);
|
||||
@@ -978,7 +979,7 @@ TEST_P(FlipTest, AccuracyTest)
|
||||
TEST_P(CropTest, AccuracyTest)
|
||||
{
|
||||
cv::Size sz_out = cv::Size(rect_to.width, rect_to.height);
|
||||
if(createOutputMatrices)
|
||||
if (dtype != -1)
|
||||
{
|
||||
out_mat_gapi = cv::Mat(sz_out, dtype);
|
||||
out_mat_ocv = cv::Mat(sz_out, dtype);
|
||||
@@ -1247,7 +1248,7 @@ TEST_P(SqrtTest, AccuracyTest)
|
||||
|
||||
TEST_P(NormalizeTest, Test)
|
||||
{
|
||||
initMatrixRandN(type, sz, CV_MAKETYPE(ddepth, CV_MAT_CN(type)), createOutputMatrices);
|
||||
initMatrixRandN(type, sz, CV_MAKETYPE(ddepth, CV_MAT_CN(type)));
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
|
||||
@@ -14,45 +14,45 @@
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
GAPI_TEST_FIXTURE(Filter2DTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
|
||||
GAPI_TEST_FIXTURE(Filter2DTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
|
||||
cmpF, kernSize, borderType)
|
||||
GAPI_TEST_FIXTURE(BoxFilterTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
|
||||
GAPI_TEST_FIXTURE(BoxFilterTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
|
||||
cmpF, filterSize, borderType)
|
||||
GAPI_TEST_FIXTURE(SepFilterTest, initMatrixRandN, FIXTURE_API(compare_f,int), 2, cmpF, kernSize)
|
||||
GAPI_TEST_FIXTURE(BlurTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
|
||||
GAPI_TEST_FIXTURE(SepFilterTest, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, kernSize)
|
||||
GAPI_TEST_FIXTURE(BlurTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
|
||||
cmpF, filterSize, borderType)
|
||||
GAPI_TEST_FIXTURE(GaussianBlurTest, initMatrixRandN, FIXTURE_API(compare_f,int), 2, cmpF, kernSize)
|
||||
GAPI_TEST_FIXTURE(MedianBlurTest, initMatrixRandN, FIXTURE_API(compare_f,int), 2, cmpF, kernSize)
|
||||
GAPI_TEST_FIXTURE(ErodeTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
|
||||
GAPI_TEST_FIXTURE(GaussianBlurTest, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, kernSize)
|
||||
GAPI_TEST_FIXTURE(MedianBlurTest, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, kernSize)
|
||||
GAPI_TEST_FIXTURE(ErodeTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
|
||||
cmpF, kernSize, kernType)
|
||||
GAPI_TEST_FIXTURE(Erode3x3Test, initMatrixRandN, FIXTURE_API(compare_f,int), 2,
|
||||
GAPI_TEST_FIXTURE(Erode3x3Test, initMatrixRandN, FIXTURE_API(CompareMats,int), 2,
|
||||
cmpF, numIters)
|
||||
GAPI_TEST_FIXTURE(DilateTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
|
||||
GAPI_TEST_FIXTURE(DilateTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
|
||||
cmpF, kernSize, kernType)
|
||||
GAPI_TEST_FIXTURE(Dilate3x3Test, initMatrixRandN, FIXTURE_API(compare_f,int), 2, cmpF, numIters)
|
||||
GAPI_TEST_FIXTURE(SobelTest, initMatrixRandN, FIXTURE_API(compare_f,int,int,int), 4,
|
||||
GAPI_TEST_FIXTURE(Dilate3x3Test, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, numIters)
|
||||
GAPI_TEST_FIXTURE(SobelTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int,int), 4,
|
||||
cmpF, kernSize, dx, dy)
|
||||
GAPI_TEST_FIXTURE(SobelXYTest, initMatrixRandN, FIXTURE_API(compare_f,int,int,int,int), 5,
|
||||
GAPI_TEST_FIXTURE(SobelXYTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int,int,int), 5,
|
||||
cmpF, kernSize, order, border_type, border_val)
|
||||
GAPI_TEST_FIXTURE(EqHistTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(CannyTest, initMatrixRandN, FIXTURE_API(compare_f,double,double,int,bool), 5,
|
||||
GAPI_TEST_FIXTURE(EqHistTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(CannyTest, initMatrixRandN, FIXTURE_API(CompareMats,double,double,int,bool), 5,
|
||||
cmpF, thrLow, thrUp, apSize, l2gr)
|
||||
GAPI_TEST_FIXTURE(RGB2GrayTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BGR2GrayTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2YUVTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(YUV2RGBTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toRGBTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toBGRpTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toRGBpTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toBGRTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2LabTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BGR2LUVTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(LUV2BGRTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BGR2YUVTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(YUV2BGRTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2HSVTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BayerGR2RGBTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2YUV422Test, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BGR2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2YUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(YUV2RGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toRGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toBGRpTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toRGBpTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(NV12toBGRTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2LabTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BGR2LUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(LUV2BGRTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BGR2YUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(YUV2BGRTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2HSVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(BayerGR2RGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(RGB2YUV422Test, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
} // opencv_test
|
||||
|
||||
#endif //OPENCV_GAPI_IMGPROC_TESTS_HPP
|
||||
|
||||
@@ -185,9 +185,9 @@ g_api_ocv_pair_mat_mat opXor = {std::string{"operator^"},
|
||||
} // anonymous namespace
|
||||
|
||||
GAPI_TEST_FIXTURE(MathOperatorMatScalarTest, initMatsRandU,
|
||||
FIXTURE_API(compare_f, g_api_ocv_pair_mat_scalar), 2, cmpF, op)
|
||||
FIXTURE_API(CompareMats, 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)
|
||||
FIXTURE_API(CompareMats, g_api_ocv_pair_mat_mat), 2, cmpF, op)
|
||||
GAPI_TEST_FIXTURE(NotOperatorTest, initMatrixRandU, <>, 0)
|
||||
} // opencv_test
|
||||
|
||||
|
||||
@@ -132,15 +132,33 @@ using compare_f = std::function<bool(const cv::Mat &a, const cv::Mat &b)>;
|
||||
|
||||
using compare_scalar_f = std::function<bool(const cv::Scalar &a, const cv::Scalar &b)>;
|
||||
|
||||
// FIXME: re-use MatType. current problem: "special values" interpreted incorrectly (-1 is printed
|
||||
// as 16FC512)
|
||||
struct MatType2
|
||||
{
|
||||
public:
|
||||
MatType2(int val = 0) : _value(val) {}
|
||||
operator int() const { return _value; }
|
||||
friend std::ostream& operator<<(std::ostream& os, const MatType2& t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case -1: return os << "SAME_TYPE";
|
||||
default: PrintTo(MatType(t), &os); return os;
|
||||
}
|
||||
}
|
||||
private:
|
||||
int _value;
|
||||
};
|
||||
|
||||
// Universal parameter wrapper for common (pre-defined) and specific (user-defined) parameters
|
||||
template<typename ...SpecificParams>
|
||||
struct Params
|
||||
{
|
||||
using gcomp_args_function_t = cv::GCompileArgs(*)();
|
||||
// TODO: delete bool (createOutputMatrices) from common parameters
|
||||
using common_params_t = std::tuple<int, cv::Size, int, bool, gcomp_args_function_t>;
|
||||
using common_params_t = std::tuple<MatType2, cv::Size, MatType2, gcomp_args_function_t>;
|
||||
using specific_params_t = std::tuple<SpecificParams...>;
|
||||
using params_t = std::tuple<int, cv::Size, int, bool, gcomp_args_function_t, SpecificParams...>;
|
||||
using params_t = std::tuple<MatType2, cv::Size, MatType2, gcomp_args_function_t, SpecificParams...>;
|
||||
static constexpr const size_t common_params_size = std::tuple_size<common_params_t>::value;
|
||||
static constexpr const size_t specific_params_size = std::tuple_size<specific_params_t>::value;
|
||||
|
||||
@@ -170,15 +188,9 @@ struct TestWithParamBase : TestFunctional,
|
||||
{
|
||||
using AllParams = Params<SpecificParams...>;
|
||||
|
||||
MatType type = getCommonParam<0>();
|
||||
MatType2 type = getCommonParam<0>();
|
||||
cv::Size sz = getCommonParam<1>();
|
||||
MatType dtype = getCommonParam<2>();
|
||||
bool createOutputMatrices = getCommonParam<3>();
|
||||
|
||||
TestWithParamBase()
|
||||
{
|
||||
if (dtype == SAME_TYPE) { dtype = type; }
|
||||
}
|
||||
MatType2 dtype = getCommonParam<2>();
|
||||
|
||||
// Get common (pre-defined) parameter value by index
|
||||
template<size_t I>
|
||||
@@ -199,7 +211,7 @@ struct TestWithParamBase : TestFunctional,
|
||||
// Return G-API compile arguments specified for test fixture
|
||||
inline cv::GCompileArgs getCompileArgs() const
|
||||
{
|
||||
return getCommonParam<4>()();
|
||||
return getCommonParam<3>()();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -220,13 +232,35 @@ struct TestWithParamBase : TestFunctional,
|
||||
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); } \
|
||||
Fixture() { InitF(type, sz, dtype); } \
|
||||
};
|
||||
|
||||
// Wrapper for test fixture API. Use to specify multiple types.
|
||||
// Example: FIXTURE_API(int, bool) expands to <int, bool>
|
||||
#define FIXTURE_API(...) <__VA_ARGS__>
|
||||
|
||||
template<typename T1, typename T2>
|
||||
struct CompareF
|
||||
{
|
||||
using callable_t = std::function<bool(const T1& a, const T2& b)>;
|
||||
CompareF(callable_t&& cmp, std::string&& cmp_name) :
|
||||
_comparator(std::move(cmp)), _name(std::move(cmp_name)) {}
|
||||
bool operator()(const T1& a, const T2& b) const
|
||||
{
|
||||
return _comparator(a, b);
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const CompareF<T1, T2>& obj)
|
||||
{
|
||||
return os << obj._name;
|
||||
}
|
||||
private:
|
||||
callable_t _comparator;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
using CompareMats = CompareF<cv::Mat, cv::Mat>;
|
||||
using CompareScalars = CompareF<cv::Scalar, cv::Scalar>;
|
||||
|
||||
template<typename T>
|
||||
struct Wrappable
|
||||
{
|
||||
@@ -238,6 +272,14 @@ struct Wrappable
|
||||
return t(a, b);
|
||||
};
|
||||
}
|
||||
|
||||
CompareMats to_compare_obj()
|
||||
{
|
||||
T t = *static_cast<T*const>(this);
|
||||
std::stringstream ss;
|
||||
ss << t;
|
||||
return CompareMats(to_compare_f(), ss.str());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -251,6 +293,14 @@ struct WrappableScalar
|
||||
return t(a, b);
|
||||
};
|
||||
}
|
||||
|
||||
CompareScalars to_compare_obj()
|
||||
{
|
||||
T t = *static_cast<T*const>(this);
|
||||
std::stringstream ss;
|
||||
ss << t;
|
||||
return CompareScalars(to_compare_f(), ss.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -270,7 +320,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private:
|
||||
friend std::ostream& operator<<(std::ostream& os, const AbsExact&)
|
||||
{
|
||||
return os << "AbsExact()";
|
||||
}
|
||||
};
|
||||
|
||||
class AbsTolerance : public Wrappable<AbsTolerance>
|
||||
@@ -290,6 +343,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const AbsTolerance& obj)
|
||||
{
|
||||
return os << "AbsTolerance(" << std::to_string(obj._tol) << ")";
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
};
|
||||
@@ -318,6 +375,10 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const Tolerance_FloatRel_IntAbs& obj)
|
||||
{
|
||||
return os << "Tolerance_FloatRel_IntAbs(" << obj._tol << ", " << obj._tol8u << ")";
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
double _tol8u;
|
||||
@@ -347,6 +408,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const AbsSimilarPoints& obj)
|
||||
{
|
||||
return os << "AbsSimilarPoints(" << obj._tol << ", " << obj._percent << ")";
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
double _percent;
|
||||
@@ -379,6 +444,11 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const ToleranceFilter& obj)
|
||||
{
|
||||
return os << "ToleranceFilter(" << obj._tol << ", " << obj._tol8u << ", "
|
||||
<< obj._inf_tol << ")";
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
double _tol8u;
|
||||
@@ -407,6 +477,10 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const ToleranceColor& obj)
|
||||
{
|
||||
return os << "ToleranceColor(" << obj._tol << ", " << obj._inf_tol << ")";
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
double _inf_tol;
|
||||
@@ -429,26 +503,66 @@ public:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const AbsToleranceScalar& obj)
|
||||
{
|
||||
return os << "AbsToleranceScalar(" << std::to_string(obj._tol) << ")";
|
||||
}
|
||||
private:
|
||||
double _tol;
|
||||
};
|
||||
|
||||
} // namespace opencv_test
|
||||
|
||||
namespace
|
||||
{
|
||||
inline std::ostream& operator<<(std::ostream& os, const opencv_test::compare_f&)
|
||||
{
|
||||
return os << "compare_f";
|
||||
}
|
||||
inline std::ostream& operator<<(std::ostream& os, const opencv_test::compare_f&)
|
||||
{
|
||||
return os << "compare_f";
|
||||
}
|
||||
|
||||
namespace
|
||||
inline std::ostream& operator<<(std::ostream& os, const opencv_test::compare_scalar_f&)
|
||||
{
|
||||
inline std::ostream& operator<<(std::ostream& os, const opencv_test::compare_scalar_f&)
|
||||
{
|
||||
return os << "compare_scalar_f";
|
||||
}
|
||||
return os << "compare_scalar_f";
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
// Note: namespace must match the namespace of the type of the printed object
|
||||
namespace cv
|
||||
{
|
||||
inline std::ostream& operator<<(std::ostream& os, CmpTypes op)
|
||||
{
|
||||
#define CASE(v) case CmpTypes::v: os << #v; break
|
||||
switch (op)
|
||||
{
|
||||
CASE(CMP_EQ);
|
||||
CASE(CMP_GT);
|
||||
CASE(CMP_GE);
|
||||
CASE(CMP_LT);
|
||||
CASE(CMP_LE);
|
||||
CASE(CMP_NE);
|
||||
default: GAPI_Assert(false && "unknown CmpTypes value");
|
||||
}
|
||||
#undef CASE
|
||||
return os;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, NormTypes op)
|
||||
{
|
||||
#define CASE(v) case NormTypes::v: os << #v; break
|
||||
switch (op)
|
||||
{
|
||||
CASE(NORM_INF);
|
||||
CASE(NORM_L1);
|
||||
CASE(NORM_L2);
|
||||
CASE(NORM_L2SQR);
|
||||
CASE(NORM_HAMMING);
|
||||
CASE(NORM_HAMMING2);
|
||||
CASE(NORM_RELATIVE);
|
||||
CASE(NORM_MINMAX);
|
||||
default: GAPI_Assert(false && "unknown NormTypes value");
|
||||
}
|
||||
#undef CASE
|
||||
return os;
|
||||
}
|
||||
} // namespace cv
|
||||
|
||||
#endif //OPENCV_GAPI_TESTS_COMMON_HPP
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
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<int>::max()
|
||||
};
|
||||
|
||||
// Ensure correct __VA_ARGS__ expansion on Windows
|
||||
#define __WRAP_VAARGS(x) x
|
||||
|
||||
|
||||
Reference in New Issue
Block a user