Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin 2019-10-05 15:45:31 +00:00
commit 626bfbf309
23 changed files with 222 additions and 98 deletions

View File

@ -5,13 +5,15 @@
# AVX / AVX2 / AVX_512F # AVX / AVX2 / AVX_512F
# FMA3 # FMA3
# #
# AVX512 details: https://en.wikipedia.org/wiki/AVX-512#CPUs_with_AVX-512
#
# CPU features groups: # CPU features groups:
# AVX512_COMMON (Common instructions AVX-512F/CD for all CPUs that support AVX-512) # AVX512_COMMON (Common instructions AVX-512F/CD for all CPUs that support AVX-512)
# AVX512_KNL (Knights Landing with AVX-512F/CD/ER/PF) # AVX512_KNL (Knights Landing with AVX-512F/CD/ER/PF)
# AVX512_KNM (Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ) # AVX512_KNM (Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ)
# AVX512_SKX (Skylake-X with AVX-512F/CD/BW/DQ/VL) # AVX512_SKX (Skylake-X with AVX-512F/CD/BW/DQ/VL)
# AVX512_CNL (Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI) # AVX512_CNL (Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI)
# AVX512_CEL (Cascade Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI) # AVX512_CLX (Cascade Lake with AVX-512F/CD/BW/DQ/VL/VNNI)
# AVX512_ICL (Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ/VPCLMULQDQ*/GFNI*/VAES*) # AVX512_ICL (Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ/VPCLMULQDQ*/GFNI*/VAES*)
# ppc64le arch: # ppc64le arch:
@ -43,7 +45,7 @@
# CPU_{opt}_ENABLED_DEFAULT=ON/OFF - has compiler support without additional flag (CPU_BASELINE_DETECT=ON only) # CPU_{opt}_ENABLED_DEFAULT=ON/OFF - has compiler support without additional flag (CPU_BASELINE_DETECT=ON only)
set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F") set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F")
list(APPEND CPU_ALL_OPTIMIZATIONS "AVX512_COMMON;AVX512_KNL;AVX512_KNM;AVX512_SKX;AVX512_CNL;AVX512_CEL;AVX512_ICL") list(APPEND CPU_ALL_OPTIMIZATIONS "AVX512_COMMON;AVX512_KNL;AVX512_KNM;AVX512_SKX;AVX512_CNL;AVX512_CLX;AVX512_ICL")
list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16) list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16)
list(APPEND CPU_ALL_OPTIMIZATIONS MSA) list(APPEND CPU_ALL_OPTIMIZATIONS MSA)
list(APPEND CPU_ALL_OPTIMIZATIONS VSX VSX3) list(APPEND CPU_ALL_OPTIMIZATIONS VSX VSX3)
@ -163,15 +165,15 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
endif() endif()
if(X86 OR X86_64) if(X86 OR X86_64)
ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX_512F;AVX512_COMMON;AVX512_KNL;AVX512_KNM;AVX512_SKX;AVX512_CNL;AVX512_CEL;AVX512_ICL") ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX_512F;AVX512_COMMON;AVX512_KNL;AVX512_KNM;AVX512_SKX;AVX512_CNL;AVX512_CLX;AVX512_ICL")
ocv_update(CPU_AVX512_COMMON_GROUP "AVX_512F;AVX_512CD") ocv_update(CPU_AVX512_COMMON_GROUP "AVX_512F;AVX_512CD")
ocv_update(CPU_AVX512_KNL_GROUP "AVX512_COMMON;AVX512_KNL_EXTRA") ocv_update(CPU_AVX512_KNL_GROUP "AVX512_COMMON;AVX512_KNL_EXTRA")
ocv_update(CPU_AVX512_KNM_GROUP "AVX512_KNL;AVX512_KNM_EXTRA;AVX_512VPOPCNTDQ") ocv_update(CPU_AVX512_KNM_GROUP "AVX512_KNL;AVX512_KNM_EXTRA;AVX_512VPOPCNTDQ")
ocv_update(CPU_AVX512_SKX_GROUP "AVX512_COMMON;AVX_512VL;AVX_512BW;AVX_512DQ") ocv_update(CPU_AVX512_SKX_GROUP "AVX512_COMMON;AVX_512VL;AVX_512BW;AVX_512DQ")
ocv_update(CPU_AVX512_CNL_GROUP "AVX512_SKX;AVX_512IFMA;AVX_512VBMI") ocv_update(CPU_AVX512_CNL_GROUP "AVX512_SKX;AVX_512IFMA;AVX_512VBMI")
ocv_update(CPU_AVX512_CEL_GROUP "AVX512_CNL;AVX_512VNNI") ocv_update(CPU_AVX512_CLX_GROUP "AVX512_SKX;AVX_512VNNI")
ocv_update(CPU_AVX512_ICL_GROUP "AVX512_CEL;AVX_512VBMI2;AVX_512BITALG;AVX_512VPOPCNTDQ") # ? VPCLMULQDQ, GFNI, VAES ocv_update(CPU_AVX512_ICL_GROUP "AVX512_SKX;AVX_512IFMA;AVX_512VBMI;AVX_512VNNI;AVX_512VBMI2;AVX_512BITALG;AVX_512VPOPCNTDQ") # ? VPCLMULQDQ, GFNI, VAES
ocv_update(CPU_SSE_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse.cpp") ocv_update(CPU_SSE_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse.cpp")
ocv_update(CPU_SSE2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp") ocv_update(CPU_SSE2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp")
@ -189,12 +191,12 @@ if(X86 OR X86_64)
ocv_update(CPU_AVX512_KNM_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512knm.cpp") ocv_update(CPU_AVX512_KNM_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512knm.cpp")
ocv_update(CPU_AVX512_SKX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512skx.cpp") ocv_update(CPU_AVX512_SKX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512skx.cpp")
ocv_update(CPU_AVX512_CNL_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512cnl.cpp") ocv_update(CPU_AVX512_CNL_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512cnl.cpp")
ocv_update(CPU_AVX512_CEL_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512cel.cpp") ocv_update(CPU_AVX512_CLX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512clx.cpp")
ocv_update(CPU_AVX512_ICL_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512icl.cpp") ocv_update(CPU_AVX512_ICL_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512icl.cpp")
if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE) if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE)
ocv_update(CPU_AVX512_ICL_IMPLIES "AVX512_CEL") ocv_update(CPU_AVX512_ICL_IMPLIES "AVX512_SKX")
ocv_update(CPU_AVX512_CEL_IMPLIES "AVX512_CNL") ocv_update(CPU_AVX512_CLX_IMPLIES "AVX512_SKX")
ocv_update(CPU_AVX512_CNL_IMPLIES "AVX512_SKX") ocv_update(CPU_AVX512_CNL_IMPLIES "AVX512_SKX")
ocv_update(CPU_AVX512_SKX_IMPLIES "AVX512_COMMON") ocv_update(CPU_AVX512_SKX_IMPLIES "AVX512_COMMON")
ocv_update(CPU_AVX512_KNM_IMPLIES "AVX512_KNL") ocv_update(CPU_AVX512_KNM_IMPLIES "AVX512_KNL")
@ -251,7 +253,7 @@ if(X86 OR X86_64)
ocv_intel_compiler_optimization_option(AVX512_KNM "-xKNM" "/Qx:KNM") ocv_intel_compiler_optimization_option(AVX512_KNM "-xKNM" "/Qx:KNM")
ocv_intel_compiler_optimization_option(AVX512_SKX "-xSKYLAKE-AVX512" "/Qx:SKYLAKE-AVX512") ocv_intel_compiler_optimization_option(AVX512_SKX "-xSKYLAKE-AVX512" "/Qx:SKYLAKE-AVX512")
ocv_intel_compiler_optimization_option(AVX512_CNL "-xCANNONLAKE" "/Qx:CANNONLAKE") ocv_intel_compiler_optimization_option(AVX512_CNL "-xCANNONLAKE" "/Qx:CANNONLAKE")
ocv_intel_compiler_optimization_option(AVX512_CEL "-xCASCADELAKE" "/Qx:CASCADELAKE") ocv_intel_compiler_optimization_option(AVX512_CLX "-xCASCADELAKE" "/Qx:CASCADELAKE")
ocv_intel_compiler_optimization_option(AVX512_ICL "-xICELAKE-CLIENT" "/Qx:ICELAKE-CLIENT") ocv_intel_compiler_optimization_option(AVX512_ICL "-xICELAKE-CLIENT" "/Qx:ICELAKE-CLIENT")
elseif(CV_GCC OR CV_CLANG) elseif(CV_GCC OR CV_CLANG)
ocv_update(CPU_AVX2_FLAGS_ON "-mavx2") ocv_update(CPU_AVX2_FLAGS_ON "-mavx2")

