diff --git a/modules/calib3d/perf/perf_filterspeckles.cpp b/modules/calib3d/perf/perf_filterspeckles.cpp new file mode 100644 index 000000000000..40c188d92d44 --- /dev/null +++ b/modules/calib3d/perf/perf_filterspeckles.cpp @@ -0,0 +1,41 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. +#include "perf_precomp.hpp" + +namespace opencv_test +{ +using namespace perf; + +#define FILTERSPECKLES_TYPES CV_8UC1, CV_16SC1 + +typedef tuple Size_MatType_t; +typedef perf::TestBaseWithParam Size_MatType_FilterSpeckles; + +PERF_TEST_P(Size_MatType_FilterSpeckles, filterSpeckles, + testing::Combine( + testing::Values(szVGA, sz720p, sz1080p), + testing::Values(FILTERSPECKLES_TYPES) + )) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + + // filterSpeckles works in place on a disparity map. + Mat src(sz, type); + Mat dst(sz, type); + declare.in(src, WARMUP_RNG).out(dst); + + while (next()) + { + src.copyTo(dst); + startTimer(); + cv::filterSpeckles(dst, 0, 2, 2); + stopTimer(); + } + + SANITY_CHECK_NOTHING(); +} + +} // namespace diff --git a/modules/core/perf/perf_arithm.cpp b/modules/core/perf/perf_arithm.cpp index d8b65e1a08fb..18ce03858c37 100644 --- a/modules/core/perf/perf_arithm.cpp +++ b/modules/core/perf/perf_arithm.cpp @@ -1,3 +1,7 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" #include #include "opencv2/core/softfloat.hpp" @@ -6,6 +10,14 @@ namespace opencv_test { using namespace perf; +// Shared BinaryOpTest coverage. +#define BINARY_OP_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_16SC2, \ + CV_16SC3, CV_16SC4, CV_32SC1, CV_32FC1, CV_64FC1 +// Integer types accepting a scale factor. +#define ARITHM_SCALE_TYPES (perf::MatType)CV_8UC1, (perf::MatType)CV_16UC1, (perf::MatType)CV_16SC1 +// Floating-point-only ops (cv::pow / sqrt). +#define ARITHM_FLOAT_TYPES CV_32FC1, CV_64FC1 + using BroadcastTest = perf::TestBaseWithParam, perf::MatType, std::vector>>; typedef Size_MatType BinaryOpTest; @@ -394,6 +406,25 @@ PERF_TEST_P_(BinaryOpTest, multiplyScale) SANITY_CHECK_NOTHING(); } +PERF_TEST_P_(BinaryOpTest, multiplyScalar) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + cv::Mat a(sz, type), c(sz, type); + cv::Scalar s = 1.333; + + declare.in(a, WARMUP_RNG).out(c); + if (CV_MAT_DEPTH(type) == CV_32S) + { + a /= (2 << 16); + s = 2.0; + } + + TEST_CYCLE() cv::multiply(a, s, c); + + SANITY_CHECK_NOTHING(); +} + PERF_TEST_P_(BinaryOpTest, divide) { Size sz = get<0>(GetParam()); @@ -436,6 +467,59 @@ PERF_TEST_P_(BinaryOpTest, transpose2d) SANITY_CHECK_NOTHING(); } +#define TRANSPOSE_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4 + +typedef Size_MatType TransposeMultiChannelTest; + +PERF_TEST_P_(TransposeMultiChannelTest, transpose2d_multichannel) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + Size tsz = Size(sz.height, sz.width); + cv::Mat a(sz, type), b(tsz, type); + + declare.in(a, WARMUP_RNG).out(b); + + TEST_CYCLE() cv::transpose(a, b); + + SANITY_CHECK_NOTHING(); +} + +INSTANTIATE_TEST_CASE_P(/*nothing*/ , TransposeMultiChannelTest, + testing::Combine( + testing::Values(szVGA, sz720p, sz1080p), + testing::Values(TRANSPOSE_TYPES) + ) +); + +typedef Size_MatType TransposeInplaceTest; + +PERF_TEST_P_(TransposeInplaceTest, transpose2d_inplace) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + cv::Mat a(sz, type), b(sz, type); + + declare.in(a, WARMUP_RNG).out(b); + + while (next()) + { + a.copyTo(b); + startTimer(); + cv::transpose(b, b); + stopTimer(); + } + + SANITY_CHECK_NOTHING(); +} + +INSTANTIATE_TEST_CASE_P(/*nothing*/ , TransposeInplaceTest, + testing::Combine( + testing::Values(cv::Size(1280, 1280), cv::Size(1920, 1920)), + testing::Values(TRANSPOSE_TYPES) + ) +); + static cv::Mat makeTransposeNDOutput(const cv::Mat& src, const std::vector& order) { std::vector new_sz(order.size()); @@ -526,7 +610,7 @@ PERF_TEST_P_(BinaryOpTest, transposeND_generic_move_tail_order) INSTANTIATE_TEST_CASE_P(/*nothing*/ , BinaryOpTest, testing::Combine( testing::Values(szVGA, sz720p, sz1080p), - testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_32SC1, CV_32FC1) + testing::Values(BINARY_OP_TYPES) ) ); @@ -784,6 +868,43 @@ INSTANTIATE_TEST_CASE_P(/*nothing*/ , ArithmMixedTest, ) ); +typedef perf::TestBaseWithParam> ArithmScaleTest; + +PERF_TEST_P_(ArithmScaleTest, add_scale) +{ + auto p = GetParam(); + Size sz = get<0>(p); + int src1Type = get<1>(p); + + cv::Mat a(sz, src1Type), b(sz, CV_16UC1), c(sz, CV_32FC1); + declare.in(a, b, WARMUP_RNG).out(c); + + TEST_CYCLE() cv::add(a, b, c, noArray(), CV_32F); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P_(ArithmScaleTest, subtract_scale) +{ + auto p = GetParam(); + Size sz = get<0>(p); + int src1Type = get<1>(p); + + cv::Mat a(sz, src1Type), b(sz, CV_16UC1), c(sz, CV_32FC1); + declare.in(a, b, WARMUP_RNG).out(c); + + TEST_CYCLE() cv::subtract(a, b, c, noArray(), CV_32F); + + SANITY_CHECK_NOTHING(); +} + +INSTANTIATE_TEST_CASE_P(/*nothing*/ , ArithmScaleTest, + testing::Combine( + testing::Values(szVGA, sz720p, sz1080p), + testing::Values(ARITHM_SCALE_TYPES) + ) +); + typedef perf::TestBaseWithParam> SqrtFixture; PERF_TEST_P_(SqrtFixture, Sqrt) { Size sz = get<0>(GetParam()); @@ -801,11 +922,34 @@ PERF_TEST_P_(SqrtFixture, Sqrt) { INSTANTIATE_TEST_CASE_P(/*nothing*/ , SqrtFixture, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_32FC1, CV_64FC1), + testing::Values(ARITHM_FLOAT_TYPES), testing::Bool() ) ); +typedef perf::TestBaseWithParam> PowFixture; +PERF_TEST_P_(PowFixture, Pow) { + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + double power = get<2>(GetParam()); + + Mat src(sz, type), dst(sz, type); + randu(src, FLT_EPSILON, 1000); + declare.in(src).out(dst); + + TEST_CYCLE() cv::pow(src, power, dst); + + SANITY_CHECK_NOTHING(); +} +INSTANTIATE_TEST_CASE_P(/*nothing*/ , PowFixture, + testing::Combine( + testing::Values(sz1080p), + testing::Values(ARITHM_FLOAT_TYPES), + testing::Values(-6.0, -5.0, -4.5, -4.0, -3.0, -2.0, -1.0, -0.7, -0.5, 0.0, + 0.5, 0.7, 1.0, 2.0, 3.0, 4.0, 4.5, 5.0, 6.0) + ) +); + ///////////// Rotate //////////////////////// typedef perf::TestBaseWithParam> RotateTest; diff --git a/modules/core/perf/perf_bitwise.cpp b/modules/core/perf/perf_bitwise.cpp index ed1279af545e..b0170709cebe 100644 --- a/modules/core/perf/perf_bitwise.cpp +++ b/modules/core/perf/perf_bitwise.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test @@ -8,6 +9,9 @@ using namespace perf; #define TYPICAL_MAT_TYPES_BITW_ARITHM CV_8UC1, CV_8SC1, CV_8UC4, CV_32SC1, CV_32SC4 #define TYPICAL_MATS_BITW_ARITHM testing::Combine(testing::Values(TYPICAL_MAT_SIZES_BITW_ARITHM), testing::Values(TYPICAL_MAT_TYPES_BITW_ARITHM)) +#define TYPICAL_MAT_TYPES_BITW_SCALAR CV_8UC1, CV_8SC1, CV_8UC4, CV_16UC1, CV_32SC1, CV_32SC4 +#define TYPICAL_MATS_BITW_SCALAR testing::Combine(testing::Values(TYPICAL_MAT_SIZES_BITW_ARITHM), testing::Values(TYPICAL_MAT_TYPES_BITW_SCALAR)) + PERF_TEST_P(Size_MatType, bitwise_not, TYPICAL_MATS_BITW_ARITHM) { Size sz = get<0>(GetParam()); @@ -72,4 +76,52 @@ PERF_TEST_P(Size_MatType, bitwise_xor, TYPICAL_MATS_BITW_ARITHM) SANITY_CHECK(c); } +PERF_TEST_P(Size_MatType, bitwise_and_scalar, TYPICAL_MATS_BITW_SCALAR) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + cv::Mat a = Mat(sz, type); + cv::Mat c = Mat(sz, type); + cv::Scalar s = Scalar::all(50); + + declare.in(a, WARMUP_RNG).out(c); + declare.time(100); + + TEST_CYCLE() cv::bitwise_and(a, s, c); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(Size_MatType, bitwise_or_scalar, TYPICAL_MATS_BITW_SCALAR) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + cv::Mat a = Mat(sz, type); + cv::Mat c = Mat(sz, type); + cv::Scalar s = Scalar::all(50); + + declare.in(a, WARMUP_RNG).out(c); + declare.time(100); + + TEST_CYCLE() cv::bitwise_or(a, s, c); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(Size_MatType, bitwise_xor_scalar, TYPICAL_MATS_BITW_SCALAR) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + cv::Mat a = Mat(sz, type); + cv::Mat c = Mat(sz, type); + cv::Scalar s = Scalar::all(50); + + declare.in(a, WARMUP_RNG).out(c); + declare.time(100); + + TEST_CYCLE() cv::bitwise_xor(a, s, c); + + SANITY_CHECK_NOTHING(); +} + } // namespace diff --git a/modules/core/perf/perf_channels.cpp b/modules/core/perf/perf_channels.cpp new file mode 100644 index 000000000000..51b10d4f36fe --- /dev/null +++ b/modules/core/perf/perf_channels.cpp @@ -0,0 +1,56 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. +#include "perf_precomp.hpp" + +namespace opencv_test +{ +using namespace perf; + +#define CHANNELS_TYPES CV_8UC3, CV_8UC4, CV_16UC3, CV_16UC4, CV_32FC3, CV_32FC4 + +typedef tuple Size_MatType_t; +typedef perf::TestBaseWithParam Size_MatType_Channels; + +PERF_TEST_P(Size_MatType_Channels, extractChannel, + testing::Combine( + testing::Values(TYPICAL_MAT_SIZES), + testing::Values(CHANNELS_TYPES) + )) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + + Mat src(sz, type); + Mat dst(sz, CV_MAKETYPE(CV_MAT_DEPTH(type), 1)); + + declare.in(src, WARMUP_RNG).out(dst); + + int coi = CV_MAT_CN(type) - 1; + TEST_CYCLE_MULTIRUN(10) cv::extractChannel(src, dst, coi); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(Size_MatType_Channels, insertChannel, + testing::Combine( + testing::Values(TYPICAL_MAT_SIZES), + testing::Values(CHANNELS_TYPES) + )) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + + Mat src(sz, CV_MAKETYPE(CV_MAT_DEPTH(type), 1)); + Mat dst(sz, type); + + declare.in(src, WARMUP_RNG).out(dst); + + int coi = CV_MAT_CN(type) - 1; + TEST_CYCLE_MULTIRUN(10) cv::insertChannel(src, dst, coi); + + SANITY_CHECK_NOTHING(); +} + +} // namespace diff --git a/modules/core/perf/perf_compare.cpp b/modules/core/perf/perf_compare.cpp index be706e1a83fc..2ea947e8520c 100644 --- a/modules/core/perf/perf_compare.cpp +++ b/modules/core/perf/perf_compare.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test @@ -6,13 +7,17 @@ using namespace perf; CV_ENUM(CmpType, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE) +#define COMPARE_TYPES CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1 +// Scalar-operand compare adds 16U/16S. +#define COMPARE_SCALAR_TYPES CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1 + typedef tuple Size_MatType_CmpType_t; typedef perf::TestBaseWithParam Size_MatType_CmpType; PERF_TEST_P( Size_MatType_CmpType, compare, testing::Combine( testing::Values(::perf::szVGA, ::perf::sz1080p), - testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1), + testing::Values(COMPARE_TYPES), CmpType::all() ) ) @@ -35,7 +40,7 @@ PERF_TEST_P( Size_MatType_CmpType, compare, PERF_TEST_P( Size_MatType_CmpType, compareScalar, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(TYPICAL_MAT_TYPES), + testing::Values(COMPARE_SCALAR_TYPES), CmpType::all() ) ) diff --git a/modules/core/perf/perf_convertTo.cpp b/modules/core/perf/perf_convertTo.cpp index 344d81cb8a59..ab130251a3a2 100644 --- a/modules/core/perf/perf_convertTo.cpp +++ b/modules/core/perf/perf_convertTo.cpp @@ -1,9 +1,13 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { using namespace perf; +// Full depth sweep exercised by convertTo (src and dst independently). +#define CONVERT_TO_DEPTHS CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F + typedef tuple Size_DepthSrc_DepthDst_Channels_alpha_t; typedef perf::TestBaseWithParam Size_DepthSrc_DepthDst_Channels_alpha; @@ -11,8 +15,8 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo, testing::Combine ( testing::Values(szVGA, sz1080p), - testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F), - testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F), + testing::Values(CONVERT_TO_DEPTHS), + testing::Values(CONVERT_TO_DEPTHS), testing::Values(1, 4), testing::Values(1.0, 1./255) ) @@ -38,4 +42,69 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo, SANITY_CHECK(dst, eps); } +PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo_scale_shift, + testing::Combine + ( + testing::Values(szVGA, sz1080p), + testing::Values(CONVERT_TO_DEPTHS), + testing::Values(CONVERT_TO_DEPTHS), + testing::Values(1, 4), + testing::Values(1.0, 1./255) + ) + ) +{ + Size sz = get<0>(GetParam()); + int depthSrc = get<1>(GetParam()); + int depthDst = get<2>(GetParam()); + int channels = get<3>(GetParam()); + double alpha = get<4>(GetParam()); + double beta = 5.0; + + Mat src(sz, CV_MAKETYPE(depthSrc, channels)); + randu(src, 0, 255); + Mat dst(sz, CV_MAKETYPE(depthDst, channels)); + + int maxValue = 255; + int runs = (sz.width <= 640) ? 8 : 1; + TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha, beta); + + double eps = depthSrc <= CV_32S && (depthDst <= CV_32S || depthDst == CV_64F) ? 1e-12 : (FLT_EPSILON * maxValue); + eps = eps * std::max(1.0, fabs(alpha)) + fabs(beta); + SANITY_CHECK_NOTHING(); +} + +typedef tuple Size_Depth_alpha_t; +typedef perf::TestBaseWithParam Size_Depth_alpha; + +PERF_TEST_P( Size_Depth_alpha, convertTo_scale_shift_inplace, + testing::Combine + ( + testing::Values(szVGA, sz1080p), + testing::Values(CONVERT_TO_DEPTHS), + testing::Values(1.0, 1./255) + ) + ) +{ + Size sz = get<0>(GetParam()); + int depth = get<1>(GetParam()); + double alpha = get<2>(GetParam()); + double beta = 5.0; + + Mat src(sz, CV_MAKETYPE(depth, 1)); + randu(src, 0, 255); + Mat dst(sz, CV_MAKETYPE(depth, 1)); + + int runs = (sz.width <= 640) ? 8 : 1; + while (next()) + { + src.copyTo(dst); + startTimer(); + for (int i = 0; i < runs; ++i) + dst.convertTo(dst, depth, alpha, beta); + stopTimer(); + } + + SANITY_CHECK_NOTHING(); +} + } // namespace diff --git a/modules/core/perf/perf_dot.cpp b/modules/core/perf/perf_dot.cpp index 1230220a4c46..7e2bffe020e9 100644 --- a/modules/core/perf/perf_dot.cpp +++ b/modules/core/perf/perf_dot.cpp @@ -1,15 +1,19 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { using namespace perf; +// Adds CV_64F over the mainline list. +#define DOT_TYPES CV_8UC1, CV_8SC1, CV_16SC1, CV_16UC1, CV_32SC1, CV_32FC1, CV_64FC1 + typedef tuple MatType_Length_t; typedef TestBaseWithParam MatType_Length; PERF_TEST_P( MatType_Length, dot, testing::Combine( - testing::Values( CV_8UC1, CV_8SC1, CV_16SC1, CV_16UC1, CV_32SC1, CV_32FC1 ), + testing::Values( DOT_TYPES ), testing::Values( 32, 64, 128, 256, 512, 1024 ) )) { diff --git a/modules/core/perf/perf_flip.cpp b/modules/core/perf/perf_flip.cpp index 6e89cd6e9aaf..18d04514c2ab 100644 --- a/modules/core/perf/perf_flip.cpp +++ b/modules/core/perf/perf_flip.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" @@ -15,8 +16,10 @@ enum }; #define FLIP_SIZES szQVGA, szVGA, sz1080p -#define FLIP_TYPES CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_32SC1, CV_32FC1 +#define FLIP_TYPES CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4, CV_8SC1, CV_16UC1, CV_16UC3, CV_16UC4, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_32SC1, CV_32FC1, CV_32FC3, CV_32FC4 #define FLIP_CODES FLIP_X, FLIP_Y, FLIP_XY +// In-place flip sweeps the IPP-relevant subset (8U/16U/32F x C1/C3/C4). +#define FLIP_INPLACE_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4 CV_FLAGS(FlipCode, FLIP_X, FLIP_Y, FLIP_XY); typedef tuple Size_MatType_FlipCode_t; @@ -42,4 +45,29 @@ PERF_TEST_P(Size_MatType_FlipCode, SANITY_CHECK_NOTHING(); } +PERF_TEST_P(Size_MatType_FlipCode, + flip_inplace, + testing::Combine(testing::Values(FLIP_SIZES), + testing::Values(FLIP_INPLACE_TYPES), + testing::Values(FLIP_CODES))) +{ + Size sz = get<0>(GetParam()); + int matType = get<1>(GetParam()); + int flipCode = get<2>(GetParam()) - 1; + + Mat src(sz, matType); + Mat dst(sz, matType); + declare.in(src, WARMUP_RNG).out(dst); + + while (next()) + { + src.copyTo(dst); + startTimer(); + cv::flip(dst, dst, flipCode); + stopTimer(); + } + + SANITY_CHECK_NOTHING(); +} + }} // namespace opencv_test diff --git a/modules/core/perf/perf_lut.cpp b/modules/core/perf/perf_lut.cpp index 6f185ac7826a..dc15b7d55b05 100644 --- a/modules/core/perf/perf_lut.cpp +++ b/modules/core/perf/perf_lut.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { namespace { @@ -43,4 +44,31 @@ PERF_TEST_P( SizePrm, LUT_multi, SANITY_CHECK_NOTHING(); } +#define LUT_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_32SC1 + +typedef perf::TestBaseWithParam< tuple > Size_MatType_LUT; + +PERF_TEST_P( Size_MatType_LUT, LUT_types, + testing::Combine( + testing::Values(szVGA, sz1080p), + testing::Values(LUT_TYPES) + ) + ) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + int cn = CV_MAT_CN(type); + int lutDepth = CV_MAT_DEPTH(type); + + Mat src(sz, CV_8UC(cn)); + randu(src, 0, 256); + Mat lut(1, 256, CV_MAKETYPE(lutDepth, 1)); + randu(lut, 0, 256); + Mat dst(sz, CV_MAKETYPE(lutDepth, cn)); + + TEST_CYCLE() LUT(src, lut, dst); + + SANITY_CHECK_NOTHING(); +} + }} // namespace diff --git a/modules/core/perf/perf_mat.cpp b/modules/core/perf/perf_mat.cpp index 277eb92c2182..b662968b71c8 100644 --- a/modules/core/perf/perf_mat.cpp +++ b/modules/core/perf/perf_mat.cpp @@ -1,9 +1,19 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { using namespace perf; +// 8U x C1..C4 — leading block common to both masked-operation sweeps below. +#define MAT_MASK_8U_TYPES CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4 +// Full type sweep for the masked copy. +#define MAT_COPYTO_MASK_TYPES MAT_MASK_8U_TYPES, CV_16UC1, CV_16UC2, CV_16UC3, CV_16UC4, \ + CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_32SC1, CV_32SC2, CV_32SC3, CV_32SC4, \ + CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4, CV_64FC1, CV_64FC2 +#define MAT_SETTO_MASK_TYPES MAT_MASK_8U_TYPES, CV_16UC1, CV_16UC3, CV_16UC4, \ + CV_32SC1, CV_32SC3, CV_32SC4, CV_32FC1, CV_32FC3, CV_32FC4 + PERF_TEST_P(Size_MatType, Mat_Eye, testing::Combine(testing::Values(TYPICAL_MAT_SIZES), testing::Values(TYPICAL_MAT_TYPES)) @@ -99,7 +109,7 @@ PERF_TEST_P(Size_MatType, Mat_Clone_Roi, PERF_TEST_P(Size_MatType, Mat_CopyToWithMask, testing::Combine(testing::Values(::perf::sz1080p, ::perf::szODD), - testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_16UC1, CV_16UC3, CV_32SC1, CV_32SC2, CV_32FC4)) + testing::Values(MAT_COPYTO_MASK_TYPES)) ) { const Size_MatType_t params = GetParam(); @@ -119,7 +129,7 @@ PERF_TEST_P(Size_MatType, Mat_CopyToWithMask, PERF_TEST_P(Size_MatType, Mat_SetToWithMask, testing::Combine(testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_8UC1, CV_8UC2)) + testing::Values(MAT_SETTO_MASK_TYPES)) ) { const Size_MatType_t params = GetParam(); diff --git a/modules/core/perf/perf_merge.cpp b/modules/core/perf/perf_merge.cpp index e10642dcb493..548c4da453b4 100644 --- a/modules/core/perf/perf_merge.cpp +++ b/modules/core/perf/perf_merge.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test @@ -11,7 +12,7 @@ PERF_TEST_P( Size_SrcDepth_DstChannels, merge, testing::Combine ( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_8U, CV_16S, CV_32S, CV_32F, CV_64F), + testing::Values(CV_8U, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F), testing::Values(2, 3, 4) ) ) diff --git a/modules/core/perf/perf_minmaxloc.cpp b/modules/core/perf/perf_minmaxloc.cpp index 9fc605233cdf..efdf084ce6ff 100644 --- a/modules/core/perf/perf_minmaxloc.cpp +++ b/modules/core/perf/perf_minmaxloc.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test @@ -32,4 +33,81 @@ PERF_TEST_P(Size_MatType, minMaxLoc, testing::Combine( SANITY_CHECK(maxVal, 1e-12); } +// minMaxIdx (n-dim min/max + linear index), with the null-pointer combinations +// IPP exercises: which of {min, max, min-idx, max-idx} outputs are requested. +enum +{ + MMI_MIN = 0x1, + MMI_MAX = 0x2, + MMI_IDX = 0x4, + MMI_MIN_IDX = MMI_MIN | MMI_IDX, + MMI_MAX_IDX = MMI_MAX | MMI_IDX, + MMI_MIN_MAX = MMI_MIN | MMI_MAX, + MMI_ALL = MMI_MIN_IDX | MMI_MAX_IDX, +}; +CV_ENUM(MinMaxType, MMI_ALL, MMI_MIN_MAX, MMI_MIN_IDX, MMI_MAX_IDX) + +#define MINMAXIDX_TYPES CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1 + +typedef tuple Size_MatType_MinMaxType_t; +typedef perf::TestBaseWithParam Size_MatType_MinMaxType; + +PERF_TEST_P(Size_MatType_MinMaxType, minMaxIdx, testing::Combine( + testing::Values(TYPICAL_MAT_SIZES), + testing::Values(MINMAXIDX_TYPES), + MinMaxType::all() + ) + ) +{ + Size sz = get<0>(GetParam()); + int matType = get<1>(GetParam()); + int flags = get<2>(GetParam()); + + Mat src(sz, matType); + double minVal = 0, maxVal = 0; + int minIdx[2] = {0}, maxIdx[2] = {0}; + + double *pMinVal = (flags & MMI_MIN) ? &minVal : NULL; + double *pMaxVal = (flags & MMI_MAX) ? &maxVal : NULL; + int *pMinIdx = ((flags & MMI_MIN) && (flags & MMI_IDX)) ? minIdx : NULL; + int *pMaxIdx = ((flags & MMI_MAX) && (flags & MMI_IDX)) ? maxIdx : NULL; + + // middle of the range to avoid early-exit short-cuts + randu(src, 1, 155); + declare.in(src); + + TEST_CYCLE() cv::minMaxIdx(src, pMinVal, pMaxVal, pMinIdx, pMaxIdx); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(Size_MatType_MinMaxType, minMaxIdx_mask, testing::Combine( + testing::Values(TYPICAL_MAT_SIZES), + testing::Values(MINMAXIDX_TYPES), + MinMaxType::all() + ) + ) +{ + Size sz = get<0>(GetParam()); + int matType = get<1>(GetParam()); + int flags = get<2>(GetParam()); + + Mat src(sz, matType); + Mat mask = Mat::ones(sz, CV_8UC1); + double minVal = 0, maxVal = 0; + int minIdx[2] = {0}, maxIdx[2] = {0}; + + double *pMinVal = (flags & MMI_MIN) ? &minVal : NULL; + double *pMaxVal = (flags & MMI_MAX) ? &maxVal : NULL; + int *pMinIdx = ((flags & MMI_MIN) && (flags & MMI_IDX)) ? minIdx : NULL; + int *pMaxIdx = ((flags & MMI_MAX) && (flags & MMI_IDX)) ? maxIdx : NULL; + + randu(src, 1, 155); + declare.in(src).in(mask); + + TEST_CYCLE() cv::minMaxIdx(src, pMinVal, pMaxVal, pMinIdx, pMaxIdx, mask); + + SANITY_CHECK_NOTHING(); +} + } // namespace diff --git a/modules/core/perf/perf_norm.cpp b/modules/core/perf/perf_norm.cpp index c47398f8fc37..8819288f1d61 100644 --- a/modules/core/perf/perf_norm.cpp +++ b/modules/core/perf/perf_norm.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test @@ -7,6 +8,9 @@ using namespace perf; #define HAMMING_NORM_SIZES cv::Size(640, 480), cv::Size(1920, 1080) #define HAMMING_NORM_TYPES CV_8UC1 +// Masked norm coverage widened to match IPP (adds C3 + 16U; shared by norm_mask/norm2_mask). +#define NORM_MASK_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_8SC1, CV_16UC1, CV_16UC3, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC3, CV_64FC1 + CV_FLAGS(NormType, NORM_HAMMING2, NORM_HAMMING, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX) typedef tuple Size_MatType_NormType_t; typedef perf::TestBaseWithParam Size_MatType_NormType; @@ -15,7 +19,7 @@ PERF_TEST_P(Size_MatType_NormType, norm, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1), - testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2) + testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)NORM_L2SQR) ) ) { @@ -36,8 +40,8 @@ PERF_TEST_P(Size_MatType_NormType, norm, PERF_TEST_P(Size_MatType_NormType, norm_mask, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1), - testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2) + testing::Values(NORM_MASK_TYPES), + testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)NORM_L2SQR) ) ) { @@ -60,7 +64,7 @@ PERF_TEST_P(Size_MatType_NormType, norm2, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1), - testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)(NORM_RELATIVE+NORM_INF), (int)(NORM_RELATIVE+NORM_L1), (int)(NORM_RELATIVE+NORM_L2)) + testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)NORM_L2SQR, (int)(NORM_RELATIVE+NORM_INF), (int)(NORM_RELATIVE+NORM_L1), (int)(NORM_RELATIVE+NORM_L2), (int)(NORM_RELATIVE+NORM_L2SQR)) ) ) { @@ -82,8 +86,8 @@ PERF_TEST_P(Size_MatType_NormType, norm2, PERF_TEST_P(Size_MatType_NormType, norm2_mask, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1), - testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)(NORM_RELATIVE|NORM_INF), (int)(NORM_RELATIVE|NORM_L1), (int)(NORM_RELATIVE|NORM_L2)) + testing::Values(NORM_MASK_TYPES), + testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)NORM_L2SQR, (int)(NORM_RELATIVE|NORM_INF), (int)(NORM_RELATIVE|NORM_L1), (int)(NORM_RELATIVE|NORM_L2), (int)(NORM_RELATIVE|NORM_L2SQR)) ) ) { diff --git a/modules/core/perf/perf_reduce.cpp b/modules/core/perf/perf_reduce.cpp index bcd10b18c539..ab6085d1662f 100644 --- a/modules/core/perf/perf_reduce.cpp +++ b/modules/core/perf/perf_reduce.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test @@ -8,11 +9,14 @@ CV_ENUM(ROp, REDUCE_SUM, REDUCE_AVG, REDUCE_MAX, REDUCE_MIN, REDUCE_SUM2) typedef tuple Size_MatType_ROp_t; typedef perf::TestBaseWithParam Size_MatType_ROp; +// C1/C3/C4 over 8U/16U/16S/32F (widened from TYPICAL_MAT_TYPES to match IPP MAX/MIN coverage). +#define TYPICAL_MAT_TYPES_REDUCE CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, \ + CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4 PERF_TEST_P(Size_MatType_ROp, reduceR, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(TYPICAL_MAT_TYPES), + testing::Values(TYPICAL_MAT_TYPES_REDUCE), ROp::all() ) ) @@ -21,8 +25,18 @@ PERF_TEST_P(Size_MatType_ROp, reduceR, int matType = get<1>(GetParam()); int reduceOp = get<2>(GetParam()); + int sdepth = CV_MAT_DEPTH(matType); + bool accumulate = (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2); + + // Accumulate ops (SUM/AVG/SUM2) over 16U/16S need a floating-point output; + // that depth-changing coverage is exercised by the reduce_diff test below. + // Here we keep the same-depth path: MAX/MIN for all types, and SUM/AVG for + // 8U (->32S) and float types. + if( accumulate && (sdepth == CV_16U || sdepth == CV_16S) ) + throw ::perf::TestBase::PerfSkipTestException(); + int ddepth = -1; - if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2) ) + if( accumulate && sdepth < CV_32S ) ddepth = CV_32S; Mat src(sz, matType); @@ -40,7 +54,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceR, PERF_TEST_P(Size_MatType_ROp, reduceC, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(TYPICAL_MAT_TYPES), + testing::Values(TYPICAL_MAT_TYPES_REDUCE), ROp::all() ) ) @@ -49,8 +63,15 @@ PERF_TEST_P(Size_MatType_ROp, reduceC, int matType = get<1>(GetParam()); int reduceOp = get<2>(GetParam()); + int sdepth = CV_MAT_DEPTH(matType); + bool accumulate = (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2); + + // See reduceR: accumulate ops over 16U/16S are covered by reduce_diff. + if( accumulate && (sdepth == CV_16U || sdepth == CV_16S) ) + throw ::perf::TestBase::PerfSkipTestException(); + int ddepth = -1; - if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2) ) + if( accumulate && sdepth < CV_32S ) ddepth = CV_32S; Mat src(sz, matType); @@ -64,6 +85,49 @@ PERF_TEST_P(Size_MatType_ROp, reduceC, SANITY_CHECK_NOTHING(); } +CV_ENUM(ROpDiff, REDUCE_SUM, REDUCE_AVG) +typedef tuple, ROpDiff, int> Size_SrcType_DstDepth_ROp_Dim_t; +typedef perf::TestBaseWithParam Size_SrcType_DstDepth_ROp_Dim; + +PERF_TEST_P(Size_SrcType_DstDepth_ROp_Dim, reduce_diff, + testing::Combine( + testing::Values(sz1080p), + testing::Values( + make_tuple((MatType)CV_8UC1, (MatDepth)CV_32S), make_tuple((MatType)CV_8UC3, (MatDepth)CV_32S), make_tuple((MatType)CV_8UC4, (MatDepth)CV_32S), + make_tuple((MatType)CV_8UC1, (MatDepth)CV_32F), make_tuple((MatType)CV_8UC3, (MatDepth)CV_32F), make_tuple((MatType)CV_8UC4, (MatDepth)CV_32F), + make_tuple((MatType)CV_8UC1, (MatDepth)CV_64F), make_tuple((MatType)CV_8UC3, (MatDepth)CV_64F), make_tuple((MatType)CV_8UC4, (MatDepth)CV_64F), + make_tuple((MatType)CV_16UC1, (MatDepth)CV_32F), make_tuple((MatType)CV_16UC3, (MatDepth)CV_32F), make_tuple((MatType)CV_16UC4, (MatDepth)CV_32F), + make_tuple((MatType)CV_16UC1, (MatDepth)CV_64F), make_tuple((MatType)CV_16UC3, (MatDepth)CV_64F), make_tuple((MatType)CV_16UC4, (MatDepth)CV_64F), + make_tuple((MatType)CV_16SC1, (MatDepth)CV_32F), make_tuple((MatType)CV_16SC3, (MatDepth)CV_32F), make_tuple((MatType)CV_16SC4, (MatDepth)CV_32F), + make_tuple((MatType)CV_16SC1, (MatDepth)CV_64F), make_tuple((MatType)CV_16SC3, (MatDepth)CV_64F), make_tuple((MatType)CV_16SC4, (MatDepth)CV_64F), + make_tuple((MatType)CV_32FC1, (MatDepth)CV_32F), make_tuple((MatType)CV_32FC3, (MatDepth)CV_32F), make_tuple((MatType)CV_32FC4, (MatDepth)CV_32F), + make_tuple((MatType)CV_32FC1, (MatDepth)CV_64F), make_tuple((MatType)CV_32FC3, (MatDepth)CV_64F), make_tuple((MatType)CV_32FC4, (MatDepth)CV_64F), + make_tuple((MatType)CV_64FC1, (MatDepth)CV_64F), make_tuple((MatType)CV_64FC3, (MatDepth)CV_64F), make_tuple((MatType)CV_64FC4, (MatDepth)CV_64F)), + ROpDiff::all(), + testing::Values(0, 1) // reduce dim: 0 = rows, 1 = columns + ) + ) +{ + Size sz = get<0>(GetParam()); + int srcType = get<0>(get<1>(GetParam())); + int dstDepth = get<1>(get<1>(GetParam())); + int reduceOp = get<2>(GetParam()); + int dim = get<3>(GetParam()); + + int cn = CV_MAT_CN(srcType); + Size dstSize = (dim == 0) ? Size(sz.width, 1) : Size(1, sz.height); + + Mat src(sz, srcType); + Mat vec(dstSize, CV_MAKETYPE(dstDepth, cn)); + + declare.in(src, WARMUP_RNG).out(vec); + declare.time(100); + + TEST_CYCLE_MULTIRUN(15) reduce(src, vec, dim, reduceOp, dstDepth); + + SANITY_CHECK_NOTHING(); +} + typedef tuple Size_MatType_RMode_t; typedef perf::TestBaseWithParam Size_MatType_RMode; diff --git a/modules/core/perf/perf_sort.cpp b/modules/core/perf/perf_sort.cpp index 98056901aea1..41f8ec1f29a0 100644 --- a/modules/core/perf/perf_sort.cpp +++ b/modules/core/perf/perf_sort.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test @@ -5,8 +6,8 @@ namespace opencv_test using namespace perf; #define TYPICAL_MAT_SIZES_SORT TYPICAL_MAT_SIZES -#define TYPICAL_MAT_TYPES_SORT CV_8UC1, CV_16UC1, CV_32FC1 -#define SORT_TYPES SORT_EVERY_ROW | SORT_ASCENDING, SORT_EVERY_ROW | SORT_DESCENDING +#define TYPICAL_MAT_TYPES_SORT CV_8UC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 +#define SORT_TYPES SORT_EVERY_ROW | SORT_ASCENDING, SORT_EVERY_ROW | SORT_DESCENDING, SORT_EVERY_COLUMN | SORT_ASCENDING, SORT_EVERY_COLUMN | SORT_DESCENDING #define TYPICAL_MATS_SORT testing::Combine( testing::Values(TYPICAL_MAT_SIZES_SORT), testing::Values(TYPICAL_MAT_TYPES_SORT), testing::Values(SORT_TYPES) ) typedef tuple sortParams; @@ -27,10 +28,28 @@ PERF_TEST_P(sortFixture, sort, TYPICAL_MATS_SORT) SANITY_CHECK(b); } -typedef sortFixture sortIdxFixture; +PERF_TEST_P(sortFixture, sort_inplace, TYPICAL_MATS_SORT) +{ + const sortParams params = GetParam(); + const Size sz = get<0>(params); + const int type = get<1>(params), flags = get<2>(params); + + cv::Mat a(sz, type), b(sz, type); -#undef SORT_TYPES -#define SORT_TYPES SORT_EVERY_COLUMN | SORT_ASCENDING, SORT_EVERY_COLUMN | SORT_DESCENDING + declare.in(a, WARMUP_RNG).out(b); + + while (next()) + { + a.copyTo(b); + startTimer(); + cv::sort(b, b, flags); + stopTimer(); + } + + SANITY_CHECK_NOTHING(); +} + +typedef sortFixture sortIdxFixture; PERF_TEST_P(sortIdxFixture, sorIdx, TYPICAL_MATS_SORT) { diff --git a/modules/core/perf/perf_split.cpp b/modules/core/perf/perf_split.cpp index 2cbc0b289cae..37165ff47f7e 100644 --- a/modules/core/perf/perf_split.cpp +++ b/modules/core/perf/perf_split.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test @@ -11,7 +12,7 @@ PERF_TEST_P( Size_Depth_Channels, split, testing::Combine ( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_8U, CV_16S, CV_32F, CV_64F), + testing::Values(CV_8U, CV_16U, CV_16S, CV_32F, CV_64F), testing::Values(2, 3, 4) ) ) diff --git a/modules/core/perf/perf_stat.cpp b/modules/core/perf/perf_stat.cpp index 884647584445..33fbc20d7ca9 100644 --- a/modules/core/perf/perf_stat.cpp +++ b/modules/core/perf/perf_stat.cpp @@ -1,10 +1,19 @@ +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { using namespace perf; -PERF_TEST_P(Size_MatType, sum, TYPICAL_MATS) +// Masked variants: 8U/16U/32F x C1/C3/C4. +#define TYPICAL_MAT_TYPES_STAT_MASK CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4 +// sum/mean/meanStdDev additionally cover 16S. +#define TYPICAL_MAT_TYPES_STAT TYPICAL_MAT_TYPES_STAT_MASK, CV_16SC1, CV_16SC3, CV_16SC4 +// Single-channel-only reductions (shared by countNonZero/hasNonZero). +#define TYPICAL_MAT_TYPES_NONZERO CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 + +PERF_TEST_P(Size_MatType, sum, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), + testing::Values( TYPICAL_MAT_TYPES_STAT ) )) { Size sz = get<0>(GetParam()); int type = get<1>(GetParam()); @@ -19,7 +28,8 @@ PERF_TEST_P(Size_MatType, sum, TYPICAL_MATS) SANITY_CHECK(s, 1e-6, ERROR_RELATIVE); } -PERF_TEST_P(Size_MatType, mean, TYPICAL_MATS) +PERF_TEST_P(Size_MatType, mean, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), + testing::Values( TYPICAL_MAT_TYPES_STAT ) )) { Size sz = get<0>(GetParam()); int type = get<1>(GetParam()); @@ -34,7 +44,8 @@ PERF_TEST_P(Size_MatType, mean, TYPICAL_MATS) SANITY_CHECK(s, 1e-5); } -PERF_TEST_P(Size_MatType, mean_mask, TYPICAL_MATS) +PERF_TEST_P(Size_MatType, mean_mask, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), + testing::Values( TYPICAL_MAT_TYPES_STAT_MASK ) )) { Size sz = get<0>(GetParam()); int type = get<1>(GetParam()); @@ -50,7 +61,8 @@ PERF_TEST_P(Size_MatType, mean_mask, TYPICAL_MATS) SANITY_CHECK(s, 5e-5); } -PERF_TEST_P(Size_MatType, meanStdDev, TYPICAL_MATS) +PERF_TEST_P(Size_MatType, meanStdDev, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), + testing::Values( TYPICAL_MAT_TYPES_STAT_MASK ) )) { Size sz = get<0>(GetParam()); int matType = get<1>(GetParam()); @@ -67,7 +79,8 @@ PERF_TEST_P(Size_MatType, meanStdDev, TYPICAL_MATS) SANITY_CHECK(dev, 1e-5, ERROR_RELATIVE); } -PERF_TEST_P(Size_MatType, meanStdDev_mask, TYPICAL_MATS) +PERF_TEST_P(Size_MatType, meanStdDev_mask, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), + testing::Values( TYPICAL_MAT_TYPES_STAT_MASK ) )) { Size sz = get<0>(GetParam()); int matType = get<1>(GetParam()); @@ -85,7 +98,7 @@ PERF_TEST_P(Size_MatType, meanStdDev_mask, TYPICAL_MATS) SANITY_CHECK(dev, 1e-5); } -PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 ) )) +PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( TYPICAL_MAT_TYPES_NONZERO ) )) { Size sz = get<0>(GetParam()); int matType = get<1>(GetParam()); @@ -101,7 +114,7 @@ PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPIC SANITY_CHECK(cnt); } -PERF_TEST_P(Size_MatType, hasNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 ) )) +PERF_TEST_P(Size_MatType, hasNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( TYPICAL_MAT_TYPES_NONZERO ) )) { Size sz = get<0>(GetParam()); int matType = get<1>(GetParam()); diff --git a/modules/imgproc/perf/perf_accumulate.cpp b/modules/imgproc/perf/perf_accumulate.cpp index 884ab9c295b2..bd6a96e8cd4c 100644 --- a/modules/imgproc/perf/perf_accumulate.cpp +++ b/modules/imgproc/perf/perf_accumulate.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { @@ -39,7 +40,7 @@ typedef Size_MatType Accumulate; /////////////////////////////////// Accumulate /////////////////////////////////// -PERF_TEST_P_ACCUMULATE(Accumulate, MAT_TYPES_ACCUMLATE, +PERF_TEST_P_ACCUMULATE(Accumulate, MAT_TYPES_ACCUMLATE_C, PERF_ACCUMULATE_INIT(CV_32FC), accumulate(src1, dst)) PERF_TEST_P_ACCUMULATE(AccumulateMask, MAT_TYPES_ACCUMLATE_C, @@ -51,7 +52,7 @@ PERF_TEST_P_ACCUMULATE(AccumulateMask32FC4, CV_32FC4, PERF_TEST_P_ACCUMULATE(AccumulateMask8UC4To32FC4, CV_8UC4, PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulate(src1, dst, mask)) -PERF_TEST_P_ACCUMULATE(AccumulateDouble, MAT_TYPES_ACCUMLATE_D, +PERF_TEST_P_ACCUMULATE(AccumulateDouble, MAT_TYPES_ACCUMLATE_D_C, PERF_ACCUMULATE_INIT(CV_64FC), accumulate(src1, dst)) PERF_TEST_P_ACCUMULATE(AccumulateDoubleMask, MAT_TYPES_ACCUMLATE_D_C, @@ -59,13 +60,13 @@ PERF_TEST_P_ACCUMULATE(AccumulateDoubleMask, MAT_TYPES_ACCUMLATE_D_C, ///////////////////////////// AccumulateSquare /////////////////////////////////// -PERF_TEST_P_ACCUMULATE(Square, MAT_TYPES_ACCUMLATE, +PERF_TEST_P_ACCUMULATE(Square, MAT_TYPES_ACCUMLATE_C, PERF_ACCUMULATE_INIT(CV_32FC), accumulateSquare(src1, dst)) PERF_TEST_P_ACCUMULATE(SquareMask, MAT_TYPES_ACCUMLATE_C, PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulateSquare(src1, dst, mask)) -PERF_TEST_P_ACCUMULATE(SquareDouble, MAT_TYPES_ACCUMLATE_D, +PERF_TEST_P_ACCUMULATE(SquareDouble, MAT_TYPES_ACCUMLATE_D_C, PERF_ACCUMULATE_INIT(CV_64FC), accumulateSquare(src1, dst)) PERF_TEST_P_ACCUMULATE(SquareDoubleMask, MAT_TYPES_ACCUMLATE_D_C, @@ -83,13 +84,13 @@ PERF_TEST_P_ACCUMULATE(SquareDoubleMask, MAT_TYPES_ACCUMLATE_D_C, Mat src2(srcSize, srcType); \ declare.in(src2); -PERF_TEST_P_ACCUMULATE(Product, MAT_TYPES_ACCUMLATE, +PERF_TEST_P_ACCUMULATE(Product, MAT_TYPES_ACCUMLATE_C, PERF_ACCUMULATE_INIT_2(CV_32FC), accumulateProduct(src1, src2, dst)) PERF_TEST_P_ACCUMULATE(ProductMask, MAT_TYPES_ACCUMLATE_C, PERF_ACCUMULATE_MASK_INIT_2(CV_32FC), accumulateProduct(src1, src2, dst, mask)) -PERF_TEST_P_ACCUMULATE(ProductDouble, MAT_TYPES_ACCUMLATE_D, +PERF_TEST_P_ACCUMULATE(ProductDouble, MAT_TYPES_ACCUMLATE_D_C, PERF_ACCUMULATE_INIT_2(CV_64FC), accumulateProduct(src1, src2, dst)) PERF_TEST_P_ACCUMULATE(ProductDoubleMask, MAT_TYPES_ACCUMLATE_D_C, @@ -97,13 +98,13 @@ PERF_TEST_P_ACCUMULATE(ProductDoubleMask, MAT_TYPES_ACCUMLATE_D_C, ///////////////////////////// AccumulateWeighted /////////////////////////////////// -PERF_TEST_P_ACCUMULATE(Weighted, MAT_TYPES_ACCUMLATE, +PERF_TEST_P_ACCUMULATE(Weighted, MAT_TYPES_ACCUMLATE_C, PERF_ACCUMULATE_INIT(CV_32FC), accumulateWeighted(src1, dst, 0.123)) PERF_TEST_P_ACCUMULATE(WeightedMask, MAT_TYPES_ACCUMLATE_C, PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulateWeighted(src1, dst, 0.123, mask)) -PERF_TEST_P_ACCUMULATE(WeightedDouble, MAT_TYPES_ACCUMLATE_D, +PERF_TEST_P_ACCUMULATE(WeightedDouble, MAT_TYPES_ACCUMLATE_D_C, PERF_ACCUMULATE_INIT(CV_64FC), accumulateWeighted(src1, dst, 0.123456)) PERF_TEST_P_ACCUMULATE(WeightedDoubleMask, MAT_TYPES_ACCUMLATE_D_C, diff --git a/modules/imgproc/perf/perf_bilateral.cpp b/modules/imgproc/perf/perf_bilateral.cpp index 38f2a503d34e..143af15075bf 100644 --- a/modules/imgproc/perf/perf_bilateral.cpp +++ b/modules/imgproc/perf/perf_bilateral.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { @@ -12,7 +13,7 @@ typedef TestBaseWithParam< tuple > TestBilateralFil PERF_TEST_P( TestBilateralFilter, BilateralFilter, Combine( Values( szVGA, sz1080p ), // image size - Values( 3, 5 ), // d + Values( 3, 5, 7, 21 ), // d Mat_Type::all(), // image type Values(1., 5.) ) diff --git a/modules/imgproc/perf/perf_blur.cpp b/modules/imgproc/perf/perf_blur.cpp index fd649b08c68a..8bf0e0f090d4 100644 --- a/modules/imgproc/perf/perf_blur.cpp +++ b/modules/imgproc/perf/perf_blur.cpp @@ -1,17 +1,32 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { +// 8U x C1/C3/C4 — depth/channel base shared by the type sweeps below. +#define BLUR_8U_TYPES CV_8UC1, CV_8UC3, CV_8UC4 +// 8U/16U/16S x C1/C3/C4 — integer coverage shared by medianBlur and boxFilter. +#define BLUR_INT_TYPES BLUR_8U_TYPES, CV_16UC1, CV_16UC3, CV_16UC4, CV_16SC1, CV_16SC3, CV_16SC4 +#define MEDIAN_BLUR_TYPES BLUR_INT_TYPES, CV_32FC1 +// cv::medianBlur supports aperture > 5 for CV_8U only. +#define MEDIAN_BLUR_LARGE_TYPES BLUR_8U_TYPES +// Full boxFilter type sweep. +#define BOX_FILTER_TYPES BLUR_INT_TYPES, CV_32SC1, CV_32FC1, CV_32FC3, CV_32FC4 +// 3x3 / 5x5 GaussianBlur type coverage. +#define GAUSSIAN_BLUR_TYPES BLUR_8U_TYPES, CV_16UC1, CV_16UC3, CV_16SC1, CV_16SC3, CV_32FC1, CV_32FC3 +// Large Gaussian kernels (7/21) drop the C4 variants. +#define GAUSSIAN_BLUR_LARGE_TYPES CV_8UC1, CV_8UC3, CV_16UC1, CV_16UC3, CV_16SC1, CV_16SC3, CV_32FC1, CV_32FC3 + typedef tuple Size_MatType_kSize_t; typedef perf::TestBaseWithParam Size_MatType_kSize; PERF_TEST_P(Size_MatType_kSize, medianBlur, testing::Combine( testing::Values(szODD, szQVGA, szVGA, sz720p), - testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1), + testing::Values(MEDIAN_BLUR_TYPES), testing::Values(3, 5) ) ) @@ -33,6 +48,59 @@ PERF_TEST_P(Size_MatType_kSize, medianBlur, SANITY_CHECK(dst); } +PERF_TEST_P(Size_MatType_kSize, medianBlur_large, + testing::Combine( + testing::Values(szODD, szQVGA, szVGA, sz720p), + testing::Values(MEDIAN_BLUR_LARGE_TYPES), + testing::Values(7, 21) + ) + ) +{ + Size size = get<0>(GetParam()); + int type = get<1>(GetParam()); + int ksize = get<2>(GetParam()); + + Mat src(size, type); + Mat dst(size, type); + + declare.in(src, WARMUP_RNG).out(dst); + declare.time(15); + + TEST_CYCLE() medianBlur(src, dst, ksize); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(Size_MatType_kSize, medianBlur_inplace, + testing::Combine( + testing::Values(szODD, szQVGA, szVGA, sz720p), + testing::Values(MEDIAN_BLUR_TYPES), + testing::Values(3, 5) + ) + ) +{ + Size size = get<0>(GetParam()); + int type = get<1>(GetParam()); + int ksize = get<2>(GetParam()); + + Mat src(size, type); + Mat dst(size, type); + + declare.in(src, WARMUP_RNG).out(dst); + if (CV_MAT_DEPTH(type) > CV_16S || CV_MAT_CN(type) > 1) + declare.time(15); + + while (next()) + { + src.copyTo(dst); + startTimer(); + cv::medianBlur(dst, dst, ksize); + stopTimer(); + } + + SANITY_CHECK_NOTHING(); +} + CV_ENUM(BorderType3x3, BORDER_REPLICATE, BORDER_CONSTANT) CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT101) @@ -52,7 +120,7 @@ typedef perf::TestBaseWithParam Size_MatType_Bo PERF_TEST_P(Size_MatType_BorderType3x3, gaussianBlur3x3, testing::Combine( testing::Values(szODD, szQVGA, szVGA, sz720p), - testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1), + testing::Values(GAUSSIAN_BLUR_TYPES), BorderType3x3::all() ) ) @@ -121,9 +189,9 @@ PERF_TEST_P(Size_MatType_BorderType, blur16x16, PERF_TEST_P(Size_MatType_BorderType_ksize, box, testing::Combine( testing::Values(szODD, szQVGA, szVGA, sz720p), - testing::Values(CV_8UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC3), + testing::Values(BOX_FILTER_TYPES), BorderType::all(), - testing::Values(3, 5) + testing::Values(3, 5, 7, 21) ) ) { @@ -199,7 +267,7 @@ PERF_TEST_P(Size_MatType_BorderType_ksize, box_inplace, PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5, testing::Combine( testing::Values(szODD, szQVGA, szVGA, sz720p), - testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1), + testing::Values(GAUSSIAN_BLUR_TYPES), BorderType::all() ) ) @@ -218,6 +286,31 @@ PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5, SANITY_CHECK(dst, 1); } +PERF_TEST_P(Size_MatType_BorderType_ksize, gaussianBlur, + testing::Combine( + testing::Values(szVGA, sz720p), + testing::Values(GAUSSIAN_BLUR_LARGE_TYPES), + BorderType::all(), + testing::Values(7, 21) + ) + ) +{ + auto p = GetParam(); + Size size = get<0>(p); + int type = get<1>(p); + BorderType btype = get<2>(p); + int ksize = get<3>(p); + + Mat src(size, type); + Mat dst(size, type); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() GaussianBlur(src, dst, Size(ksize, ksize), 0, 0, btype); + + SANITY_CHECK_NOTHING(); +} + PERF_TEST_P(Size_MatType_BorderType, blur5x5, testing::Combine( testing::Values(szVGA, sz720p), diff --git a/modules/imgproc/perf/perf_canny.cpp b/modules/imgproc/perf/perf_canny.cpp index 87d00f9a6cd4..ef1645995315 100644 --- a/modules/imgproc/perf/perf_canny.cpp +++ b/modules/imgproc/perf/perf_canny.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { @@ -37,4 +38,34 @@ PERF_TEST_P(Img_Aperture_L2_thresholds, canny, SANITY_CHECK(edges); } +typedef tuple Img_L2_t; +typedef perf::TestBaseWithParam Img_L2; + +PERF_TEST_P(Img_L2, cannyDeriv, + testing::Combine( + testing::Values("cv/shared/lena.png", "stitching/b1.png"), + testing::Bool() + )) +{ + string filename = getDataPath(get<0>(GetParam())); + bool useL2 = get<1>(GetParam()); + + Mat img = imread(filename, IMREAD_GRAYSCALE); + if (img.empty()) + FAIL() << "Unable to load source image " << filename; + + Mat dx, dy; + cv::Sobel(img, dx, CV_16S, 1, 0); + cv::Sobel(img, dy, CV_16S, 0, 1); + + Mat edges(img.size(), CV_8UC1); + double low = 50, high = 100; + + declare.in(dx, dy).out(edges); + + TEST_CYCLE() cv::Canny(dx, dy, edges, low, high, useL2); + + SANITY_CHECK_NOTHING(); +} + } // namespace diff --git a/modules/imgproc/perf/perf_copymakeborder.cpp b/modules/imgproc/perf/perf_copymakeborder.cpp new file mode 100644 index 000000000000..e02cbde5427d --- /dev/null +++ b/modules/imgproc/perf/perf_copymakeborder.cpp @@ -0,0 +1,71 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. +#include "perf_precomp.hpp" + +namespace opencv_test +{ +using namespace perf; + +CV_ENUM(BorderTypeCopy, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101) + +// 8U/16U/16S/32S/32F x C1/C3/C4. +#define COPYMAKEBORDER_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, \ + CV_16SC1, CV_16SC3, CV_16SC4, CV_32SC1, CV_32SC3, CV_32SC4, \ + CV_32FC1, CV_32FC3, CV_32FC4 + +typedef tuple Size_MatType_Border_BorderSize_t; +typedef perf::TestBaseWithParam Size_MatType_Border_BorderSize; + +PERF_TEST_P(Size_MatType_Border_BorderSize, copyMakeBorder, + testing::Combine( + testing::Values(szVGA, sz720p, sz1080p), + testing::Values(COPYMAKEBORDER_TYPES), + BorderTypeCopy::all(), + testing::Values(1, 2, 6) + )) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + int borderType = get<2>(GetParam()); + int borderSize = get<3>(GetParam()); + + Mat src(sz, type); + Mat dst(sz + Size(borderSize * 2, borderSize * 2), type); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE_MULTIRUN(10) + cv::copyMakeBorder(src, dst, borderSize, borderSize, borderSize, borderSize, + borderType | BORDER_ISOLATED, Scalar(-50)); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(Size_MatType_Border_BorderSize, copyMakeBorder_inplace, + testing::Combine( + testing::Values(szVGA, sz720p, sz1080p), + testing::Values(COPYMAKEBORDER_TYPES), + BorderTypeCopy::all(), + testing::Values(1, 2, 6) + )) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + int borderType = get<2>(GetParam()); + int borderSize = get<3>(GetParam()); + + Mat dst(sz + Size(borderSize * 2, borderSize * 2), type); + Mat src = Mat(dst, Rect(borderSize, borderSize, sz.width, sz.height)); + + declare.in(src, WARMUP_RNG); + + TEST_CYCLE_MULTIRUN(100) + cv::copyMakeBorder(src, dst, borderSize, borderSize, borderSize, borderSize, + borderType | BORDER_ISOLATED, Scalar(-50)); + + SANITY_CHECK_NOTHING(); +} + +} // namespace diff --git a/modules/imgproc/perf/perf_corners.cpp b/modules/imgproc/perf/perf_corners.cpp index 38f602107648..d9b2280b58b4 100644 --- a/modules/imgproc/perf/perf_corners.cpp +++ b/modules/imgproc/perf/perf_corners.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { @@ -14,7 +15,7 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris, testing::Combine( testing::Values( "stitching/a1.png", "cv/shared/pic5.png"), testing::Values( 3, 5 ), - testing::Values( 3, 5 ), + testing::Values( -1, 3, 5 ), // -1 = Scharr aperture testing::Values( 0.04, 0.1 ), BorderType::all() ) @@ -36,6 +37,34 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris, SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE); } +PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris_32f, + testing::Combine( + testing::Values( "stitching/a1.png", "cv/shared/pic5.png"), + testing::Values( 3, 5 ), + testing::Values( -1, 3, 5 ), + testing::Values( 0.04, 0.1 ), + BorderType::all() + ) + ) +{ + string filename = getDataPath(get<0>(GetParam())); + int blockSize = get<1>(GetParam()); + int apertureSize = get<2>(GetParam()); + double k = get<3>(GetParam()); + BorderType borderType = get<4>(GetParam()); + + Mat src8u = imread(filename, IMREAD_GRAYSCALE); + ASSERT_FALSE(src8u.empty()) << "Unable to load source image: " << filename; + Mat src; + src8u.convertTo(src, CV_32F, 1.0 / 255); + + Mat dst; + + TEST_CYCLE() cornerHarris(src, dst, blockSize, apertureSize, k, borderType); + + SANITY_CHECK_NOTHING(); +} + typedef tuple Img_BlockSize_ApertureSize_BorderType_t; typedef perf::TestBaseWithParam Img_BlockSize_ApertureSize_BorderType; @@ -70,7 +99,7 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal, testing::Combine( testing::Values( "stitching/a1.png", "cv/shared/pic5.png"), testing::Values( 3, 5 ), - testing::Values( 3, 5 ), + testing::Values( -1, 3, 5 ), // -1 = Scharr aperture BorderType::all() ) ) @@ -90,4 +119,30 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal, SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE); } +PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal_32f, + testing::Combine( + testing::Values( "stitching/a1.png", "cv/shared/pic5.png"), + testing::Values( 3, 5 ), + testing::Values( -1, 3, 5 ), + BorderType::all() + ) + ) +{ + string filename = getDataPath(get<0>(GetParam())); + int blockSize = get<1>(GetParam()); + int apertureSize = get<2>(GetParam()); + BorderType borderType = get<3>(GetParam()); + + Mat src8u = imread(filename, IMREAD_GRAYSCALE); + ASSERT_FALSE(src8u.empty()) << "Unable to load source image: " << filename; + Mat src; + src8u.convertTo(src, CV_32F, 1.0 / 255); + + Mat dst; + + TEST_CYCLE() cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType); + + SANITY_CHECK_NOTHING(); +} + } // namespace diff --git a/modules/imgproc/perf/perf_filter2d.cpp b/modules/imgproc/perf/perf_filter2d.cpp index 6eae9891b87a..0478f80c4155 100644 --- a/modules/imgproc/perf/perf_filter2d.cpp +++ b/modules/imgproc/perf/perf_filter2d.cpp @@ -1,12 +1,22 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101) +// 8U/16U/16S/32F x C1/C3/C4. +#define FILTER2D_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, \ + CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4 +// filter2D accepts both integer and float kernels; separable kernels are float only. +#define FILTER2D_KERNEL_TYPES CV_16SC1, CV_32FC1 +#define SEPFILTER2D_KERNEL_TYPES CV_32FC1 +// Common types for the tiled parallel FilterEngine path. +#define FILTER2D_PARALLEL_TYPES CV_8UC1, CV_8UC3, CV_32FC1 + typedef TestBaseWithParam< tuple > TestFilter2d; typedef TestBaseWithParam< tuple > Image_KernelSize; @@ -39,6 +49,68 @@ PERF_TEST_P( TestFilter2d, Filter2d, SANITY_CHECK(dst, 1); } +typedef TestBaseWithParam< tuple > TestFilter2dTypes; + +PERF_TEST_P( TestFilter2dTypes, Filter2d_types, + Combine( + Values( sz1080p ), + Values( FILTER2D_TYPES ), + Values( 3, 5, 7, 21 ), + Values( FILTER2D_KERNEL_TYPES ) // kernel type + ) +) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + int kSize = get<2>(GetParam()); + int kernType = get<3>(GetParam()); + + Mat src(sz, type); + Mat dst(sz, type); + + Mat kernel(kSize, kSize, kernType); + randu(kernel, -3, 10); + if (kernType == CV_32FC1) + { + double s = fabs( sum(kernel)[0] ); + if(s > 1e-3) kernel /= s; + } + + declare.in(src, WARMUP_RNG).out(dst).time(20); + + TEST_CYCLE() cv::filter2D(src, dst, -1, kernel, Point(-1, -1), 0., BORDER_REPLICATE); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P( TestFilter2dTypes, sepFilter2D_types, + Combine( + Values( sz1080p ), + Values( FILTER2D_TYPES ), + Values( 3, 5, 7, 21 ), + Values( SEPFILTER2D_KERNEL_TYPES ) // separable kernels are float + ) +) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + int kSize = get<2>(GetParam()); + + Mat src(sz, type); + Mat dst(sz, type); + + Mat kernelX(1, kSize, CV_32FC1); + Mat kernelY(1, kSize, CV_32FC1); + randu(kernelX, -6, 6); + randu(kernelY, -6, 6); + + declare.in(src, WARMUP_RNG).out(dst).time(20); + + TEST_CYCLE() cv::sepFilter2D(src, dst, -1, kernelX, kernelY, Point(-1, -1), 0., BORDER_REPLICATE); + + SANITY_CHECK_NOTHING(); +} + PERF_TEST_P(TestFilter2d, DISABLED_Filter2d_ovx, Combine( Values(Size(320, 240), sz1080p), @@ -104,7 +176,7 @@ typedef TestBaseWithParam< tuple > ImgProc_Parallel PERF_TEST_P( ImgProc_ParallelFilter_Perf, filter2D_parallel, Combine( Values( Size(1280, 1024), sz1080p ), - Values( CV_8UC1, CV_8UC3, CV_32FC1 ), + Values( FILTER2D_PARALLEL_TYPES ), Values( BORDER_DEFAULT, BORDER_CONSTANT ), Values( false, true ) // false = filter2D, true = sepFilter2D ) diff --git a/modules/imgproc/perf/perf_getrectsubpix.cpp b/modules/imgproc/perf/perf_getrectsubpix.cpp new file mode 100644 index 000000000000..a86d1776e9ad --- /dev/null +++ b/modules/imgproc/perf/perf_getrectsubpix.cpp @@ -0,0 +1,44 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. +#include "perf_precomp.hpp" + +namespace opencv_test +{ +using namespace perf; + +#define GETRECTSUBPIX_TYPES CV_8UC1, CV_32FC1 + +typedef tuple Size_SrcType_DstType_t; +typedef perf::TestBaseWithParam Size_SrcType_DstType; + +PERF_TEST_P(Size_SrcType_DstType, getRectSubPix, + testing::Combine( + testing::Values(szVGA, sz720p, sz1080p), + testing::Values(GETRECTSUBPIX_TYPES), + testing::Values(GETRECTSUBPIX_TYPES) + )) +{ + Size sz = get<0>(GetParam()); + int srcType = get<1>(GetParam()); + int dstType = get<2>(GetParam()); + + // getRectSubPix does not support a lower-depth output than the input + if (CV_MAT_DEPTH(dstType) < CV_MAT_DEPTH(srcType)) + throw ::perf::TestBase::PerfSkipTestException(); + + Size rectSize(std::min(800, sz.width), std::min(600, sz.height)); + Point2f rectCenter(100.33f, 100.77f); + + Mat src(sz, srcType); + Mat dst(rectSize, dstType); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() cv::getRectSubPix(src, rectSize, rectCenter, dst, dstType); + + SANITY_CHECK_NOTHING(); +} + +} // namespace diff --git a/modules/imgproc/perf/perf_histogram.cpp b/modules/imgproc/perf/perf_histogram.cpp index d80d8a6d517f..6653e0d549eb 100644 --- a/modules/imgproc/perf/perf_histogram.cpp +++ b/modules/imgproc/perf/perf_histogram.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { @@ -41,6 +42,49 @@ PERF_TEST_P(Size_Source, calcHist1d, SANITY_CHECK(hist); } +typedef tuple Size_Source_Uniform_Accum_t; +typedef TestBaseWithParam Size_Source_Uniform_Accum; + +PERF_TEST_P(Size_Source_Uniform_Accum, calcHist1d_mode, + testing::Combine(testing::Values(sz3MP, sz5MP), + testing::Values(CV_8U, CV_16U, CV_32F), + testing::Bool(), // uniform + testing::Bool()) ) // accumulate +{ + Size size = get<0>(GetParam()); + MatType type = get<1>(GetParam()); + bool uniform = get<2>(GetParam()); + bool accumulate = get<3>(GetParam()); + + Mat source(size.height, size.width, type); + Mat hist; + int channels [] = {0}; + const int bins = 256; + int histSize [] = {bins}; + int dims = 1; + int numberOfImages = 1; + + randu(source, rangeLow, rangeHight); + + // Uniform ranges use the {low, high} form; non-uniform needs explicit bin edges. + const float uni[] = {rangeLow, rangeHight}; + std::vector edges(bins + 1); + for (int i = 0; i <= bins; ++i) + edges[i] = rangeLow + (rangeHight - rangeLow) * i / bins; + const float* ranges[] = { uniform ? uni : edges.data() }; + + declare.in(source); + + // With accumulate=true, calcHist adds into the existing hist, so the result + // compounds across timing iterations and is not a stable value to baseline. + TEST_CYCLE_MULTIRUN(3) + { + cv::calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges, uniform, accumulate); + } + + SANITY_CHECK_NOTHING(); +} + PERF_TEST_P(Size_Source, calcHist2d, testing::Combine(testing::Values(sz3MP, sz5MP), testing::Values(CV_8UC2, CV_16UC2, CV_32FC2) ) diff --git a/modules/imgproc/perf/perf_laplacian.cpp b/modules/imgproc/perf/perf_laplacian.cpp index cacd88d13043..ea6ad75032b1 100644 --- a/modules/imgproc/perf/perf_laplacian.cpp +++ b/modules/imgproc/perf/perf_laplacian.cpp @@ -1,12 +1,14 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101) -CV_ENUM(TargetDepth, CV_8U, CV_16S) +CV_ENUM(TargetDepth, CV_8U, CV_16S, CV_32F) +CV_ENUM(SrcDepth, CV_8U, CV_32F) typedef tuple LaplacianParams; typedef perf::TestBaseWithParam Perf_Laplacian; @@ -15,7 +17,7 @@ PERF_TEST_P(Perf_Laplacian, Laplacian, testing::Combine( testing::Values(szVGA, sz720p, sz1080p), testing::Values(1, 3, 5), // ksize: 1, 3, 5 - TargetDepth::all(), // CV_8U and CV_16S + TargetDepth::all(), // CV_8U, CV_16S and CV_32F BorderMode::all() )) { @@ -25,7 +27,7 @@ PERF_TEST_P(Perf_Laplacian, Laplacian, int borderMode = get<3>(GetParam()); Mat src(sz, CV_8UC1); - Mat dst(sz, ddepth == CV_16S ? CV_16SC1 : CV_8UC1); + Mat dst(sz, ddepth == CV_16S ? CV_16SC1 : ddepth == CV_32F ? CV_32FC1 : CV_8UC1); declare.in(src, WARMUP_RNG).out(dst); @@ -37,4 +39,66 @@ PERF_TEST_P(Perf_Laplacian, Laplacian, SANITY_CHECK(dst); } +typedef tuple LaplacianParams32f; +typedef perf::TestBaseWithParam Perf_Laplacian32f; + +PERF_TEST_P(Perf_Laplacian32f, Laplacian, + testing::Combine( + testing::Values(szVGA, sz720p, sz1080p), + testing::Values(1, 3, 5), + testing::Values((int)CV_32F), + BorderMode::all(), + testing::Bool() + )) +{ + Size sz = get<0>(GetParam()); + int ksize = get<1>(GetParam()); + int ddepth = get<2>(GetParam()); + int borderMode = get<3>(GetParam()); + bool scaled = get<4>(GetParam()); + double scale = scaled ? 1.333 : 1.0; + double delta = scaled ? 2.0 : 0.0; + + Mat src(sz, CV_32FC1); + Mat dst(sz, ddepth); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() + { + cv::Laplacian(src, dst, ddepth, ksize, scale, delta, borderMode); + } + + SANITY_CHECK_NOTHING(); +} + +typedef tuple LaplacianParamsScaled; +typedef perf::TestBaseWithParam Perf_Laplacian_scaled; + +PERF_TEST_P(Perf_Laplacian_scaled, Laplacian, + testing::Combine( + testing::Values(szVGA, sz720p, sz1080p), + testing::Values(1, 3, 5), + TargetDepth::all(), // CV_8U, CV_16S, CV_32F + BorderMode::all() + )) +{ + Size sz = get<0>(GetParam()); + int ksize = get<1>(GetParam()); + int ddepth = get<2>(GetParam()); + int borderMode = get<3>(GetParam()); + + Mat src(sz, CV_8UC1); + Mat dst(sz, ddepth == CV_16S ? CV_16SC1 : ddepth == CV_32F ? CV_32FC1 : CV_8UC1); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() + { + cv::Laplacian(src, dst, ddepth, ksize, 1.333, 2.0, borderMode); + } + + SANITY_CHECK_NOTHING(); +} + } // namespace opencv_test \ No newline at end of file diff --git a/modules/imgproc/perf/perf_matchTemplate.cpp b/modules/imgproc/perf/perf_matchTemplate.cpp index 9a50c4cc5d01..22735774d47f 100644 --- a/modules/imgproc/perf/perf_matchTemplate.cpp +++ b/modules/imgproc/perf/perf_matchTemplate.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { @@ -47,6 +48,34 @@ PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateSmall, SANITY_CHECK(result, eps); } +PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateSmall_32f, + testing::Combine( + testing::Values(cv::Size(320, 240), cv::Size(640, 480), + cv::Size(1024, 768)), + testing::Values(cv::Size(12, 12), cv::Size(16, 16)), + MethodType::all() + ) + ) +{ + Size imgSz = get<0>(GetParam()); + Size tmplSz = get<1>(GetParam()); + int method = get<2>(GetParam()); + + Mat img(imgSz, CV_32FC1); + Mat tmpl(tmplSz, CV_32FC1); + Mat result(imgSz - tmplSz + Size(1,1), CV_32F); + + declare + .in(img, WARMUP_RNG) + .in(tmpl, WARMUP_RNG) + .out(result) + .time(30); + + TEST_CYCLE() cv::matchTemplate(img, tmpl, result, method); + + SANITY_CHECK_NOTHING(); +} + PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateBig, testing::Combine( testing::Values(cv::Size(1280, 1024)), diff --git a/modules/imgproc/perf/perf_moments.cpp b/modules/imgproc/perf/perf_moments.cpp index 5d9c0366a174..26467c1d9fb2 100644 --- a/modules/imgproc/perf/perf_moments.cpp +++ b/modules/imgproc/perf/perf_moments.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. // Copyright (C) 2014, Itseez, Inc., all rights reserved. // Third party copyrights are property of their respective owners. @@ -15,7 +16,7 @@ typedef perf::TestBaseWithParam MomentsFixture_val; PERF_TEST_P(MomentsFixture_val, Moments1, ::testing::Combine( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_16U, CV_16S, CV_32F, CV_64F), + testing::Values(CV_8U, CV_16U, CV_16S, CV_32F, CV_64F), testing::Bool())) { const MomentsParams_t params = GetParam(); diff --git a/modules/imgproc/perf/perf_morph.cpp b/modules/imgproc/perf/perf_morph.cpp index dc9e975a21fb..c2057c95c847 100644 --- a/modules/imgproc/perf/perf_morph.cpp +++ b/modules/imgproc/perf/perf_morph.cpp @@ -1,12 +1,17 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { -#define TYPICAL_MAT_TYPES_MORPH CV_8UC1, CV_8UC4 +#define TYPICAL_MAT_TYPES_MORPH CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1, CV_32FC3, CV_32FC4 #define TYPICAL_MATS_MORPH testing::Combine(SZ_ALL_GA, testing::Values(TYPICAL_MAT_TYPES_MORPH)) +// The new kernel/iteration morphology tests below are heavy (types × kernel × +// iterations); IPP used a single size (sz1080p). Keep a small 2-size sweep +// (small + large) for size-scaling insight without the full SZ_ALL_GA cost. +#define MORPH_KERNEL_SIZES testing::Values(::perf::szVGA, ::perf::szXGA) PERF_TEST_P(Size_MatType, erode, TYPICAL_MATS_MORPH) { @@ -39,4 +44,85 @@ PERF_TEST_P(Size_MatType, dilate, TYPICAL_MATS_MORPH) SANITY_CHECK(dst); } +typedef tuple Size_MatType_kSize_iter_t; +typedef perf::TestBaseWithParam Size_MatType_kSize_iter; + +PERF_TEST_P(Size_MatType_kSize_iter, erode_kernel, + testing::Combine( + MORPH_KERNEL_SIZES, + testing::Values(TYPICAL_MAT_TYPES_MORPH), + testing::Values(3, 5, 7), + testing::Values(1, 3) + )) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + int ksize = get<2>(GetParam()); + int iters = get<3>(GetParam()); + + Mat src(sz, type); + Mat dst(sz, type); + Mat kernel = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() erode(src, dst, kernel, Point(-1, -1), iters); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(Size_MatType_kSize_iter, dilate_kernel, + testing::Combine( + MORPH_KERNEL_SIZES, + testing::Values(TYPICAL_MAT_TYPES_MORPH), + testing::Values(3, 5, 7), + testing::Values(1, 3) + )) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + int ksize = get<2>(GetParam()); + int iters = get<3>(GetParam()); + + Mat src(sz, type); + Mat dst(sz, type); + Mat kernel = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() dilate(src, dst, kernel, Point(-1, -1), iters); + + SANITY_CHECK_NOTHING(); +} + +CV_ENUM(MorphExOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT) +typedef tuple Size_MatType_MorphExOp_kSize_iter_t; +typedef perf::TestBaseWithParam Size_MatType_MorphExOp_kSize_iter; + +PERF_TEST_P(Size_MatType_MorphExOp_kSize_iter, morphologyEx, + testing::Combine( + MORPH_KERNEL_SIZES, + testing::Values(TYPICAL_MAT_TYPES_MORPH), + MorphExOp::all(), + testing::Values(3, 5, 7), + testing::Values(1, 3) + )) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + int op = get<2>(GetParam()); + int ksize = get<3>(GetParam()); + int iters = get<4>(GetParam()); + + Mat src(sz, type); + Mat dst(sz, type); + Mat kernel = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() cv::morphologyEx(src, dst, op, kernel, Point(-1, -1), iters); + + SANITY_CHECK_NOTHING(); +} + } // namespace diff --git a/modules/imgproc/perf/perf_resize.cpp b/modules/imgproc/perf/perf_resize.cpp index 0f470a5f8156..d38d392a1cdc 100644 --- a/modules/imgproc/perf/perf_resize.cpp +++ b/modules/imgproc/perf/perf_resize.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { @@ -15,6 +16,9 @@ typedef TestBaseWithParam MatInfo_SizePair; CV_16UC1, CV_16UC2, CV_16UC3, CV_16UC4, \ CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4 +#define RESIZE_INTER_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, \ + CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4 + // For gradient-ish testing of the other matrix formats template static void fillFPGradient(Mat& img) @@ -280,4 +284,57 @@ PERF_TEST_P(MatInfo_Size_Scale_NN, ResizeNNExact, SANITY_CHECK_NOTHING(); } +CV_ENUM(ResizeInterCubicLanczos, INTER_CUBIC, INTER_LANCZOS4) +typedef tuple MatInfo_Size_Scale_Inter_t; +typedef TestBaseWithParam MatInfo_Size_Scale_Inter; + +PERF_TEST_P(MatInfo_Size_Scale_Inter, resizeCubicLanczos, + testing::Combine( + testing::Values(RESIZE_INTER_TYPES), + testing::Values(sz1080p), + testing::Values(0.777, 1.333, 2.0, 0.5, 0.25), + ResizeInterCubicLanczos::all() + )) +{ + int type = get<0>(GetParam()); + Size from = get<1>(GetParam()); + double scale = get<2>(GetParam()); + int inter = get<3>(GetParam()); + + Size to(saturate_cast(from.width * scale), saturate_cast(from.height * scale)); + + Mat src(from, type), dst(to, type); + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() cv::resize(src, dst, to, 0, 0, inter); + + SANITY_CHECK_NOTHING(); +} + +CV_ENUM(ResizeInterAffine, INTER_LINEAR, INTER_CUBIC) +typedef tuple MatInfo_Size_Scale_InterAffine_t; +typedef TestBaseWithParam MatInfo_Size_Scale_InterAffine; + +PERF_TEST_P(MatInfo_Size_Scale_InterAffine, resizeAffine, + testing::Combine( + testing::Values(RESIZE_INTER_TYPES), + testing::Values(sz1080p), + testing::Values(0.777, 1.333, 2.0, 0.5, 0.25), + ResizeInterAffine::all() + )) +{ + int type = get<0>(GetParam()); + Size from = get<1>(GetParam()); + double scale = get<2>(GetParam()); + int inter = get<3>(GetParam()); + + Mat src(from, type); + Mat dst(saturate_cast(from.width * scale), saturate_cast(from.height * scale), type); + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() cv::resize(src, dst, Size(), scale, scale, inter); + + SANITY_CHECK_NOTHING(); +} + } // namespace diff --git a/modules/imgproc/perf/perf_sepfilters.cpp b/modules/imgproc/perf/perf_sepfilters.cpp index 480aab9f2014..5d6f88a45139 100644 --- a/modules/imgproc/perf/perf_sepfilters.cpp +++ b/modules/imgproc/perf/perf_sepfilters.cpp @@ -1,6 +1,7 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { @@ -242,4 +243,74 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrViaSobelFilter, SANITY_CHECK(dst); } +/**************** Sobel / Scharr with 16S and 32F source ********************/ + +// Extra tuple slot for ksize {3,5} (IPP ippSobel swept both). +typedef tuple, BorderType3x3, bool, int> Size_MatType_dx_dy_Border3x3_scale_ksize_t; +typedef perf::TestBaseWithParam Size_MatType_dx_dy_Border3x3_scale_ksize; + +// Scharr's kernel is fixed 3x3, so it keeps the no-ksize fixture. +typedef tuple, BorderType3x3, bool> Size_MatType_dx_dy_Border3x3_scale_t; +typedef perf::TestBaseWithParam Size_MatType_dx_dy_Border3x3_scale; + +PERF_TEST_P(Size_MatType_dx_dy_Border3x3_scale_ksize, sobelFilter_srcType, + testing::Combine( + testing::Values(FILTER_SRC_SIZES), + testing::Values(CV_16S, CV_32F), // source depth (dst = same) + testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0), make_tuple(2, 2)), + BorderType3x3::all(), + testing::Bool(), // scaled: false=scale 1/delta 0, true=scale 1.333/delta 2 + testing::Values(3, 5) // ksize + ) + ) +{ + Size size = get<0>(GetParam()); + int depth = get<1>(GetParam()); + int dx = get<0>(get<2>(GetParam())); + int dy = get<1>(get<2>(GetParam())); + BorderType3x3 border = get<3>(GetParam()); + bool scaled = get<4>(GetParam()); + int ksize = get<5>(GetParam()); + double scale = scaled ? 1.333 : 1.0; + double delta = scaled ? 2.0 : 0.0; + + Mat src(size, depth); + Mat dst(size, depth); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() cv::Sobel(src, dst, depth, dx, dy, ksize, scale, delta, border); + + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(Size_MatType_dx_dy_Border3x3_scale, scharrFilter_srcType, + testing::Combine( + testing::Values(FILTER_SRC_SIZES), + testing::Values(CV_16S, CV_32F), // source depth (dst = same) + testing::Values(make_tuple(0, 1), make_tuple(1, 0)), + BorderType3x3::all(), + testing::Bool() + ) + ) +{ + Size size = get<0>(GetParam()); + int depth = get<1>(GetParam()); + int dx = get<0>(get<2>(GetParam())); + int dy = get<1>(get<2>(GetParam())); + BorderType3x3 border = get<3>(GetParam()); + bool scaled = get<4>(GetParam()); + double scale = scaled ? 1.333 : 1.0; + double delta = scaled ? 2.0 : 0.0; + + Mat src(size, depth); + Mat dst(size, depth); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() cv::Scharr(src, dst, depth, dx, dy, scale, delta, border); + + SANITY_CHECK_NOTHING(); +} + } // namespace diff --git a/modules/imgproc/perf/perf_threshold.cpp b/modules/imgproc/perf/perf_threshold.cpp index ab1d14fbf8bd..6491c0c13020 100644 --- a/modules/imgproc/perf/perf_threshold.cpp +++ b/modules/imgproc/perf/perf_threshold.cpp @@ -1,19 +1,23 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. +// Copyright (C) 2026, Intel Corporation, all rights reserved. #include "perf_precomp.hpp" namespace opencv_test { CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV) +#define THRESHOLD_INPLACE_TYPES CV_8UC1, CV_16SC1, CV_32FC1 +#define THRESHOLD_TYPES THRESHOLD_INPLACE_TYPES, CV_64FC1 + typedef tuple Size_MatType_ThreshType_t; typedef perf::TestBaseWithParam Size_MatType_ThreshType; PERF_TEST_P(Size_MatType_ThreshType, threshold, testing::Combine( testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_8UC1, CV_16SC1, CV_32FC1, CV_64FC1), + testing::Values(THRESHOLD_TYPES), ThreshType::all() ) ) @@ -37,6 +41,59 @@ PERF_TEST_P(Size_MatType_ThreshType, threshold, SANITY_CHECK(dst); } +PERF_TEST_P(Size_MatType_ThreshType, threshold_inplace, + testing::Combine( + testing::Values(TYPICAL_MAT_SIZES), + testing::Values(THRESHOLD_INPLACE_TYPES), + ThreshType::all() + ) + ) +{ + Size sz = get<0>(GetParam()); + int type = get<1>(GetParam()); + ThreshType threshType = get<2>(GetParam()); + + Mat src(sz, type); + Mat dst(sz, type); + + double thresh = theRNG().uniform(1, 254); + double maxval = theRNG().uniform(1, 254); + + declare.in(src, WARMUP_RNG).out(dst); + + while (next()) + { + src.copyTo(dst); + startTimer(); + cv::threshold(dst, dst, thresh, maxval, threshType); + stopTimer(); + } + + SANITY_CHECK_NOTHING(); +} + +typedef perf::TestBaseWithParam Size_ThreshInplaceOtsu; +PERF_TEST_P(Size_ThreshInplaceOtsu, threshold_inplace_otsu, testing::Values(TYPICAL_MAT_SIZES)) +{ + Size sz = GetParam(); + + Mat src(sz, CV_8UC1); + Mat dst(sz, CV_8UC1); + double maxval = theRNG().uniform(1, 254); + + declare.in(src, WARMUP_RNG).out(dst); + + while (next()) + { + src.copyTo(dst); + startTimer(); + cv::threshold(dst, dst, 0, maxval, THRESH_BINARY | THRESH_OTSU); + stopTimer(); + } + + SANITY_CHECK_NOTHING(); +} + typedef perf::TestBaseWithParam Size_Only; PERF_TEST_P(Size_Only, threshold_otsu, testing::Values(TYPICAL_MAT_SIZES))