Skip to content
41 changes: 41 additions & 0 deletions modules/calib3d/perf/perf_filterspeckles.cpp
Original file line number Diff line number Diff line change
@@ -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> Size_MatType_t;
typedef perf::TestBaseWithParam<Size_MatType_t> 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
145 changes: 143 additions & 2 deletions modules/core/perf/perf_arithm.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (C) 2026, Intel Corporation, all rights reserved.
#include "perf_precomp.hpp"
#include <numeric>
#include "opencv2/core/softfloat.hpp"
Expand All @@ -6,6 +7,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<std::tuple<std::vector<int>, perf::MatType, std::vector<int>>>;
typedef Size_MatType BinaryOpTest;

Expand Down Expand Up @@ -394,6 +403,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());
Expand Down Expand Up @@ -436,6 +464,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<int>& order)
{
std::vector<int> new_sz(order.size());
Expand Down Expand Up @@ -526,7 +607,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)
)
);

Expand Down Expand Up @@ -784,6 +865,43 @@ INSTANTIATE_TEST_CASE_P(/*nothing*/ , ArithmMixedTest,
)
);

typedef perf::TestBaseWithParam<std::tuple<cv::Size, perf::MatType>> 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<std::tuple<cv::Size, int, bool>> SqrtFixture;
PERF_TEST_P_(SqrtFixture, Sqrt) {
Size sz = get<0>(GetParam());
Expand All @@ -801,11 +919,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<std::tuple<cv::Size, int, double>> 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<std::tuple<cv::Size, int, perf::MatType>> RotateTest;
Expand Down
52 changes: 52 additions & 0 deletions modules/core/perf/perf_bitwise.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (C) 2026, Intel Corporation, all rights reserved.
#include "perf_precomp.hpp"

namespace opencv_test
Expand All @@ -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());
Expand Down Expand Up @@ -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
56 changes: 56 additions & 0 deletions modules/core/perf/perf_channels.cpp
Original file line number Diff line number Diff line change
@@ -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> Size_MatType_t;
typedef perf::TestBaseWithParam<Size_MatType_t> 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
9 changes: 7 additions & 2 deletions modules/core/perf/perf_compare.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (C) 2026, Intel Corporation, all rights reserved.
#include "perf_precomp.hpp"

namespace opencv_test
Expand All @@ -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> Size_MatType_CmpType_t;
typedef perf::TestBaseWithParam<Size_MatType_CmpType_t> 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()
)
)
Expand 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),
Comment thread
andreyfe1 marked this conversation as resolved.
testing::Values(COMPARE_SCALAR_TYPES),
CmpType::all()
)
)
Expand Down
Loading
Loading