View File

@ -80,9 +80,9 @@ endif()
if(INF_ENGINE_TARGET) if(INF_ENGINE_TARGET)
if(NOT INF_ENGINE_RELEASE) if(NOT INF_ENGINE_RELEASE)
message(WARNING "InferenceEngine version have not been set, 2019R2 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.") message(WARNING "InferenceEngine version have not been set, 2019R3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
endif() endif()
set(INF_ENGINE_RELEASE "2019020000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)") set(INF_ENGINE_RELEASE "2019030000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)")
set_target_properties(${INF_ENGINE_TARGET} PROPERTIES set_target_properties(${INF_ENGINE_TARGET} PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}" INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
) )

View File

@ -3,9 +3,9 @@
void test() void test()
{ {
__m512i a, b, c; __m512i a, b, c;
a = _mm512_dpwssd_epi32(a, b, c); a = _mm512_dpwssd_epi32(a, b, c); // VNNI
} }
#else #else
#error "AVX512-CEL is not supported" #error "AVX512-CLX is not supported"
#endif #endif
int main() { return 0; } int main() { return 0; }

View File

@ -3,9 +3,10 @@
void test() void test()
{ {
__m512i a, b, c; __m512i a, b, c;
a = _mm512_popcnt_epi8(a); a = _mm512_popcnt_epi8(a); // BITALG
a = _mm512_shrdv_epi64(a, b, c); a = _mm512_shrdv_epi64(a, b, c); // VBMI2
a = _mm512_popcnt_epi64(a); a = _mm512_popcnt_epi64(a); // VPOPCNTDQ
a = _mm512_dpwssd_epi32(a, b, c); // VNNI
} }
#else #else
#error "AVX512-ICL is not supported" #error "AVX512-ICL is not supported"

