mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge branch '4.x' into '5.x'
This commit is contained in:
@@ -300,8 +300,8 @@ Mat randomMat(RNG& rng, Size size, int type, double minVal, double maxVal, bool
|
||||
Mat randomMat(RNG& rng, const vector<int>& size, int type, double minVal, double maxVal, bool useRoi);
|
||||
void add(const Mat& a, double alpha, const Mat& b, double beta,
|
||||
Scalar gamma, Mat& c, int ctype, bool calcAbs=false);
|
||||
void multiply(const Mat& a, const Mat& b, Mat& c, double alpha=1);
|
||||
void divide(const Mat& a, const Mat& b, Mat& c, double alpha=1);
|
||||
void multiply(const Mat& a, const Mat& b, Mat& c, double alpha=1, int ctype=-1);
|
||||
void divide(const Mat& a, const Mat& b, Mat& c, double alpha=1, int ctype=-1);
|
||||
|
||||
void convert(const Mat& src, cv::OutputArray dst, int dtype, double alpha=1, double beta=0);
|
||||
void copy(const Mat& src, Mat& dst, const Mat& mask=Mat(), bool invertMask=false);
|
||||
@@ -611,7 +611,7 @@ public:
|
||||
};
|
||||
|
||||
// get RNG to generate random input data for a test
|
||||
RNG& get_rng() { return rng; }
|
||||
RNG& get_rng() { return cv::theRNG(); }
|
||||
|
||||
// returns the current error code
|
||||
TS::FailureCode get_err_code() { return TS::FailureCode(current_test_info.code); }
|
||||
@@ -629,7 +629,6 @@ public:
|
||||
protected:
|
||||
|
||||
// these are allocated within a test to try to keep them valid in case of stack corruption
|
||||
RNG rng;
|
||||
|
||||
// information about the current test
|
||||
TestInfo current_test_info;
|
||||
|
||||
@@ -21317,6 +21317,13 @@ AssertionResult CmpHelperEQFailure(const char* lhs_expression,
|
||||
false);
|
||||
}
|
||||
|
||||
// See https://github.com/opencv/opencv/issues/25674
|
||||
// Disable optimization for workaround to mis-branch for GCC14.
|
||||
#if defined(__GNUC__) && (__GNUC__ == 14)
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("O0")
|
||||
#endif
|
||||
|
||||
// The helper function for {ASSERT|EXPECT}_EQ.
|
||||
template <typename T1, typename T2>
|
||||
AssertionResult CmpHelperEQ(const char* lhs_expression,
|
||||
@@ -21330,6 +21337,10 @@ AssertionResult CmpHelperEQ(const char* lhs_expression,
|
||||
return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ == 14)
|
||||
#pragma GCC pop_options
|
||||
#endif
|
||||
|
||||
// With this overloaded version, we allow anonymous enums to be used
|
||||
// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
|
||||
// can be implicitly cast to BiggestInt.
|
||||
|
||||
@@ -591,8 +591,6 @@ void TS::init( const string& modulename )
|
||||
|
||||
if( params.use_optimized == 0 )
|
||||
cv::setUseOptimized(false);
|
||||
|
||||
rng = RNG(params.rng_seed);
|
||||
}
|
||||
|
||||
|
||||
@@ -635,9 +633,6 @@ void TS::update_context( BaseTest* test, int test_case_idx, bool update_ts_conte
|
||||
{
|
||||
current_test_info.rng_seed = param_seed + test_case_idx;
|
||||
current_test_info.rng_seed0 = current_test_info.rng_seed;
|
||||
|
||||
rng = RNG(current_test_info.rng_seed);
|
||||
cv::theRNG() = rng;
|
||||
}
|
||||
|
||||
current_test_info.test = test;
|
||||
|
||||
+84
-57
@@ -2782,18 +2782,19 @@ void max(const Mat& src1, double val, Mat& dst)
|
||||
}
|
||||
|
||||
|
||||
template<typename _Tp> static void
|
||||
muldiv_(const _Tp* src1, const _Tp* src2, _Tp* dst, size_t total, double scale, char op)
|
||||
template<typename SrcType, typename DstType> static void
|
||||
muldiv_(const SrcType* src1, const SrcType* src2, DstType* dst, size_t total, double scale, char op)
|
||||
{
|
||||
if( op == '*' )
|
||||
for( size_t i = 0; i < total; i++ )
|
||||
dst[i] = saturate_cast<_Tp>((scale*src1[i])*src2[i]);
|
||||
else if( src1 )
|
||||
for( size_t i = 0; i < total; i++ )
|
||||
dst[i] = src2[i] ? saturate_cast<_Tp>((scale*src1[i])/src2[i]) : 0;
|
||||
else
|
||||
for( size_t i = 0; i < total; i++ )
|
||||
dst[i] = src2[i] ? saturate_cast<_Tp>(scale/src2[i]) : 0;
|
||||
for( size_t i = 0; i < total; i++ )
|
||||
{
|
||||
double m1 = src1 ? (double)src1[i] : 1.0;
|
||||
double m2 = src2 ? (double)src2[i] : 1.0;
|
||||
if (op == '/')
|
||||
{
|
||||
m2 = abs(m2) > FLT_EPSILON ? (1.0 / m2) : 0;
|
||||
}
|
||||
dst[i] = saturate_cast<DstType>(scale * m1 * m2);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp> static void
|
||||
@@ -2810,16 +2811,16 @@ muldiv_16f(const _Tp* src1, const _Tp* src2, _Tp* dst, size_t total, double scal
|
||||
dst[i] = saturate_cast<_Tp>(scale/(float)src2[i]);
|
||||
}
|
||||
|
||||
static void muldiv(const Mat& src1, const Mat& src2, Mat& dst, double scale, char op)
|
||||
static void muldiv(const Mat& src1, const Mat& src2, Mat& dst, int ctype, double scale, char op)
|
||||
{
|
||||
dst.create(src2.dims, src2.size, src2.type());
|
||||
dst.create(src2.dims, src2.size, (ctype >= 0 ? ctype : src2.type()));
|
||||
CV_Assert( src1.empty() || (src1.type() == src2.type() && src1.size == src2.size) );
|
||||
const Mat *arrays[]={&src1, &src2, &dst, 0};
|
||||
Mat planes[3];
|
||||
|
||||
NAryMatIterator it(arrays, planes);
|
||||
size_t total = planes[1].total()*planes[1].channels();
|
||||
size_t i, nplanes = it.nplanes, depth = src2.depth();
|
||||
size_t i, nplanes = it.nplanes, srcDepth = src2.depth(), dstDepth = dst.depth();
|
||||
|
||||
for( i = 0; i < nplanes; i++, ++it )
|
||||
{
|
||||
@@ -2827,59 +2828,85 @@ static void muldiv(const Mat& src1, const Mat& src2, Mat& dst, double scale, cha
|
||||
const uchar* sptr2 = planes[1].ptr();
|
||||
uchar* dptr = planes[2].ptr();
|
||||
|
||||
switch( depth )
|
||||
if (srcDepth == dstDepth)
|
||||
{
|
||||
case CV_8U:
|
||||
muldiv_((const uchar*)sptr1, (const uchar*)sptr2, (uchar*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_8S:
|
||||
muldiv_((const schar*)sptr1, (const schar*)sptr2, (schar*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_16U:
|
||||
muldiv_((const ushort*)sptr1, (const ushort*)sptr2, (ushort*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_16S:
|
||||
muldiv_((const short*)sptr1, (const short*)sptr2, (short*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_32U:
|
||||
muldiv_((const unsigned*)sptr1, (const unsigned*)sptr2, (unsigned*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_32S:
|
||||
muldiv_((const int*)sptr1, (const int*)sptr2, (int*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_64U:
|
||||
muldiv_((const uint64*)sptr1, (const uint64*)sptr2, (uint64*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_64S:
|
||||
muldiv_((const int64*)sptr1, (const int64*)sptr2, (int64*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_32F:
|
||||
muldiv_((const float*)sptr1, (const float*)sptr2, (float*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_64F:
|
||||
muldiv_((const double*)sptr1, (const double*)sptr2, (double*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_16F:
|
||||
muldiv_16f((const cv::hfloat*)sptr1, (const cv::hfloat*)sptr2, (cv::hfloat*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_16BF:
|
||||
muldiv_16f((const cv::bfloat*)sptr1, (const cv::bfloat*)sptr2, (cv::bfloat*)dptr, total, scale, op);
|
||||
break;
|
||||
default:
|
||||
CV_Error(Error::StsUnsupportedFormat, "");
|
||||
switch( srcDepth )
|
||||
{
|
||||
case CV_8U:
|
||||
muldiv_((const uchar*)sptr1, (const uchar*)sptr2, (uchar*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_8S:
|
||||
muldiv_((const schar*)sptr1, (const schar*)sptr2, (schar*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_16U:
|
||||
muldiv_((const ushort*)sptr1, (const ushort*)sptr2, (ushort*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_16S:
|
||||
muldiv_((const short*)sptr1, (const short*)sptr2, (short*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_32U:
|
||||
muldiv_((const unsigned*)sptr1, (const unsigned*)sptr2, (unsigned*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_32S:
|
||||
muldiv_((const int*)sptr1, (const int*)sptr2, (int*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_64U:
|
||||
muldiv_((const uint64*)sptr1, (const uint64*)sptr2, (uint64*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_64S:
|
||||
muldiv_((const int64*)sptr1, (const int64*)sptr2, (int64*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_32F:
|
||||
muldiv_((const float*)sptr1, (const float*)sptr2, (float*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_64F:
|
||||
muldiv_((const double*)sptr1, (const double*)sptr2, (double*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_16F:
|
||||
muldiv_16f((const cv::hfloat*)sptr1, (const cv::hfloat*)sptr2, (cv::hfloat*)dptr, total, scale, op);
|
||||
break;
|
||||
case CV_16BF:
|
||||
muldiv_16f((const cv::bfloat*)sptr1, (const cv::bfloat*)sptr2, (cv::bfloat*)dptr, total, scale, op);
|
||||
break;
|
||||
default:
|
||||
CV_Error(Error::StsUnsupportedFormat, "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (srcDepth == CV_8U && dstDepth == CV_16U)
|
||||
{
|
||||
muldiv_((const uchar*)sptr1, (const uchar*)sptr2, (ushort*)dptr, total, scale, op);
|
||||
}
|
||||
else if (srcDepth == CV_8S && dstDepth == CV_16S)
|
||||
{
|
||||
muldiv_((const schar*)sptr1, (const schar*)sptr2, (short*)dptr, total, scale, op);
|
||||
}
|
||||
else if (srcDepth == CV_8U && dstDepth == CV_32F)
|
||||
{
|
||||
muldiv_((const uchar*)sptr1, (const uchar*)sptr2, (float*)dptr, total, scale, op);
|
||||
}
|
||||
else if (srcDepth == CV_8S && dstDepth == CV_32F)
|
||||
{
|
||||
muldiv_((const schar*)sptr1, (const schar*)sptr2, (float*)dptr, total, scale, op);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Error(Error::StsUnsupportedFormat, "This format combination is not supported yet");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void multiply(const Mat& src1, const Mat& src2, Mat& dst, double scale)
|
||||
void multiply(const Mat& src1, const Mat& src2, Mat& dst, double scale, int ctype)
|
||||
{
|
||||
muldiv( src1, src2, dst, scale, '*' );
|
||||
muldiv( src1, src2, dst, ctype, scale, '*' );
|
||||
}
|
||||
|
||||
void divide(const Mat& src1, const Mat& src2, Mat& dst, double scale)
|
||||
void divide(const Mat& src1, const Mat& src2, Mat& dst, double scale, int ctype)
|
||||
{
|
||||
muldiv( src1, src2, dst, scale, '/' );
|
||||
muldiv( src1, src2, dst, ctype, scale, '/' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user