1
0
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:
Alexander Alekhin
2023-01-09 11:08:02 +00:00
880 changed files with 83958 additions and 9368 deletions
+10 -3
View File
@@ -1102,6 +1102,13 @@ around both axes.
*/
CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode);
/** @brief Flips a n-dimensional at given axis
* @param src input array
* @param dst output array that has the same shape of src
* @param axis axis that performs a flip on. 0 <= axis < src.dims.
*/
CV_EXPORTS_W void flipND(InputArray src, OutputArray dst, int axis);
enum RotateFlags {
ROTATE_90_CLOCKWISE = 0, //!<Rotate 90 degrees clockwise
ROTATE_180 = 1, //!<Rotate 180 degrees clockwise
@@ -3142,12 +3149,12 @@ public:
/** @brief Stores algorithm parameters in a file storage
*/
virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
CV_WRAP virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
/** @brief simplified API for language bindings
/**
* @overload
*/
CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
CV_WRAP void write(FileStorage& fs, const String& name) const;
/** @brief Reads algorithm parameters from a file storage
*/
@@ -35,6 +35,14 @@ String dumpInt(int argument)
return cv::format("Int: %d", argument);
}
CV_WRAP static inline
String dumpInt64(int64 argument)
{
std::ostringstream oss("Int64: ", std::ios::ate);
oss << argument;
return oss.str();
}
CV_WRAP static inline
String dumpSizeT(size_t argument)
{
@@ -219,6 +227,22 @@ AsyncArray testAsyncException()
return p.getArrayResult();
}
CV_WRAP static inline
String dumpVec2i(const cv::Vec2i value = cv::Vec2i(42, 24)) {
return format("Vec2i(%d, %d)", value[0], value[1]);
}
struct CV_EXPORTS_W_SIMPLE ClassWithKeywordProperties {
CV_PROP_RW int lambda;
CV_PROP int except;
CV_WRAP explicit ClassWithKeywordProperties(int lambda_arg = 24, int except_arg = 42)
{
lambda = lambda_arg;
except = except_arg;
}
};
namespace nested {
CV_WRAP static inline bool testEchoBooleanFunction(bool flag) {
return flag;
@@ -65,6 +65,7 @@ struct CheckContext {
static const cv::detail::CheckContext CV__CHECK_LOCATION_VARNAME(id) = \
{ CV__CHECK_FUNCTION, CV__CHECK_FILENAME, __LINE__, testOp, "" message, "" p1_str, "" p2_str }
CV_EXPORTS void CV_NORETURN check_failed_auto(const bool v1, const bool v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx);
@@ -74,6 +75,9 @@ CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, co
CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_true(const bool v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_false(const bool v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx);
@@ -134,6 +138,12 @@ CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckCon
/// Example: v == A || v == B
#define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
/// Example: v == true
#define CV_CheckTrue(v, msg) CV__CHECK_CUSTOM_TEST(_, true, v, v, #v, "", msg)
/// Example: v == false
#define CV_CheckFalse(v, msg) CV__CHECK_CUSTOM_TEST(_, false, v, (!(v)), #v, "", msg)
/// Some complex conditions: CV_Check(src2, src2.empty() || (src2.type() == src1.type() && src2.size() == src1.size()), "src2 should have same size/type as src1")
// TODO define pretty-printers
@@ -65,8 +65,10 @@
namespace cv { namespace cuda {
static inline void checkCudaError(cudaError_t err, const char* file, const int line, const char* func)
{
if (cudaSuccess != err)
if (cudaSuccess != err) {
cudaGetLastError(); // reset the last stored error to cudaSuccess
cv::error(cv::Error::GpuApiCallError, cudaGetErrorString(err), func, file, line);
}
}
}}
@@ -95,26 +97,6 @@ namespace cv { namespace cuda
{
return (total + grain - 1) / grain;
}
template<class T> inline void bindTexture(const textureReference* tex, const PtrStepSz<T>& img)
{
cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
cudaSafeCall( cudaBindTexture2D(0, tex, img.ptr(), &desc, img.cols, img.rows, img.step) );
}
template<class T> inline void createTextureObjectPitch2D(cudaTextureObject_t* tex, PtrStepSz<T>& img, const cudaTextureDesc& texDesc)
{
cudaResourceDesc resDesc;
memset(&resDesc, 0, sizeof(resDesc));
resDesc.resType = cudaResourceTypePitch2D;
resDesc.res.pitch2D.devPtr = static_cast<void*>(img.ptr());
resDesc.res.pitch2D.height = img.rows;
resDesc.res.pitch2D.width = img.cols;
resDesc.res.pitch2D.pitchInBytes = img.step;
resDesc.res.pitch2D.desc = cudaCreateChannelDesc<T>();
cudaSafeCall( cudaCreateTextureObject(tex, &resDesc, &texDesc, NULL) );
}
}
}}
@@ -172,6 +172,11 @@
# define CV_MSA 1
#endif
#ifdef CV_CPU_COMPILE_LASX
# include <lasxintrin.h>
# define CV_LASX 1
#endif
#ifdef __EMSCRIPTEN__
# define CV_WASM_SIMD 1
# include <wasm_simd128.h>
@@ -370,3 +375,7 @@ struct VZeroUpperGuard {
#ifndef CV_RVV
# define CV_RVV 0
#endif
#ifndef CV_LASX
# define CV_LASX 0
#endif
@@ -525,5 +525,26 @@
#endif
#define __CV_CPU_DISPATCH_CHAIN_RVV(fn, args, mode, ...) CV_CPU_CALL_RVV(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_LASX
# define CV_TRY_LASX 1
# define CV_CPU_FORCE_LASX 1
# define CV_CPU_HAS_SUPPORT_LASX 1
# define CV_CPU_CALL_LASX(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_LASX_(fn, args) return (opt_LASX::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_LASX
# define CV_TRY_LASX 1
# define CV_CPU_FORCE_LASX 0
# define CV_CPU_HAS_SUPPORT_LASX (cv::checkHardwareSupport(CV_CPU_LASX))
# define CV_CPU_CALL_LASX(fn, args) if (CV_CPU_HAS_SUPPORT_LASX) return (opt_LASX::fn args)
# define CV_CPU_CALL_LASX_(fn, args) if (CV_CPU_HAS_SUPPORT_LASX) return (opt_LASX::fn args)
#else
# define CV_TRY_LASX 0
# define CV_CPU_FORCE_LASX 0
# define CV_CPU_HAS_SUPPORT_LASX 0
# define CV_CPU_CALL_LASX(fn, args)
# define CV_CPU_CALL_LASX_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_LASX(fn, args, mode, ...) CV_CPU_CALL_LASX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
+5 -1
View File
@@ -279,6 +279,8 @@ namespace cv {
#define CV_CPU_RVV 210
#define CV_CPU_LASX 230
// CPU features groups
#define CV_CPU_AVX512_SKX 256
#define CV_CPU_AVX512_COMMON 257
@@ -336,6 +338,8 @@ enum CpuFeatures {
CPU_RVV = 210,
CPU_LASX = 230,
CPU_AVX512_SKX = 256, //!< Skylake-X with AVX-512F/CD/BW/DQ/VL
CPU_AVX512_COMMON = 257, //!< Common instructions AVX-512F/CD for all CPUs that support AVX-512
CPU_AVX512_KNL = 258, //!< Knights Landing with AVX-512F/CD/ER/PF
@@ -808,7 +812,7 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType)
# define CV_CONSTEXPR
#endif
// Integer types portatibility
// Integer types portability
#ifdef OPENCV_STDINT_HEADER
#include OPENCV_STDINT_HEADER
#elif defined(__cplusplus)
@@ -128,8 +128,12 @@
#define CV_INLINE_ISNAN_FLT(value) CV_INLINE_ISNAN_DBL(value)
#endif
#if !defined(OPENCV_USE_FASTMATH_BUILTINS) && \
(defined __GNUC__ || defined __clang__ || defined _MSC_VER)
#if !defined(OPENCV_USE_FASTMATH_BUILTINS) \
&& ( \
defined(__x86_64__) || defined(__i686__) \
|| defined(__arm__) \
|| defined(__PPC64__) \
)
/* Let builtin C math functions when available. Dedicated hardware is available to
round and convert FP values. */
#define OPENCV_USE_FASTMATH_BUILTINS 1
@@ -229,6 +233,15 @@ CV_INLINE int cvFloor( double value )
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
return (int)__builtin_floor(value);
#elif defined __loongarch64
int i;
double tmp;
__asm__ ("ftintrm.l.d %[tmp], %[in] \n\t"
"movfr2gr.d %[i], %[tmp] \n\t"
: [i] "=r" (i), [tmp] "=f" (tmp)
: [in] "f" (value)
:);
return i;
#else
int i = (int)value;
return i - (i > value);
@@ -247,6 +260,15 @@ CV_INLINE int cvCeil( double value )
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
return (int)__builtin_ceil(value);
#elif defined __loongarch64
int i;
double tmp;
__asm__ ("ftintrp.l.d %[tmp], %[in] \n\t"
"movfr2gr.d %[i], %[tmp] \n\t"
: [i] "=r" (i), [tmp] "=f" (tmp)
: [in] "f" (value)
:);
return i;
#else
int i = (int)value;
return i + (i < value);
@@ -281,7 +303,7 @@ CV_INLINE int cvIsInf( double value )
{
#if defined CV_INLINE_ISINF_DBL
CV_INLINE_ISINF_DBL(value);
#elif defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__PPC64__)
#elif defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__PPC64__) || defined(__loongarch64)
Cv64suf ieee754;
ieee754.f = value;
return (ieee754.u & 0x7fffffff00000000) ==
@@ -332,6 +354,15 @@ CV_INLINE int cvFloor( float value )
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
return (int)__builtin_floorf(value);
#elif defined __loongarch
int i;
float tmp;
__asm__ ("ftintrm.w.s %[tmp], %[in] \n\t"
"movfr2gr.s %[i], %[tmp] \n\t"
: [i] "=r" (i), [tmp] "=f" (tmp)
: [in] "f" (value)
:);
return i;
#else
int i = (int)value;
return i - (i > value);
@@ -350,6 +381,15 @@ CV_INLINE int cvCeil( float value )
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
return (int)__builtin_ceilf(value);
#elif defined __loongarch
int i;
float tmp;
__asm__ ("ftintrp.w.s %[tmp], %[in] \n\t"
"movfr2gr.s %[i], %[tmp] \n\t"
: [i] "=r" (i), [tmp] "=f" (tmp)
: [in] "f" (value)
:);
return i;
#else
int i = (int)value;
return i + (i < value);
@@ -50,6 +50,12 @@
#include <stdlib.h>
#include "opencv2/core/cvdef.h"
#if defined(__GNUC__) && __GNUC__ == 12
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
#define OPENCV_HAL_ADD(a, b) ((a) + (b))
#define OPENCV_HAL_AND(a, b) ((a) & (b))
#define OPENCV_HAL_NOP(a) (a)
@@ -229,10 +235,19 @@ using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE;
#elif CV_WASM_SIMD && !defined(CV_FORCE_SIMD128_CPP)
#include "opencv2/core/hal/intrin_wasm.hpp"
#elif CV_RVV && !defined(CV_FORCE_SIMD128_CPP) && !defined(CV_RVV_SCALABLE)
#include "opencv2/core/hal/intrin_rvv.hpp"
#elif CV_RVV && !defined(CV_FORCE_SIMD128_CPP) && CV_RVV_SCALABLE
#elif CV_RVV && !defined(CV_FORCE_SIMD128_CPP)
#if defined(CV_RVV_SCALABLE)
#include "opencv2/core/hal/intrin_rvv_scalable.hpp"
#else
#include "opencv2/core/hal/intrin_rvv.hpp"
#endif
#elif CV_LASX
#if !defined(CV_FORCE_SIMD128_CPP)
#define CV_FORCE_SIMD128_CPP 1
#endif
#include "opencv2/core/hal/intrin_cpp.hpp"
#else
#include "opencv2/core/hal/intrin_cpp.hpp"
@@ -267,6 +282,14 @@ using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE;
#endif
#if CV_LASX
#define CV__SIMD_FORWARD 256
#include "opencv2/core/hal/intrin_forward.hpp"
#include "opencv2/core/hal/intrin_lasx.hpp"
#endif
//! @cond IGNORED
namespace cv {
@@ -522,6 +545,11 @@ using namespace CV__SIMD_NAMESPACE;
#endif
//! @cond IGNORED
#ifndef CV_SIMD_64F
#define CV_SIMD_64F 0
#endif
namespace CV__SIMD_NAMESPACE {
//! @addtogroup core_hal_intrin
//! @{
@@ -537,7 +565,7 @@ namespace CV__SIMD_NAMESPACE {
inline v_float32 vx_setall_f32(float v) { return VXPREFIX(_setall_f32)(v); }
inline v_int64 vx_setall_s64(int64 v) { return VXPREFIX(_setall_s64)(v); }
inline v_uint64 vx_setall_u64(uint64 v) { return VXPREFIX(_setall_u64)(v); }
#if CV_SIMD_64F
#if CV_SIMD_64F || CV_SIMD_SCALABLE_64F
inline v_float64 vx_setall_f64(double v) { return VXPREFIX(_setall_f64)(v); }
#endif
//! @}
@@ -554,7 +582,7 @@ namespace CV__SIMD_NAMESPACE {
inline v_float32 vx_setzero_f32() { return VXPREFIX(_setzero_f32)(); }
inline v_int64 vx_setzero_s64() { return VXPREFIX(_setzero_s64)(); }
inline v_uint64 vx_setzero_u64() { return VXPREFIX(_setzero_u64)(); }
#if CV_SIMD_64F
#if CV_SIMD_64F || CV_SIMD_SCALABLE_64F
inline v_float64 vx_setzero_f64() { return VXPREFIX(_setzero_f64)(); }
#endif
//! @}
@@ -571,7 +599,7 @@ namespace CV__SIMD_NAMESPACE {
inline v_float32 vx_load(const float * ptr) { return VXPREFIX(_load)(ptr); }
inline v_int64 vx_load(const int64 * ptr) { return VXPREFIX(_load)(ptr); }
inline v_uint64 vx_load(const uint64 * ptr) { return VXPREFIX(_load)(ptr); }
#if CV_SIMD_64F
#if CV_SIMD_64F || CV_SIMD_SCALABLE_64F
inline v_float64 vx_load(const double * ptr) { return VXPREFIX(_load)(ptr); }
#endif
//! @}
@@ -588,7 +616,7 @@ namespace CV__SIMD_NAMESPACE {
inline v_float32 vx_load_aligned(const float * ptr) { return VXPREFIX(_load_aligned)(ptr); }
inline v_int64 vx_load_aligned(const int64 * ptr) { return VXPREFIX(_load_aligned)(ptr); }
inline v_uint64 vx_load_aligned(const uint64 * ptr) { return VXPREFIX(_load_aligned)(ptr); }
#if CV_SIMD_64F
#if CV_SIMD_64F || CV_SIMD_SCALABLE_64F
inline v_float64 vx_load_aligned(const double * ptr) { return VXPREFIX(_load_aligned)(ptr); }
#endif
//! @}
@@ -605,7 +633,7 @@ namespace CV__SIMD_NAMESPACE {
inline v_float32 vx_load_low(const float * ptr) { return VXPREFIX(_load_low)(ptr); }
inline v_int64 vx_load_low(const int64 * ptr) { return VXPREFIX(_load_low)(ptr); }
inline v_uint64 vx_load_low(const uint64 * ptr) { return VXPREFIX(_load_low)(ptr); }
#if CV_SIMD_64F
#if CV_SIMD_64F || CV_SIMD_SCALABLE_64F
inline v_float64 vx_load_low(const double * ptr) { return VXPREFIX(_load_low)(ptr); }
#endif
//! @}
@@ -622,7 +650,7 @@ namespace CV__SIMD_NAMESPACE {
inline v_float32 vx_load_halves(const float * ptr0, const float * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); }
inline v_int64 vx_load_halves(const int64 * ptr0, const int64 * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); }
inline v_uint64 vx_load_halves(const uint64 * ptr0, const uint64 * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); }
#if CV_SIMD_64F
#if CV_SIMD_64F || CV_SIMD_SCALABLE_64F
inline v_float64 vx_load_halves(const double * ptr0, const double * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); }
#endif
//! @}
@@ -639,7 +667,7 @@ namespace CV__SIMD_NAMESPACE {
inline v_float32 vx_lut(const float* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); }
inline v_int64 vx_lut(const int64 * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); }
inline v_uint64 vx_lut(const uint64 * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); }
#if CV_SIMD_64F
#if CV_SIMD_64F || CV_SIMD_SCALABLE_64F
inline v_float64 vx_lut(const double* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); }
#endif
//! @}
@@ -656,7 +684,7 @@ namespace CV__SIMD_NAMESPACE {
inline v_float32 vx_lut_pairs(const float* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); }
inline v_int64 vx_lut_pairs(const int64 * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); }
inline v_uint64 vx_lut_pairs(const uint64 * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); }
#if CV_SIMD_64F
#if CV_SIMD_64F || CV_SIMD_SCALABLE_64F
inline v_float64 vx_lut_pairs(const double* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); }
#endif
//! @}
@@ -758,7 +786,6 @@ namespace CV__SIMD_NAMESPACE {
OPENCV_HAL_WRAP_BIN_OP_LOGIC(v_int32)
OPENCV_HAL_WRAP_BIN_OP_LOGIC(v_int64)
#define OPENCV_HAL_WRAP_BIN_OP_MUL(_Tpvec) \
inline _Tpvec v_mul(const _Tpvec& a, const _Tpvec& b) \
{ \
@@ -886,10 +913,6 @@ namespace CV__SIMD_NAMESPACE {
#undef VXPREFIX
} // namespace
//! @cond IGNORED
#ifndef CV_SIMD_64F
#define CV_SIMD_64F 0
#endif
#ifndef CV_SIMD_FP16
#define CV_SIMD_FP16 0 //!< Defined to 1 on native support of operations with float16x8_t / float16x16_t (SIMD256) types
@@ -909,4 +932,8 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
//! @endcond
#if defined(__GNUC__) && __GNUC__ == 12
#pragma GCC diagnostic pop
#endif
#endif
File diff suppressed because it is too large Load Diff
@@ -2646,14 +2646,14 @@ inline v_##_Tpvec v_interleave_quads(const v_##_Tpvec& vec) \
v_store(ptrvec, vec); \
for (int i = 0; i < v_##_Tpvec::nlanes/8; i++) \
{ \
ptr[8*i ] = ptrvec[4*i ]; \
ptr[8*i+1] = ptrvec[4*i+4]; \
ptr[8*i+2] = ptrvec[4*i+1]; \
ptr[8*i+3] = ptrvec[4*i+5]; \
ptr[8*i+4] = ptrvec[4*i+2]; \
ptr[8*i+5] = ptrvec[4*i+6]; \
ptr[8*i+6] = ptrvec[4*i+3]; \
ptr[8*i+7] = ptrvec[4*i+7]; \
ptr[8*i ] = ptrvec[8*i ]; \
ptr[8*i+1] = ptrvec[8*i+4]; \
ptr[8*i+2] = ptrvec[8*i+1]; \
ptr[8*i+3] = ptrvec[8*i+5]; \
ptr[8*i+4] = ptrvec[8*i+2]; \
ptr[8*i+5] = ptrvec[8*i+6]; \
ptr[8*i+6] = ptrvec[8*i+3]; \
ptr[8*i+7] = ptrvec[8*i+7]; \
} \
return v_load(ptr); \
}
@@ -2753,7 +2753,7 @@ inline int v_signmask(const _Tpvec& a) \
{ \
uint8_t ans[16] = {0};\
vsm(ans, vmslt(a, 0, vl), vl);\
return reinterpret_cast<int*>(ans)[0];\
return reinterpret_cast<int*>(ans)[0] & ((1 << (vl)) - 1);\
}
OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_int8x16, 8, 16)
@@ -2810,7 +2810,7 @@ OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_float64x2, double, f64)
#ifndef __clang__
inline v_int8x16 v_pack_triplets(const v_int8x16& vec)
{
uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
uint64 ptr[2] = {0x0908060504020100, 0xFFFFFF0F0E0D0C0A};
return v_int8x16((vint8m1_t)vrgather_vv_u8m1((vuint8m1_t)vint8m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16));
}
inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec)
@@ -2820,7 +2820,7 @@ inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec)
inline v_int16x8 v_pack_triplets(const v_int16x8& vec)
{
uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
uint64 ptr[2] = {0x0908050403020100, 0xFFFF0F0E0D0C0B0A};
return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)vint16m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16));
}
inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec)
@@ -2836,7 +2836,7 @@ inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; }
inline v_int8x16 v_pack_triplets(const v_int8x16& vec)
{
uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
uint64 ptr[2] = {0x0908060504020100, 0xFFFFFF0F0E0D0C0A};
return v_int8x16(vreinterpret_i8m1(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16)));
}
inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec)
@@ -2846,7 +2846,7 @@ inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec)
inline v_int16x8 v_pack_triplets(const v_int16x8& vec)
{
uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
uint64 ptr[2] = {0x0908050403020100, 0xFFFF0F0E0D0C0B0A};
return v_int16x8(v_reinterpret_as_s16(v_uint8x16(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16))));
}
inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec)
File diff suppressed because it is too large Load Diff
@@ -57,6 +57,11 @@
#include "opencv2/core/cvstd.hpp"
#include "opencv2/core/matx.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4459) // declaration of '...' hides global declaration
#endif
namespace cv
{
@@ -2014,6 +2019,15 @@ double jaccardDistance(const Rect_<_Tp>& a, const Rect_<_Tp>& b) {
return 1.0 - Aab / (Aa + Ab - Aab);
}
/** @brief Finds out if there is any intersection between two rectangles
*
* mainly useful for language bindings
* @param rect1 First rectangle
* @param rect2 Second rectangle
* @return the area of the intersection
*/
CV_EXPORTS_W inline double rectangleIntersectionArea(const Rect2d& a, const Rect2d& b) { return (a & b).area(); }
////////////////////////////// RotatedRect //////////////////////////////
inline
@@ -2453,4 +2467,8 @@ inline TermCriteria::TermCriteria(int _maxCount, double _epsilon)
} // cv
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif //OPENCV_CORE_TYPES_HPP
@@ -62,7 +62,7 @@ CV_EXPORTS void glob_relative(const cv::String& directory, const cv::String& pat
CV_EXPORTS bool createDirectory(const cv::String& path);
CV_EXPORTS bool createDirectories(const cv::String& path);
#ifdef __OPENCV_BUILD
#if defined(__OPENCV_BUILD) || defined(BUILD_PLUGIN)
// TODO
//CV_EXPORTS cv::String getTempDirectory();
@@ -63,7 +63,7 @@ class TraceMessage;
class TraceStorage {
public:
TraceStorage() {}
virtual ~TraceStorage() {};
virtual ~TraceStorage() {}
virtual bool put(const TraceMessage& msg) const = 0;
};
+5 -5
View File
@@ -55,17 +55,17 @@ Algorithm::~Algorithm()
CV_TRACE_FUNCTION();
}
void Algorithm::write(const Ptr<FileStorage>& fs, const String& name) const
void Algorithm::write(FileStorage& fs, const String& name) const
{
CV_TRACE_FUNCTION();
if(name.empty())
{
write(*fs);
write(fs);
return;
}
*fs << name << "{";
write(*fs);
*fs << "}";
fs << name << "{";
write(fs);
fs << "}";
}
void Algorithm::save(const String& filename) const
+2 -2
View File
@@ -168,7 +168,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,
if( dims1 <= 2 && dims2 <= 2 && kind1 == kind2 && sz1 == sz2 && type1 == type2 && !haveMask )
{
_dst.create(sz1, type1);
_dst.createSameSize(*psrc1, type1);
CV_OCL_RUN(use_opencl,
ocl_binary_op(*psrc1, *psrc2, _dst, _mask, bitwise, oclop, false))
@@ -1225,7 +1225,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
if( kind1 == kind2 && src1.dims <= 2 && src2.dims <= 2 && src1.size() == src2.size() && src1.type() == src2.type() )
{
int cn = src1.channels();
_dst.create(src1.size(), CV_8UC(cn));
_dst.createSameSize(src1, CV_8UC(cn));
Mat dst = _dst.getMat();
Size sz = getContinuousSize2D(src1, src2, dst, src1.channels());
BinaryFuncC cmpFn = getCmpFunc(depth1);
+20
View File
@@ -97,6 +97,10 @@ void check_failed_MatChannels(const int v1, const int v2, const CheckContext& ct
{
check_failed_auto_<int>(v1, v2, ctx);
}
void check_failed_auto(const bool v1, const bool v2, const CheckContext& ctx)
{
check_failed_auto_<bool>(v1, v2, ctx);
}
void check_failed_auto(const int v1, const int v2, const CheckContext& ctx)
{
check_failed_auto_<int>(v1, v2, ctx);
@@ -151,6 +155,22 @@ void check_failed_MatChannels(const int v, const CheckContext& ctx)
{
check_failed_auto_<int>(v, ctx);
}
void check_failed_true(const bool v, const CheckContext& ctx)
{
CV_UNUSED(v);
std::stringstream ss;
ss << ctx.message << ":" << std::endl
<< " '" << ctx.p1_str << "' must be 'true'";
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void check_failed_false(const bool v, const CheckContext& ctx)
{
CV_UNUSED(v);
std::stringstream ss;
ss << ctx.message << ":" << std::endl
<< " '" << ctx.p1_str << "' must be 'false'";
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void check_failed_auto(const int v, const CheckContext& ctx)
{
check_failed_auto_<int>(v, ctx);
+5 -1
View File
@@ -251,6 +251,11 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype
lwork = (int)round(work1); //optimal buffer size
std::vector<fptype> buffer(lwork + 1);
// Make sure MSAN sees the memory as having been written.
// MSAN does not think it has been written because a different language is called.
// Note: we do this here because if dgesdd is C++, MSAN errors can be reported within it.
CV_ANNOTATE_MEMORY_IS_INITIALIZED(buffer, sizeof(fptype) * (lwork + 1));
if(typeid(fptype) == typeid(float))
OCV_LAPACK_FUNC(sgesdd)(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu,
(float*)vt, &ldv, (float*)&buffer[0], &lwork, &iworkBuf[0], info);
@@ -261,7 +266,6 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype
// Make sure MSAN sees the memory as having been written.
// MSAN does not think it has been written because a different language was called.
CV_ANNOTATE_MEMORY_IS_INITIALIZED(a, a_step * n);
CV_ANNOTATE_MEMORY_IS_INITIALIZED(buffer, sizeof(fptype) * (lwork + 1));
if (u)
CV_ANNOTATE_MEMORY_IS_INITIALIZED(u, u_step * m);
if (vt)
+25 -7
View File
@@ -233,24 +233,42 @@ void writeLogMessage(LogLevel logLevel, const char* message)
(*out) << std::flush;
}
static const char* stripSourceFilePathPrefix(const char* file)
{
CV_Assert(file);
const char* pos = file;
const char* strip_pos = NULL;
char ch = 0;
while ((ch = pos[0]) != 0)
{
++pos;
if (ch == '/' || ch == '\\')
strip_pos = pos;
}
if (strip_pos == NULL || strip_pos == pos/*eos*/)
return file;
return strip_pos;
}
void writeLogMessageEx(LogLevel logLevel, const char* tag, const char* file, int line, const char* func, const char* message)
{
std::ostringstream strm;
if (tag)
{
strm << tag << " ";
strm << tag << ' ';
}
if (file)
{
strm << file << " ";
}
if (line > 0)
{
strm << "(" << line << ") ";
strm << stripSourceFilePathPrefix(file);
if (line > 0)
{
strm << ':' << line;
}
strm << ' ';
}
if (func)
{
strm << func << " ";
strm << func << ' ';
}
strm << message;
writeLogMessage(logLevel, strm.str().c_str());
+45
View File
@@ -6,6 +6,8 @@
#include "opencl_kernels_core.hpp"
#include "opencv2/core/detail/dispatch_helper.impl.hpp"
#include <algorithm> // std::swap_ranges
namespace cv {
////////////////////////////////////// transpose /////////////////////////////////////////
@@ -812,6 +814,49 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
flipHoriz( dst.ptr(), dst.step, dst.ptr(), dst.step, dst.size(), esz );
}
static void
flipNDImpl(uchar* data, const int* shape, const size_t* step, int axis)
{
int total = 1;
for (int i = 0; i < axis; ++i)
total *= shape[i];
int shape_at_axis = shape[axis];
size_t step_at_axis = step[axis];
size_t offset = 0;
size_t offset_increment = axis == 0 ? 0 : step[axis - 1];
for (int i = 0; i < total; ++i, offset += offset_increment)
for (int j = 0, k = shape_at_axis - 1; j < shape_at_axis / 2; ++j, --k)
std::swap_ranges(data + offset + j * step_at_axis,
data + offset + j * step_at_axis + step_at_axis,
data + offset + k * step_at_axis);
}
void flipND(InputArray _src, OutputArray _dst, int _axis)
{
CV_INSTRUMENT_REGION();
Mat src = _src.getMat();
// verify axis
int ndim = src.dims;
CV_CheckLT(_axis, ndim, "flipND: given axis is out of range");
CV_CheckGE(_axis, -ndim, "flipND: given axis is out of range");
int axis = (_axis + ndim) % ndim;
// in-place flip
_src.copyTo(_dst);
// return the src if it has only one element on the flip axis
const auto shape = src.size.p;
if (shape[axis] == 1)
return ;
// call impl
Mat dst = _dst.getMat();
flipNDImpl(dst.ptr(), dst.size.p, dst.step.p, axis);
}
void rotate(InputArray _src, OutputArray _dst, int rotateMode)
{
CV_Assert(_src.dims() <= 2);
+20 -3
View File
@@ -976,6 +976,12 @@ bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc
return false;
#endif
if (dev.deviceVersionMajor() == 1 && dev.deviceVersionMinor() < 2)
{
// 'static' storage class specifier used by "minmaxloc" is available from OpenCL 1.2+ only
return false;
}
bool doubleSupport = dev.doubleFPConfig() > 0, haveMask = !_mask.empty(),
haveSrc2 = _src2.kind() != _InputArray::NONE;
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type),
@@ -1565,13 +1571,24 @@ void cv::minMaxLoc( InputArray _img, double* minVal, double* maxVal,
{
CV_INSTRUMENT_REGION();
CV_Assert(_img.dims() <= 2);
int dims = _img.dims();
CV_CheckLE(dims, 2, "");
minMaxIdx(_img, minVal, maxVal, (int*)minLoc, (int*)maxLoc, mask);
if( minLoc )
std::swap(minLoc->x, minLoc->y);
{
if (dims == 2)
std::swap(minLoc->x, minLoc->y);
else
minLoc->y = 0;
}
if( maxLoc )
std::swap(maxLoc->x, maxLoc->y);
{
if (dims == 2)
std::swap(maxLoc->x, maxLoc->y);
else
maxLoc->y = 0;
}
}
enum class ReduceMode
+20 -20
View File
@@ -1638,14 +1638,14 @@ Context& initializeContextFromGL()
cl_uint numPlatforms;
cl_int status = clGetPlatformIDs(0, NULL, &numPlatforms);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get number of platforms");
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get number of platforms: %d", status));
if (numPlatforms == 0)
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No available platforms");
std::vector<cl_platform_id> platforms(numPlatforms);
status = clGetPlatformIDs(numPlatforms, &platforms[0], NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get number of platforms");
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get number of platforms: %d", status));
// TODO Filter platforms by name from OPENCV_OPENCL_DEVICE
@@ -1667,7 +1667,7 @@ Context& initializeContextFromGL()
status = clGetPlatformInfo(platforms[i], CL_PLATFORM_EXTENSIONS, extensionSize, (char*)extensionStr.data(), NULL);
}
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get platform extension string");
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get platform extension string: %d", status));
if (!strstr((const char*)extensionStr.data(), "cl_khr_gl_sharing"))
continue;
@@ -1759,31 +1759,31 @@ void convertToGLTexture2D(InputArray src, Texture2D& texture)
cl_int status = 0;
cl_mem clImage = clCreateFromGLTexture(context, CL_MEM_WRITE_ONLY, gl::TEXTURE_2D, 0, texture.texId(), &status);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromGLTexture failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clCreateFromGLTexture failed: %d", status));
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
status = clEnqueueAcquireGLObjects(q, 1, &clImage, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireGLObjects failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueAcquireGLObjects failed: %d", status));
size_t offset = 0; // TODO
size_t dst_origin[3] = {0, 0, 0};
size_t region[3] = { (size_t)u.cols, (size_t)u.rows, 1};
status = clEnqueueCopyBufferToImage(q, clBuffer, clImage, offset, dst_origin, region, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyBufferToImage failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueCopyBufferToImage failed: %d", status));
status = clEnqueueReleaseGLObjects(q, 1, &clImage, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseGLObjects failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueReleaseGLObjects failed: %d", status));
status = clFinish(q); // TODO Use events
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clFinish failed: %d", status));
status = clReleaseMemObject(clImage); // TODO RAII
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMemObject failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clReleaseMemObject failed: %d", status));
#endif
}
@@ -1821,31 +1821,31 @@ void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst)
cl_int status = 0;
cl_mem clImage = clCreateFromGLTexture(context, CL_MEM_READ_ONLY, gl::TEXTURE_2D, 0, texture.texId(), &status);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromGLTexture failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clCreateFromGLTexture failed: %d", status));
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
status = clEnqueueAcquireGLObjects(q, 1, &clImage, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireGLObjects failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueAcquireGLObjects failed: %d", status));
size_t offset = 0; // TODO
size_t src_origin[3] = {0, 0, 0};
size_t region[3] = { (size_t)u.cols, (size_t)u.rows, 1};
status = clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyImageToBuffer failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueCopyImageToBuffer failed: %d", status));
status = clEnqueueReleaseGLObjects(q, 1, &clImage, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseGLObjects failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueReleaseGLObjects failed: %d", status));
status = clFinish(q); // TODO Use events
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clFinish failed: %d", status));
status = clReleaseMemObject(clImage); // TODO RAII
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMemObject failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clReleaseMemObject failed: %d", status));
#endif
}
@@ -1883,13 +1883,13 @@ UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags)
cl_int status = 0;
cl_mem clBuffer = clCreateFromGLBuffer(context, clAccessFlags, buffer.bufId(), &status);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromGLBuffer failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clCreateFromGLBuffer failed: %d", status));
gl::Finish();
status = clEnqueueAcquireGLObjects(clQueue, 1, &clBuffer, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireGLObjects failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueAcquireGLObjects failed: %d", status));
size_t step = buffer.cols() * buffer.elemSize();
int rows = buffer.rows();
@@ -1921,15 +1921,15 @@ void unmapGLBuffer(UMat& u)
cl_int status = clEnqueueReleaseGLObjects(clQueue, 1, &clBuffer, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseGLObjects failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueReleaseGLObjects failed: %d", status));
status = clFinish(clQueue);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clFinish failed: %d", status));
status = clReleaseMemObject(clBuffer);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMemObject failed");
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clReleaseMemObject failed: %d", status));
#endif
}
@@ -43,7 +43,7 @@ std::vector<ParallelBackendInfo>& getBuiltinParallelBackendsInfo()
#endif
};
return g_backends;
};
}
static
bool sortByPriority(const ParallelBackendInfo &lhs, const ParallelBackendInfo &rhs)
+5 -1
View File
@@ -40,11 +40,13 @@ DECLARE_CV_PAUSE
#endif
#ifndef CV_PAUSE
# if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
# include <x86intrin.h> /* for __rdtsc */
# if !defined(__SSE2__)
static inline void cv_non_sse_mm_pause() { __asm__ __volatile__ ("rep; nop"); }
# define _mm_pause cv_non_sse_mm_pause
# endif
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { _mm_pause(); } } while (0)
// With Skylake CPUs and above, _mm_pause takes 140 cycles so no need for a loop.
# define CV_PAUSE(v) do { (void)v; _mm_pause(); } while (0)
# elif defined __GNUC__ && defined __aarch64__
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("yield" ::: "memory"); } } while (0)
# elif defined __GNUC__ && defined __arm__
@@ -59,6 +61,8 @@ DECLARE_CV_PAUSE
// https://github.com/riscv/riscv-isa-manual/issues/43
// # define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("pause"); } } while (0)
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("nop"); } } while (0)
# elif defined __GNUC__ && defined __loongarch__
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("nop"); } } while (0)
# else
# warning "Can't detect 'pause' (CPU-yield) instruction on the target platform. Specify CV_PAUSE() definition via compiler flags."
# define CV_PAUSE(...) do { /* no-op: works, but not effective */ } while (0)
+6
View File
@@ -434,6 +434,8 @@ struct HWFeatures
g_hwFeatureNames[CPU_AVX512_ICL] = "AVX512-ICL";
g_hwFeatureNames[CPU_RVV] = "RVV";
g_hwFeatureNames[CPU_LASX] = "LASX";
}
void initialize(void)
@@ -689,6 +691,10 @@ struct HWFeatures
have[CV_CPU_RVV] = true;
#endif
#if defined __loongarch_asx
have[CV_CPU_LASX] = true;
#endif
bool skip_baseline_check = false;
#ifndef NO_GETENV
if (getenv("OPENCV_SKIP_CPU_BASELINE_CHECK"))
+66
View File
@@ -2201,6 +2201,72 @@ INSTANTIATE_TEST_CASE_P(Arithm, TransposeND, testing::Combine(
testing::Values(perf::MatType(CV_8UC1), CV_32FC1)
));
class FlipND : public testing::TestWithParam< tuple<std::vector<int>, perf::MatType> >
{
public:
std::vector<int> m_shape;
int m_type;
void SetUp()
{
std::tie(m_shape, m_type) = GetParam();
}
};
TEST_P(FlipND, basic)
{
Mat inp(m_shape, m_type);
randu(inp, 0, 255);
int ndim = static_cast<int>(m_shape.size());
std::vector<int> axes(ndim*2); // [-shape, shape)
std::iota(axes.begin(), axes.end(), -ndim);
auto get_flipped_indices = [&inp, ndim] (size_t total, std::vector<int>& indices, int axis)
{
const int* shape = inp.size.p;
size_t t = total, idx;
for (int i = ndim - 1; i >= 0; --i)
{
idx = t / shape[i];
indices[i] = int(t - idx * shape[i]);
t = idx;
}
int _axis = (axis + ndim) % ndim;
std::vector<int> flipped_indices = indices;
flipped_indices[_axis] = shape[_axis] - 1 - indices[_axis];
return flipped_indices;
};
for (size_t i = 0; i < axes.size(); ++i)
{
int axis = axes[i];
Mat out;
cv::flipND(inp, out, axis);
// check values
std::vector<int> indices(ndim, 0);
for (size_t j = 0; j < inp.total(); ++j)
{
auto flipped_indices = get_flipped_indices(j, indices, axis);
switch (inp.type())
{
case CV_8UC1:
ASSERT_EQ(inp.at<uint8_t>(indices.data()), out.at<uint8_t>(flipped_indices.data()));
break;
case CV_32FC1:
ASSERT_EQ(inp.at<float>(indices.data()), out.at<float>(flipped_indices.data()));
break;
default:
FAIL() << "Unsupported type: " << inp.type();
}
}
}
}
INSTANTIATE_TEST_CASE_P(Arithm, FlipND, testing::Combine(
testing::Values(std::vector<int>{5, 10}, std::vector<int>{2, 3, 4}),
testing::Values(perf::MatType(CV_8UC1), CV_32FC1)
));
TEST(Core_minMaxIdx, regression_9207_2)
{
+4
View File
@@ -136,7 +136,11 @@ TEST_P(HAL, mat_decomp)
int size = (hcase / 2) % 4;
size = size == 0 ? 3 : size == 1 ? 4 : size == 2 ? 6 : 15;
int nfunc = (hcase / 8);
#if CV_LASX
double eps = depth == CV_32F ? 1e-5 : 2e-10;
#else
double eps = depth == CV_32F ? 1e-5 : 1e-10;
#endif
if( size == 3 )
return; // TODO ???
+133 -176
View File
@@ -503,6 +503,34 @@ template<typename R> struct TheTest
return *this;
}
TheTest & test_interleave_pq()
{
Data<R> dataA;
R a = dataA;
Data<R> resP = v_interleave_pairs(a);
Data<R> resQ = v_interleave_quads(a);
for (int i = 0; i < VTraits<R>::vlanes()/4; ++i)
{
SCOPED_TRACE(cv::format("i=%d", i));
EXPECT_EQ(resP[4*i], dataA[4*i ]);
EXPECT_EQ(resP[4*i + 1], dataA[4*i+2]);
EXPECT_EQ(resP[4*i + 2], dataA[4*i+1]);
EXPECT_EQ(resP[4*i + 3], dataA[4*i+3]);
}
for (int i = 0; i < VTraits<R>::vlanes()/8; ++i)
{
SCOPED_TRACE(cv::format("i=%d", i));
EXPECT_EQ(resQ[8*i], dataA[8*i ]);
EXPECT_EQ(resQ[8*i + 1], dataA[8*i+4]);
EXPECT_EQ(resQ[8*i + 2], dataA[8*i+1]);
EXPECT_EQ(resQ[8*i + 3], dataA[8*i+5]);
EXPECT_EQ(resQ[8*i + 4], dataA[8*i+2]);
EXPECT_EQ(resQ[8*i + 5], dataA[8*i+6]);
EXPECT_EQ(resQ[8*i + 6], dataA[8*i+3]);
EXPECT_EQ(resQ[8*i + 7], dataA[8*i+7]);
}
return *this;
}
// float32x4 only
TheTest & test_interleave_2channel()
@@ -578,16 +606,18 @@ template<typename R> struct TheTest
TheTest & test_addsub()
{
Data<R> dataA, dataB;
Data<R> dataA, dataB, dataC;
dataB.reverse();
R a = dataA, b = dataB;
dataA[1] = static_cast<LaneType>(std::numeric_limits<LaneType>::max());
R a = dataA, b = dataB, c = dataC;
Data<R> resC = v_add(a, b), resD = v_sub(a, b);
Data<R> resD = v_add(a, b), resE = v_add(a, b, c), resF = v_sub(a, b);
for (int i = 0; i < VTraits<R>::vlanes(); ++i)
{
SCOPED_TRACE(cv::format("i=%d", i));
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] + dataB[i]), resC[i]);
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] - dataB[i]), resD[i]);
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] + dataB[i]), resD[i]);
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] + dataB[i] + dataC[i]), resE[i]);
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] - dataB[i]), resF[i]);
}
return *this;
@@ -614,16 +644,18 @@ template<typename R> struct TheTest
TheTest & test_mul()
{
Data<R> dataA, dataB;
Data<R> dataA, dataB, dataC;
dataA[1] = static_cast<LaneType>(std::numeric_limits<LaneType>::max());
dataB.reverse();
R a = dataA, b = dataB;
R a = dataA, b = dataB, c = dataC;
Data<R> resC = v_mul(a, b);
Data<R> resD = v_mul(a, b);
Data<R> resE = v_mul(a, b, c);
for (int i = 0; i < VTraits<R>::vlanes(); ++i)
{
SCOPED_TRACE(cv::format("i=%d", i));
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] * dataB[i]), resC[i]);
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] * dataB[i]), resD[i]);
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] * dataB[i] * dataC[i]), resE[i]);
}
return *this;
@@ -699,7 +731,7 @@ template<typename R> struct TheTest
for (int i = 0; i < VTraits<Ru>::vlanes(); ++i)
{
SCOPED_TRACE(cv::format("i=%d", i));
R_type ssub = dataA[i] - dataB[i] < std::numeric_limits<R_type>::min() ? std::numeric_limits<R_type>::min() : dataA[i] - dataB[i];
R_type ssub = dataA[i] - dataB[i] < std::numeric_limits<R_type>::lowest() ? std::numeric_limits<R_type>::lowest() : dataA[i] - dataB[i];
EXPECT_EQ((u_type)std::abs(ssub), resC[i]);
}
@@ -1049,6 +1081,7 @@ template<typename R> struct TheTest
typedef typename VTraits<uint_reg>::lane_type uint_type;
Data<R> dataA, dataB(0), dataC, dataD(1), dataE(2);
dataA[0] = (LaneType)std::numeric_limits<int_type>::max();
dataA[1] *= (LaneType)-1;
union
{
@@ -1131,6 +1164,22 @@ template<typename R> struct TheTest
return *this;
}
TheTest & test_pack_triplets()
{
Data<R> dataA;
R a = dataA;
Data<R> res = v_pack_triplets(a);
for (int i = 0; i < VTraits<R>::vlanes()/4; ++i)
{
SCOPED_TRACE(cv::format("i=%d", i));
EXPECT_EQ(dataA[4*i], res[3*i]);
EXPECT_EQ(dataA[4*i+1], res[3*i+1]);
EXPECT_EQ(dataA[4*i+2], res[3*i+2]);
}
return *this;
}
template <int s>
TheTest & test_pack_u()
{
@@ -1573,19 +1622,27 @@ template<typename R> struct TheTest
v_transpose4x4(a, b, c, d,
e, f, g, h);
Data<R> res[4] = {e, f, g, h};
// for (int i = 0; i < VTraits<R>::vlanes(); i += 4)
// {
int i = 0;
for (int j = 0; j < 4; ++j)
{
SCOPED_TRACE(cv::format("i=%d j=%d", i, j));
EXPECT_EQ(dataA[i + j], res[j][i]);
EXPECT_EQ(dataB[i + j], res[j][i + 1]);
EXPECT_EQ(dataC[i + j], res[j][i + 2]);
EXPECT_EQ(dataD[i + j], res[j][i + 3]);
}
// }
// Data<R> res[4] = {e, f, g, h}; // Generates incorrect data in certain RVV case.
Data<R> res0 = e, res1 = f, res2 = g, res3 = h;
EXPECT_EQ(dataA[0], res0[0]);
EXPECT_EQ(dataB[0], res0[1]);
EXPECT_EQ(dataC[0], res0[2]);
EXPECT_EQ(dataD[0], res0[3]);
EXPECT_EQ(dataA[1], res1[0]);
EXPECT_EQ(dataB[1], res1[1]);
EXPECT_EQ(dataC[1], res1[2]);
EXPECT_EQ(dataD[1], res1[3]);
EXPECT_EQ(dataA[2], res2[0]);
EXPECT_EQ(dataB[2], res2[1]);
EXPECT_EQ(dataC[2], res2[2]);
EXPECT_EQ(dataD[2], res2[3]);
EXPECT_EQ(dataA[3], res3[0]);
EXPECT_EQ(dataB[3], res3[1]);
EXPECT_EQ(dataC[3], res3[2]);
EXPECT_EQ(dataD[3], res3[3]);
return *this;
}
@@ -1599,15 +1656,14 @@ template<typename R> struct TheTest
R a = dataA, b = dataB, c = dataC, d = dataD;
Data<R> res = v_reduce_sum4(a, b, c, d);
// for (int i = 0; i < VTraits<R>::vlanes(); i += 4)
// {
int i = 0;
for (int i = 0; i < VTraits<R>::vlanes(); i += 4)
{
SCOPED_TRACE(cv::format("i=%d", i));
EXPECT_COMPARE_EQ(dataA.sum(i, 4), res[i]);
EXPECT_COMPARE_EQ(dataB.sum(i, 4), res[i + 1]);
EXPECT_COMPARE_EQ(dataC.sum(i, 4), res[i + 2]);
EXPECT_COMPARE_EQ(dataD.sum(i, 4), res[i + 3]);
// }
}
return *this;
}
@@ -1725,132 +1781,16 @@ template<typename R> struct TheTest
#endif
};
#if CV_SIMD_SCALABLE //Temporary
#define DUMP_ENTRY(type) printf("SIMD: %s\n", CV__TRACE_FUNCTION);
#define DUMP_ENTRY(type) printf("SIMD%d: %s\n", 8*VTraits<v_uint8>::vlanes(), CV__TRACE_FUNCTION);
//============= 8-bit integer =====================================================================
void test_hal_intrin_uint8()
{
DUMP_ENTRY(v_uint8);
// typedef v_uint8 R;
TheTest<v_uint8>()
.test_loadstore()
.test_min_max()
;
}
void test_hal_intrin_int8()
{
DUMP_ENTRY(v_int8);
// typedef v_int8 R;
TheTest<v_int8>()
.test_loadstore()
.test_min_max()
;
}
//============= 16-bit integer =====================================================================
void test_hal_intrin_uint16()
{
DUMP_ENTRY(v_uint16);
// typedef v_uint16 R;
TheTest<v_uint16>()
.test_loadstore()
.test_min_max()
;
}
void test_hal_intrin_int16()
{
DUMP_ENTRY(v_int16);
// typedef v_int16 R;
TheTest<v_int16>()
.test_loadstore()
.test_min_max()
;
}
//============= 32-bit integer =====================================================================
void test_hal_intrin_uint32()
{
DUMP_ENTRY(v_uint32);
// typedef v_uint32 R;
TheTest<v_uint32>()
.test_loadstore()
.test_min_max()
;
}
void test_hal_intrin_int32()
{
DUMP_ENTRY(v_int32);
// typedef v_int32 R;
TheTest<v_int32>()
.test_loadstore()
.test_min_max()
;
}
//============= 64-bit integer =====================================================================
void test_hal_intrin_uint64()
{
DUMP_ENTRY(v_uint64);
// typedef v_uint64 R;
TheTest<v_uint64>()
.test_loadstore()
;
}
void test_hal_intrin_int64()
{
DUMP_ENTRY(v_int64);
// typedef v_int64 R;
TheTest<v_int64>()
.test_loadstore()
;
}
//============= Floating point =====================================================================
void test_hal_intrin_float32()
{
DUMP_ENTRY(v_float32);
// typedef v_float32 R;
TheTest<v_float32>()
.test_loadstore()
.test_min_max()
;
}
void test_hal_intrin_float64()
{
DUMP_ENTRY(v_float64);
#if CV_SIMD_64F
// typedef v_float64 R;
TheTest<v_float64>()
.test_loadstore()
.test_min_max()
;
#endif
}
#else
#define DUMP_ENTRY(type) printf("SIMD%d: %s\n", 8*(int)sizeof(v_uint8), CV__TRACE_FUNCTION);
//============= 8-bit integer =====================================================================
void test_hal_intrin_uint8()
{
DUMP_ENTRY(v_uint8);
typedef v_uint8 R;
TheTest<v_uint8>()
.test_loadstore()
.test_interleave()
.test_interleave_pq()
.test_expand()
.test_expand_q()
.test_addsub()
@@ -1873,8 +1813,10 @@ void test_hal_intrin_uint8()
.test_reverse()
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
.test_rotate<0>().test_rotate<1>().test_rotate<8>().test_rotate<15>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
//.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_extract_highest()
.test_pack_triplets()
//.test_broadcast_element<0>().test_broadcast_element<1>()
#if CV_SIMD_WIDTH == 32
.test_pack<9>().test_pack<10>().test_pack<13>().test_pack<15>()
.test_pack_u<9>().test_pack_u<10>().test_pack_u<13>().test_pack_u<15>()
@@ -1887,10 +1829,10 @@ void test_hal_intrin_uint8()
void test_hal_intrin_int8()
{
DUMP_ENTRY(v_int8);
typedef v_int8 R;
TheTest<v_int8>()
.test_loadstore()
.test_interleave()
.test_interleave_pq()
.test_expand()
.test_expand_q()
.test_addsub()
@@ -1913,8 +1855,10 @@ void test_hal_intrin_int8()
.test_reverse()
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
.test_rotate<0>().test_rotate<1>().test_rotate<8>().test_rotate<15>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
//.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_extract_highest()
.test_pack_triplets()
//.test_broadcast_element<0>().test_broadcast_element<1>()
;
}
@@ -1923,10 +1867,10 @@ void test_hal_intrin_int8()
void test_hal_intrin_uint16()
{
DUMP_ENTRY(v_uint16);
typedef v_uint16 R;
TheTest<v_uint16>()
.test_loadstore()
.test_interleave()
.test_interleave_pq()
.test_expand()
.test_addsub()
.test_arithm_wrap()
@@ -1950,18 +1894,20 @@ void test_hal_intrin_uint16()
.test_reverse()
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
.test_rotate<0>().test_rotate<1>().test_rotate<4>().test_rotate<7>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
//.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_extract_highest()
.test_pack_triplets()
//.test_broadcast_element<0>().test_broadcast_element<1>()
;
}
void test_hal_intrin_int16()
{
DUMP_ENTRY(v_int16);
typedef v_int16 R;
TheTest<v_int16>()
.test_loadstore()
.test_interleave()
.test_interleave_pq()
.test_expand()
.test_addsub()
.test_arithm_wrap()
@@ -1987,8 +1933,10 @@ void test_hal_intrin_int16()
.test_reverse()
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
.test_rotate<0>().test_rotate<1>().test_rotate<4>().test_rotate<7>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
//.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_extract_highest()
.test_pack_triplets()
//.test_broadcast_element<0>().test_broadcast_element<1>()
;
}
@@ -1997,10 +1945,10 @@ void test_hal_intrin_int16()
void test_hal_intrin_uint32()
{
DUMP_ENTRY(v_uint32);
typedef v_uint32 R;
TheTest<v_uint32>()
.test_loadstore()
.test_interleave()
// .test_interleave_pq() //not implemented in AVX
.test_expand()
.test_addsub()
.test_mul()
@@ -2020,19 +1968,22 @@ void test_hal_intrin_uint32()
.test_reverse()
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_broadcast_element<0>().test_broadcast_element<1>()
.test_extract_highest()
.test_broadcast_highest()
.test_transpose()
.test_pack_triplets()
;
}
void test_hal_intrin_int32()
{
DUMP_ENTRY(v_int32);
typedef v_int32 R;
TheTest<v_int32>()
.test_loadstore()
.test_interleave()
// .test_interleave_pq() //not implemented in AVX
.test_expand()
.test_addsub()
.test_mul()
@@ -2053,11 +2004,14 @@ void test_hal_intrin_int32()
.test_reverse()
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_broadcast_element<0>().test_broadcast_element<1>()
.test_float_cvt32()
.test_float_cvt64()
.test_transpose()
.test_extract_highest()
.test_broadcast_highest()
.test_pack_triplets()
;
}
@@ -2066,7 +2020,6 @@ void test_hal_intrin_int32()
void test_hal_intrin_uint64()
{
DUMP_ENTRY(v_uint64);
typedef v_uint64 R;
TheTest<v_uint64>()
.test_loadstore()
.test_addsub()
@@ -2078,15 +2031,15 @@ void test_hal_intrin_uint64()
.test_reverse()
.test_extract<0>().test_extract<1>()
.test_rotate<0>().test_rotate<1>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
//.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_extract_highest()
//.test_broadcast_element<0>().test_broadcast_element<1>()
;
}
void test_hal_intrin_int64()
{
DUMP_ENTRY(v_int64);
typedef v_int64 R;
TheTest<v_int64>()
.test_loadstore()
.test_addsub()
@@ -2098,8 +2051,9 @@ void test_hal_intrin_int64()
.test_reverse()
.test_extract<0>().test_extract<1>()
.test_rotate<0>().test_rotate<1>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
//.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_extract_highest()
//.test_broadcast_element<0>().test_broadcast_element<1>()
.test_cvt64_double()
;
}
@@ -2108,14 +2062,15 @@ void test_hal_intrin_int64()
void test_hal_intrin_float32()
{
DUMP_ENTRY(v_float32);
typedef v_float32 R;
TheTest<v_float32>()
.test_loadstore()
.test_interleave()
.test_interleave_2channel()
// .test_interleave_pq() //not implemented in AVX
.test_addsub()
.test_mul()
.test_div()
.test_abs()
.test_cmp()
.test_sqrt_abs()
.test_min_max()
@@ -2132,8 +2087,11 @@ void test_hal_intrin_float32()
.test_reverse()
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_broadcast_element<0>().test_broadcast_element<1>()
.test_extract_highest()
.test_broadcast_highest()
.test_pack_triplets()
#if CV_SIMD_WIDTH == 32
.test_extract<4>().test_extract<5>().test_extract<6>().test_extract<7>()
.test_rotate<4>().test_rotate<5>().test_rotate<6>().test_rotate<7>()
@@ -2145,12 +2103,12 @@ void test_hal_intrin_float64()
{
DUMP_ENTRY(v_float64);
#if CV_SIMD_64F
typedef v_float64 R;
TheTest<v_float64>()
.test_loadstore()
.test_addsub()
.test_mul()
.test_div()
.test_abs()
.test_cmp()
.test_sqrt_abs()
.test_min_max()
@@ -2162,8 +2120,9 @@ void test_hal_intrin_float64()
.test_reverse()
.test_extract<0>().test_extract<1>()
.test_rotate<0>().test_rotate<1>()
.test_extract_n<0>().test_extract_n<1>().test_extract_n<R::nlanes - 1>()
//.test_broadcast_element<0>().test_broadcast_element<1>().test_broadcast_element<R::nlanes - 1>()
.test_extract_n<0>().test_extract_n<1>()
.test_extract_highest()
//.test_broadcast_element<0>().test_broadcast_element<1>()
#if CV_SIMD_WIDTH == 32
.test_extract<2>().test_extract<3>()
.test_rotate<2>().test_rotate<3>()
@@ -2189,8 +2148,6 @@ void test_hal_intrin_float16()
#endif
}
#endif
/*#if defined(CV_CPU_DISPATCH_MODE_FP16) && CV_CPU_DISPATCH_MODE == FP16
void test_hal_intrin_float16()
+90
View File
@@ -2353,6 +2353,96 @@ TEST(Mat, regression_18473)
EXPECT_EQ((int)5, (int)m.at<short>(19, 49, 99));
}
// FITIT: remove DISABLE_ when 1D Mat is supported
TEST(Mat1D, DISABLED_basic)
{
std::vector<int> sizes { 100 };
Mat m1(sizes, CV_8UC1, Scalar::all(5));
m1.at<uchar>(50) = 10;
EXPECT_FALSE(m1.empty());
ASSERT_EQ(1, m1.dims);
ASSERT_EQ(1, m1.size.dims()); // hack map on .rows
EXPECT_EQ(Size(100, 1), m1.size());
{
SCOPED_TRACE("clone");
Mat m = m1.clone();
EXPECT_EQ(1, m.dims);
EXPECT_EQ(Size(100, 1), m.size());
}
{
SCOPED_TRACE("colRange()");
Mat m = m1.colRange(Range(10, 30));
EXPECT_EQ(1, m.dims);
EXPECT_EQ(Size(20, 1), m.size());
}
{
SCOPED_TRACE("reshape(1, 1)");
Mat m = m1.reshape(1, 1);
EXPECT_EQ(1, m.dims);
EXPECT_EQ(Size(100, 1), m.size());
}
{
SCOPED_TRACE("reshape(1, 100)");
Mat m = m1.reshape(1, 100);
EXPECT_EQ(2, m.dims);
EXPECT_EQ(Size(1, 100), m.size());
}
{
SCOPED_TRACE("reshape(1, {1, 100})");
Mat m = m1.reshape(1, {1, 100});
EXPECT_EQ(2, m.dims);
EXPECT_EQ(Size(100, 1), m.size());
}
{
SCOPED_TRACE("copyTo(std::vector<uchar>)");
std::vector<uchar> dst;
m1.copyTo(dst);
EXPECT_EQ(100u, dst.size());
}
{
SCOPED_TRACE("copyTo(row2D)");
Mat m(5, 100, CV_8UC1, Scalar::all(0));
const Mat row2D = m.row(2);
EXPECT_NO_THROW(m1.copyTo(row2D));
}
{
SCOPED_TRACE("convertTo(row2D)");
Mat m(5, 100, CV_32FC1, Scalar::all(0));
const Mat row2D = m.row(2);
EXPECT_NO_THROW(m1.convertTo(row2D, CV_32FC1));
}
{
SCOPED_TRACE("CvMat");
CvMat c_mat = cvMat(m1);
EXPECT_EQ(100, c_mat.cols);
EXPECT_EQ(1, c_mat.rows);
}
{
SCOPED_TRACE("CvMatND");
CvMatND c_mat = cvMatND(m1);
EXPECT_EQ(2, c_mat.dims);
EXPECT_EQ(100, c_mat.dim[0].size);
EXPECT_EQ(1, c_mat.dim[1].size);
}
{
SCOPED_TRACE("minMaxLoc");
Point pt;
minMaxLoc(m1, 0, 0, 0, &pt);
EXPECT_EQ(50, pt.x);
EXPECT_EQ(0, pt.y);
}
}
TEST(Mat, ptrVecni_20044)
{