View File

@ -5,7 +5,7 @@ Goals
----- -----
In this tutorial We will learn to setup OpenCV-Python in Ubuntu System. In this tutorial We will learn to setup OpenCV-Python in Ubuntu System.
Below steps are tested for Ubuntu 16.04 (64-bit) and Ubuntu 14.04 (32-bit). Below steps are tested for Ubuntu 16.04 and 18.04 (both 64-bit).
OpenCV-Python can be installed in Ubuntu in two ways: OpenCV-Python can be installed in Ubuntu in two ways:
- Install from pre-built binaries available in Ubuntu repositories - Install from pre-built binaries available in Ubuntu repositories
@ -62,17 +62,36 @@ We need **CMake** to configure the installation, **GCC** for compilation, **Pyth
``` ```
sudo apt-get install cmake sudo apt-get install cmake
sudo apt-get install python-dev python-numpy
sudo apt-get install gcc g++ sudo apt-get install gcc g++
``` ```
to support python2:
```
sudo apt-get install python-dev python-numpy
```
to support python3:
```
sudo apt-get install python3-dev python3-numpy
```
Next we need **GTK** support for GUI features, Camera support (v4l), Media Support Next we need **GTK** support for GUI features, Camera support (v4l), Media Support
(ffmpeg, gstreamer) etc. (ffmpeg, gstreamer) etc.
``` ```
sudo apt-get install gtk2-devel sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install ffmpeg-devel sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
sudo apt-get install gstreamer-plugins-base-devel ```
to support gtk2:
```
sudo apt-get install libgtk2.0-dev
```
to support gtk3:
```
sudo apt-get install libgtk-3-dev
``` ```
### Optional Dependencies ### Optional Dependencies
@ -86,14 +105,15 @@ But it may be a little old.
If you want to get latest libraries, you can install development files for system libraries of these formats. If you want to get latest libraries, you can install development files for system libraries of these formats.
``` ```
sudo apt-get install libpng-devel sudo apt-get install libpng-dev
sudo apt-get install libjpeg-turbo-devel sudo apt-get install libjpeg-dev
sudo apt-get install jasper-devel sudo apt-get install libopenexr-dev
sudo apt-get install openexr-devel sudo apt-get install libtiff-dev
sudo apt-get install libtiff-devel sudo apt-get install libwebp-dev
sudo apt-get install libwebp-devel
``` ```
@note If you are using Ubuntu 16.04 you can also install ```libjasper-dev``` to add a system level support for the JPEG2000 format.
### Downloading OpenCV ### Downloading OpenCV
To download the latest source from OpenCV's [GitHub Repository](https://github.com/opencv/opencv). To download the latest source from OpenCV's [GitHub Repository](https://github.com/opencv/opencv).

View File

@ -113,12 +113,18 @@
# define CV_AVX_512IFMA 1 # define CV_AVX_512IFMA 1
# define CV_AVX_512VBMI 1 # define CV_AVX_512VBMI 1
#endif #endif
#ifdef CV_CPU_COMPILE_AVX512_CEL #ifdef CV_CPU_COMPILE_AVX512_CLX
# define CV_AVX512_CEL 1 # define CV_AVX512_CLX 1
# define CV_AVX_512VNNI 1 # define CV_AVX_512VNNI 1
#endif #endif
#ifdef CV_CPU_COMPILE_AVX512_ICL #ifdef CV_CPU_COMPILE_AVX512_ICL
# define CV_AVX512_ICL 1 # define CV_AVX512_ICL 1
# undef CV_AVX_512IFMA
# define CV_AVX_512IFMA 1
# undef CV_AVX_512VBMI
# define CV_AVX_512VBMI 1
# undef CV_AVX_512VNNI
# define CV_AVX_512VNNI 1
# define CV_AVX_512VBMI2 1 # define CV_AVX_512VBMI2 1
# define CV_AVX_512BITALG 1 # define CV_AVX_512BITALG 1
# define CV_AVX_512VPOPCNTDQ 1 # define CV_AVX_512VPOPCNTDQ 1
@ -311,8 +317,8 @@ struct VZeroUpperGuard {
#ifndef CV_AVX512_CNL #ifndef CV_AVX512_CNL
# define CV_AVX512_CNL 0 # define CV_AVX512_CNL 0
#endif #endif
#ifndef CV_AVX512_CEL #ifndef CV_AVX512_CLX
# define CV_AVX512_CEL 0 # define CV_AVX512_CLX 0
#endif #endif
#ifndef CV_AVX512_ICL #ifndef CV_AVX512_ICL
# define CV_AVX512_ICL 0 # define CV_AVX512_ICL 0

View File

@ -357,26 +357,26 @@
#endif #endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_CNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_CNL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) #define __CV_CPU_DISPATCH_CHAIN_AVX512_CNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_CNL(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_AVX512_CEL #if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CLX
# define CV_TRY_AVX512_CEL 1 # define CV_TRY_AVX512_CLX 1
# define CV_CPU_FORCE_AVX512_CEL 1 # define CV_CPU_FORCE_AVX512_CLX 1
# define CV_CPU_HAS_SUPPORT_AVX512_CEL 1 # define CV_CPU_HAS_SUPPORT_AVX512_CLX 1
# define CV_CPU_CALL_AVX512_CEL(fn, args) return (cpu_baseline::fn args) # define CV_CPU_CALL_AVX512_CLX(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX512_CEL_(fn, args) return (opt_AVX512_CEL::fn args) # define CV_CPU_CALL_AVX512_CLX_(fn, args) return (opt_AVX512_CLX::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CEL #elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CLX
# define CV_TRY_AVX512_CEL 1 # define CV_TRY_AVX512_CLX 1
# define CV_CPU_FORCE_AVX512_CEL 0 # define CV_CPU_FORCE_AVX512_CLX 0
# define CV_CPU_HAS_SUPPORT_AVX512_CEL (cv::checkHardwareSupport(CV_CPU_AVX512_CEL)) # define CV_CPU_HAS_SUPPORT_AVX512_CLX (cv::checkHardwareSupport(CV_CPU_AVX512_CLX))
# define CV_CPU_CALL_AVX512_CEL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CEL) return (opt_AVX512_CEL::fn args) # define CV_CPU_CALL_AVX512_CLX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args)
# define CV_CPU_CALL_AVX512_CEL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CEL) return (opt_AVX512_CEL::fn args) # define CV_CPU_CALL_AVX512_CLX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args)
#else #else
# define CV_TRY_AVX512_CEL 0 # define CV_TRY_AVX512_CLX 0
# define CV_CPU_FORCE_AVX512_CEL 0 # define CV_CPU_FORCE_AVX512_CLX 0
# define CV_CPU_HAS_SUPPORT_AVX512_CEL 0 # define CV_CPU_HAS_SUPPORT_AVX512_CLX 0
# define CV_CPU_CALL_AVX512_CEL(fn, args) # define CV_CPU_CALL_AVX512_CLX(fn, args)
# define CV_CPU_CALL_AVX512_CEL_(fn, args) # define CV_CPU_CALL_AVX512_CLX_(fn, args)
#endif #endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_CEL(fn, args, mode, ...) CV_CPU_CALL_AVX512_CEL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) #define __CV_CPU_DISPATCH_CHAIN_AVX512_CLX(fn, args, mode, ...) CV_CPU_CALL_AVX512_CLX(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_AVX512_ICL #if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_ICL
# define CV_TRY_AVX512_ICL 1 # define CV_TRY_AVX512_ICL 1

View File

@ -255,7 +255,7 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
#define CV_CPU_AVX512_KNL 258 #define CV_CPU_AVX512_KNL 258
#define CV_CPU_AVX512_KNM 259 #define CV_CPU_AVX512_KNM 259
#define CV_CPU_AVX512_CNL 260 #define CV_CPU_AVX512_CNL 260
#define CV_CPU_AVX512_CEL 261 #define CV_CPU_AVX512_CLX 261
#define CV_CPU_AVX512_ICL 262 #define CV_CPU_AVX512_ICL 262
// when adding to this list remember to update the following enum // when adding to this list remember to update the following enum
@ -306,7 +306,7 @@ enum CpuFeatures {
CPU_AVX512_KNL = 258, //!< Knights Landing with AVX-512F/CD/ER/PF CPU_AVX512_KNL = 258, //!< Knights Landing with AVX-512F/CD/ER/PF
CPU_AVX512_KNM = 259, //!< Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ CPU_AVX512_KNM = 259, //!< Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ
CPU_AVX512_CNL = 260, //!< Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI CPU_AVX512_CNL = 260, //!< Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI
CPU_AVX512_CEL = 261, //!< Cascade Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI CPU_AVX512_CLX = 261, //!< Cascade Lake with AVX-512F/CD/BW/DQ/VL/VNNI
CPU_AVX512_ICL = 262, //!< Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ CPU_AVX512_ICL = 262, //!< Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ
CPU_MAX_FEATURE = 512 // see CV_HARDWARE_MAX_FEATURE CPU_MAX_FEATURE = 512 // see CV_HARDWARE_MAX_FEATURE

View File

@ -2065,14 +2065,18 @@ static int_fast64_t f64_to_i64(float64_t a, uint_fast8_t roundingMode, bool exac
if (exp) sig |= UINT64_C(0x0010000000000000); if (exp) sig |= UINT64_C(0x0010000000000000);
shiftDist = 0x433 - exp; shiftDist = 0x433 - exp;
if (shiftDist <= 0) { if (shiftDist <= 0) {
uint_fast64_t z = sig << -shiftDist; bool isValid = shiftDist >= -11;
if ((shiftDist < -11) || (z & UINT64_C(0x8000000000000000))) if (isValid)
{ {
uint_fast64_t z = sig << -shiftDist;
if (0 == (z & UINT64_C(0x8000000000000000)))
{
return sign ? -(int_fast64_t)z : (int_fast64_t)z;
}
}
raiseFlags(flag_invalid); raiseFlags(flag_invalid);
return sign ? i64_fromNegOverflow : i64_fromPosOverflow; return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
} }
return sign ? -(int_fast64_t)z : (int_fast64_t)z;
}
else { else {
if (shiftDist < 64) if (shiftDist < 64)
return return

View File

@ -370,11 +370,12 @@ struct HWFeatures
g_hwFeatureNames[CPU_MSA] = "CPU_MSA"; g_hwFeatureNames[CPU_MSA] = "CPU_MSA";
g_hwFeatureNames[CPU_AVX512_COMMON] = "AVX512-COMMON";
g_hwFeatureNames[CPU_AVX512_SKX] = "AVX512-SKX"; g_hwFeatureNames[CPU_AVX512_SKX] = "AVX512-SKX";
g_hwFeatureNames[CPU_AVX512_KNL] = "AVX512-KNL"; g_hwFeatureNames[CPU_AVX512_KNL] = "AVX512-KNL";
g_hwFeatureNames[CPU_AVX512_KNM] = "AVX512-KNM"; g_hwFeatureNames[CPU_AVX512_KNM] = "AVX512-KNM";
g_hwFeatureNames[CPU_AVX512_CNL] = "AVX512-CNL"; g_hwFeatureNames[CPU_AVX512_CNL] = "AVX512-CNL";
g_hwFeatureNames[CPU_AVX512_CEL] = "AVX512-CEL"; g_hwFeatureNames[CPU_AVX512_CLX] = "AVX512-CLX";
g_hwFeatureNames[CPU_AVX512_ICL] = "AVX512-ICL"; g_hwFeatureNames[CPU_AVX512_ICL] = "AVX512-ICL";
} }
@ -485,9 +486,11 @@ struct HWFeatures
have[CV_CPU_AVX_5124VNNIW] && have[CV_CPU_AVX_512VPOPCNTDQ]; have[CV_CPU_AVX_5124VNNIW] && have[CV_CPU_AVX_512VPOPCNTDQ];
have[CV_CPU_AVX512_SKX] = have[CV_CPU_AVX_512BW] && have[CV_CPU_AVX_512DQ] && have[CV_CPU_AVX_512VL]; have[CV_CPU_AVX512_SKX] = have[CV_CPU_AVX_512BW] && have[CV_CPU_AVX_512DQ] && have[CV_CPU_AVX_512VL];
have[CV_CPU_AVX512_CNL] = have[CV_CPU_AVX512_SKX] && have[CV_CPU_AVX_512IFMA] && have[CV_CPU_AVX_512VBMI]; have[CV_CPU_AVX512_CNL] = have[CV_CPU_AVX512_SKX] && have[CV_CPU_AVX_512IFMA] && have[CV_CPU_AVX_512VBMI];
have[CV_CPU_AVX512_CEL] = have[CV_CPU_AVX512_CNL] && have[CV_CPU_AVX_512VNNI]; have[CV_CPU_AVX512_CLX] = have[CV_CPU_AVX512_SKX] && have[CV_CPU_AVX_512VNNI];
have[CV_CPU_AVX512_ICL] = have[CV_CPU_AVX512_CEL] && have[CV_CPU_AVX_512VBMI2] && have[CV_CPU_AVX512_ICL] = have[CV_CPU_AVX512_SKX] &&
have[CV_CPU_AVX_512BITALG] && have[CV_CPU_AVX_512VPOPCNTDQ]; have[CV_CPU_AVX_512IFMA] && have[CV_CPU_AVX_512VBMI] &&
have[CV_CPU_AVX_512VNNI] &&
have[CV_CPU_AVX_512VBMI2] && have[CV_CPU_AVX_512BITALG] && have[CV_CPU_AVX_512VPOPCNTDQ];
} }
else else
{ {
@ -495,7 +498,7 @@ struct HWFeatures
have[CV_CPU_AVX512_KNM] = false; have[CV_CPU_AVX512_KNM] = false;
have[CV_CPU_AVX512_SKX] = false; have[CV_CPU_AVX512_SKX] = false;
have[CV_CPU_AVX512_CNL] = false; have[CV_CPU_AVX512_CNL] = false;
have[CV_CPU_AVX512_CEL] = false; have[CV_CPU_AVX512_CLX] = false;
have[CV_CPU_AVX512_ICL] = false; have[CV_CPU_AVX512_ICL] = false;
} }
} }
@ -572,8 +575,16 @@ struct HWFeatures
have[CV_CPU_VSX3] = (CV_VSX3); have[CV_CPU_VSX3] = (CV_VSX3);
#endif #endif
bool skip_baseline_check = false;
#ifndef NO_GETENV
if (getenv("OPENCV_SKIP_CPU_BASELINE_CHECK"))
{
skip_baseline_check = true;
}
#endif
int baseline_features[] = { CV_CPU_BASELINE_FEATURES }; int baseline_features[] = { CV_CPU_BASELINE_FEATURES };
if (!checkFeatures(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0]))) if (!checkFeatures(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0]))
&& !skip_baseline_check)
{ {
fprintf(stderr, "\n" fprintf(stderr, "\n"
"******************************************************************\n" "******************************************************************\n"
@ -600,12 +611,12 @@ struct HWFeatures
{ {
if (have[feature]) if (have[feature])
{ {
if (dump) fprintf(stderr, "%s - OK\n", getHWFeatureNameSafe(feature)); if (dump) fprintf(stderr, " ID=%3d (%s) - OK\n", feature, getHWFeatureNameSafe(feature));
} }
else else
{ {
result = false; result = false;
if (dump) fprintf(stderr, "%s - NOT AVAILABLE\n", getHWFeatureNameSafe(feature)); if (dump) fprintf(stderr, " ID=%3d (%s) - NOT AVAILABLE\n", feature, getHWFeatureNameSafe(feature));
} }
} }
} }

View File

@ -64,11 +64,19 @@ def printParams(backend, target):
testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False)) testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False))
g_dnnBackendsAndTargets = None
class dnn_test(NewOpenCVTests): class dnn_test(NewOpenCVTests):
def setUp(self): def setUp(self):
super(dnn_test, self).setUp() super(dnn_test, self).setUp()
global g_dnnBackendsAndTargets
if g_dnnBackendsAndTargets is None:
g_dnnBackendsAndTargets = self.initBackendsAndTargets()
self.dnnBackendsAndTargets = g_dnnBackendsAndTargets
def initBackendsAndTargets(self):
self.dnnBackendsAndTargets = [ self.dnnBackendsAndTargets = [
[cv.dnn.DNN_BACKEND_OPENCV, cv.dnn.DNN_TARGET_CPU], [cv.dnn.DNN_BACKEND_OPENCV, cv.dnn.DNN_TARGET_CPU],
] ]
@ -86,6 +94,7 @@ class dnn_test(NewOpenCVTests):
self.dnnBackendsAndTargets.append([cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL]) self.dnnBackendsAndTargets.append([cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL])
if self.checkIETarget(cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL_FP16): if self.checkIETarget(cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL_FP16):
self.dnnBackendsAndTargets.append([cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL_FP16]) self.dnnBackendsAndTargets.append([cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL_FP16])
return self.dnnBackendsAndTargets
def find_dnn_file(self, filename, required=True): def find_dnn_file(self, filename, required=True):
if not required: if not required:

