Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ SerialPrograms/*.lib
Resources/*
Packages/
SerialPrograms/CMakeLists.txt.user
opencv_world4110d.dll
opencv_world4120.dll
opencv_world4120d.dll

# Python cache
__pycache__
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,11 @@ Possible usage with some positive example data:
normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
@endcode

@note Due to rounding issues, min-max normalization can result in values outside provided boundaries.
If exact range conformity is needed, following workarounds can be used:
- use double floating point precision (dtype = CV_64F)
- manually clip values (`cv::max(res, left_bound, res)`, `cv::min(res, right_bound, res)` or `np.clip`)

@param src input array.
@param dst output array of the same size as src .
@param alpha norm value to normalize to or the lower range boundary in case of the range
Expand Down Expand Up @@ -2004,8 +2009,8 @@ The function solveCubic finds the real roots of a cubic equation:

The roots are stored in the roots array.
@param coeffs equation coefficients, an array of 3 or 4 elements.
@param roots output array of real roots that has 1 or 3 elements.
@return number of real roots. It can be 0, 1 or 2.
@param roots output array of real roots that has 0, 1, 2 or 3 elements.
@return number of real roots. It can be -1 (all real numbers), 0, 1, 2 or 3.
*/
CV_EXPORTS_W int solveCubic(InputArray coeffs, OutputArray roots);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,72 @@ enum DftFlags {
DCT_ROWS = DFT_ROWS
};

//! Various border types, image boundaries are denoted with `|`
//! @see borderInterpolate, copyMakeBorder
/*! Various border types, image boundaries are denoted with the `|` character in the table below, when describing each method.

The following examples show the result of the @ref copyMakeBorder call according to different methods.
Input image is `6x4` (width x height) size and the @ref copyMakeBorder function is used with a border size of 2 pixels
in each direction, giving a resulting image of `10x8` resolution.

@code
Input image:
[[ 0 1 2 3 4 5]
[ 6 7 8 9 10 11]
[12 13 14 15 16 17]
[18 19 20 21 22 23]]

Border type: BORDER_CONSTANT (a constant value of 255 is used)
[[255 255 255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255 255 255]
[255 255 0 1 2 3 4 5 255 255]
[255 255 6 7 8 9 10 11 255 255]
[255 255 12 13 14 15 16 17 255 255]
[255 255 18 19 20 21 22 23 255 255]
[255 255 255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255 255 255]]

Border type: BORDER_REPLICATE
[[ 0 0 0 1 2 3 4 5 5 5]
[ 0 0 0 1 2 3 4 5 5 5]
[ 0 0 0 1 2 3 4 5 5 5]
[ 6 6 6 7 8 9 10 11 11 11]
[12 12 12 13 14 15 16 17 17 17]
[18 18 18 19 20 21 22 23 23 23]
[18 18 18 19 20 21 22 23 23 23]
[18 18 18 19 20 21 22 23 23 23]]

Border type: BORDER_REFLECT
[[ 7 6 6 7 8 9 10 11 11 10]
[ 1 0 0 1 2 3 4 5 5 4]
[ 1 0 0 1 2 3 4 5 5 4]
[ 7 6 6 7 8 9 10 11 11 10]
[13 12 12 13 14 15 16 17 17 16]
[19 18 18 19 20 21 22 23 23 22]
[19 18 18 19 20 21 22 23 23 22]
[13 12 12 13 14 15 16 17 17 16]]

Border type: BORDER_WRAP
[[16 17 12 13 14 15 16 17 12 13]
[22 23 18 19 20 21 22 23 18 19]
[ 4 5 0 1 2 3 4 5 0 1]
[10 11 6 7 8 9 10 11 6 7]
[16 17 12 13 14 15 16 17 12 13]
[22 23 18 19 20 21 22 23 18 19]
[ 4 5 0 1 2 3 4 5 0 1]
[10 11 6 7 8 9 10 11 6 7]]

Border type: BORDER_REFLECT_101
[[14 13 12 13 14 15 16 17 16 15]
[ 8 7 6 7 8 9 10 11 10 9]
[ 2 1 0 1 2 3 4 5 4 3]
[ 8 7 6 7 8 9 10 11 10 9]
[14 13 12 13 14 15 16 17 16 15]
[20 19 18 19 20 21 22 23 22 21]
[14 13 12 13 14 15 16 17 16 15]
[ 8 7 6 7 8 9 10 11 10 9]]
@endcode

@see borderInterpolate, copyMakeBorder
*/
enum BorderTypes {
BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i`
BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh`
Expand Down Expand Up @@ -386,7 +450,7 @@ It does not throw exception, but terminates the application.

//! @endcond

#if defined _DEBUG || defined CV_STATIC_ANALYSIS
#if !defined(NDEBUG) || defined(CV_STATIC_ANALYSIS)
# define CV_DbgAssert(expr) CV_Assert(expr)
#else
/** replaced with CV_Assert(expr) in Debug configuration */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ class CV_EXPORTS_W GpuMat

//! converts GpuMat to another datatype (Blocking call)
void convertTo(OutputArray dst, int rtype) const;
//! bindings overload which converts GpuMat to another datatype (Blocking call)
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype) const {
convertTo(static_cast<OutputArray>(dst), rtype);
}

