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 Smorkalov
2025-07-17 18:23:51 +03:00
140 changed files with 2891 additions and 1208 deletions
+5
View File
@@ -749,6 +749,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
+8 -1
View File
@@ -240,6 +240,10 @@ public:
//! 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;
@@ -250,10 +254,13 @@ public:
//! 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;
@@ -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>
# elif defined(__riscv_vector)
# include <riscv_vector.h>
@@ -139,7 +139,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
@@ -232,7 +232,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
+2 -2
View File
@@ -370,7 +370,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
@@ -710,7 +710,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
@@ -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) ==
@@ -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
@@ -77,7 +77,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
@@ -1221,7 +1221,7 @@ 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));
@@ -2053,7 +2053,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) \
{ \
@@ -190,8 +190,6 @@ T* allocSingletonNew() { return new(allocSingletonNewBuffer(sizeof(T))) T(); }
#define IPP_DISABLE_PYRAMIDS_UP 1 // Different results
#define IPP_DISABLE_PYRAMIDS_DOWN 1 // Different results
#define IPP_DISABLE_PYRAMIDS_BUILD 1 // Different results
#define IPP_DISABLE_WARPAFFINE 1 // Different results
#define IPP_DISABLE_WARPPERSPECTIVE 1 // Different results
#define IPP_DISABLE_REMAP 1 // Different results
#define IPP_DISABLE_YUV_RGB 1 // accuracy difference
#define IPP_DISABLE_RGB_YUV 1 // breaks OCL accuracy tests
@@ -202,7 +200,6 @@ T* allocSingletonNew() { return new(allocSingletonNewBuffer(sizeof(T))) T(); }
#define IPP_DISABLE_XYZ_RGB 1 // big accuracy difference
#define IPP_DISABLE_HOUGH 1 // improper integration/results
#define IPP_DISABLE_FILTER2D_BIG_MASK 1 // different results on masks > 7x7
#define IPP_DISABLE_NORM_8U 1 // accuracy difference in perf test sanity check
// Temporary disabled named IPP region. Performance
#define IPP_DISABLE_PERF_COPYMAKE 1 // performance variations
@@ -11,7 +11,7 @@
/* no support */
# elif defined WINRT || defined _WIN32_WCE
/* not supported */
# elif defined __ANDROID__ || defined __linux__ || defined _WIN32 || \
# elif defined __ANDROID__ || defined __linux__ || defined _WIN32 || defined __CYGWIN__ || \
defined __FreeBSD__ || defined __bsdi__ || defined __HAIKU__ || \
defined __GNU__ || defined __QNX__
# define OPENCV_HAVE_FILESYSTEM_SUPPORT 1
@@ -12,7 +12,7 @@
#if defined(_WIN32)
#include <windows.h>
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__)
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__CYGWIN__)
#include <dlfcn.h>
#endif
@@ -65,7 +65,7 @@ void* getSymbol_(LibHandle_t h, const char* symbolName)
{
#if defined(_WIN32)
return (void*)GetProcAddress(h, symbolName);
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__)
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__CYGWIN__)
return dlsym(h, symbolName);
#endif
}
@@ -79,7 +79,7 @@ LibHandle_t libraryLoad_(const FileSystemPath_t& filename)
# else
return LoadLibraryW(filename.c_str());
#endif
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__)
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__CYGWIN__)
void* handle = dlopen(filename.c_str(), RTLD_NOW);
CV_LOG_IF_DEBUG(NULL, !handle, "dlopen() error: " << dlerror());
return handle;
@@ -91,7 +91,7 @@ void libraryRelease_(LibHandle_t h)
{
#if defined(_WIN32)
FreeLibrary(h);
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__)
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__CYGWIN__)
dlclose(h);
#endif
}
+26 -24
View File
@@ -47,49 +47,50 @@ inline fun <reified T> Mat.at(idx: IntArray) : Atable<T> =
class AtableUByte(val mat: Mat, val indices: IntArray): Atable<UByte> {
constructor(mat: Mat, row: Int, col: Int) : this(mat, intArrayOf(row, col))
override fun getV(): UByte {
val data = UByteArray(1)
val data = ByteArray(1)
mat.get(indices, data)
return data[0]
return data[0].toUByte()
}
override fun setV(v: UByte) {
val data = ubyteArrayOf(v)
val data = byteArrayOf(v.toByte())
mat.put(indices, data)
}
override fun getV2c(): Tuple2<UByte> {
val data = UByteArray(2)
val data = ByteArray(2)
mat.get(indices, data)
return Tuple2(data[0], data[1])
return Tuple2(data[0].toUByte(), data[1].toUByte())
}
override fun setV2c(v: Tuple2<UByte>) {
val data = ubyteArrayOf(v._0, v._1)
val data = byteArrayOf(v._0.toByte(), v._1.toByte())
mat.put(indices, data)
}
override fun getV3c(): Tuple3<UByte> {
val data = UByteArray(3)
val data = ByteArray(3)
mat.get(indices, data)
return Tuple3(data[0], data[1], data[2])
return Tuple3(data[0].toUByte(), data[1].toUByte(), data[2].toUByte())
}
override fun setV3c(v: Tuple3<UByte>) {
val data = ubyteArrayOf(v._0, v._1, v._2)
val data = byteArrayOf(v._0.toByte(), v._1.toByte(), v._2.toByte())
mat.put(indices, data)
}
override fun getV4c(): Tuple4<UByte> {
val data = UByteArray(4)
val data = ByteArray(4)
mat.get(indices, data)
return Tuple4(data[0], data[1], data[2], data[3])
return Tuple4(data[0].toUByte(), data[1].toUByte(), data[2].toUByte(), data[3].toUByte())
}
override fun setV4c(v: Tuple4<UByte>) {
val data = ubyteArrayOf(v._0, v._1, v._2, v._3)
val data = byteArrayOf(v._0.toByte(), v._1.toByte(), v._2.toByte(), v._3.toByte())
mat.put(indices, data)
}
}
@@ -99,46 +100,47 @@ class AtableUShort(val mat: Mat, val indices: IntArray): Atable<UShort> {
constructor(mat: Mat, row: Int, col: Int) : this(mat, intArrayOf(row, col))
override fun getV(): UShort {
val data = UShortArray(1)
val data = ShortArray(1)
mat.get(indices, data)
return data[0]
return data[0].toUShort()
}
override fun setV(v: UShort) {
val data = ushortArrayOf(v)
val data = shortArrayOf(v.toShort())
mat.put(indices, data)
}
override fun getV2c(): Tuple2<UShort> {
val data = UShortArray(2)
val data = ShortArray(2)
mat.get(indices, data)
return Tuple2(data[0], data[1])
return Tuple2(data[0].toUShort(), data[1].toUShort())
}
override fun setV2c(v: Tuple2<UShort>) {
val data = ushortArrayOf(v._0, v._1)
val data = shortArrayOf(v._0.toShort(), v._1.toShort())
mat.put(indices, data)
}
override fun getV3c(): Tuple3<UShort> {
val data = UShortArray(3)
val data = ShortArray(3)
mat.get(indices, data)
return Tuple3(data[0], data[1], data[2])
return Tuple3(data[0].toUShort(), data[1].toUShort(), data[2].toUShort())
}
override fun setV3c(v: Tuple3<UShort>) {
val data = ushortArrayOf(v._0, v._1, v._2)
val data = shortArrayOf(v._0.toShort(), v._1.toShort(), v._2.toShort())
mat.put(indices, data)
}
override fun getV4c(): Tuple4<UShort> {
val data = UShortArray(4)
val data = ShortArray(4)
mat.get(indices, data)
return Tuple4(data[0], data[1], data[2], data[3])
return Tuple4(data[0].toUShort(), data[1].toUShort(), data[2].toUShort(), data[3].toUShort())
}
override fun setV4c(v: Tuple4<UShort>) {
val data = ushortArrayOf(v._0, v._1, v._2, v._3)
val data = shortArrayOf(v._0.toShort(), v._1.toShort(), v._2.toShort(), v._3.toShort())
mat.put(indices, data)
}
}
+3 -1
View File
@@ -548,7 +548,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) co
return;
}
CV_DbgAssert( sdepth <= CV_64F && ddepth <= CV_64F );
CV_Assert( sdepth <= CV_64F && ddepth <= CV_64F );
GpuMat src = *this;
@@ -580,6 +580,8 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, doub
const int sdepth = depth();
const int ddepth = CV_MAT_DEPTH(rtype);
CV_Assert(sdepth <= CV_64F && ddepth <= CV_64F);
GpuMat src = *this;
_dst.create(size(), rtype);
+1 -1
View File
@@ -1598,7 +1598,7 @@ transform_32f( const float* src, float* dst, const float* m, int len, int scn, i
// Disabled for RISC-V Vector (scalable), because of:
// 1. v_matmuladd for RVV is 128-bit only but not scalable, this will fail the test `Core_Transform.accuracy`.
// 2. Both gcc and clang can autovectorize this, with better performance than using Universal intrinsic.
#if (CV_SIMD || CV_SIMD_SCALABLE) && !defined(__aarch64__) && !defined(_M_ARM64) && !(CV_TRY_RVV && CV_RVV)
#if (CV_SIMD || CV_SIMD_SCALABLE) && !defined(__aarch64__) && !defined(_M_ARM64) && !defined(_M_ARM64EC) && !(CV_TRY_RVV && CV_RVV)
int x = 0;
if( scn == 3 && dcn == 3 )
{
+1 -1
View File
@@ -316,7 +316,7 @@ double norm( InputArray _src, int normType, InputArray _mask )
}
NormFunc func = getNormFunc(normType >> 1, depth);
CV_Assert( func != 0 );
CV_Assert( (normType >> 1) >= 3 || func != 0 );
if( src.isContinuous() && mask.empty() )
{
+2
View File
@@ -1525,6 +1525,8 @@ NormFunc getNormFunc(int normType, int depth)
}
};
if (normType >= 3 || normType < 0) return nullptr;
return normTab[normType][depth];
}
+1 -1
View File
@@ -947,7 +947,7 @@ int getNumberOfCPUs_()
#if defined _WIN32
SYSTEM_INFO sysinfo = {};
#if (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_X64) || defined(WINRT)) && _WIN32_WINNT >= 0x501
#if (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_X64) || defined(WINRT)) && _WIN32_WINNT >= 0x501
GetNativeSystemInfo( &sysinfo );
#else
GetSystemInfo( &sysinfo );
+2 -2
View File
@@ -44,6 +44,7 @@
#include "precomp.hpp"
//#include "opencv2/core/core_c.h"
#include <atomic>
#include <exception>
#include <iostream>
#include <ostream>
@@ -126,7 +127,6 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
#endif
#ifdef CV_ERROR_SET_TERMINATE_HANDLER
#include <exception> // std::set_terminate
#include <cstdlib> // std::abort
#endif
@@ -728,7 +728,7 @@ struct HWFeatures
#if defined _ARM_ && (defined(_WIN32_WCE) && _WIN32_WCE >= 0x800)
have[CV_CPU_NEON] = true;
#endif
#if defined _M_ARM64
#if defined _M_ARM64 || defined _M_ARM64EC
have[CV_CPU_NEON] = true;
#endif
#ifdef __riscv_vector
+4 -4
View File
@@ -34,7 +34,7 @@
#include <errno.h>
#include <io.h>
#include <stdio.h>
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__ || defined __GNU__ || defined __EMSCRIPTEN__ || defined __QNX__
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__ || defined __GNU__ || defined __EMSCRIPTEN__ || defined __QNX__ || defined __CYGWIN__
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -194,7 +194,7 @@ cv::String getcwd()
sz = GetCurrentDirectoryA((DWORD)buf.size(), buf.data());
return cv::String(buf.data(), (size_t)sz);
#endif
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__ || defined __EMSCRIPTEN__ || defined __QNX__
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__ || defined __EMSCRIPTEN__ || defined __QNX__ || defined __CYGWIN__
for(;;)
{
char* p = ::getcwd(buf.data(), buf.size());
@@ -228,7 +228,7 @@ bool createDirectory(const cv::String& path)
#else
int result = _mkdir(path.c_str());
#endif
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__ || defined __EMSCRIPTEN__ || defined __QNX__
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__ || defined __EMSCRIPTEN__ || defined __QNX__ || defined __CYGWIN__
int result = mkdir(path.c_str(), 0777);
#else
int result = -1;
@@ -343,7 +343,7 @@ private:
Impl& operator=(const Impl&); // disabled
};
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__ || defined __GNU__ || defined __EMSCRIPTEN__ || defined __QNX__
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__ || defined __GNU__ || defined __EMSCRIPTEN__ || defined __QNX__ || defined __CYGWIN__
struct FileLock::Impl
{