View File

@ -163,6 +163,8 @@ public:
{ {
if (backendId == DNN_BACKEND_INFERENCE_ENGINE) if (backendId == DNN_BACKEND_INFERENCE_ENGINE)
{ {
if (computeMaxIdx)
return false;
#ifdef HAVE_INF_ENGINE #ifdef HAVE_INF_ENGINE
if (kernel_size.size() == 3) if (kernel_size.size() == 3)
return preferableTarget == DNN_TARGET_CPU; return preferableTarget == DNN_TARGET_CPU;

View File

@ -22,10 +22,11 @@
#define INF_ENGINE_RELEASE_2018R5 2018050000 #define INF_ENGINE_RELEASE_2018R5 2018050000
#define INF_ENGINE_RELEASE_2019R1 2019010000 #define INF_ENGINE_RELEASE_2019R1 2019010000
#define INF_ENGINE_RELEASE_2019R2 2019020000 #define INF_ENGINE_RELEASE_2019R2 2019020000
#define INF_ENGINE_RELEASE_2019R3 2019030000
#ifndef INF_ENGINE_RELEASE #ifndef INF_ENGINE_RELEASE
#warning("IE version have not been provided via command-line. Using 2019R2 by default") #warning("IE version have not been provided via command-line. Using 2019R3 by default")
#define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2019R2 #define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2019R3
#endif #endif
#define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000)) #define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000))

View File

@ -19,6 +19,7 @@
#define CV_TEST_TAG_DNN_SKIP_IE_2019R1 "dnn_skip_ie_2019r1" #define CV_TEST_TAG_DNN_SKIP_IE_2019R1 "dnn_skip_ie_2019r1"
#define CV_TEST_TAG_DNN_SKIP_IE_2019R1_1 "dnn_skip_ie_2019r1_1" #define CV_TEST_TAG_DNN_SKIP_IE_2019R1_1 "dnn_skip_ie_2019r1_1"
#define CV_TEST_TAG_DNN_SKIP_IE_2019R2 "dnn_skip_ie_2019r2" #define CV_TEST_TAG_DNN_SKIP_IE_2019R2 "dnn_skip_ie_2019r2"
#define CV_TEST_TAG_DNN_SKIP_IE_2019R3 "dnn_skip_ie_2019r3"
#define CV_TEST_TAG_DNN_SKIP_IE_OPENCL "dnn_skip_ie_ocl" #define CV_TEST_TAG_DNN_SKIP_IE_OPENCL "dnn_skip_ie_ocl"
#define CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16 "dnn_skip_ie_ocl_fp16" #define CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16 "dnn_skip_ie_ocl_fp16"
#define CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_2 "dnn_skip_ie_myriad2" #define CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_2 "dnn_skip_ie_myriad2"

View File

@ -324,6 +324,8 @@ void initDNNTests()
# endif # endif
#elif INF_ENGINE_VER_MAJOR_EQ(2019020000) #elif INF_ENGINE_VER_MAJOR_EQ(2019020000)
CV_TEST_TAG_DNN_SKIP_IE_2019R2, CV_TEST_TAG_DNN_SKIP_IE_2019R2,
#elif INF_ENGINE_VER_MAJOR_EQ(2019030000)
CV_TEST_TAG_DNN_SKIP_IE_2019R3,
#endif #endif
CV_TEST_TAG_DNN_SKIP_IE CV_TEST_TAG_DNN_SKIP_IE
); );

View File

@ -554,9 +554,9 @@ TEST_P(ReLU, Accuracy)
Backend backendId = get<0>(get<1>(GetParam())); Backend backendId = get<0>(get<1>(GetParam()));
Target targetId = get<1>(get<1>(GetParam())); Target targetId = get<1>(get<1>(GetParam()));
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000) #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2019020000)
if (backendId == DNN_BACKEND_INFERENCE_ENGINE && targetId == DNN_TARGET_MYRIAD && negativeSlope < 0) if (backendId == DNN_BACKEND_INFERENCE_ENGINE && targetId == DNN_TARGET_MYRIAD && negativeSlope < 0)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE, CV_TEST_TAG_DNN_SKIP_IE_2019R2); applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_2019R3, CV_TEST_TAG_DNN_SKIP_IE_2019R2, CV_TEST_TAG_DNN_SKIP_IE);
#endif #endif
LayerParams lp; LayerParams lp;