//! converts GpuMat to another datatype (Non-Blocking call)
void convertTo(OutputArray dst, int rtype, Stream& stream) const;
Expand All @@ -250,10 +254,13 @@ class CV_EXPORTS_W GpuMat

//! converts GpuMat to another datatype with scaling (Blocking call)
void convertTo(OutputArray dst, int rtype, double alpha, double beta = 0.0) const;

//! bindings overload which converts GpuMat to another datatype with scaling(Blocking call)
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype, double alpha = 1.0, double beta = 0.0) const {
#ifdef OPENCV_BINDINGS_PARSER
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype, double alpha=1.0, double beta = 0.0) const {
convertTo(static_cast<OutputArray>(dst), rtype, alpha, beta);
}
#endif

//! converts GpuMat to another datatype with scaling (Non-Blocking call)
void convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
# define CV_AVX 1
#endif
#ifdef CV_CPU_COMPILE_FP16
# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)
# include <arm_neon.h>
# else
# include <immintrin.h>
Expand Down Expand Up @@ -137,7 +137,7 @@
# define CV_FMA3 1
#endif

#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER))
#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER))
# include <Intrin.h>
# include <arm_neon.h>
# define CV_NEON 1
Expand Down Expand Up @@ -230,7 +230,7 @@ struct VZeroUpperGuard {
# define CV_MMX 1
# define CV_SSE 1
# define CV_SSE2 1
#elif defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER))
#elif defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER))
# include <Intrin.h>
# include <arm_neon.h>
# define CV_NEON 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ enum CpuFeatures {

#include "cv_cpu_dispatch.h"

#if !defined(CV_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64))
#if !defined(CV_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC))
// int*, int64* should be propertly aligned pointers on ARMv7
#define CV_STRONG_ALIGNMENT 1
#endif
Expand Down Expand Up @@ -697,7 +697,7 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType)
#ifdef CV_XADD
// allow to use user-defined macro
#elif defined __GNUC__ || defined __clang__
# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER
# if defined __clang__ && __clang_major__ >= 3 && !defined __EMSCRIPTEN__ && !defined __INTEL_COMPILER
# ifdef __ATOMIC_ACQ_REL
# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL)
# else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,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__) || defined(__loongarch64)
#elif defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(__PPC64__) || defined(__loongarch64)
Cv64suf ieee754;
ieee754.f = value;
return (ieee754.u & 0x7fffffffffffffff) ==
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,32 +225,30 @@ These operations allow to reorder or recombine elements in one or multiple vecto
Element-wise binary and unary operations.

- Arithmetics:
@ref v_add(const v_reg &a, const v_reg &b) "+",
@ref v_sub(const v_reg &a, const v_reg &b) "-",
@ref v_mul(const v_reg &a, const v_reg &b) "*",
@ref v_div(const v_reg &a, const v_reg &b) "/",
@ref v_add,
@ref v_sub,
@ref v_mul,
@ref v_div,
@ref v_mul_expand

- Non-saturating arithmetics: @ref v_add_wrap, @ref v_sub_wrap

- Bitwise shifts:
@ref v_shl(const v_reg &a, int s) "<<",
@ref v_shr(const v_reg &a, int s) ">>",
@ref v_shl, @ref v_shr

- Bitwise logic:
@ref v_and(const v_reg &a, const v_reg &b) "&",
@ref v_or(const v_reg &a, const v_reg &b) "|",
@ref v_xor(const v_reg &a, const v_reg &b) "^",
@ref v_not(const v_reg &a) "~"
@ref v_and,
@ref v_or,
@ref v_xor,
@ref v_not

- Comparison:
@ref v_gt(const v_reg &a, const v_reg &b) ">",
@ref v_ge(const v_reg &a, const v_reg &b) ">=",
@ref v_lt(const v_reg &a, const v_reg &b) "<",
@ref v_le(const v_reg &a, const v_reg &b) "<=",
@ref v_eq(const v_reg &a, const v_reg &b) "==",
@ref v_ne(const v_reg &a, const v_reg &b) "!="
@ref v_gt,
@ref v_ge,
@ref v_lt,
@ref v_le,
@ref v_eq,
@ref v_ne

