mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -1571,4 +1571,54 @@ TEST(Core_Arithm, scalar_handling_19599) // https://github.com/opencv/opencv/is
|
||||
EXPECT_EQ(1, c.rows);
|
||||
}
|
||||
|
||||
// https://github.com/opencv/opencv/issues/24163
|
||||
typedef tuple<perf::MatDepth,int,int,int> Arith_Regression24163Param;
|
||||
typedef testing::TestWithParam<Arith_Regression24163Param> Core_Arith_Regression24163;
|
||||
|
||||
#if defined __riscv
|
||||
TEST_P(Core_Arith_Regression24163, DISABLED_test_for_ties_to_even)
|
||||
#else
|
||||
TEST_P(Core_Arith_Regression24163, test_for_ties_to_even)
|
||||
#endif
|
||||
{
|
||||
const int matDepth = get<0>(GetParam());
|
||||
const int matHeight= get<1>(GetParam());
|
||||
const int matWidth = 3; // Fixed
|
||||
const int alpha = get<2>(GetParam());
|
||||
const int beta = get<3>(GetParam());
|
||||
|
||||
// If alpha and/or beta are negative, and matDepth is unsigned, test is passed.
|
||||
if( ( (alpha < 0) || (beta < 0) )
|
||||
&&
|
||||
( (matDepth != CV_8S) && (matDepth != CV_16S) && (matDepth != CV_32S) ) )
|
||||
{
|
||||
throw SkipTestException( cv::format("Test is skipped(matDepth is not signed, alpha = %d, beta = %d)", alpha, beta) );
|
||||
}
|
||||
|
||||
const int matType = CV_MAKE_TYPE(matDepth, 1);
|
||||
const Size matSize(matWidth, matHeight);
|
||||
const Mat src1(matSize, matType, Scalar(alpha,alpha,alpha,alpha));
|
||||
const Mat src2(matSize, matType, Scalar(beta, beta, beta, beta));
|
||||
const Mat result = ( src1 + src2 ) / 2;
|
||||
|
||||
// Expected that default is FE_TONEAREST(Ties to Even).
|
||||
const int mean = lrint( static_cast<double>(alpha + beta) / 2.0 );
|
||||
const Mat expected(matSize, matType, Scalar(mean,mean,mean,mean));
|
||||
|
||||
// Compare result and extected.
|
||||
ASSERT_EQ(expected.size(), result.size());
|
||||
EXPECT_EQ(0, cvtest::norm(expected, result, NORM_INF)) <<
|
||||
"result=" << std::endl << result << std::endl <<
|
||||
"expected=" << std::endl << expected;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/* */, Core_Arith_Regression24163,
|
||||
testing::Combine(
|
||||
testing::Values(perf::MatDepth(CV_8U), CV_8S, CV_16U, CV_16S, CV_32S), // MatType
|
||||
testing::Values( 3, 4, 5, 6), // MatHeight
|
||||
testing::Values(-2,-1, 0, 1, 2), // src1
|
||||
testing::Values( -1, 0, 1 ) // src2
|
||||
)
|
||||
);
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user