View File

@ -86,8 +86,8 @@ TEST_P(Test_ONNX_layers, InstanceNorm)
TEST_P(Test_ONNX_layers, MaxPooling) TEST_P(Test_ONNX_layers, MaxPooling)
{ {
testONNXModels("maxpooling"); testONNXModels("maxpooling", npy, 0, 0, false, false);
testONNXModels("two_maxpooling"); testONNXModels("two_maxpooling", npy, 0, 0, false, false);
} }
TEST_P(Test_ONNX_layers, Convolution) TEST_P(Test_ONNX_layers, Convolution)
@ -212,7 +212,7 @@ TEST_P(Test_ONNX_layers, MaxPooling3D)
#endif #endif
if (target != DNN_TARGET_CPU) if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported"); throw SkipTestException("Only CPU is supported");
testONNXModels("max_pool3d"); testONNXModels("max_pool3d", npy, 0, 0, false, false);
} }
TEST_P(Test_ONNX_layers, AvePooling3D) TEST_P(Test_ONNX_layers, AvePooling3D)
@ -422,13 +422,22 @@ TEST_P(Test_ONNX_nets, Googlenet)
TEST_P(Test_ONNX_nets, CaffeNet) TEST_P(Test_ONNX_nets, CaffeNet)
{ {
applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB); applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_2019R3);
#endif
testONNXModels("caffenet", pb); testONNXModels("caffenet", pb);
} }
TEST_P(Test_ONNX_nets, RCNN_ILSVRC13) TEST_P(Test_ONNX_nets, RCNN_ILSVRC13)
{ {
applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB); applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_2019R3);
#endif
// Reference output values are in range [-4.992, -1.161] // Reference output values are in range [-4.992, -1.161]
testONNXModels("rcnn_ilsvrc13", pb, 0.0045); testONNXModels("rcnn_ilsvrc13", pb, 0.0045);
} }