- min/max: @ref v_min, @ref v_max

Expand Down
111 changes: 111 additions & 0 deletions 3rdParty/opencv-4.12.0/opencv2/core/hal/intrin_legacy_ops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html

// This file has been created for compatibility with older versions of Universal Intrinscs
// Binary operators for vector types has been removed since version 4.11
// Include this file manually after OpenCV headers if you need these operators

#ifndef OPENCV_HAL_INTRIN_LEGACY_OPS_HPP
#define OPENCV_HAL_INTRIN_LEGACY_OPS_HPP

#ifdef __OPENCV_BUILD
#error "Universal Intrinsics operators are deprecated and should not be used in OpenCV library"
#endif

#ifdef __riscv
#warning "Operators might conflict with built-in functions on RISC-V platform"
#endif

#if defined(CV_VERSION) && CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR < 9
#warning "Older versions of OpenCV (<4.9) already have Universal Intrinscs operators"
#endif


namespace cv { namespace hal {

#define BIN_OP(OP, FUN) \
template <typename R> R operator OP (const R & lhs, const R & rhs) { return FUN(lhs, rhs); }

#define BIN_A_OP(OP, FUN) \
template <typename R> R & operator OP (R & res, const R & val) { res = FUN(res, val); return res; }

#define UN_OP(OP, FUN) \
template <typename R> R operator OP (const R & val) { return FUN(val); }

BIN_OP(+, v_add)
BIN_OP(-, v_sub)
BIN_OP(*, v_mul)
BIN_OP(/, v_div)
BIN_OP(&, v_and)
BIN_OP(|, v_or)
BIN_OP(^, v_xor)

BIN_OP(==, v_eq)
BIN_OP(!=, v_ne)
BIN_OP(<, v_lt)
BIN_OP(>, v_gt)
BIN_OP(<=, v_le)
BIN_OP(>=, v_ge)

BIN_A_OP(+=, v_add)
BIN_A_OP(-=, v_sub)
BIN_A_OP(*=, v_mul)
BIN_A_OP(/=, v_div)
BIN_A_OP(&=, v_and)
BIN_A_OP(|=, v_or)
BIN_A_OP(^=, v_xor)

UN_OP(~, v_not)

// TODO: shift operators?

}} // cv::hal::

//==============================================================================

#ifdef OPENCV_ENABLE_INLINE_INTRIN_OPERATOR_TEST

namespace cv { namespace hal {

inline static void opencv_operator_compile_test()
{
using namespace cv;
v_float32 a, b, c;
uint8_t shift = 1;
a = b + c;
a = b - c;
a = b * c;
a = b / c;
a = b & c;
a = b | c;
a = b ^ c;
// a = b >> shift;
// a = b << shift;

a = (b == c);
a = (b != c);
a = (b < c);}}
a = (b > c);
a = (b <= c);
a = (b >= c);

a += b;
a -= b;
a *= b;
a /= b;
a &= b;
a |= b;
a ^= b;
// a <<= shift;
// a >>= shift;

a = ~b;
}

}} // cv::hal::

#endif


#endif // OPENCV_HAL_INTRIN_LEGACY_OPS_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace cv
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN

#define CV_SIMD128 1
#if defined(__aarch64__) || defined(_M_ARM64)
#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define CV_SIMD128_64F 1
#else
#define CV_SIMD128_64F 0
Expand All @@ -72,7 +72,7 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
//
// [1] https://developer.arm.com/documentation/101028/0012/13--Advanced-SIMD--Neon--intrinsics
// [2] https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
#if defined(__ARM_64BIT_STATE) || defined(_M_ARM64)
#if defined(__ARM_64BIT_STATE) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define CV_NEON_AARCH64 1
#else
#define CV_NEON_AARCH64 0
Expand Down Expand Up @@ -1080,7 +1080,7 @@ OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int16x8, vreinterpretq_s16_u16, s16, u16)
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint32x4, OPENCV_HAL_NOP, u32, u32)
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int32x4, vreinterpretq_s32_u32, s32, u32)
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float32x4, vreinterpretq_f32_u32, f32, u32)
#if defined(__aarch64__) || defined(_M_ARM64)
#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
static inline uint64x2_t vmvnq_u64(uint64x2_t a)
{
uint64x2_t vx = vreinterpretq_u64_u32(vdupq_n_u32(0xFFFFFFFF));
Expand Down Expand Up @@ -1822,7 +1822,7 @@ inline v_int32x4 v_load_expand_q(const schar* ptr)
return v_int32x4(vmovl_s16(v1));
}

#if defined(__aarch64__) || defined(_M_ARM64)
#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \
inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \
{ \
Expand Down
Loading