Skip to content

Commit fcfdd31

Browse files
authored
Merge pull request opencv#26134 from savuor:rv/mixed_arithm_channels
Mixed arithmetics tests: multichannel support
2 parents 976fb3e + 8725a7e commit fcfdd31

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

modules/core/test/test_arithm.cpp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ INSTANTIATE_TEST_CASE_P(Core_CartToPolarToCart, ElemWiseTest, ::testing::Values(
16401640

16411641
// Mixed Type Arithmetic Operations
16421642

1643-
typedef std::tuple<ElemWiseOpPtr, std::tuple<cvtest::MatDepth, cvtest::MatDepth>> SomeType;
1643+
typedef std::tuple<ElemWiseOpPtr, std::tuple<cvtest::MatDepth, cvtest::MatDepth>, int> SomeType;
16441644
class ArithmMixedTest : public ::testing::TestWithParam<SomeType> {};
16451645

16461646
TEST_P(ArithmMixedTest, accuracy)
@@ -1649,7 +1649,10 @@ TEST_P(ArithmMixedTest, accuracy)
16491649
ElemWiseOpPtr op = std::get<0>(p);
16501650
int srcDepth = std::get<0>(std::get<1>(p));
16511651
int dstDepth = std::get<1>(std::get<1>(p));
1652+
int channels = std::get<2>(p);
16521653

1654+
int srcType = CV_MAKETYPE(srcDepth, channels);
1655+
int dstType = CV_MAKETYPE(dstDepth, channels);
16531656
op->flags |= BaseElemWiseOp::MIXED_TYPE;
16541657
int testIdx = 0;
16551658
RNG rng((uint64)ARITHM_RNG_SEED);
@@ -1664,15 +1667,15 @@ TEST_P(ArithmMixedTest, accuracy)
16641667
int ninputs = op->ninputs;
16651668
vector<Mat> src(ninputs);
16661669
for(int i = 0; i < ninputs; i++ )
1667-
src[i] = cvtest::randomMat(rng, size, srcDepth, minval, maxval, true);
1670+
src[i] = cvtest::randomMat(rng, size, srcType, minval, maxval, true);
16681671
Mat dst0, dst, mask;
16691672
if( haveMask )
16701673
{
16711674
mask = cvtest::randomMat(rng, size, CV_8UC1, 0, 2, true);
16721675
}
16731676

1674-
dst0 = cvtest::randomMat(rng, size, dstDepth, minval, maxval, false);
1675-
dst = cvtest::randomMat(rng, size, dstDepth, minval, maxval, true);
1677+
dst0 = cvtest::randomMat(rng, size, dstType, minval, maxval, false);
1678+
dst = cvtest::randomMat(rng, size, dstType, minval, maxval, true);
16761679
cvtest::copy(dst, dst0);
16771680

16781681
op->generateScalars(dstDepth, rng);
@@ -1692,53 +1695,62 @@ INSTANTIATE_TEST_CASE_P(Core_AddMixed, ArithmMixedTest,
16921695
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
16931696
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_16S},
16941697
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1695-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1698+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1699+
::testing::Values(1, 3, 4)));
16961700
INSTANTIATE_TEST_CASE_P(Core_AddScalarMixed, ArithmMixedTest,
16971701
::testing::Combine(::testing::Values(ElemWiseOpPtr(new AddSOp)),
16981702
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
16991703
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_16S},
17001704
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1701-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1705+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1706+
::testing::Values(1, 3, 4)));
17021707
INSTANTIATE_TEST_CASE_P(Core_AddWeightedMixed, ArithmMixedTest,
17031708
::testing::Combine(::testing::Values(ElemWiseOpPtr(new AddWeightedOp)),
17041709
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
17051710
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_16S},
17061711
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1707-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1712+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1713+
::testing::Values(1, 3, 4)));
17081714
INSTANTIATE_TEST_CASE_P(Core_SubMixed, ArithmMixedTest,
17091715
::testing::Combine(::testing::Values(ElemWiseOpPtr(new SubOp)),
17101716
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
17111717
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_16S},
17121718
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1713-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1719+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1720+
::testing::Values(1, 3, 4)));
17141721
INSTANTIATE_TEST_CASE_P(Core_SubScalarMinusArgMixed, ArithmMixedTest,
17151722
::testing::Combine(::testing::Values(ElemWiseOpPtr(new SubRSOp)),
17161723
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
17171724
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_16S},
17181725
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1719-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1726+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1727+
::testing::Values(1, 3, 4)));
17201728
INSTANTIATE_TEST_CASE_P(Core_MulMixed, ArithmMixedTest,
17211729
::testing::Combine(::testing::Values(ElemWiseOpPtr(new MulOp)),
17221730
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
17231731
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_16S},
17241732
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1725-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1733+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1734+
::testing::Values(1, 3, 4)));
17261735
INSTANTIATE_TEST_CASE_P(Core_MulScalarMixed, ArithmMixedTest,
17271736
::testing::Combine(::testing::Values(ElemWiseOpPtr(new MulSOp)),
17281737
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
17291738
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_16S},
17301739
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1731-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1740+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1741+
::testing::Values(1, 3, 4)));
17321742
INSTANTIATE_TEST_CASE_P(Core_DivMixed, ArithmMixedTest,
17331743
::testing::Combine(::testing::Values(ElemWiseOpPtr(new DivOp)),
17341744
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
17351745
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_16S},
17361746
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1737-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1747+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1748+
::testing::Values(1, 3, 4)));
17381749
INSTANTIATE_TEST_CASE_P(Core_RecipMixed, ArithmMixedTest,
17391750
::testing::Combine(::testing::Values(ElemWiseOpPtr(new RecipOp)),
1740-
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_32F},
1741-
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F})));
1751+
::testing::Values(std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8U, CV_16U},
1752+
std::tuple<cvtest::MatDepth, cvtest::MatDepth>{CV_8S, CV_32F}),
1753+
::testing::Values(1, 3, 4)));
17421754

17431755
TEST(Core_ArithmMask, uninitialized)
17441756
{

0 commit comments

Comments
 (0)