1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Extended several core functions to support new types (#24962)

* started adding support for new types (16f, 16bf, 32u, 64u, 64s) to arithmetic functions

* fixed several tests; refactored and extended sum(), extended inRange().

* extended countNonZero(), mean(), meanStdDev(), minMaxIdx(), norm() and sum() to support new types (F16, BF16, U32, U64, S64)

* put missing CV_DEPTH_MAX to some function dispatcher tables
* extended findnonzero, hasnonzero with the new types support

* extended mixChannels() to support new types

* minor fix

* fixed a few compile errors on Linux and a few failures in core tests

* fixed a few more warnings and test failures

* trying to fix the remaining warnings and test failures. The test `MulTestGPU.MathOpTest` was disabled - not clear whether to set tolerance - it's not bit-exact operation, as possibly assumed by the test, due to the use of scale and possibly limited accuracy of the intermediate floating-point calculations.

* found that in the current snapshot G-API produces incorrect results in Mul, Div and AddWeighted (at least when using OpenCL on Windows x64 or MacOS x64). Disabled the respective tests.
This commit is contained in:
Vadim Pisarevsky
2024-02-11 10:42:41 +03:00
committed by GitHub
parent f05ef64df8
commit 1d18aba587
45 changed files with 3286 additions and 4706 deletions
+23 -76
View File
@@ -394,27 +394,35 @@ typedef Hamming HammingLUT;
/////////////////////////////////// inline norms ////////////////////////////////////
template<typename _Tp> inline _Tp cv_abs(_Tp x) { return std::abs(x); }
template<typename _Tp> inline _Tp cv_abs(_Tp x) { return (_Tp)std::abs(x); }
template<typename _Tp> inline _Tp cv_absdiff(_Tp x, _Tp y) { return (_Tp)std::abs(x - y); }
inline int cv_abs(uchar x) { return x; }
inline int cv_abs(schar x) { return std::abs(x); }
inline int cv_abs(ushort x) { return x; }
inline int cv_abs(short x) { return std::abs(x); }
inline unsigned cv_abs(int x) { return (unsigned)std::abs(x); }
inline unsigned cv_abs(unsigned x) { return x; }
inline uint64 cv_abs(uint64 x) { return x; }
inline uint64 cv_abs(int64 x) { return (uint64)std::abs(x); }
inline float cv_abs(float16_t x) { return std::abs((float)x); }
inline float cv_abs(bfloat16_t x) { return std::abs((float)x); }
inline int cv_absdiff(uchar x, uchar y) { return (int)std::abs((int)x - (int)y); }
inline int cv_absdiff(schar x, schar y) { return (int)std::abs((int)x - (int)y); }
inline int cv_absdiff(ushort x, ushort y) { return (int)std::abs((int)x - (int)y); }
inline int cv_absdiff(short x, short y) { return (int)std::abs((int)x - (int)y); }
inline unsigned cv_absdiff(int x, int y) { return (unsigned)(std::max(x, y) - std::min(x, y)); }
inline unsigned cv_absdiff(unsigned x, unsigned y) { return std::max(x, y) - std::min(x, y); }
inline uint64 cv_absdiff(uint64 x, uint64 y) { return std::max(x, y) - std::min(x, y); }
inline float cv_absdiff(float16_t x, float16_t y) { return std::abs((float)x - (float)y); }
inline float cv_absdiff(bfloat16_t x, bfloat16_t y) { return std::abs((float)x - (float)y); }
template<typename _Tp, typename _AccTp> static inline
_AccTp normL2Sqr(const _Tp* a, int n)
{
_AccTp s = 0;
int i=0;
#if CV_ENABLE_UNROLLED
for( ; i <= n - 4; i += 4 )
for( int i = 0; i < n; i++ )
{
_AccTp v0 = a[i], v1 = a[i+1], v2 = a[i+2], v3 = a[i+3];
s += v0*v0 + v1*v1 + v2*v2 + v3*v3;
}
#endif
for( ; i < n; i++ )
{
_AccTp v = a[i];
_AccTp v = (_AccTp)a[i];
s += v*v;
}
return s;
@@ -424,15 +432,7 @@ template<typename _Tp, typename _AccTp> static inline
_AccTp normL1(const _Tp* a, int n)
{
_AccTp s = 0;
int i = 0;
#if CV_ENABLE_UNROLLED
for(; i <= n - 4; i += 4 )
{
s += (_AccTp)cv_abs(a[i]) + (_AccTp)cv_abs(a[i+1]) +
(_AccTp)cv_abs(a[i+2]) + (_AccTp)cv_abs(a[i+3]);
}
#endif
for( ; i < n; i++ )
for( int i = 0; i < n; i++ )
s += cv_abs(a[i]);
return s;
}
@@ -450,28 +450,9 @@ template<typename _Tp, typename _AccTp> static inline
_AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n)
{
_AccTp s = 0;
int i= 0;
#if CV_ENABLE_UNROLLED
for(; i <= n - 4; i += 4 )
{
_AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]);
s += v0*v0 + v1*v1 + v2*v2 + v3*v3;
}
#endif
for( ; i < n; i++ )
{
_AccTp v = _AccTp(a[i] - b[i]);
s += v*v;
}
return s;
}
static inline float normL2Sqr(const float* a, const float* b, int n)
{
float s = 0.f;
for( int i = 0; i < n; i++ )
{
float v = a[i] - b[i];
_AccTp v = (_AccTp)a[i] - (_AccTp)b[i];
s += v*v;
}
return s;
@@ -481,39 +462,8 @@ template<typename _Tp, typename _AccTp> static inline
_AccTp normL1(const _Tp* a, const _Tp* b, int n)
{
_AccTp s = 0;
int i= 0;
#if CV_ENABLE_UNROLLED
for(; i <= n - 4; i += 4 )
{
_AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]);
s += std::abs(v0) + std::abs(v1) + std::abs(v2) + std::abs(v3);
}
#endif
for( ; i < n; i++ )
{
_AccTp v = _AccTp(a[i] - b[i]);
s += std::abs(v);
}
return s;
}
inline float normL1(const float* a, const float* b, int n)
{
float s = 0.f;
for( int i = 0; i < n; i++ )
{
s += std::abs(a[i] - b[i]);
}
return s;
}
inline int normL1(const uchar* a, const uchar* b, int n)
{
int s = 0;
for( int i = 0; i < n; i++ )
{
s += std::abs(a[i] - b[i]);
}
s += (_AccTp)cv_absdiff(a[i], b[i]);
return s;
}
@@ -522,10 +472,7 @@ _AccTp normInf(const _Tp* a, const _Tp* b, int n)
{
_AccTp s = 0;
for( int i = 0; i < n; i++ )
{
_AccTp v0 = a[i] - b[i];
s = std::max(s, std::abs(v0));
}
s = std::max(s, (_AccTp)cv_absdiff(a[i], b[i]));
return s;
}
@@ -27,6 +27,9 @@ static inline void depthDispatch(const int depth, Args&&... args)
case CV_16S:
Functor<int16_t>{}(std::forward<Args>(args)...);
break;
case CV_32U:
Functor<uint32_t>{}(std::forward<Args>(args)...);
break;
case CV_32S:
Functor<int32_t>{}(std::forward<Args>(args)...);
break;
@@ -36,7 +39,18 @@ static inline void depthDispatch(const int depth, Args&&... args)
case CV_64F:
Functor<double>{}(std::forward<Args>(args)...);
break;
case CV_64U:
Functor<uint64_t>{}(std::forward<Args>(args)...);
break;
case CV_64S:
Functor<int64_t>{}(std::forward<Args>(args)...);
break;
case CV_16F:
Functor<cv::float16_t>{}(std::forward<Args>(args)...);
break;
case CV_16BF:
Functor<cv::bfloat16_t>{}(std::forward<Args>(args)...);
break;
default:
CV_Error(cv::Error::BadDepth, "Unsupported matrix type.");
};
@@ -117,6 +117,11 @@ CV_EXPORTS void add16s( const short* src1, size_t step1, const short* src2, size
CV_EXPORTS void add32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* );
CV_EXPORTS void add32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* );
CV_EXPORTS void add64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* );
CV_EXPORTS void add16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void add16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void add64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void add64s( const int64* src1, size_t step1, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void add32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* );
@@ -125,6 +130,11 @@ CV_EXPORTS void sub16s( const short* src1, size_t step1, const short* src2, size
CV_EXPORTS void sub32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub64s( const int64* src1, size_t step1, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void sub32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* );
@@ -133,6 +143,11 @@ CV_EXPORTS void max16s( const short* src1, size_t step1, const short* src2, size
CV_EXPORTS void max32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max64s( const int64* src1, size_t step1, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void max32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* );
@@ -141,6 +156,11 @@ CV_EXPORTS void min16s( const short* src1, size_t step1, const short* src2, size
CV_EXPORTS void min32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min64s( const int64* src1, size_t step1, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void min32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* );
@@ -149,6 +169,11 @@ CV_EXPORTS void absdiff16s( const short* src1, size_t step1, const short* src2,
CV_EXPORTS void absdiff32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff64s( const int64* src1, size_t step1, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void absdiff32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* );
CV_EXPORTS void and8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* );
CV_EXPORTS void or8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* );
@@ -162,6 +187,11 @@ CV_EXPORTS void cmp16s(const short* src1, size_t step1, const short* src2, size_
CV_EXPORTS void cmp32s(const int* src1, size_t step1, const int* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop);
CV_EXPORTS void cmp32f(const float* src1, size_t step1, const float* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop);
CV_EXPORTS void cmp64f(const double* src1, size_t step1, const double* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop);
CV_EXPORTS void cmp16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop);
CV_EXPORTS void cmp16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop);
CV_EXPORTS void cmp64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop);
CV_EXPORTS void cmp64s( const int64* src1, size_t step1, const int64* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop);
CV_EXPORTS void cmp32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop);
CV_EXPORTS void mul8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void mul8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale);
@@ -170,6 +200,11 @@ CV_EXPORTS void mul16s( const short* src1, size_t step1, const short* src2, size
CV_EXPORTS void mul32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void mul32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void mul64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void mul16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void mul16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void mul64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void mul64s( const int64* src1, size_t step1, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void mul32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale);
@@ -178,6 +213,11 @@ CV_EXPORTS void div16s( const short* src1, size_t step1, const short* src2, size
CV_EXPORTS void div32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div64s( const int64* src1, size_t step1, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void div32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void recip8u( const uchar *, size_t, const uchar * src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void recip8s( const schar *, size_t, const schar * src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale);
@@ -186,6 +226,11 @@ CV_EXPORTS void recip16s( const short *, size_t, const short * src2, size_t step
CV_EXPORTS void recip32s( const int *, size_t, const int * src2, size_t step2, int* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void recip32f( const float *, size_t, const float * src2, size_t step2, float* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void recip64f( const double *, size_t, const double * src2, size_t step2, double* dst, size_t step, int width, int height, void* scale);
CV_EXPORTS void recip16f( const cv_hal_f16 *, size_t, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void recip16bf( const cv_hal_bf16 *, size_t, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* );
CV_EXPORTS void recip64u( const uint64 *, size_t, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void recip64s( const int64 *, size_t, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* );
CV_EXPORTS void recip32u( const unsigned *, size_t, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* );
CV_EXPORTS void addWeighted8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _scalars );
CV_EXPORTS void addWeighted8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scalars );
@@ -194,6 +239,11 @@ CV_EXPORTS void addWeighted16s( const short* src1, size_t step1, const short* sr
CV_EXPORTS void addWeighted32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scalars );
CV_EXPORTS void addWeighted32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scalars );
CV_EXPORTS void addWeighted64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scalars );
CV_EXPORTS void addWeighted16f( const cv_hal_f16* src1, size_t step1, const cv_hal_f16* src2, size_t step2, cv_hal_f16* dst, size_t step, int width, int height, void* scalars );
CV_EXPORTS void addWeighted16bf( const cv_hal_bf16* src1, size_t step1, const cv_hal_bf16* src2, size_t step2, cv_hal_bf16* dst, size_t step, int width, int height, void* scalars );
CV_EXPORTS void addWeighted64u( const uint64* src1, size_t step1, const uint64* src2, size_t step2, uint64* dst, size_t step, int width, int height, void* scalars );
CV_EXPORTS void addWeighted64s( const int64* src1, size_t step1, const int64* src2, size_t step2, int64* dst, size_t step, int width, int height, void* scalars );
CV_EXPORTS void addWeighted32u( const unsigned* src1, size_t step1, const unsigned* src2, size_t step2, unsigned* dst, size_t step, int width, int height, void* scalars );
CV_EXPORTS void cvt16f32f( const float16_t* src, float* dst, int len );
CV_EXPORTS void cvt32f16f( const float* src, float16_t* dst, int len );
@@ -64,6 +64,9 @@ typedef signed char schar;
# define CV_BIG_UINT(n) n##ULL
#endif
typedef short cv_hal_f16;
typedef short cv_hal_bf16;
#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0"
#define CV_CN_MAX 128
@@ -300,6 +300,11 @@ public:
DEPTH_MASK_32F = 1 << CV_32F,
DEPTH_MASK_64F = 1 << CV_64F,
DEPTH_MASK_16F = 1 << CV_16F,
DEPTH_MASK_16BF = 1 << CV_16BF,
DEPTH_MASK_BOOL = 1 << CV_Bool,
DEPTH_MASK_64U = 1 << CV_64U,
DEPTH_MASK_64S = 1 << CV_64S,
DEPTH_MASK_32U = 1 << CV_32U,
DEPTH_MASK_ALL = (1 << CV_DEPTH_CURR_MAX)-1,
DEPTH_MASK_ALL_BUT_8S = DEPTH_MASK_ALL & ~DEPTH_MASK_8S,
DEPTH_MASK_ALL_16F = DEPTH_MASK_ALL,
@@ -178,6 +178,7 @@ template<> inline float16_t saturate_cast<float16_t>(uint64 v) { return float16
template<> inline float16_t saturate_cast<float16_t>(int64 v) { return float16_t((float)v); }
template<> inline float16_t saturate_cast<float16_t>(float v) { return float16_t(v); }
template<> inline float16_t saturate_cast<float16_t>(double v) { return float16_t((float)v); }
template<> inline float16_t saturate_cast<float16_t>(float16_t v) { return v; }
template<> inline float16_t saturate_cast<float16_t>(bfloat16_t v) { return float16_t((float)v); }
template<> inline bfloat16_t saturate_cast<bfloat16_t>(uchar v) { return bfloat16_t((float)v); }
@@ -190,7 +191,8 @@ template<> inline bfloat16_t saturate_cast<bfloat16_t>(uint64 v) { return bfloa
template<> inline bfloat16_t saturate_cast<bfloat16_t>(int64 v) { return bfloat16_t((float)v); }
template<> inline bfloat16_t saturate_cast<bfloat16_t>(float v) { return bfloat16_t(v); }
template<> inline bfloat16_t saturate_cast<bfloat16_t>(double v) { return bfloat16_t((float)v); }
template<> inline bfloat16_t saturate_cast<bfloat16_t>(float16_t v) { return bfloat16_t((float)v); }
template<> inline bfloat16_t saturate_cast<bfloat16_t>(float16_t v) { return bfloat16_t((float)v); }
template<> inline bfloat16_t saturate_cast<bfloat16_t>(bfloat16_t v) { return v; }
template<> inline bool saturate_cast<bool>(uchar v) { return v != 0; }
template<> inline bool saturate_cast<bool>(schar v) { return v != 0; }