View File

@ -146,13 +146,13 @@ TEST_P(Test_TensorFlow_layers, padding)
runTensorFlowNet("padding_valid"); runTensorFlowNet("padding_valid");
runTensorFlowNet("spatial_padding"); runTensorFlowNet("spatial_padding");
runTensorFlowNet("mirror_pad"); runTensorFlowNet("mirror_pad");
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000) #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE) if (backend == DNN_BACKEND_INFERENCE_ENGINE)
{ {
if (target == DNN_TARGET_MYRIAD) if (target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_2019R2); applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_2019R3, CV_TEST_TAG_DNN_SKIP_IE_2019R2);
if (target == DNN_TARGET_OPENCL_FP16) if (target == DNN_TARGET_OPENCL_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_2019R2); applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_2019R3, CV_TEST_TAG_DNN_SKIP_IE_2019R2);
} }
#endif #endif
runTensorFlowNet("keras_pad_concat"); runTensorFlowNet("keras_pad_concat");

View File

@ -337,9 +337,15 @@ TEST_P(Test_Torch_nets, ENet_accuracy)
{ {
applyTestTag(target == DNN_TARGET_CPU ? "" : CV_TEST_TAG_MEMORY_512MB); applyTestTag(target == DNN_TARGET_CPU ? "" : CV_TEST_TAG_MEMORY_512MB);
checkBackend(); checkBackend();
if (backend == DNN_BACKEND_INFERENCE_ENGINE || if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
(backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)) throw SkipTestException("");
applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16); if (backend == DNN_BACKEND_INFERENCE_ENGINE && target != DNN_TARGET_CPU)
{
if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16);
if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL);
if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
throw SkipTestException("");
}
Net net; Net net;
{ {

View File

@ -807,7 +807,7 @@ public class ImgprocTest extends OpenCVTestCase {
points.put(0, 0, 0, 0, 2, 3, 3, 4, 5, 8); points.put(0, 0, 0, 0, 2, 3, 3, 4, 5, 8);
Mat linePoints = new Mat(4, 1, CvType.CV_32FC1); Mat linePoints = new Mat(4, 1, CvType.CV_32FC1);
linePoints.put(0, 0, 0.53196341, 0.84676737, 2.496531, 3.7467217); linePoints.put(0, 0, 0.53198653, 0.84675282, 2.5, 3.75);
Imgproc.fitLine(points, dst, Imgproc.CV_DIST_L12, 0, 0.01, 0.01); Imgproc.fitLine(points, dst, Imgproc.CV_DIST_L12, 0, 0.01, 0.01);

View File

@ -408,8 +408,14 @@ static void fitLine2D( const Point2f * points, int count, int dist,
} }
/* calculate distances */ /* calculate distances */
err = calcDist2D( points, count, _line, r ); err = calcDist2D( points, count, _line, r );
if( err < EPS )
if (err < min_err)
{
min_err = err;
memcpy(line, _line, 4 * sizeof(line[0]));
if (err < EPS)
break; break;
}
/* calculate weights */ /* calculate weights */
if( calc_weights ) if( calc_weights )
@ -550,8 +556,13 @@ static void fitLine3D( Point3f * points, int count, int dist,
} }
/* calculate distances */ /* calculate distances */
err = calcDist3D( points, count, _line, r ); err = calcDist3D( points, count, _line, r );
//if( err < FLT_EPSILON*count ) if (err < min_err)
// break; {
min_err = err;
memcpy(line, _line, 6 * sizeof(line[0]));
if (err < EPS)
break;
}
/* calculate weights */ /* calculate weights */
if( calc_weights ) if( calc_weights )

