diff --git a/modules/ocl/perf/perf_arithm.cpp b/modules/ocl/perf/perf_arithm.cpp index 2699b44a78..3faedfcc7f 100644 --- a/modules/ocl/perf/perf_arithm.cpp +++ b/modules/ocl/perf/perf_arithm.cpp @@ -54,22 +54,20 @@ using std::tr1::tuple; typedef Size_MatType LUTFixture; -PERF_TEST_P(LUTFixture, LUT, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC3))) +OCL_PERF_TEST_P(LUTFixture, LUT, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) { // getting params const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const int type = get<1>(params), cn = CV_MAT_CN(type); // creating src data - Mat src(srcSize, type), lut(1, 256, CV_8UC1); + Mat src(srcSize, CV_8UC(cn)), lut(1, 256, type); int dstType = CV_MAKETYPE(lut.depth(), src.channels()); Mat dst(srcSize, dstType); - randu(lut, 0, 2); - declare.in(src, WARMUP_RNG).in(lut).out(dst); + declare.in(src, lut, WARMUP_RNG).out(dst); // select implementation if (RUN_OCL_IMPL) @@ -93,16 +91,19 @@ PERF_TEST_P(LUTFixture, LUT, ///////////// Exp //////////////////////// -typedef TestBaseWithParam ExpFixture; +typedef Size_MatType ExpFixture; -PERF_TEST_P(ExpFixture, Exp, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(ExpFixture, Exp, ::testing::Combine( + OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { // getting params - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); const double eps = 1e-6; // creating src data - Mat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); + Mat src(srcSize, type), dst(srcSize, type); declare.in(src).out(dst); randu(src, 5, 16); @@ -125,18 +126,21 @@ PERF_TEST_P(ExpFixture, Exp, OCL_TYPICAL_MAT_SIZES) SANITY_CHECK(dst, eps, ERROR_RELATIVE); } -///////////// LOG //////////////////////// +///////////// Log //////////////////////// -typedef TestBaseWithParam LogFixture; +typedef Size_MatType LogFixture; -PERF_TEST_P(LogFixture, Log, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(LogFixture, Log, ::testing::Combine( + OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { // getting params - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); const double eps = 1e-6; // creating src data - Mat src(srcSize, CV_32F), dst(srcSize, src.type()); + Mat src(srcSize, type), dst(srcSize, type); randu(src, 1, 10); declare.in(src).out(dst); @@ -166,9 +170,8 @@ PERF_TEST_P(LogFixture, Log, OCL_TYPICAL_MAT_SIZES) typedef Size_MatType AddFixture; -PERF_TEST_P(AddFixture, Add, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +OCL_PERF_TEST_P(AddFixture, Add, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { // getting params const Size_MatType_t params = GetParam(); @@ -202,12 +205,51 @@ PERF_TEST_P(AddFixture, Add, OCL_PERF_ELSE } +///////////// Subtract //////////////////////// + +typedef Size_MatType SubtractFixture; + +OCL_PERF_TEST_P(SubtractFixture, Subtract, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) +{ + // getting params + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + // creating src data + Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type); + randu(src1, 0, 1); + randu(src2, 0, 1); + declare.in(src1, src2).out(dst); + + // select implementation + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, type); + + OCL_TEST_CYCLE() cv::ocl::subtract(oclSrc1, oclSrc2, oclDst); + + oclDst.download(dst); + + SANITY_CHECK(dst); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::subtract(src1, src2, dst); + + SANITY_CHECK(dst); + } + else + OCL_PERF_ELSE +} + + ///////////// Mul //////////////////////// typedef Size_MatType MulFixture; -PERF_TEST_P(MulFixture, Mul, ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(MulFixture, Multiply, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { // getting params const Size_MatType_t params = GetParam(); @@ -245,9 +287,8 @@ PERF_TEST_P(MulFixture, Mul, ::testing::Combine(OCL_TYPICAL_MAT_SIZES, typedef Size_MatType DivFixture; -PERF_TEST_P(DivFixture, Div, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(DivFixture, Divide, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { // getting params const Size_MatType_t params = GetParam(); @@ -260,12 +301,6 @@ PERF_TEST_P(DivFixture, Div, randu(src1, 0, 256); randu(src2, 0, 256); - if ((srcSize == OCL_SIZE_4000 && type == CV_8UC1) || - (srcSize == OCL_SIZE_2000 && type == CV_8UC4)) - declare.time(4.2); - else if (srcSize == OCL_SIZE_4000 && type == CV_8UC4) - declare.time(16.6); - // select implementation if (RUN_OCL_IMPL) { @@ -275,13 +310,13 @@ PERF_TEST_P(DivFixture, Div, oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); } else if (RUN_PLAIN_IMPL) { TEST_CYCLE() cv::divide(src1, src2, dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); } else OCL_PERF_ELSE @@ -291,9 +326,8 @@ PERF_TEST_P(DivFixture, Div, typedef Size_MatType AbsDiffFixture; -PERF_TEST_P(AbsDiffFixture, Absdiff, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(AbsDiffFixture, Absdiff, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -326,15 +360,18 @@ PERF_TEST_P(AbsDiffFixture, Absdiff, ///////////// CartToPolar //////////////////////// -typedef TestBaseWithParam CartToPolarFixture; +typedef Size_MatType CartToPolarFixture; -PERF_TEST_P(CartToPolarFixture, CartToPolar, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(CartToPolarFixture, CartToPolar, ::testing::Combine( + OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); const double eps = 8e-3; - Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), - dst1(srcSize, CV_32FC1), dst2(srcSize, CV_32FC1); + Mat src1(srcSize, type), src2(srcSize, type), + dst1(srcSize, type), dst2(srcSize, type); declare.in(src1, src2).out(dst1, dst2); randu(src1, 0, 256); randu(src2, 0, 256); @@ -368,14 +405,17 @@ PERF_TEST_P(CartToPolarFixture, CartToPolar, OCL_TYPICAL_MAT_SIZES) ///////////// PolarToCart //////////////////////// -typedef TestBaseWithParam PolarToCartFixture; +typedef Size_MatType PolarToCartFixture; -PERF_TEST_P(PolarToCartFixture, PolarToCart, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(PolarToCartFixture, PolarToCart, ::testing::Combine( + OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); - Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), - dst1(srcSize, CV_32FC1), dst2(srcSize, CV_32FC1); + Mat src1(srcSize, type), src2(srcSize, type), + dst1(srcSize, type), dst2(srcSize, type); declare.in(src1, src2).out(dst1, dst2); randu(src1, 0, 256); randu(src2, 0, 256); @@ -409,14 +449,17 @@ PERF_TEST_P(PolarToCartFixture, PolarToCart, OCL_TYPICAL_MAT_SIZES) ///////////// Magnitude //////////////////////// -typedef TestBaseWithParam MagnitudeFixture; +typedef Size_MatType MagnitudeFixture; -PERF_TEST_P(MagnitudeFixture, Magnitude, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(MagnitudeFixture, Magnitude, ::testing::Combine( + OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); - Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), - dst(srcSize, CV_32FC1); + Mat src1(srcSize, type), src2(srcSize, type), + dst(srcSize, type); randu(src1, 0, 1); randu(src2, 0, 1); declare.in(src1, src2).out(dst); @@ -446,9 +489,8 @@ PERF_TEST_P(MagnitudeFixture, Magnitude, OCL_TYPICAL_MAT_SIZES) typedef Size_MatType TransposeFixture; -PERF_TEST_P(TransposeFixture, Transpose, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(TransposeFixture, Transpose, ::testing::Combine( + OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -479,15 +521,24 @@ PERF_TEST_P(TransposeFixture, Transpose, ///////////// Flip //////////////////////// -typedef Size_MatType FlipFixture; +enum +{ + FLIP_BOTH = 0, FLIP_ROWS, FLIP_COLS +}; + +CV_ENUM(FlipType, FLIP_BOTH, FLIP_ROWS, FLIP_COLS) -PERF_TEST_P(FlipFixture, Flip, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +typedef std::tr1::tuple FlipParams; +typedef TestBaseWithParam FlipFixture; + +OCL_PERF_TEST_P(FlipFixture, Flip, + ::testing::Combine(OCL_TEST_SIZES, + OCL_TEST_TYPES, FlipType::all())) { - const Size_MatType_t params = GetParam(); + const FlipParams params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params); + const int flipType = get<2>(params); Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); @@ -496,7 +547,7 @@ PERF_TEST_P(FlipFixture, Flip, { ocl::oclMat oclSrc(src), oclDst(srcSize, type); - OCL_TEST_CYCLE() cv::ocl::flip(oclSrc, oclDst, 0); + OCL_TEST_CYCLE() cv::ocl::flip(oclSrc, oclDst, flipType - 1); oclDst.download(dst); @@ -504,7 +555,7 @@ PERF_TEST_P(FlipFixture, Flip, } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() cv::flip(src, dst, 0); + TEST_CYCLE() cv::flip(src, dst, flipType - 1); SANITY_CHECK(dst); } @@ -512,169 +563,18 @@ PERF_TEST_P(FlipFixture, Flip, OCL_PERF_ELSE } -///////////// minMax //////////////////////// - -typedef Size_MatType minMaxFixture; - -PERF_TEST_P(minMaxFixture, minMax, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) -{ - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - - Mat src(srcSize, type); - declare.in(src, WARMUP_RNG); - - double min_val = std::numeric_limits::max(), - max_val = std::numeric_limits::min(); - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc(src); - - OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val); - - ASSERT_GE(max_val, min_val); - SANITY_CHECK(min_val); - SANITY_CHECK(max_val); - } - else if (RUN_PLAIN_IMPL) - { - Point min_loc, max_loc; - - TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); - - ASSERT_GE(max_val, min_val); - SANITY_CHECK(min_val); - SANITY_CHECK(max_val); - } - else - OCL_PERF_ELSE -} - -///////////// minMaxLoc //////////////////////// - -typedef Size_MatType minMaxLocFixture; - -PERF_TEST_P(minMaxLocFixture, minMaxLoc, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) -{ - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - - Mat src(srcSize, type); - randu(src, 0, 1); - declare.in(src); - - double min_val = 0.0, max_val = 0.0; - Point min_loc, max_loc; - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc(src); - - OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc); - - ASSERT_GE(max_val, min_val); - SANITY_CHECK(min_val); - SANITY_CHECK(max_val); - } - else if (RUN_PLAIN_IMPL) - { - TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); - - ASSERT_GE(max_val, min_val); - SANITY_CHECK(min_val); - SANITY_CHECK(max_val); - } - else - OCL_PERF_ELSE -} - -///////////// Sum //////////////////////// - -typedef Size_MatType SumFixture; - -PERF_TEST_P(SumFixture, Sum, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32SC1))) -{ - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - - Mat src(srcSize, type); - Scalar result; - randu(src, 0, 60); - declare.in(src); - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc(src); - - OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc); - - SANITY_CHECK(result); - } - else if (RUN_PLAIN_IMPL) - { - TEST_CYCLE() result = cv::sum(src); - - SANITY_CHECK(result); - } - else - OCL_PERF_ELSE -} - -///////////// countNonZero //////////////////////// +///////////// Phase //////////////////////// -typedef Size_MatType countNonZeroFixture; +typedef Size_MatType PhaseFixture; -PERF_TEST_P(countNonZeroFixture, countNonZero, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +OCL_PERF_TEST_P(PhaseFixture, Phase, ::testing::Combine( + OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params); - Mat src(srcSize, type); - int result = 0; - randu(src, 0, 256); - declare.in(src); - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc(src); - - OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc); - - SANITY_CHECK(result); - } - else if (RUN_PLAIN_IMPL) - { - TEST_CYCLE() result = cv::countNonZero(src); - - SANITY_CHECK(result); - } - else - OCL_PERF_ELSE -} - -///////////// Phase //////////////////////// - -typedef TestBaseWithParam PhaseFixture; - -PERF_TEST_P(PhaseFixture, Phase, OCL_TYPICAL_MAT_SIZES) -{ - const Size srcSize = GetParam(); - - Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), - dst(srcSize, CV_32FC1); + Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, type); declare.in(src1, src2).out(dst); randu(src1, 0, 256); randu(src2, 0, 256); @@ -704,9 +604,8 @@ PERF_TEST_P(PhaseFixture, Phase, OCL_TYPICAL_MAT_SIZES) typedef Size_MatType BitwiseAndFixture; -PERF_TEST_P(BitwiseAndFixture, bitwise_and, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32SC1))) +OCL_PERF_TEST_P(BitwiseAndFixture, Bitwise_and, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -741,9 +640,8 @@ PERF_TEST_P(BitwiseAndFixture, bitwise_and, typedef Size_MatType BitwiseXorFixture; -PERF_TEST_P(BitwiseXorFixture, bitwise_xor, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32SC1))) +OCL_PERF_TEST_P(BitwiseXorFixture, Bitwise_xor, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -778,9 +676,8 @@ PERF_TEST_P(BitwiseXorFixture, bitwise_xor, typedef Size_MatType BitwiseOrFixture; -PERF_TEST_P(BitwiseOrFixture, bitwise_or, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32SC1))) +OCL_PERF_TEST_P(BitwiseOrFixture, Bitwise_or, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -798,26 +695,25 @@ PERF_TEST_P(BitwiseOrFixture, bitwise_or, OCL_TEST_CYCLE() cv::ocl::bitwise_or(oclSrc1, oclSrc2, oclDst); oclDst.download(dst); - - SANITY_CHECK(dst); } else if (RUN_PLAIN_IMPL) { TEST_CYCLE() cv::bitwise_or(src1, src2, dst); - - SANITY_CHECK(dst); } else OCL_PERF_ELSE + + if (CV_MAT_DEPTH(type) >= CV_32F) + cv::patchNaNs(dst, 17); + SANITY_CHECK(dst); } ///////////// bitwise_not//////////////////////// typedef Size_MatType BitwiseNotFixture; -PERF_TEST_P(BitwiseAndFixture, bitwise_not, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32SC1))) +OCL_PERF_TEST_P(BitwiseNotFixture, Bitwise_not, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -846,18 +742,57 @@ PERF_TEST_P(BitwiseAndFixture, bitwise_not, OCL_PERF_ELSE } -///////////// compare//////////////////////// +///////////// SetIdentity //////////////////////// -typedef Size_MatType CompareFixture; +typedef Size_MatType SetIdentityFixture; -PERF_TEST_P(CompareFixture, compare, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +OCL_PERF_TEST_P(SetIdentityFixture, SetIdentity, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params); + Mat src(srcSize, type); + Scalar s = Scalar::all(17); + declare.in(src, WARMUP_RNG).out(src); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() cv::ocl::setIdentity(oclSrc, s); + + oclSrc.download(src); + + SANITY_CHECK(src); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::setIdentity(src, s); + + SANITY_CHECK(src); + } + else + OCL_PERF_ELSE +} + +///////////// compare//////////////////////// + +CV_ENUM(CmpCode, CMP_LT, CMP_LE, CMP_EQ, CMP_NE, CMP_GE, CMP_GT) + +typedef std::tr1::tuple CompareParams; +typedef TestBaseWithParam CompareFixture; + +OCL_PERF_TEST_P(CompareFixture, Compare, + ::testing::Combine(OCL_TEST_SIZES, + OCL_PERF_ENUM(CV_8UC1, CV_32FC1), CmpCode::all())) +{ + const CompareParams params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + const int cmpCode = get<2>(params); + Mat src1(srcSize, type), src2(srcSize, type), dst(srcSize, CV_8UC1); declare.in(src1, src2, WARMUP_RNG).out(dst); @@ -865,7 +800,7 @@ PERF_TEST_P(CompareFixture, compare, { ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, CV_8UC1); - OCL_TEST_CYCLE() cv::ocl::compare(oclSrc1, oclSrc2, oclDst, CMP_EQ); + OCL_TEST_CYCLE() cv::ocl::compare(oclSrc1, oclSrc2, oclDst, cmpCode); oclDst.download(dst); @@ -873,7 +808,7 @@ PERF_TEST_P(CompareFixture, compare, } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() cv::compare(src1, src2, dst, CMP_EQ); + TEST_CYCLE() cv::compare(src1, src2, dst, cmpCode); SANITY_CHECK(dst); } @@ -883,14 +818,17 @@ PERF_TEST_P(CompareFixture, compare, ///////////// pow //////////////////////// -typedef TestBaseWithParam PowFixture; +typedef Size_MatType PowFixture; -PERF_TEST_P(PowFixture, pow, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(PowFixture, Pow, ::testing::Combine( + OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); const double eps = 1e-6; - Mat src(srcSize, CV_32F), dst(srcSize, CV_32F); + Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); if (RUN_OCL_IMPL) @@ -915,9 +853,8 @@ PERF_TEST_P(PowFixture, pow, OCL_TYPICAL_MAT_SIZES) typedef Size_MatType AddWeightedFixture; -PERF_TEST_P(AddWeightedFixture, AddWeighted, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +OCL_PERF_TEST_P(AddWeightedFixture, AddWeighted, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -951,9 +888,8 @@ PERF_TEST_P(AddWeightedFixture, AddWeighted, typedef Size_MatType MinFixture; -PERF_TEST_P(MinFixture, Min, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +OCL_PERF_TEST_P(MinFixture, Min, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -986,9 +922,8 @@ PERF_TEST_P(MinFixture, Min, typedef Size_MatType MaxFixture; -PERF_TEST_P(MaxFixture, Max, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +OCL_PERF_TEST_P(MaxFixture, Max, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -1017,7 +952,7 @@ PERF_TEST_P(MaxFixture, Max, OCL_PERF_ELSE } -///////////// Max //////////////////////// +///////////// Abs //////////////////////// typedef Size_MatType AbsFixture; @@ -1056,9 +991,9 @@ PERF_TEST_P(AbsFixture, Abs, typedef Size_MatType RepeatFixture; -PERF_TEST_P(RepeatFixture, Repeat, - ::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000), - OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4))) +OCL_PERF_TEST_P(RepeatFixture, Repeat, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); diff --git a/modules/ocl/perf/perf_bgfg.cpp b/modules/ocl/perf/perf_bgfg.cpp index b361a9232a..c2a1941e9b 100644 --- a/modules/ocl/perf/perf_bgfg.cpp +++ b/modules/ocl/perf/perf_bgfg.cpp @@ -165,11 +165,11 @@ PERF_TEST_P(VideoMOGFixture, MOG, ///////////// MOG2 //////////////////////// typedef tuple VideoMOG2ParamType; -typedef TestBaseWithParam VideoMOG2Fixture; +typedef TestBaseWithParam MOG2_Apply; -PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on buildslave - ::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), - ::testing::Values(1, 3))) +OCL_PERF_TEST_P(MOG2_Apply, Mog2, + testing::Combine(testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), + testing::Values(1, 3))) { VideoMOG2ParamType params = GetParam(); @@ -195,9 +195,7 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b foreground.release(); for (int i = 0; i < nFrame; i++) - { mog2(frame_buffer[i], foreground); - } } SANITY_CHECK(foreground); } @@ -210,9 +208,7 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b cv::ocl::MOG2 d_mog2; foreground_d.release(); for (int i = 0; i < nFrame; i++) - { d_mog2(frame_buffer_ocl[i], foreground_d); - } } foreground_d.download(foreground); SANITY_CHECK(foreground); @@ -223,11 +219,11 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b ///////////// MOG2_GetBackgroundImage ////////////////// -typedef TestBaseWithParam Video_MOG2GetBackgroundImage; +typedef TestBaseWithParam MOG2_GetBackgroundImage; -PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2, - ::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), - ::testing::Values(3))) +OCL_PERF_TEST_P(MOG2_GetBackgroundImage, Mog2, + testing::Combine(testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), + testing::Values(3))) { VideoMOG2ParamType params = GetParam(); @@ -248,7 +244,7 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2, cv::ocl::oclMat foreground_d; cv::ocl::oclMat background_d; - if(RUN_PLAIN_IMPL) + if (RUN_PLAIN_IMPL) { TEST_CYCLE() { @@ -264,7 +260,7 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2, } SANITY_CHECK(background); } - else if(RUN_OCL_IMPL) + else if (RUN_OCL_IMPL) { prepareData(frame_buffer, frame_buffer_ocl); CV_Assert((int)(frame_buffer_ocl.size()) == nFrame); diff --git a/modules/ocl/perf/perf_blend.cpp b/modules/ocl/perf/perf_blend.cpp index 6f611bbc34..5471dee2e2 100644 --- a/modules/ocl/perf/perf_blend.cpp +++ b/modules/ocl/perf/perf_blend.cpp @@ -88,10 +88,10 @@ typedef void (*blendFunction)(const Mat &img1, const Mat &img2, const Mat &weights1, const Mat &weights2, Mat &result_gold); -typedef Size_MatType blendLinearFixture; +typedef Size_MatType BlendLinearFixture; -PERF_TEST_P(blendLinearFixture, blendLinear, ::testing::Combine( - OCL_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_32FC1))) +OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); diff --git a/modules/ocl/perf/perf_brute_force_matcher.cpp b/modules/ocl/perf/perf_brute_force_matcher.cpp index d124428e9d..b8ad81361b 100644 --- a/modules/ocl/perf/perf_brute_force_matcher.cpp +++ b/modules/ocl/perf/perf_brute_force_matcher.cpp @@ -46,21 +46,23 @@ #include "perf_precomp.hpp" using namespace perf; - -#define OCL_BFMATCHER_TYPICAL_MAT_SIZES ::testing::Values(cv::Size(128, 500), cv::Size(128, 1000), cv::Size(128, 2000)) +using std::tr1::get; //////////////////// BruteForceMatch ///////////////// -typedef TestBaseWithParam BruteForceMatcherFixture; +typedef Size_MatType BruteForceMatcherFixture; -PERF_TEST_P(BruteForceMatcherFixture, match, - OCL_BFMATCHER_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_PERF_ENUM(MatType(CV_32FC1)))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); vector matches; - Mat query(srcSize, CV_32F), train(srcSize, CV_32F); - declare.in(query, train).time(srcSize.height == 2000 ? 9 : 4 ); + Mat query(srcSize, type), train(srcSize, type); + declare.in(query, train); randu(query, 0.0f, 1.0f); randu(train, 0.0f, 1.0f); @@ -75,12 +77,9 @@ PERF_TEST_P(BruteForceMatcherFixture, match, { ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist); ocl::oclMat oclQuery(query), oclTrain(train); - ocl::oclMat oclTrainIdx, oclDistance; OCL_TEST_CYCLE() - oclMatcher.matchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance); - - oclMatcher.matchDownload(oclTrainIdx, oclDistance, matches); + oclMatcher.match(oclQuery, oclTrain, matches); SANITY_CHECK_MATCHES(matches, 1e-5); } @@ -88,19 +87,20 @@ PERF_TEST_P(BruteForceMatcherFixture, match, OCL_PERF_ELSE } -PERF_TEST_P(BruteForceMatcherFixture, knnMatch, - OCL_BFMATCHER_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_PERF_ENUM(MatType(CV_32FC1)))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); vector > matches(2); - Mat query(srcSize, CV_32F), train(srcSize, CV_32F); + Mat query(srcSize, type), train(srcSize, type); randu(query, 0.0f, 1.0f); randu(train, 0.0f, 1.0f); declare.in(query, train); - if (srcSize.height == 2000) - declare.time(9); if (RUN_PLAIN_IMPL) { @@ -115,10 +115,10 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch, { ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist); ocl::oclMat oclQuery(query), oclTrain(train); - ocl::oclMat oclTrainIdx, oclDistance, oclAllDist; + ocl::oclMat oclTrainIdx, oclDistance; OCL_TEST_CYCLE() - oclMatcher.knnMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclAllDist, 2); + oclMatcher.knnMatch(oclQuery, oclTrain, matches, 2); oclMatcher.knnMatchDownload(oclTrainIdx, oclDistance, matches); @@ -130,22 +130,22 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch, OCL_PERF_ELSE } -PERF_TEST_P(BruteForceMatcherFixture, radiusMatch, - OCL_BFMATCHER_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_PERF_ENUM(MatType(CV_32FC1)))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); const float max_distance = 2.0f; vector > matches(2); - Mat query(srcSize, CV_32F), train(srcSize, CV_32F); + Mat query(srcSize, type), train(srcSize, type); declare.in(query, train); randu(query, 0.0f, 1.0f); randu(train, 0.0f, 1.0f); - if (srcSize.height == 2000) - declare.time(9.15); - if (RUN_PLAIN_IMPL) { cv::BFMatcher matcher(NORM_L2); @@ -162,7 +162,7 @@ PERF_TEST_P(BruteForceMatcherFixture, radiusMatch, ocl::oclMat oclTrainIdx, oclDistance, oclNMatches; OCL_TEST_CYCLE() - oclMatcher.radiusMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclNMatches, max_distance); + oclMatcher.radiusMatch(oclQuery, oclTrain, matches, max_distance); oclMatcher.radiusMatchDownload(oclTrainIdx, oclDistance, oclNMatches, matches); @@ -173,5 +173,3 @@ PERF_TEST_P(BruteForceMatcherFixture, radiusMatch, else OCL_PERF_ELSE } - -#undef OCL_BFMATCHER_TYPICAL_MAT_SIZES diff --git a/modules/ocl/perf/perf_canny.cpp b/modules/ocl/perf/perf_canny.cpp index 33723daa32..96c4441513 100644 --- a/modules/ocl/perf/perf_canny.cpp +++ b/modules/ocl/perf/perf_canny.cpp @@ -46,11 +46,21 @@ #include "perf_precomp.hpp" using namespace perf; +using std::tr1::tuple; +using std::tr1::get; ///////////// Canny //////////////////////// -PERF_TEST(CannyFixture, Canny) +typedef tuple CannyParams; +typedef TestBaseWithParam CannyFixture; + +OCL_PERF_TEST_P(CannyFixture, Canny, + ::testing::Combine(OCL_PERF_ENUM(3, 5), testing::Bool())) { + const CannyParams params = GetParam(); + int apertureSize = get<0>(params); + bool L2Grad = get<1>(params); + Mat img = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE), edges(img.size(), CV_8UC1); ASSERT_TRUE(!img.empty()) << "can't open aloe-L.png"; @@ -61,16 +71,15 @@ PERF_TEST(CannyFixture, Canny) { ocl::oclMat oclImg(img), oclEdges(img.size(), CV_8UC1); - OCL_TEST_CYCLE() ocl::Canny(oclImg, oclEdges, 50.0, 100.0); + OCL_TEST_CYCLE() ocl::Canny(oclImg, oclEdges, 50.0, 100.0, apertureSize, L2Grad); oclEdges.download(edges); } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() Canny(img, edges, 50.0, 100.0); + TEST_CYCLE() Canny(img, edges, 50.0, 100.0, apertureSize, L2Grad); } else OCL_PERF_ELSE - int value = 0; - SANITY_CHECK(value); + SANITY_CHECK_NOTHING(); } diff --git a/modules/ocl/perf/perf_color.cpp b/modules/ocl/perf/perf_color.cpp index 8433315189..0797a87fdf 100644 --- a/modules/ocl/perf/perf_color.cpp +++ b/modules/ocl/perf/perf_color.cpp @@ -52,36 +52,36 @@ using std::tr1::make_tuple; ///////////// cvtColor//////////////////////// -CV_ENUM(ConversionTypes, CV_RGB2GRAY, CV_RGB2BGR, CV_RGB2YUV, CV_YUV2RGB, CV_RGB2YCrCb, - CV_YCrCb2RGB, CV_RGB2XYZ, CV_XYZ2RGB, CV_RGB2HSV, CV_HSV2RGB, CV_RGB2HLS, - CV_HLS2RGB, CV_BGR5652BGR, CV_BGR2BGR565, CV_RGBA2mRGBA, CV_mRGBA2RGBA, CV_YUV2RGB_NV12) +CV_ENUM(ConversionTypes, COLOR_RGB2GRAY, COLOR_RGB2BGR, COLOR_RGB2YUV, COLOR_YUV2RGB, COLOR_RGB2YCrCb, + COLOR_YCrCb2RGB, COLOR_RGB2XYZ, COLOR_XYZ2RGB, COLOR_RGB2HSV, COLOR_HSV2RGB, COLOR_RGB2HLS, + COLOR_HLS2RGB, COLOR_BGR5652BGR, COLOR_BGR2BGR565, COLOR_RGBA2mRGBA, COLOR_mRGBA2RGBA, COLOR_YUV2RGB_NV12) -typedef tuple > cvtColorParams; -typedef TestBaseWithParam cvtColorFixture; +typedef tuple > CvtColorParams; +typedef TestBaseWithParam CvtColorFixture; -PERF_TEST_P(cvtColorFixture, cvtColor, testing::Combine( - testing::Values(Size(1000, 1002), Size(2000, 2004), Size(4000, 4008)), +OCL_PERF_TEST_P(CvtColorFixture, CvtColor, testing::Combine( + OCL_TEST_SIZES, testing::Values( - make_tuple(ConversionTypes(CV_RGB2GRAY), 3, 1), - make_tuple(ConversionTypes(CV_RGB2BGR), 3, 3), - make_tuple(ConversionTypes(CV_RGB2YUV), 3, 3), - make_tuple(ConversionTypes(CV_YUV2RGB), 3, 3), - make_tuple(ConversionTypes(CV_RGB2YCrCb), 3, 3), - make_tuple(ConversionTypes(CV_YCrCb2RGB), 3, 3), - make_tuple(ConversionTypes(CV_RGB2XYZ), 3, 3), - make_tuple(ConversionTypes(CV_XYZ2RGB), 3, 3), - make_tuple(ConversionTypes(CV_RGB2HSV), 3, 3), - make_tuple(ConversionTypes(CV_HSV2RGB), 3, 3), - make_tuple(ConversionTypes(CV_RGB2HLS), 3, 3), - make_tuple(ConversionTypes(CV_HLS2RGB), 3, 3), - make_tuple(ConversionTypes(CV_BGR5652BGR), 2, 3), - make_tuple(ConversionTypes(CV_BGR2BGR565), 3, 2), - make_tuple(ConversionTypes(CV_RGBA2mRGBA), 4, 4), - make_tuple(ConversionTypes(CV_mRGBA2RGBA), 4, 4), - make_tuple(ConversionTypes(CV_YUV2RGB_NV12), 1, 3) + make_tuple(ConversionTypes(COLOR_RGB2GRAY), 3, 1), + make_tuple(ConversionTypes(COLOR_RGB2BGR), 3, 3), + make_tuple(ConversionTypes(COLOR_RGB2YUV), 3, 3), + make_tuple(ConversionTypes(COLOR_YUV2RGB), 3, 3), + make_tuple(ConversionTypes(COLOR_RGB2YCrCb), 3, 3), + make_tuple(ConversionTypes(COLOR_YCrCb2RGB), 3, 3), + make_tuple(ConversionTypes(COLOR_RGB2XYZ), 3, 3), + make_tuple(ConversionTypes(COLOR_XYZ2RGB), 3, 3), + make_tuple(ConversionTypes(COLOR_RGB2HSV), 3, 3), + make_tuple(ConversionTypes(COLOR_HSV2RGB), 3, 3), + make_tuple(ConversionTypes(COLOR_RGB2HLS), 3, 3), + make_tuple(ConversionTypes(COLOR_HLS2RGB), 3, 3), + make_tuple(ConversionTypes(COLOR_BGR5652BGR), 2, 3), + make_tuple(ConversionTypes(COLOR_BGR2BGR565), 3, 2), + make_tuple(ConversionTypes(COLOR_RGBA2mRGBA), 4, 4), + make_tuple(ConversionTypes(COLOR_mRGBA2RGBA), 4, 4), + make_tuple(ConversionTypes(COLOR_YUV2RGB_NV12), 1, 3) ))) { - cvtColorParams params = GetParam(); + CvtColorParams params = GetParam(); const Size srcSize = get<0>(params); const tuple conversionParams = get<1>(params); const int code = get<0>(conversionParams), scn = get<1>(conversionParams), diff --git a/modules/ocl/perf/perf_fft.cpp b/modules/ocl/perf/perf_fft.cpp index 49da659361..95701b7dab 100644 --- a/modules/ocl/perf/perf_fft.cpp +++ b/modules/ocl/perf/perf_fft.cpp @@ -47,6 +47,8 @@ #include "perf_precomp.hpp" using namespace perf; +using std::tr1::tuple; +using std::tr1::get; ///////////// dft //////////////////////// @@ -54,22 +56,26 @@ typedef TestBaseWithParam dftFixture; #ifdef HAVE_CLAMDFFT -PERF_TEST_P(dftFixture, dft, OCL_TYPICAL_MAT_SIZES) +typedef tuple DftParams; +typedef TestBaseWithParam DftFixture; + +OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + ::testing::Values((int)DFT_ROWS, (int)DFT_SCALE, (int)DFT_INVERSE, + (int)DFT_INVERSE | DFT_SCALE, (int)DFT_ROWS | DFT_INVERSE))) { - const Size srcSize = GetParam(); + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int flags = get<1>(params); Mat src(srcSize, CV_32FC2), dst; randu(src, 0.0f, 1.0f); declare.in(src); - if (srcSize == OCL_SIZE_4000) - declare.time(7.4); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst; - OCL_TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst); + OCL_TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst, Size(), flags | DFT_COMPLEX_OUTPUT); oclDst.download(dst); @@ -77,7 +83,7 @@ PERF_TEST_P(dftFixture, dft, OCL_TYPICAL_MAT_SIZES) } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() cv::dft(src, dst); + TEST_CYCLE() cv::dft(src, dst, flags | DFT_COMPLEX_OUTPUT); SANITY_CHECK(dst); } diff --git a/modules/ocl/perf/perf_filters.cpp b/modules/ocl/perf/perf_filters.cpp index c625caa474..70e51b4662 100644 --- a/modules/ocl/perf/perf_filters.cpp +++ b/modules/ocl/perf/perf_filters.cpp @@ -49,31 +49,30 @@ using namespace perf; using std::tr1::get; using std::tr1::tuple; +typedef tuple FilterParams; +typedef TestBaseWithParam FilterFixture; + ///////////// Blur//////////////////////// -typedef Size_MatType BlurFixture; +typedef FilterFixture BlurFixture; -PERF_TEST_P(BlurFixture, Blur, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(BlurFixture, Blur, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params), ksize(3, 3); - const int type = get<1>(params), bordertype = BORDER_CONSTANT; + const FilterParams params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), ksize = get<2>(params), bordertype = BORDER_CONSTANT; checkDeviceMaxMemoryAllocSize(srcSize, type); Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - if (srcSize == OCL_SIZE_4000 && type == CV_8UC4) - declare.time(5); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, type); - OCL_TEST_CYCLE() cv::ocl::blur(oclSrc, oclDst, ksize, Point(-1, -1), bordertype); + OCL_TEST_CYCLE() cv::ocl::blur(oclSrc, oclDst, Size(ksize, ksize), Point(-1, -1), bordertype); oclDst.download(dst); @@ -81,7 +80,7 @@ PERF_TEST_P(BlurFixture, Blur, } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() cv::blur(src, dst, ksize, Point(-1, -1), bordertype); + TEST_CYCLE() cv::blur(src, dst, Size(ksize, ksize), Point(-1, -1), bordertype); SANITY_CHECK(dst, 1 + DBL_EPSILON); } @@ -91,24 +90,20 @@ PERF_TEST_P(BlurFixture, Blur, ///////////// Laplacian//////////////////////// -typedef Size_MatType LaplacianFixture; +typedef FilterFixture LaplacianFixture; -PERF_TEST_P(LaplacianFixture, Laplacian, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(LaplacianFixture, Laplacian, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(1, 3))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 3; + const int type = get<1>(params), ksize = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - if (srcSize == OCL_SIZE_4000 && type == CV_8UC4) - declare.time(6); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, type); @@ -117,13 +112,13 @@ PERF_TEST_P(LaplacianFixture, Laplacian, oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 5e-3); } else if (RUN_PLAIN_IMPL) { TEST_CYCLE() cv::Laplacian(src, dst, -1, ksize, 1); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 5e-3); } else OCL_PERF_ELSE @@ -131,15 +126,14 @@ PERF_TEST_P(LaplacianFixture, Laplacian, ///////////// Erode //////////////////// -typedef Size_MatType ErodeFixture; +typedef FilterFixture ErodeFixture; -PERF_TEST_P(ErodeFixture, Erode, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4))) +OCL_PERF_TEST_P(ErodeFixture, Erode, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 3; + const int type = get<1>(params), ksize = get<2>(params); const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -147,9 +141,6 @@ PERF_TEST_P(ErodeFixture, Erode, Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst).in(ker); - if (srcSize == OCL_SIZE_4000 && type == CV_8UC4) - declare.time(5); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, type), oclKer(ker); @@ -170,13 +161,89 @@ PERF_TEST_P(ErodeFixture, Erode, OCL_PERF_ELSE } +///////////// Dilate //////////////////// + +typedef FilterFixture DilateFixture; + +OCL_PERF_TEST_P(DilateFixture, Dilate, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) +{ + const FilterParams params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), ksize = get<2>(params); + const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + Mat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst).in(ker); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src), oclDst(srcSize, type), oclKer(ker); + + OCL_TEST_CYCLE() cv::ocl::dilate(oclSrc, oclDst, oclKer); + + oclDst.download(dst); + + SANITY_CHECK(dst); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::dilate(src, dst, ker); + + SANITY_CHECK(dst); + } + else + OCL_PERF_ELSE +} + +///////////// MorphologyEx //////////////////// + +CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT) + +typedef tuple MorphologyExParams; +typedef TestBaseWithParam MorphologyExFixture; + +OCL_PERF_TEST_P(MorphologyExFixture, MorphologyEx, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, MorphOp::all(), OCL_PERF_ENUM(3, 5))) +{ + const MorphologyExParams params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), op = get<2>(params), ksize = get<3>(params); + const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + Mat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst).in(ker); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src), oclDst(srcSize, type), oclKer(ker); + + OCL_TEST_CYCLE() cv::ocl::morphologyEx(oclSrc, oclDst, op, oclKer); + + oclDst.download(dst); + + SANITY_CHECK(dst); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::morphologyEx(src, dst, op, ker); + + SANITY_CHECK(dst); + } + else + OCL_PERF_ELSE +} + ///////////// Sobel //////////////////////// typedef Size_MatType SobelFixture; -PERF_TEST_P(SobelFixture, Sobel, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(SobelFixture, Sobel, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -187,12 +254,6 @@ PERF_TEST_P(SobelFixture, Sobel, Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - if ((srcSize == OCL_SIZE_2000 && type == CV_8UC4) || - (srcSize == OCL_SIZE_4000 && type == CV_8UC1)) - declare.time(5.5); - else if (srcSize == OCL_SIZE_4000 && type == CV_8UC4) - declare.time(20); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, type); @@ -217,9 +278,8 @@ PERF_TEST_P(SobelFixture, Sobel, typedef Size_MatType ScharrFixture; -PERF_TEST_P(ScharrFixture, Scharr, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(ScharrFixture, Scharr, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -230,12 +290,6 @@ PERF_TEST_P(ScharrFixture, Scharr, Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - if ((srcSize == OCL_SIZE_2000 && type == CV_8UC4) || - (srcSize == OCL_SIZE_4000 && type == CV_8UC1)) - declare.time(5.5); - else if (srcSize == OCL_SIZE_4000 && type == CV_8UC4) - declare.time(21); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, type); @@ -244,7 +298,7 @@ PERF_TEST_P(ScharrFixture, Scharr, oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 3e-3); } else if (RUN_PLAIN_IMPL) { @@ -258,15 +312,14 @@ PERF_TEST_P(ScharrFixture, Scharr, ///////////// GaussianBlur //////////////////////// -typedef Size_MatType GaussianBlurFixture; +typedef FilterFixture GaussianBlurFixture; -PERF_TEST_P(GaussianBlurFixture, GaussianBlur, - ::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000), - OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4))) +OCL_PERF_TEST_P(GaussianBlurFixture, GaussianBlur, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5, 7))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 7; + const int type = get<1>(params), ksize = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -297,15 +350,14 @@ PERF_TEST_P(GaussianBlurFixture, GaussianBlur, ///////////// filter2D//////////////////////// -typedef Size_MatType filter2DFixture; +typedef FilterFixture Filter2DFixture; -PERF_TEST_P(filter2DFixture, filter2D, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(Filter2DFixture, Filter2D, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 3; + const int type = get<1>(params), ksize = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -313,9 +365,6 @@ PERF_TEST_P(filter2DFixture, filter2D, declare.in(src, WARMUP_RNG).in(kernel).out(dst); randu(kernel, -3.0, 3.0); - if (srcSize == OCL_SIZE_4000 && type == CV_8UC4) - declare.time(8); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, type), oclKernel(kernel); @@ -324,13 +373,13 @@ PERF_TEST_P(filter2DFixture, filter2D, oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 3e-2); } else if (RUN_PLAIN_IMPL) { TEST_CYCLE() cv::filter2D(src, dst, -1, kernel); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1e-2); } else OCL_PERF_ELSE @@ -338,28 +387,22 @@ PERF_TEST_P(filter2DFixture, filter2D, ///////////// Bilateral//////////////////////// -typedef Size_MatType BilateralFixture; +typedef TestBaseWithParam BilateralFixture; -PERF_TEST_P(BilateralFixture, Bilateral, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC3))) +OCL_PERF_TEST_P(BilateralFixture, Bilateral, OCL_TEST_SIZES) { - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params), d = 7; + const Size srcSize = GetParam(); + const int d = 7; const double sigmacolor = 50.0, sigmaspace = 50.0; - checkDeviceMaxMemoryAllocSize(srcSize, type); + checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1); - Mat src(srcSize, type), dst(srcSize, type); + Mat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1); declare.in(src, WARMUP_RNG).out(dst); - if (srcSize == OCL_SIZE_4000) - declare.time(type == CV_8UC3 ? 8 : 4.5); - if (RUN_OCL_IMPL) { - ocl::oclMat oclSrc(src), oclDst(srcSize, type); + ocl::oclMat oclSrc(src), oclDst(srcSize, CV_8UC1); OCL_TEST_CYCLE() cv::ocl::bilateralFilter(oclSrc, oclDst, d, sigmacolor, sigmaspace); @@ -377,37 +420,35 @@ PERF_TEST_P(BilateralFixture, Bilateral, OCL_PERF_ELSE } -///////////// adaptiveBilateral//////////////////////// +///////////// MedianBlur//////////////////////// -typedef Size_MatType adaptiveBilateralFixture; +typedef tuple MedianBlurParams; +typedef TestBaseWithParam MedianBlurFixture; -PERF_TEST_P(adaptiveBilateralFixture, DISABLED_adaptiveBilateral, - ::testing::Combine(::testing::Values(OCL_SIZE_1000), OCL_PERF_ENUM(CV_8UC1, CV_8UC3))) +OCL_PERF_TEST_P(MedianBlurFixture, Bilateral, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); + MedianBlurParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); - const double sigmaspace = 10.0; - Size ksize(9, 9); + const int ksize = get<1>(params); - checkDeviceMaxMemoryAllocSize(srcSize, type); + checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1); - Mat src(srcSize, type), dst(srcSize, type); + Mat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1); declare.in(src, WARMUP_RNG).out(dst); if (RUN_OCL_IMPL) { - ocl::oclMat oclSrc(src), oclDst(srcSize, type); + ocl::oclMat oclSrc(src), oclDst(srcSize, CV_8UC1); - OCL_TEST_CYCLE() cv::ocl::adaptiveBilateralFilter(oclSrc, oclDst, ksize, sigmaspace); + OCL_TEST_CYCLE() cv::ocl::medianFilter(oclSrc, oclDst, ksize); oclDst.download(dst); - SANITY_CHECK(dst, 1.0); + SANITY_CHECK(dst); } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() cv::adaptiveBilateralFilter(src, dst, ksize, sigmaspace); + TEST_CYCLE() cv::medianBlur(src, dst, ksize); SANITY_CHECK(dst); } diff --git a/modules/ocl/perf/perf_gemm.cpp b/modules/ocl/perf/perf_gemm.cpp index 4dcd5d4d6a..69db3a099f 100644 --- a/modules/ocl/perf/perf_gemm.cpp +++ b/modules/ocl/perf/perf_gemm.cpp @@ -46,30 +46,39 @@ #include "perf_precomp.hpp" using namespace perf; +using std::tr1::get; +using std::tr1::tuple; ///////////// gemm //////////////////////// -typedef TestBaseWithParam gemmFixture; - #ifdef HAVE_CLAMDBLAS -PERF_TEST_P(gemmFixture, gemm, ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000)) +typedef tuple GemmParams; +typedef TestBaseWithParam GemmFixture; + +OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine( + ::testing::Values(Size(1000, 1000), Size(1500, 1500)), + ::testing::Values((int)cv::GEMM_1_T, (int)cv::GEMM_1_T | (int)cv::GEMM_2_T))) { - const Size srcSize = GetParam(); + const GemmParams params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); - declare.in(src1, src2, src3).out(dst).time(srcSize == OCL_SIZE_2000 ? 65 : 8); + randu(src1, -10.0f, 10.0f); randu(src2, -10.0f, 10.0f); randu(src3, -10.0f, 10.0f); + declare.in(src1, src2, src3).out(dst); + if (RUN_OCL_IMPL) { ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclSrc3(src3), oclDst(srcSize, CV_32FC1); - OCL_TEST_CYCLE() cv::ocl::gemm(oclSrc1, oclSrc2, 1.0, oclSrc3, 1.0, oclDst); + OCL_TEST_CYCLE() cv::ocl::gemm(oclSrc1, oclSrc2, 1.0, oclSrc3, 1.0, oclDst, type); oclDst.download(dst); @@ -77,7 +86,7 @@ PERF_TEST_P(gemmFixture, gemm, ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000)) } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() cv::gemm(src1, src2, 1.0, src3, 1.0, dst); + TEST_CYCLE() cv::gemm(src1, src2, 1.0, src3, 1.0, dst, type); SANITY_CHECK(dst, 0.01); } diff --git a/modules/ocl/perf/perf_gftt.cpp b/modules/ocl/perf/perf_gftt.cpp index af24c3489a..688d24316b 100644 --- a/modules/ocl/perf/perf_gftt.cpp +++ b/modules/ocl/perf/perf_gftt.cpp @@ -52,22 +52,21 @@ using std::tr1::get; ///////////// GoodFeaturesToTrack //////////////////////// -typedef tuple GoodFeaturesToTrackParams; +typedef tuple GoodFeaturesToTrackParams; typedef TestBaseWithParam GoodFeaturesToTrackFixture; -PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack, - ::testing::Combine(::testing::Values(string("gpu/opticalflow/rubberwhale1.png"), - string("gpu/stereobm/aloe-L.png")), - ::testing::Range(0.0, 4.0, 3.0))) +OCL_PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack, + ::testing::Combine(OCL_PERF_ENUM(String("gpu/opticalflow/rubberwhale1.png")), + OCL_PERF_ENUM(0.0, 3.0), testing::Bool())) { + const GoodFeaturesToTrackParams params = GetParam(); + const String fileName = get<0>(params); + const double minDistance = get<1>(params), qualityLevel = 0.01; + const bool harrisDetector = get<2>(params); + const int maxCorners = 1000; - const GoodFeaturesToTrackParams param = GetParam(); - const string fileName = getDataPath(get<0>(param)); - const int maxCorners = 2000; - const double qualityLevel = 0.01, minDistance = get<1>(param); - - Mat frame = imread(fileName, IMREAD_GRAYSCALE); - ASSERT_TRUE(!frame.empty()) << "no input image"; + Mat frame = imread(getDataPath(fileName), IMREAD_GRAYSCALE); + ASSERT_FALSE(frame.empty()) << "no input image"; vector pts_gold; declare.in(frame); @@ -75,7 +74,8 @@ PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack, if (RUN_OCL_IMPL) { ocl::oclMat oclFrame(frame), pts_oclmat; - ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance); + ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance, 3, + harrisDetector); OCL_TEST_CYCLE() detector(oclFrame, pts_oclmat); @@ -86,7 +86,7 @@ PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack, else if (RUN_PLAIN_IMPL) { TEST_CYCLE() cv::goodFeaturesToTrack(frame, pts_gold, - maxCorners, qualityLevel, minDistance); + maxCorners, qualityLevel, minDistance, noArray(), 3, harrisDetector); SANITY_CHECK(pts_gold); } diff --git a/modules/ocl/perf/perf_haar.cpp b/modules/ocl/perf/perf_haar.cpp index 1a97e908c1..e70641d061 100644 --- a/modules/ocl/perf/perf_haar.cpp +++ b/modules/ocl/perf/perf_haar.cpp @@ -46,8 +46,13 @@ #include "perf_precomp.hpp" using namespace perf; +using namespace std; +using namespace cv; +using std::tr1::make_tuple; +using std::tr1::get; ///////////// Haar //////////////////////// + PERF_TEST(HaarFixture, Haar) { vector faces; @@ -84,23 +89,16 @@ PERF_TEST(HaarFixture, Haar) OCL_PERF_ELSE } -using namespace std; -using namespace cv; -using namespace perf; -using std::tr1::make_tuple; -using std::tr1::get; +typedef std::tr1::tuple Cascade_Image_MinSize_t; +typedef perf::TestBaseWithParam Cascade_Image_MinSize; -typedef std::tr1::tuple OCL_Cascade_Image_MinSize_t; -typedef perf::TestBaseWithParam OCL_Cascade_Image_MinSize; - -PERF_TEST_P( OCL_Cascade_Image_MinSize, CascadeClassifier, - testing::Combine( - testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml"), - string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt2.xml") ), - testing::Values( string("cv/shared/lena.png"), - string("cv/cascadeandhog/images/bttf301.png")/*, - string("cv/cascadeandhog/images/class57.png")*/ ), - testing::Values(30, 64, 90) ) ) +OCL_PERF_TEST_P(Cascade_Image_MinSize, DISABLED_CascadeClassifier, + testing::Combine(testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml"), + string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt2.xml") ), + testing::Values(string("cv/shared/lena.png"), + string("cv/cascadeandhog/images/bttf301.png")/*, + string("cv/cascadeandhog/images/class57.png")*/ ), + testing::Values(30, 64, 90))) { const string cascasePath = get<0>(GetParam()); const string imagePath = get<1>(GetParam()); @@ -109,7 +107,7 @@ PERF_TEST_P( OCL_Cascade_Image_MinSize, CascadeClassifier, vector faces; Mat img = imread(getDataPath(imagePath), IMREAD_GRAYSCALE); - ASSERT_TRUE(!img.empty()) << "Can't load source image: " << getDataPath(imagePath); + ASSERT_FALSE(img.empty()) << "Can't load source image: " << getDataPath(imagePath); equalizeHist(img, img); declare.in(img); @@ -146,7 +144,7 @@ PERF_TEST_P( OCL_Cascade_Image_MinSize, CascadeClassifier, else OCL_PERF_ELSE - //sort(faces.begin(), faces.end(), comparators::RectLess()); - SANITY_CHECK_NOTHING();//(faces, min_size/5); - // using SANITY_CHECK_NOTHING() since OCL and PLAIN version may find different faces number + //sort(faces.begin(), faces.end(), comparators::RectLess()); + SANITY_CHECK_NOTHING();//(faces, min_size/5); + // using SANITY_CHECK_NOTHING() since OCL and PLAIN version may find different faces number } diff --git a/modules/ocl/perf/perf_hog.cpp b/modules/ocl/perf/perf_hog.cpp index 2a67311170..497b73d693 100644 --- a/modules/ocl/perf/perf_hog.cpp +++ b/modules/ocl/perf/perf_hog.cpp @@ -43,7 +43,9 @@ // the use of this software, even if advised of the possibility of such damage. // //M*/ + #include "perf_precomp.hpp" +#include using namespace perf; @@ -66,13 +68,13 @@ struct RectLess : } }; -PERF_TEST(HOGFixture, HOG) +OCL_PERF_TEST(HOGFixture, HOG) { Mat src = imread(getDataPath("gpu/hog/road.png"), cv::IMREAD_GRAYSCALE); ASSERT_TRUE(!src.empty()) << "can't open input image road.png"; vector found_locations; - declare.in(src).time(5); + declare.in(src); if (RUN_PLAIN_IMPL) { diff --git a/modules/ocl/perf/perf_imgproc.cpp b/modules/ocl/perf/perf_imgproc.cpp index e0ffe56e7e..e6f6a0582e 100644 --- a/modules/ocl/perf/perf_imgproc.cpp +++ b/modules/ocl/perf/perf_imgproc.cpp @@ -51,9 +51,9 @@ using std::tr1::get; ///////////// equalizeHist //////////////////////// -typedef TestBaseWithParam equalizeHistFixture; +typedef TestBaseWithParam EqualizeHistFixture; -PERF_TEST_P(equalizeHistFixture, equalizeHist, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(EqualizeHistFixture, EqualizeHist, OCL_TEST_SIZES) { const Size srcSize = GetParam(); const double eps = 1 + DBL_EPSILON; @@ -83,16 +83,13 @@ PERF_TEST_P(equalizeHistFixture, equalizeHist, OCL_TYPICAL_MAT_SIZES) /////////// CopyMakeBorder ////////////////////// -CV_ENUM(Border, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, - BORDER_WRAP, BORDER_REFLECT_101) +CV_ENUM(Border, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101) typedef tuple CopyMakeBorderParamType; typedef TestBaseWithParam CopyMakeBorderFixture; -PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4), - Border::all())) +OCL_PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, Border::all())) { const CopyMakeBorderParamType params = GetParam(); const Size srcSize = get<0>(params); @@ -125,11 +122,10 @@ PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder, ///////////// cornerMinEigenVal //////////////////////// -typedef Size_MatType cornerMinEigenValFixture; +typedef Size_MatType CornerMinEigenValFixture; -PERF_TEST_P(cornerMinEigenValFixture, cornerMinEigenVal, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -137,8 +133,7 @@ PERF_TEST_P(cornerMinEigenValFixture, cornerMinEigenVal, const int blockSize = 7, apertureSize = 1 + 2 * 3; Mat src(srcSize, type), dst(srcSize, CV_32FC1); - declare.in(src, WARMUP_RNG).out(dst) - .time(srcSize == OCL_SIZE_4000 ? 20 : srcSize == OCL_SIZE_2000 ? 5 : 3); + declare.in(src, WARMUP_RNG).out(dst); const int depth = CV_MAT_DEPTH(type); const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE; @@ -165,11 +160,10 @@ PERF_TEST_P(cornerMinEigenValFixture, cornerMinEigenVal, ///////////// cornerHarris //////////////////////// -typedef Size_MatType cornerHarrisFixture; +typedef Size_MatType CornerHarrisFixture; -PERF_TEST_P(cornerHarrisFixture, cornerHarris, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -177,8 +171,7 @@ PERF_TEST_P(cornerHarrisFixture, cornerHarris, Mat src(srcSize, type), dst(srcSize, CV_32FC1); randu(src, 0, 1); - declare.in(src).out(dst) - .time(srcSize == OCL_SIZE_4000 ? 20 : srcSize == OCL_SIZE_2000 ? 5 : 3); + declare.in(src).out(dst); if (RUN_OCL_IMPL) { @@ -202,11 +195,14 @@ PERF_TEST_P(cornerHarrisFixture, cornerHarris, ///////////// integral //////////////////////// -typedef TestBaseWithParam integralFixture; +typedef tuple IntegralParams; +typedef TestBaseWithParam IntegralFixture; -PERF_TEST_P(integralFixture, integral, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32S, CV_32F))) { - const Size srcSize = GetParam(); + const IntegralParams params = GetParam(); + const Size srcSize = get<0>(params); + const int sdepth = get<1>(params); Mat src(srcSize, CV_8UC1), dst; declare.in(src, WARMUP_RNG); @@ -215,17 +211,17 @@ PERF_TEST_P(integralFixture, integral, OCL_TYPICAL_MAT_SIZES) { ocl::oclMat oclSrc(src), oclDst; - OCL_TEST_CYCLE() cv::ocl::integral(oclSrc, oclDst); + OCL_TEST_CYCLE() cv::ocl::integral(oclSrc, oclDst, sdepth); oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); } else if (RUN_PLAIN_IMPL) { - TEST_CYCLE() cv::integral(src, dst); + TEST_CYCLE() cv::integral(src, dst, sdepth); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); } else OCL_PERF_ELSE @@ -233,15 +229,13 @@ PERF_TEST_P(integralFixture, integral, OCL_TYPICAL_MAT_SIZES) ///////////// threshold//////////////////////// -CV_ENUM(ThreshType, THRESH_BINARY, THRESH_TOZERO_INV) +CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO_INV) typedef tuple ThreshParams; typedef TestBaseWithParam ThreshFixture; -PERF_TEST_P(ThreshFixture, threshold, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC4, CV_32FC1), - ThreshType::all())) +OCL_PERF_TEST_P(ThreshFixture, Threshold, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, ThreshType::all())) { const ThreshParams params = GetParam(); const Size srcSize = get<0>(params); @@ -463,9 +457,9 @@ static void meanShiftFiltering_(const Mat &src_roi, Mat &dst_roi, int sp, int sr } } -typedef TestBaseWithParam meanShiftFilteringFixture; +typedef TestBaseWithParam MeanShiftFilteringFixture; -PERF_TEST_P(meanShiftFilteringFixture, meanShiftFiltering, +PERF_TEST_P(MeanShiftFilteringFixture, MeanShiftFiltering, OCL_TYPICAL_MAT_SIZES) { const Size srcSize = GetParam(); @@ -473,9 +467,7 @@ PERF_TEST_P(meanShiftFilteringFixture, meanShiftFiltering, cv::TermCriteria crit(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1); Mat src(srcSize, CV_8UC4), dst(srcSize, CV_8UC4); - declare.in(src, WARMUP_RNG).out(dst) - .time(srcSize == OCL_SIZE_4000 ? - 56 : srcSize == OCL_SIZE_2000 ? 15 : 3.8); + declare.in(src, WARMUP_RNG).out(dst); if (RUN_PLAIN_IMPL) { @@ -556,9 +548,9 @@ static void meanShiftProc_(const Mat &src_roi, Mat &dst_roi, Mat &dstCoor_roi, i } -typedef TestBaseWithParam meanShiftProcFixture; +typedef TestBaseWithParam MeanShiftProcFixture; -PERF_TEST_P(meanShiftProcFixture, meanShiftProc, +PERF_TEST_P(MeanShiftProcFixture, MeanShiftProc, OCL_TYPICAL_MAT_SIZES) { const Size srcSize = GetParam(); @@ -566,9 +558,7 @@ PERF_TEST_P(meanShiftProcFixture, meanShiftProc, Mat src(srcSize, CV_8UC4), dst1(srcSize, CV_8UC4), dst2(srcSize, CV_16SC2); - declare.in(src, WARMUP_RNG).out(dst1, dst2) - .time(srcSize == OCL_SIZE_4000 ? - 56 : srcSize == OCL_SIZE_2000 ? 15 : 3.8);; + declare.in(src, WARMUP_RNG).out(dst1, dst2); if (RUN_PLAIN_IMPL) { @@ -598,7 +588,7 @@ PERF_TEST_P(meanShiftProcFixture, meanShiftProc, typedef TestBaseWithParam CLAHEFixture; -PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES) { const Size srcSize = GetParam(); const string impl = getSelectedImpl(); @@ -607,9 +597,6 @@ PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TYPICAL_MAT_SIZES) const double clipLimit = 40.0; declare.in(src, WARMUP_RNG); - if (srcSize == OCL_SIZE_4000) - declare.time(11); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst; @@ -632,9 +619,9 @@ PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TYPICAL_MAT_SIZES) OCL_PERF_ELSE } -///////////// columnSum//////////////////////// +///////////// ColumnSum//////////////////////// -typedef TestBaseWithParam columnSumFixture; +typedef TestBaseWithParam ColumnSumFixture; static void columnSumPerfTest(const Mat & src, Mat & dst) { @@ -646,16 +633,13 @@ static void columnSumPerfTest(const Mat & src, Mat & dst) dst.at(i, j) = dst.at(i - 1 , j) + src.at(i , j); } -PERF_TEST_P(columnSumFixture, columnSum, OCL_TYPICAL_MAT_SIZES) +PERF_TEST_P(ColumnSumFixture, ColumnSum, OCL_TYPICAL_MAT_SIZES) { const Size srcSize = GetParam(); Mat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); declare.in(src, WARMUP_RNG).out(dst); - if (srcSize == OCL_SIZE_4000) - declare.time(5); - if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src), oclDst(srcSize, CV_32FC1); @@ -680,8 +664,8 @@ PERF_TEST_P(columnSumFixture, columnSum, OCL_TYPICAL_MAT_SIZES) CV_ENUM(DistType, NORM_L1, NORM_L2SQR) -typedef tuple distanceToCentersParameters; -typedef TestBaseWithParam distanceToCentersFixture; +typedef tuple DistanceToCentersParams; +typedef TestBaseWithParam DistanceToCentersFixture; static void distanceToCentersPerfTest(Mat& src, Mat& centers, Mat& dists, Mat& labels, int distType) { @@ -706,10 +690,11 @@ static void distanceToCentersPerfTest(Mat& src, Mat& centers, Mat& dists, Mat& l Mat(labels_v).copyTo(labels); } -PERF_TEST_P(distanceToCentersFixture, distanceToCenters, ::testing::Combine(::testing::Values(cv::Size(256,256), cv::Size(512,512)), DistType::all()) ) +PERF_TEST_P(DistanceToCentersFixture, DistanceToCenters, ::testing::Combine(::testing::Values(cv::Size(256,256), cv::Size(512,512)), DistType::all()) ) { - Size size = get<0>(GetParam()); - int distType = get<1>(GetParam()); + const DistanceToCentersParams params = GetParam(); + Size size = get<0>(params); + int distType = get<1>(params); Mat src(size, CV_32FC1), centers(size, CV_32FC1); Mat dists(src.rows, 1, CV_32FC1), labels(src.rows, 1, CV_32SC1); diff --git a/modules/ocl/perf/perf_imgwarp.cpp b/modules/ocl/perf/perf_imgwarp.cpp index e768d66219..56d55c03c6 100644 --- a/modules/ocl/perf/perf_imgwarp.cpp +++ b/modules/ocl/perf/perf_imgwarp.cpp @@ -51,11 +51,13 @@ using std::tr1::get; ///////////// WarpAffine //////////////////////// -typedef Size_MatType WarpAffineFixture; +CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR) -PERF_TEST_P(WarpAffineFixture, WarpAffine, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +typedef tuple WarpAffineParams; +typedef TestBaseWithParam WarpAffineFixture; + +OCL_PERF_TEST_P(WarpAffineFixture, WarpAffine, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, InterType::all())) { static const double coeffs[2][3] = { @@ -63,11 +65,12 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine, { sin(CV_PI / 6), cos(CV_PI / 6), -100.0 } }; Mat M(2, 3, CV_64F, (void *)coeffs); - const int interpolation = INTER_NEAREST; - const Size_MatType_t params = GetParam(); + const WarpAffineParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const int type = get<1>(params), interpolation = get<2>(params); + + checkDeviceMaxMemoryAllocSize(srcSize, type); Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); @@ -80,13 +83,13 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine, oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 5e-4); } else if (RUN_PLAIN_IMPL) { TEST_CYCLE() cv::warpAffine(src, dst, M, srcSize, interpolation); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 5e-4); } else OCL_PERF_ELSE @@ -94,11 +97,11 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine, ///////////// WarpPerspective //////////////////////// -typedef Size_MatType WarpPerspectiveFixture; +typedef WarpAffineParams WarpPerspectiveParams; +typedef TestBaseWithParam WarpPerspectiveFixture; -PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, InterType::all())) { static const double coeffs[3][3] = { @@ -107,15 +110,15 @@ PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, {0.0, 0.0, 1.0} }; Mat M(3, 3, CV_64F, (void *)coeffs); - const int interpolation = INTER_LINEAR; - const Size_MatType_t params = GetParam(); + const WarpPerspectiveParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const int type = get<1>(params), interpolation = get<2>(params); + + checkDeviceMaxMemoryAllocSize(srcSize, type); Mat src(srcSize, type), dst(srcSize, type); - declare.in(src, WARMUP_RNG).out(dst) - .time(srcSize == OCL_SIZE_4000 ? 18 : srcSize == OCL_SIZE_2000 ? 5 : 2); + declare.in(src, WARMUP_RNG).out(dst); if (RUN_OCL_IMPL) { @@ -125,32 +128,28 @@ PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 5e-4); } else if (RUN_PLAIN_IMPL) { TEST_CYCLE() cv::warpPerspective(src, dst, M, srcSize, interpolation); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 5e-4); } else OCL_PERF_ELSE } -///////////// resize //////////////////////// +///////////// Resize //////////////////////// -CV_ENUM(resizeInterType, INTER_NEAREST, INTER_LINEAR) +typedef tuple ResizeParams; +typedef TestBaseWithParam ResizeFixture; -typedef tuple resizeParams; -typedef TestBaseWithParam resizeFixture; - -PERF_TEST_P(resizeFixture, resize, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4), - resizeInterType::all(), - ::testing::Values(0.5, 2.0))) +OCL_PERF_TEST_P(ResizeFixture, Resize, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, + InterType::all(), ::testing::Values(0.5, 2.0))) { - const resizeParams params = GetParam(); + const ResizeParams params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params), interType = get<2>(params); double scale = get<3>(params); @@ -162,8 +161,6 @@ PERF_TEST_P(resizeFixture, resize, Mat src(srcSize, type), dst; dst.create(dstSize, type); declare.in(src, WARMUP_RNG).out(dst); - if (interType == INTER_LINEAR && type == CV_8UC4 && OCL_SIZE_4000 == srcSize) - declare.time(11); if (RUN_OCL_IMPL) { @@ -185,15 +182,13 @@ PERF_TEST_P(resizeFixture, resize, OCL_PERF_ELSE } -typedef tuple resizeAreaParams; -typedef TestBaseWithParam resizeAreaFixture; +typedef tuple ResizeAreaParams; +typedef TestBaseWithParam ResizeAreaFixture; -PERF_TEST_P(resizeAreaFixture, resize, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), - ::testing::Values(0.3, 0.5, 0.6))) +OCL_PERF_TEST_P(ResizeAreaFixture, Resize, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, ::testing::Values(0.3, 0.5, 0.6))) { - const resizeAreaParams params = GetParam(); + const ResizeAreaParams params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params); double scale = get<2>(params); @@ -225,28 +220,21 @@ PERF_TEST_P(resizeAreaFixture, resize, OCL_PERF_ELSE } -///////////// remap//////////////////////// - -CV_ENUM(RemapInterType, INTER_NEAREST, INTER_LINEAR) +///////////// Remap //////////////////////// -typedef tuple remapParams; -typedef TestBaseWithParam remapFixture; +typedef tuple RemapParams; +typedef TestBaseWithParam RemapFixture; -PERF_TEST_P(remapFixture, remap, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4), - RemapInterType::all())) +OCL_PERF_TEST_P(RemapFixture, Remap, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, InterType::all())) { - const remapParams params = GetParam(); + const RemapParams params = GetParam(); const Size srcSize = get<0>(params); const int type = get<1>(params), interpolation = get<2>(params); Mat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - if (srcSize == OCL_SIZE_4000 && interpolation == INTER_LINEAR) - declare.time(9); - Mat xmap, ymap; xmap.create(srcSize, CV_32FC1); ymap.create(srcSize, CV_32FC1); @@ -287,7 +275,7 @@ PERF_TEST_P(remapFixture, remap, } -///////////// buildWarpPerspectiveMaps //////////////////////// +///////////// BuildWarpPerspectiveMaps //////////////////////// static void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, Mat &xmap, Mat &ymap) { @@ -323,9 +311,9 @@ static void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, Mat } } -typedef TestBaseWithParam buildWarpPerspectiveMapsFixture; +typedef TestBaseWithParam BuildWarpPerspectiveMapsFixture; -PERF_TEST_P(buildWarpPerspectiveMapsFixture, Inverse, OCL_TYPICAL_MAT_SIZES) +PERF_TEST_P(BuildWarpPerspectiveMapsFixture, Inverse, OCL_TYPICAL_MAT_SIZES) { static const double coeffs[3][3] = { diff --git a/modules/ocl/perf/perf_kalman.cpp b/modules/ocl/perf/perf_kalman.cpp index 946444ad9f..e384fcd696 100644 --- a/modules/ocl/perf/perf_kalman.cpp +++ b/modules/ocl/perf/perf_kalman.cpp @@ -46,7 +46,7 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CLAMDBLAS +//#ifdef HAVE_CLAMDBLAS using namespace perf; using namespace std; @@ -100,4 +100,4 @@ PERF_TEST_P(KalmanFilterFixture, KalmanFilter, SANITY_CHECK(statePre_); } -#endif // HAVE_CLAMDBLAS +//#endif // HAVE_CLAMDBLAS diff --git a/modules/ocl/perf/perf_match_template.cpp b/modules/ocl/perf/perf_match_template.cpp index 561a978ae3..ae8c55719c 100644 --- a/modules/ocl/perf/perf_match_template.cpp +++ b/modules/ocl/perf/perf_match_template.cpp @@ -43,6 +43,7 @@ // the use of this software, even if advised of the possibility of such damage. // //M*/ + #include "perf_precomp.hpp" using namespace perf; @@ -53,8 +54,8 @@ using std::tr1::get; typedef Size_MatType CV_TM_CCORRFixture; -PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate, - ::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000), +OCL_PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate, + ::testing::Combine(::testing::Values(Size(1000, 1000), Size(2000, 2000)), OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) { const Size_MatType_t params = GetParam(); @@ -66,7 +67,7 @@ PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate, Mat dst(dstSize, CV_32F); randu(src, 0.0f, 1.0f); randu(templ, 0.0f, 1.0f); - declare.time(srcSize == OCL_SIZE_2000 ? 20 : 6).in(src, templ).out(dst); + declare.in(src, templ).out(dst); if (RUN_OCL_IMPL) { @@ -90,15 +91,15 @@ PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate, typedef TestBaseWithParam CV_TM_CCORR_NORMEDFixture; -PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate, OCL_TYPICAL_MAT_SIZES) +OCL_PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate, + ::testing::Values(Size(1000, 1000), Size(2000, 2000), Size(4000, 4000))) { const Size srcSize = GetParam(), templSize(5, 5); Mat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1), dst; const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1); dst.create(dstSize, CV_8UC1); - declare.in(src, templ, WARMUP_RNG).out(dst) - .time(srcSize == OCL_SIZE_2000 ? 10 : srcSize == OCL_SIZE_4000 ? 23 : 2); + declare.in(src, templ, WARMUP_RNG).out(dst); if (RUN_OCL_IMPL) { @@ -125,7 +126,7 @@ CV_ENUM(MethodType, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_C typedef std::tr1::tuple ImgSize_TmplSize_Method_t; typedef TestBaseWithParam ImgSize_TmplSize_Method; -PERF_TEST_P(ImgSize_TmplSize_Method, MatchTemplate, +OCL_PERF_TEST_P(ImgSize_TmplSize_Method, MatchTemplate, ::testing::Combine( testing::Values(szSmall128, cv::Size(320, 240), cv::Size(640, 480), cv::Size(800, 600), diff --git a/modules/ocl/perf/perf_matrix_operation.cpp b/modules/ocl/perf/perf_matrix_operation.cpp index 5ca322e22f..434f134ca3 100644 --- a/modules/ocl/perf/perf_matrix_operation.cpp +++ b/modules/ocl/perf/perf_matrix_operation.cpp @@ -53,9 +53,7 @@ using std::tr1::get; typedef Size_MatType ConvertToFixture; -PERF_TEST_P(ConvertToFixture, ConvertTo, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(ConvertToFixture, ConvertTo, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -92,11 +90,9 @@ PERF_TEST_P(ConvertToFixture, ConvertTo, ///////////// copyTo//////////////////////// -typedef Size_MatType copyToFixture; +typedef Size_MatType CopyToFixture; -PERF_TEST_P(copyToFixture, copyTo, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(CopyToFixture, CopyTo, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -127,11 +123,9 @@ PERF_TEST_P(copyToFixture, copyTo, ///////////// setTo//////////////////////// -typedef Size_MatType setToFixture; +typedef Size_MatType SetToFixture; -PERF_TEST_P(setToFixture, setTo, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(SetToFixture, SetTo, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -164,16 +158,16 @@ PERF_TEST_P(setToFixture, setTo, /////////////////// upload /////////////////////////// -typedef tuple uploadParams; -typedef TestBaseWithParam uploadFixture; +typedef tuple UploadParams; +typedef TestBaseWithParam UploadFixture; -PERF_TEST_P(uploadFixture, upload, +PERF_TEST_P(UploadFixture, Upload, testing::Combine( OCL_TYPICAL_MAT_SIZES, testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F), testing::Range(1, 5))) { - const uploadParams params = GetParam(); + const UploadParams params = GetParam(); const Size srcSize = get<0>(params); const int depth = get<1>(params), cn = get<2>(params); const int type = CV_MAKE_TYPE(depth, cn); @@ -201,15 +195,15 @@ PERF_TEST_P(uploadFixture, upload, /////////////////// download /////////////////////////// -typedef TestBaseWithParam downloadFixture; +typedef TestBaseWithParam DownloadFixture; -PERF_TEST_P(downloadFixture, download, +PERF_TEST_P(DownloadFixture, Download, testing::Combine( OCL_TYPICAL_MAT_SIZES, testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F), testing::Range(1, 5))) { - const uploadParams params = GetParam(); + const UploadParams params = GetParam(); const Size srcSize = get<0>(params); const int depth = get<1>(params), cn = get<2>(params); const int type = CV_MAKE_TYPE(depth, cn); diff --git a/modules/ocl/perf/perf_ml.cpp b/modules/ocl/perf/perf_ml.cpp index 13dcaa18f0..680045673b 100644 --- a/modules/ocl/perf/perf_ml.cpp +++ b/modules/ocl/perf/perf_ml.cpp @@ -55,7 +55,7 @@ static void genData(Mat& trainData, Size size, Mat& trainLabel = Mat().setTo(Sca trainData.create(size, CV_32FC1); randu(trainData, 1.0, 100.0); - if(nClasses != 0) + if (nClasses != 0) { trainLabel.create(size.height, 1, CV_8UC1); randu(trainLabel, 0, nClasses - 1); @@ -82,7 +82,7 @@ PERF_TEST_P(KNNFixture, KNN, genData(testData, size); Mat best_label; - if(RUN_PLAIN_IMPL) + if (RUN_PLAIN_IMPL) { TEST_CYCLE() { @@ -90,7 +90,8 @@ PERF_TEST_P(KNNFixture, KNN, knn_cpu.train(trainData, trainLabels); knn_cpu.find_nearest(testData, k, &best_label); } - }else if(RUN_OCL_IMPL) + } + else if (RUN_OCL_IMPL) { cv::ocl::oclMat best_label_ocl; cv::ocl::oclMat testdata; @@ -103,7 +104,8 @@ PERF_TEST_P(KNNFixture, KNN, knn_ocl.find_nearest(testdata, k, best_label_ocl); } best_label_ocl.download(best_label); - }else + } + else OCL_PERF_ELSE SANITY_CHECK(best_label); } @@ -188,7 +190,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM, CvMat samples_ = samples; CvMat results_ = results; - if(RUN_PLAIN_IMPL) + if (RUN_PLAIN_IMPL) { CvSVM svm; svm.train(trainData, labels, Mat(), Mat(), params); @@ -197,7 +199,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM, svm.predict(&samples_, &results_); } } - else if(RUN_OCL_IMPL) + else if (RUN_OCL_IMPL) { CvSVM_OCL svm; svm.train(trainData, labels, Mat(), Mat(), params); diff --git a/modules/ocl/perf/perf_moments.cpp b/modules/ocl/perf/perf_moments.cpp index 631031ecb4..d6a9b5c203 100644 --- a/modules/ocl/perf/perf_moments.cpp +++ b/modules/ocl/perf/perf_moments.cpp @@ -55,22 +55,19 @@ using namespace cvtest; using namespace testing; using namespace std; - ///////////// Moments //////////////////////// -//*! performance of image -typedef tuple MomentsParamType; -typedef TestBaseWithParam MomentsFixture; -PERF_TEST_P(MomentsFixture, Moments, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_16SC1, CV_16UC1, CV_32FC1), ::testing::Bool())) +typedef tuple MomentsParams; +typedef TestBaseWithParam MomentsFixture; + +OCL_PERF_TEST_P(MomentsFixture, Moments, + ::testing::Combine(OCL_TEST_SIZES, ::testing::Bool())) { - const MomentsParamType params = GetParam(); + const MomentsParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); - const bool binaryImage = get<2>(params); + const bool binaryImage = get<1>(params); - Mat src(srcSize, type), dst(7, 1, CV_64F); + Mat src(srcSize, CV_8UC1), dst(7, 1, CV_64F); randu(src, 0, 255); cv::Moments mom; @@ -85,6 +82,7 @@ PERF_TEST_P(MomentsFixture, Moments, } else OCL_PERF_ELSE + cv::HuMoments(mom, dst); SANITY_CHECK(dst, 2e-1); } diff --git a/modules/ocl/perf/perf_norm.cpp b/modules/ocl/perf/perf_norm.cpp deleted file mode 100644 index ff49eb4eda..0000000000 --- a/modules/ocl/perf/perf_norm.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. -// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// @Authors -// Fangfang Bai, fangfang@multicorewareinc.com -// Jin Ma, jin@multicorewareinc.com -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors as is and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ -#include "perf_precomp.hpp" - -using namespace perf; -using std::tr1::tuple; -using std::tr1::get; - -///////////// norm//////////////////////// - -typedef tuple normParams; -typedef TestBaseWithParam normFixture; - -PERF_TEST_P(normFixture, norm, testing::Combine( - OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) -{ - const normParams params = GetParam(); - const Size srcSize = get<0>(params); - const int type = get<1>(params); - double value = 0.0; - const double eps = CV_MAT_DEPTH(type) == CV_8U ? DBL_EPSILON : 1e-3; - - Mat src1(srcSize, type), src2(srcSize, type); - declare.in(src1, src2, WARMUP_RNG); - - if (RUN_OCL_IMPL) - { - ocl::oclMat oclSrc1(src1), oclSrc2(src2); - - OCL_TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, NORM_INF); - - SANITY_CHECK(value, eps); - } - else if (RUN_PLAIN_IMPL) - { - TEST_CYCLE() value = cv::norm(src1, src2, NORM_INF); - - SANITY_CHECK(value); - } - else - OCL_PERF_ELSE -} diff --git a/modules/ocl/perf/perf_opticalflow.cpp b/modules/ocl/perf/perf_opticalflow.cpp index bc1761b497..67079f3926 100644 --- a/modules/ocl/perf/perf_opticalflow.cpp +++ b/modules/ocl/perf/perf_opticalflow.cpp @@ -52,55 +52,27 @@ using std::tr1::get; using std::tr1::tuple; using std::tr1::make_tuple; -CV_ENUM(LoadMode, IMREAD_GRAYSCALE, IMREAD_COLOR) - -typedef tuple > PyrLKOpticalFlowParamType; -typedef TestBaseWithParam PyrLKOpticalFlowFixture; - -PERF_TEST_P(PyrLKOpticalFlowFixture, - PyrLKOpticalFlow, - ::testing::Combine( - ::testing::Values(1000, 2000, 4000), - ::testing::Values( - make_tuple - ( - string("gpu/opticalflow/rubberwhale1.png"), - string("gpu/opticalflow/rubberwhale2.png"), - LoadMode(IMREAD_COLOR) - ), - make_tuple - ( - string("gpu/stereobm/aloe-L.png"), - string("gpu/stereobm/aloe-R.png"), - LoadMode(IMREAD_GRAYSCALE) - ) - ) - ) - ) +typedef TestBaseWithParam > PyrLKOpticalFlowFixture; + +OCL_PERF_TEST_P(PyrLKOpticalFlowFixture, + PyrLKOpticalFlow, ::testing::Values(1000, 2000, 4000)) { - PyrLKOpticalFlowParamType params = GetParam(); - tuple fileParam = get<1>(params); - const int pointsCount = get<0>(params); - const int openMode = static_cast(get<2>(fileParam)); - const string fileName0 = get<0>(fileParam), fileName1 = get<1>(fileParam); - Mat frame0 = imread(getDataPath(fileName0), openMode); - Mat frame1 = imread(getDataPath(fileName1), openMode); + const int pointsCount = get<0>(GetParam()); + + const string fileName0 = "gpu/opticalflow/rubberwhale1.png", + fileName1 = "gpu/opticalflow/rubberwhale2.png"; + Mat frame0 = imread(getDataPath(fileName0), cv::IMREAD_GRAYSCALE); + Mat frame1 = imread(getDataPath(fileName1), cv::IMREAD_GRAYSCALE); declare.in(frame0, frame1); ASSERT_FALSE(frame0.empty()) << "can't load " << fileName0; ASSERT_FALSE(frame1.empty()) << "can't load " << fileName1; - Mat grayFrame; - if (openMode == IMREAD_COLOR) - cvtColor(frame0, grayFrame, COLOR_BGR2GRAY); - else - grayFrame = frame0; - vector pts, nextPts; vector status; vector err; - goodFeaturesToTrack(grayFrame, pts, pointsCount, 0.01, 0.0); + goodFeaturesToTrack(frame0, pts, pointsCount, 0.01, 0.0); Mat ptsMat(1, static_cast(pts.size()), CV_32FC2, (void *)&pts[0]); if (RUN_PLAIN_IMPL) @@ -136,7 +108,7 @@ PERF_TEST(tvl1flowFixture, tvl1flow) const Size srcSize = frame0.size(); const double eps = 1.2; Mat flow(srcSize, CV_32FC2), flow1(srcSize, CV_32FC1), flow2(srcSize, CV_32FC1); - declare.in(frame0, frame1).out(flow1, flow2).time(159); + declare.in(frame0, frame1).out(flow1, flow2); if (RUN_PLAIN_IMPL) { @@ -178,12 +150,11 @@ CV_ENUM(farneFlagType, 0, OPTFLOW_FARNEBACK_GAUSSIAN) typedef tuple, farneFlagType, bool> FarnebackOpticalFlowParams; typedef TestBaseWithParam FarnebackOpticalFlowFixture; -PERF_TEST_P(FarnebackOpticalFlowFixture, FarnebackOpticalFlow, - ::testing::Combine( - ::testing::Values(make_tuple(5, 1.1), - make_tuple(7, 1.5)), - farneFlagType::all(), - ::testing::Bool())) +OCL_PERF_TEST_P(FarnebackOpticalFlowFixture, FarnebackOpticalFlow, + ::testing::Combine( + ::testing::Values(make_tuple(5, 1.1), + make_tuple(7, 1.5)), + farneFlagType::all(), ::testing::Bool())) { Mat frame0 = imread(getDataPath("gpu/opticalflow/rubberwhale1.png"), cv::IMREAD_GRAYSCALE); ASSERT_FALSE(frame0.empty()) << "can't load rubberwhale1.png"; diff --git a/modules/ocl/perf/perf_precomp.hpp b/modules/ocl/perf/perf_precomp.hpp index a8663df99a..5f92be8203 100644 --- a/modules/ocl/perf/perf_precomp.hpp +++ b/modules/ocl/perf/perf_precomp.hpp @@ -70,8 +70,7 @@ #include "opencv2/ocl/ocl.hpp" #include "opencv2/ts/ts.hpp" -using namespace std; -using namespace cv; +// TODO remove it #define OCL_SIZE_1000 Size(1000, 1000) #define OCL_SIZE_2000 Size(2000, 2000) @@ -79,6 +78,19 @@ using namespace cv; #define OCL_TYPICAL_MAT_SIZES ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000, OCL_SIZE_4000) +using namespace std; +using namespace cv; + +#define OCL_SIZE_1 szVGA +#define OCL_SIZE_2 sz720p +#define OCL_SIZE_3 sz1080p +#define OCL_SIZE_4 sz2160p + +#define OCL_TEST_SIZES ::testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, OCL_SIZE_4) +#define OCL_TEST_TYPES ::testing::Values(CV_8UC1, CV_32FC1, CV_8UC4, CV_32FC4) +#define OCL_TEST_TYPES_14 OCL_TEST_TYPES +#define OCL_TEST_TYPES_134 ::testing::Values(CV_8UC1, CV_32FC1, CV_8UC3, CV_32FC3, CV_8UC4, CV_32FC4) + #define OCL_PERF_ENUM(type, ...) ::testing::Values(type, ## __VA_ARGS__ ) #define IMPL_OCL "ocl" @@ -103,6 +115,31 @@ using namespace cv; CV_TEST_FAIL_NO_IMPL(); #endif +#define OCL_PERF_TEST(fixture, name) \ + class OCL##_##fixture##_##name : \ + public ::perf::TestBase \ + { \ + public: \ + OCL##_##fixture##_##name() { } \ + protected: \ + virtual void PerfTestBody(); \ + }; \ + TEST_F(OCL##_##fixture##_##name, name) { RunPerfTestBody(); } \ + void OCL##_##fixture##_##name::PerfTestBody() + +#define OCL_PERF_TEST_P(fixture, name, params) \ + class OCL##_##fixture##_##name : \ + public fixture \ + { \ + public: \ + OCL##_##fixture##_##name() { } \ + protected: \ + virtual void PerfTestBody(); \ + }; \ + TEST_P(OCL##_##fixture##_##name, name) { RunPerfTestBody(); } \ + INSTANTIATE_TEST_CASE_P(/*none*/, OCL##_##fixture##_##name, params); \ + void OCL##_##fixture##_##name::PerfTestBody() + #define OCL_TEST_CYCLE_N(n) for(declare.iterations(n); startTimer(), next(); cv::ocl::finish(), stopTimer()) #define OCL_TEST_CYCLE() for(; startTimer(), next(); cv::ocl::finish(), stopTimer()) #define OCL_TEST_CYCLE_MULTIRUN(runsNum) for(declare.runs(runsNum); startTimer(), next(); stopTimer()) for(int r = 0; r < runsNum; cv::ocl::finish(), ++r) diff --git a/modules/ocl/perf/perf_pyramid.cpp b/modules/ocl/perf/perf_pyramid.cpp index 820dd60620..b4ca253565 100644 --- a/modules/ocl/perf/perf_pyramid.cpp +++ b/modules/ocl/perf/perf_pyramid.cpp @@ -51,11 +51,10 @@ using std::tr1::get; ///////////// pyrDown ////////////////////// -typedef Size_MatType pyrDownFixture; +typedef Size_MatType PyrDownFixture; -PERF_TEST_P(pyrDownFixture, pyrDown, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(PyrDownFixture, PyrDown, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -77,7 +76,7 @@ PERF_TEST_P(pyrDownFixture, pyrDown, oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 5e-4); } else if (RUN_PLAIN_IMPL) { @@ -91,11 +90,10 @@ PERF_TEST_P(pyrDownFixture, pyrDown, ///////////// pyrUp //////////////////////// -typedef Size_MatType pyrUpFixture; +typedef Size_MatType PyrUpFixture; -PERF_TEST_P(pyrUpFixture, pyrUp, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8UC1, CV_8UC4))) +OCL_PERF_TEST_P(PyrUpFixture, PyrUp, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); @@ -117,7 +115,7 @@ PERF_TEST_P(pyrUpFixture, pyrUp, oclDst.download(dst); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 5e-4); } else if (RUN_PLAIN_IMPL) { diff --git a/modules/ocl/perf/perf_split_merge.cpp b/modules/ocl/perf/perf_split_merge.cpp index ecfc49e33d..ab3f82f583 100644 --- a/modules/ocl/perf/perf_split_merge.cpp +++ b/modules/ocl/perf/perf_split_merge.cpp @@ -51,21 +51,22 @@ using std::tr1::get; ///////////// Merge//////////////////////// -typedef Size_MatType MergeFixture; +typedef tuple MergeParams; +typedef TestBaseWithParam MergeFixture; -PERF_TEST_P(MergeFixture, Merge, - ::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000), - OCL_PERF_ENUM(CV_8U, CV_32F))) +OCL_PERF_TEST_P(MergeFixture, Merge, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8U, CV_32F), + OCL_PERF_ENUM(2, 3))) { - const Size_MatType_t params = GetParam(); + const MergeParams params = GetParam(); const Size srcSize = get<0>(params); - const int depth = get<1>(params), channels = 3; - const int dstType = CV_MAKE_TYPE(depth, channels); + const int depth = get<1>(params), cn = get<2>(params), + dtype = CV_MAKE_TYPE(depth, cn); - checkDeviceMaxMemoryAllocSize(srcSize, dstType); + checkDeviceMaxMemoryAllocSize(srcSize, dtype); - Mat dst(srcSize, dstType); - vector src(channels); + Mat dst(srcSize, dtype); + vector src(cn); for (vector::iterator i = src.begin(), end = src.end(); i != end; ++i) { i->create(srcSize, CV_MAKE_TYPE(depth, 1)); @@ -75,7 +76,7 @@ PERF_TEST_P(MergeFixture, Merge, if (RUN_OCL_IMPL) { - ocl::oclMat oclDst(srcSize, dstType); + ocl::oclMat oclDst(srcSize, dtype); vector oclSrc(src.size()); for (vector::size_type i = 0, end = src.size(); i < end; ++i) oclSrc[i] = src[i]; @@ -98,49 +99,69 @@ PERF_TEST_P(MergeFixture, Merge, ///////////// Split//////////////////////// -typedef Size_MatType SplitFixture; +typedef MergeParams SplitParams; +typedef TestBaseWithParam SplitFixture; -PERF_TEST_P(SplitFixture, Split, - ::testing::Combine(OCL_TYPICAL_MAT_SIZES, - OCL_PERF_ENUM(CV_8U, CV_32F))) +OCL_PERF_TEST_P(SplitFixture, Split, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8U, CV_32F), + OCL_PERF_ENUM(2, 3))) { - const Size_MatType_t params = GetParam(); + const SplitParams params = GetParam(); const Size srcSize = get<0>(params); - const int depth = get<1>(params), channels = 3; - const int type = CV_MAKE_TYPE(depth, channels); + const int depth = get<1>(params), cn = get<2>(params); + const int type = CV_MAKE_TYPE(depth, cn); checkDeviceMaxMemoryAllocSize(srcSize, type); Mat src(srcSize, type); + Mat dst0, dst1, dst2; declare.in(src, WARMUP_RNG); + ASSERT_TRUE(cn == 3 || cn == 2); + if (RUN_OCL_IMPL) { ocl::oclMat oclSrc(src); - vector oclDst(channels, ocl::oclMat(srcSize, CV_MAKE_TYPE(depth, 1))); + vector oclDst(cn); + oclDst[0] = ocl::oclMat(srcSize, depth); + oclDst[1] = ocl::oclMat(srcSize, depth); + if (cn == 3) + oclDst[2] = ocl::oclMat(srcSize, depth); OCL_TEST_CYCLE() cv::ocl::split(oclSrc, oclDst); - ASSERT_EQ(3, channels); - Mat dst0, dst1, dst2; oclDst[0].download(dst0); oclDst[1].download(dst1); - oclDst[2].download(dst2); - SANITY_CHECK(dst0); - SANITY_CHECK(dst1); - SANITY_CHECK(dst2); + if (cn == 3) + oclDst[2].download(dst2); } else if (RUN_PLAIN_IMPL) { - vector dst(channels, Mat(srcSize, CV_MAKE_TYPE(depth, 1))); + vector dst(cn); + dst[0] = Mat(srcSize, depth); + dst[1] = Mat(srcSize, depth); + if (cn == 3) + dst[2] = Mat(srcSize, depth); + TEST_CYCLE() cv::split(src, dst); - ASSERT_EQ(3, channels); - Mat & dst0 = dst[0], & dst1 = dst[1], & dst2 = dst[2]; + dst0 = dst[0]; + dst1 = dst[1]; + if (cn == 3) + dst2 = dst[2]; + } + else + OCL_PERF_ELSE + + if (cn == 2) + { + SANITY_CHECK(dst0); + SANITY_CHECK(dst1); + } + else if (cn == 3) + { SANITY_CHECK(dst0); SANITY_CHECK(dst1); SANITY_CHECK(dst2); } - else - OCL_PERF_ELSE } diff --git a/modules/ocl/perf/perf_stat.cpp b/modules/ocl/perf/perf_stat.cpp new file mode 100644 index 0000000000..a48cacb59a --- /dev/null +++ b/modules/ocl/perf/perf_stat.cpp @@ -0,0 +1,276 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. +// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// @Authors +// Fangfang Bai, fangfang@multicorewareinc.com +// Jin Ma, jin@multicorewareinc.com +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ +#include "perf_precomp.hpp" + +using namespace perf; +using std::tr1::tuple; +using std::tr1::get; + + +///////////// MinMax //////////////////////// + +typedef Size_MatType MinMaxFixture; + +PERF_TEST_P(MinMaxFixture, MinMax, + ::testing::Combine(OCL_TYPICAL_MAT_SIZES, + OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + declare.in(src, WARMUP_RNG); + + double min_val = std::numeric_limits::max(), + max_val = std::numeric_limits::min(); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val); + + ASSERT_GE(max_val, min_val); + SANITY_CHECK(min_val); + SANITY_CHECK(max_val); + } + else if (RUN_PLAIN_IMPL) + { + Point min_loc, max_loc; + + TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); + + ASSERT_GE(max_val, min_val); + SANITY_CHECK(min_val); + SANITY_CHECK(max_val); + } + else + OCL_PERF_ELSE +} + +///////////// MinMaxLoc //////////////////////// + +typedef Size_MatType MinMaxLocFixture; + +OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + randu(src, 0, 1); + declare.in(src); + + double min_val = 0.0, max_val = 0.0; + Point min_loc, max_loc; + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc); + + ASSERT_GE(max_val, min_val); + SANITY_CHECK(min_val); + SANITY_CHECK(max_val); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); + + ASSERT_GE(max_val, min_val); + SANITY_CHECK(min_val); + SANITY_CHECK(max_val); + } + else + OCL_PERF_ELSE +} + +///////////// Sum //////////////////////// + +typedef Size_MatType SumFixture; + +OCL_PERF_TEST_P(SumFixture, Sum, + ::testing::Combine(OCL_TEST_SIZES, + OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + Scalar result; + randu(src, 0, 60); + declare.in(src); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc); + + SANITY_CHECK(result, 1e-6, ERROR_RELATIVE); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() result = cv::sum(src); + + SANITY_CHECK(result, 1e-6, ERROR_RELATIVE); + } + else + OCL_PERF_ELSE +} + +///////////// countNonZero //////////////////////// + +typedef Size_MatType CountNonZeroFixture; + +OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero, + ::testing::Combine(OCL_TEST_SIZES, + OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + int result = 0; + randu(src, 0, 256); + declare.in(src); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc); + + SANITY_CHECK(result); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() result = cv::countNonZero(src); + + SANITY_CHECK(result); + } + else + OCL_PERF_ELSE +} + +///////////// meanStdDev //////////////////////// + +typedef Size_MatType MeanStdDevFixture; + +OCL_PERF_TEST_P(MeanStdDevFixture, MeanStdDev, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + Mat src(srcSize, type); + Scalar mean, stddev; + randu(src, 0, 256); + declare.in(src); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc(src); + + OCL_TEST_CYCLE() cv::ocl::meanStdDev(oclSrc, mean, stddev); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() cv::meanStdDev(src, mean, stddev); + } + else + OCL_PERF_ELSE + + SANITY_CHECK_NOTHING(); +// SANITY_CHECK(mean, 1e-6, ERROR_RELATIVE); +// SANITY_CHECK(stddev, 1e-6, ERROR_RELATIVE); +} + +///////////// norm//////////////////////// + +CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2) + +typedef std::tr1::tuple NormParams; +typedef TestBaseWithParam NormFixture; + +OCL_PERF_TEST_P(NormFixture, Norm, + ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), + OCL_TEST_TYPES, NormType::all())) +{ + const NormParams params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + const int normType = get<2>(params); + perf::ERROR_TYPE errorType = type != NORM_INF ? ERROR_RELATIVE : ERROR_ABSOLUTE; + double eps = 1e-5, value; + + Mat src1(srcSize, type), src2(srcSize, type); + declare.in(src1, src2, WARMUP_RNG); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclSrc1(src1), oclSrc2(src2); + + OCL_TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, normType); + + SANITY_CHECK(value, eps, errorType); + } + else if (RUN_PLAIN_IMPL) + { + TEST_CYCLE() value = cv::norm(src1, src2, normType); + + SANITY_CHECK(value, eps, errorType); + } + else + OCL_PERF_ELSE +}