View File

@ -1609,6 +1609,8 @@ int CV_FitLineTest::validate_test_results( int test_case_idx )
int k, max_k = 0; int k, max_k = 0;
double vec_diff = 0, t; double vec_diff = 0, t;
//std::cout << dims << " " << Mat(1, dims*2, CV_32FC1, line.data()) << " " << Mat(1, dims, CV_32FC1, line0.data()) << std::endl;
for( k = 0; k < dims*2; k++ ) for( k = 0; k < dims*2; k++ )
{ {
if( cvIsNaN(line[k]) || cvIsInf(line[k]) ) if( cvIsNaN(line[k]) || cvIsInf(line[k]) )
@ -2038,5 +2040,38 @@ INSTANTIATE_TEST_CASE_P(Imgproc, ConvexityDefects_regression_5908,
testing::Values(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) testing::Values(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
)); ));
TEST(Imgproc_FitLine, regression_15083)
{
int points2i_[] = {
432, 654,
370, 656,
390, 656,
410, 656,
348, 658
};
Mat points(5, 1, CV_32SC2, points2i_);
Vec4f lineParam;
fitLine(points, lineParam, DIST_L1, 0, 0.01, 0.01);
EXPECT_GE(fabs(lineParam[0]), fabs(lineParam[1]) * 4) << lineParam;
}
TEST(Imgproc_FitLine, regression_4903)
{
float points2f_[] = {
1224.0, 576.0,
1234.0, 683.0,
1215.0, 471.0,
1184.0, 137.0,
1079.0, 377.0,
1239.0, 788.0,
};
Mat points(6, 1, CV_32FC2, points2f_);
Vec4f lineParam;
fitLine(points, lineParam, DIST_WELSCH, 0, 0.01, 0.01);
EXPECT_GE(fabs(lineParam[1]), fabs(lineParam[0]) * 4) << lineParam;
}
}} // namespace }} // namespace
/* End of file. */ /* End of file. */

View File

@ -359,22 +359,26 @@ bool QRDetect::localization()
bool suare_flag = false, local_points_flag = false; bool suare_flag = false, local_points_flag = false;
double triangle_sides[3]; double triangle_sides[3];
double triangle_perim, square_area, img_square_area;
if (localization_points.size() == 3)
{
triangle_sides[0] = norm(localization_points[0] - localization_points[1]); triangle_sides[0] = norm(localization_points[0] - localization_points[1]);
triangle_sides[1] = norm(localization_points[1] - localization_points[2]); triangle_sides[1] = norm(localization_points[1] - localization_points[2]);
triangle_sides[2] = norm(localization_points[2] - localization_points[0]); triangle_sides[2] = norm(localization_points[2] - localization_points[0]);
double triangle_perim = (triangle_sides[0] + triangle_sides[1] + triangle_sides[2]) / 2; triangle_perim = (triangle_sides[0] + triangle_sides[1] + triangle_sides[2]) / 2;
double square_area = sqrt((triangle_perim * (triangle_perim - triangle_sides[0]) square_area = sqrt((triangle_perim * (triangle_perim - triangle_sides[0])
* (triangle_perim - triangle_sides[1]) * (triangle_perim - triangle_sides[1])
* (triangle_perim - triangle_sides[2]))) * 2; * (triangle_perim - triangle_sides[2]))) * 2;
double img_square_area = bin_barcode.cols * bin_barcode.rows; img_square_area = bin_barcode.cols * bin_barcode.rows;
if (square_area > (img_square_area * 0.2)) if (square_area > (img_square_area * 0.2))
{ {
suare_flag = true; suare_flag = true;
} }
if (localization_points.size() != 3) }
else
{ {
local_points_flag = true; local_points_flag = true;
} }