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

This commit is contained in:
Alexander Alekhin 2019-08-23 19:24:37 +03:00
commit a7b954f655
23 changed files with 285 additions and 104 deletions

View File

@ -17,6 +17,12 @@
#if !defined(JAS_WIN_MSVC_BUILD)
/* A configure-based build is being used. */
#include <stdio.h>
// uClibc-ng workaround: https://github.com/opencv/opencv/pull/15279
#ifndef L_tmpnam
#define L_tmpnam 20
#endif
/* Extra debugging support */

View File

@ -47,7 +47,9 @@ if(";${CPU_BASELINE_FINAL};" MATCHES "SSE2"
endif()
if(PPC64LE OR PPC64)
if(ENABLE_VSX AND NOT PPC64)
# VSX3 features are backwards compatible
if(";${CPU_BASELINE_FINAL};" MATCHES "VSX.*"
AND NOT PPC64)
list(APPEND lib_srcs powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c)
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
else()

View File

@ -64,6 +64,10 @@ if(POLICY CMP0068)
cmake_policy(SET CMP0068 NEW) # CMake 3.9+: `RPATH` settings on macOS do not affect `install_name`.
endif()
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW) # CMake 3.12+: Include file check macros honor `CMAKE_REQUIRED_LIBRARIES`
endif()
#
# Configure OpenCV CMake hooks
@ -1502,19 +1506,22 @@ endif()
if(WITH_INF_ENGINE OR INF_ENGINE_TARGET)
if(INF_ENGINE_TARGET)
list(GET INF_ENGINE_TARGET 0 ie_target)
set(__msg "YES (${INF_ENGINE_RELEASE} / ${INF_ENGINE_VERSION})")
get_target_property(_lib ${INF_ENGINE_TARGET} IMPORTED_LOCATION)
get_target_property(_lib_imp_rel ${INF_ENGINE_TARGET} IMPORTED_IMPLIB_RELEASE)
get_target_property(_lib_imp_dbg ${INF_ENGINE_TARGET} IMPORTED_IMPLIB_DEBUG)
get_target_property(_lib_rel ${INF_ENGINE_TARGET} IMPORTED_LOCATION_RELEASE)
get_target_property(_lib_dbg ${INF_ENGINE_TARGET} IMPORTED_LOCATION_DEBUG)
get_target_property(_lib ${ie_target} IMPORTED_LOCATION)
get_target_property(_lib_imp_rel ${ie_target} IMPORTED_IMPLIB_RELEASE)
get_target_property(_lib_imp_dbg ${ie_target} IMPORTED_IMPLIB_DEBUG)
get_target_property(_lib_rel ${ie_target} IMPORTED_LOCATION_RELEASE)
get_target_property(_lib_dbg ${ie_target} IMPORTED_LOCATION_DEBUG)
ocv_build_features_string(_lib
IF _lib THEN "${_lib}"
IF _lib_imp_rel AND _lib_imp_dbg THEN "${_lib_imp_rel} / ${_lib_imp_dbg}"
IF _lib_rel AND _lib_dbg THEN "${_lib_rel} / ${_lib_dbg}"
IF _lib_rel THEN "${_lib_rel}"
IF _lib_dbg THEN "${_lib_dbg}"
ELSE "unknown"
)
get_target_property(_inc ${INF_ENGINE_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(_inc ${ie_target} INTERFACE_INCLUDE_DIRECTORIES)
status(" Inference Engine:" "${__msg}")
status(" libs:" "${_lib}")
status(" includes:" "${_inc}")

View File

@ -191,6 +191,25 @@ if(NOT HAVE_CXX11)
endif()
endif()
endif()
if(NOT HAVE_CXX11)
message(FATAL_ERROR "OpenCV 4.x requires C++11")
endif()
if((HAVE_CXX11
AND NOT MSVC
AND NOT (X86 OR X86_64)
AND NOT OPENCV_SKIP_LIBATOMIC_COMPILER_CHECK)
OR OPENCV_FORCE_LIBATOMIC_COMPILER_CHECK
)
ocv_check_compiler_flag(CXX "" HAVE_CXX_ATOMICS_WITHOUT_LIB "${OpenCV_SOURCE_DIR}/cmake/checks/atomic_check.cpp")
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES atomic)
ocv_check_compiler_flag(CXX "" HAVE_CXX_ATOMICS_WITH_LIB "${OpenCV_SOURCE_DIR}/cmake/checks/atomic_check.cpp")
if(HAVE_CXX_ATOMICS_WITH_LIB)
list(APPEND OPENCV_LINKER_LIBS atomic)
else()
message(FATAL_ERROR "C++11 compiler must support std::atomic")
endif()
endif()
endif()

View File

@ -45,7 +45,7 @@ endfunction()
find_package(InferenceEngine QUIET)
if(InferenceEngine_FOUND)
set(INF_ENGINE_TARGET IE::inference_engine)
set(INF_ENGINE_TARGET ${InferenceEngine_LIBRARIES})
set(INF_ENGINE_VERSION "${InferenceEngine_VERSION}" CACHE STRING "")
message(STATUS "Detected InferenceEngine: cmake package")
endif()

View File

@ -415,12 +415,34 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
else()
set(__msg "")
endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(__link_libs LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
else()
set(__link_libs)
endif()
set(__cmake_flags "")
if(CMAKE_EXE_LINKER_FLAGS) # CMP0056 do this on new CMake
list(APPEND __cmake_flags "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}")
endif()
# CMP0067 do this on new CMake
if(DEFINED CMAKE_CXX_STANDARD)
list(APPEND __cmake_flags "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
endif()
if(DEFINED CMAKE_CXX_STANDARD_REQUIRED)
list(APPEND __cmake_flags "-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}")
endif()
if(DEFINED CMAKE_CXX_EXTENSIONS)
list(APPEND __cmake_flags "-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}")
endif()
MESSAGE(STATUS "Performing Test ${RESULT}${__msg}")
TRY_COMPILE(${RESULT}
"${CMAKE_BINARY_DIR}"
"${_fname}"
CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" # CMP0056 do this on new CMake
CMAKE_FLAGS ${__cmake_flags}
COMPILE_DEFINITIONS "${FLAG}"
${__link_libs}
OUTPUT_VARIABLE OUTPUT)
if(${RESULT})

View File

@ -0,0 +1,12 @@
#include <atomic>
static int test()
{
std::atomic<int> x;
return x;
}
int main()
{
return test();
}

View File

@ -40,7 +40,7 @@ goal):
img1 = cv.imread('messi5.jpg')
e1 = cv.getTickCount()
for i in xrange(5,49,2):
for i in range(5,49,2):
img1 = cv.medianBlur(img1,i)
e2 = cv.getTickCount()
t = (e2 - e1)/cv.getTickFrequency()

View File

@ -38,13 +38,13 @@ best matches. There is also **cv.drawMatchesKnn** which draws all the k best mat
will draw two match-lines for each keypoint. So we have to pass a mask if we want to selectively
draw it.
Let's see one example for each of SURF and ORB (Both use different distance measurements).
Let's see one example for each of SIFT and ORB (Both use different distance measurements).
### Brute-Force Matching with ORB Descriptors
Here, we will see a simple example on how to match features between two images. In this case, I have
a queryImage and a trainImage. We will try to find the queryImage in trainImage using feature
matching. ( The images are /samples/c/box.png and /samples/c/box_in_scene.png)
matching. ( The images are /samples/data/box.png and /samples/data/box_in_scene.png)
We are using ORB descriptors to match features. So let's start with loading images, finding
descriptors etc.

View File

@ -15,7 +15,7 @@ Code
----
This tutorial code's is shown lines below. You can also download it from
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/samples/cpp/stitching.cpp).
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/stitching.cpp).
@include samples/cpp/stitching.cpp

View File

@ -47,12 +47,6 @@
#include "opencv2/core/cvdef.h"
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
&& defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
#include <emmintrin.h>
#endif
//! @addtogroup core_utils
//! @{
@ -70,14 +64,24 @@
# endif
#endif
#if defined __PPC64__ && defined __GNUC__ && defined _ARCH_PWR8 && !defined (__CUDACC__)
# include <altivec.h>
#endif
#if defined(__CUDACC__)
// nothing, intrinsics/asm code is not supported
#else
#if ((defined _MSC_VER && defined _M_X64) \
|| (defined __GNUC__ && defined __x86_64__ && defined __SSE2__)) \
&& !defined(OPENCV_SKIP_INCLUDE_EMMINTRIN_H)
#include <emmintrin.h>
#endif
#if defined(CV_INLINE_ROUND_FLT)
#if defined __PPC64__ && defined __GNUC__ && defined _ARCH_PWR8 \
&& !defined(OPENCV_SKIP_INCLUDE_ALTIVEC_H)
#include <altivec.h>
#endif
#if defined(CV_INLINE_ROUND_FLT)
// user-specified version
// CV_INLINE_ROUND_DBL should be defined too
#elif defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ && !defined(__CUDACC__)
#elif defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__
// 1. general scheme
#define ARM_ROUND(_value, _asm_string) \
int res; \
@ -93,7 +97,7 @@
#endif
// 3. version for float
#define CV_INLINE_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]")
#elif defined __PPC64__ && defined __GNUC__ && defined _ARCH_PWR8 && !defined (__CUDACC__)
#elif defined __PPC64__ && defined __GNUC__ && defined _ARCH_PWR8
// P8 and newer machines can convert fp32/64 to int quickly.
#define CV_INLINE_ROUND_DBL(value) \
int out; \
@ -103,40 +107,86 @@
// FP32 also works with FP64 routine above
#define CV_INLINE_ROUND_FLT(value) CV_INLINE_ROUND_DBL(value)
#endif
#ifdef _ARCH_PWR9
#define CV_INLINE_ISINF_DBL(value) return scalar_test_data_class(value, 0x30);
#define CV_INLINE_ISNAN_DBL(value) return scalar_test_data_class(value, 0x40);
#define CV_INLINE_ISINF_FLT(value) CV_INLINE_ISINF_DBL(value)
#define CV_INLINE_ISNAN_FLT(value) CV_INLINE_ISNAN_DBL(value)
#ifdef CV_INLINE_ISINF_FLT
// user-specified version
// CV_INLINE_ISINF_DBL should be defined too
#elif defined __PPC64__ && defined _ARCH_PWR9 && defined(scalar_test_data_class)
#define CV_INLINE_ISINF_DBL(value) return scalar_test_data_class(value, 0x30);
#define CV_INLINE_ISINF_FLT(value) CV_INLINE_ISINF_DBL(value)
#endif
#ifdef CV_INLINE_ISNAN_FLT
// user-specified version
// CV_INLINE_ISNAN_DBL should be defined too
#elif defined __PPC64__ && defined _ARCH_PWR9 && defined(scalar_test_data_class)
#define CV_INLINE_ISNAN_DBL(value) return scalar_test_data_class(value, 0x40);
#define CV_INLINE_ISNAN_FLT(value) CV_INLINE_ISNAN_DBL(value)
#endif
#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
#endif
/* Enable builtin math functions if possible, desired, and available.
Note, not all math functions inline equally. E.g lrint will not inline
without the -fno-math-errno option. */
#if defined(CV_ICC)
// nothing
#elif defined(OPENCV_USE_FASTMATH_BUILTINS) && OPENCV_USE_FASTMATH_BUILTINS
#if defined(__clang__)
#define CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
#if !defined(CV_INLINE_ISNAN_DBL) && __has_builtin(__builtin_isnan)
#define CV_INLINE_ISNAN_DBL(value) return __builtin_isnan(value);
#endif
#if !defined(CV_INLINE_ISNAN_FLT) && __has_builtin(__builtin_isnan)
#define CV_INLINE_ISNAN_FLT(value) return __builtin_isnan(value);
#endif
#if !defined(CV_INLINE_ISINF_DBL) && __has_builtin(__builtin_isinf)
#define CV_INLINE_ISINF_DBL(value) return __builtin_isinf(value);
#endif
#if !defined(CV_INLINE_ISINF_FLT) && __has_builtin(__builtin_isinf)
#define CV_INLINE_ISINF_FLT(value) return __builtin_isinf(value);
#endif
#elif defined(__GNUC__)
#define CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS
#if !defined(CV_INLINE_ISNAN_DBL)
#define CV_INLINE_ISNAN_DBL(value) return __builtin_isnan(value);
#endif
#if !defined(CV_INLINE_ISNAN_FLT)
#define CV_INLINE_ISNAN_FLT(value) return __builtin_isnanf(value);
#endif
#if !defined(CV_INLINE_ISINF_DBL)
#define CV_INLINE_ISINF_DBL(value) return __builtin_isinf(value);
#endif
#if !defined(CV_INLINE_ISINF_FLT)
#define CV_INLINE_ISINF_FLT(value) return __builtin_isinff(value);
#endif
#elif defined(_MSC_VER)
#if !defined(CV_INLINE_ISNAN_DBL)
#define CV_INLINE_ISNAN_DBL(value) return isnan(value);
#endif
#if !defined(CV_INLINE_ISNAN_FLT)
#define CV_INLINE_ISNAN_FLT(value) return isnan(value);
#endif
#if !defined(CV_INLINE_ISINF_DBL)
#define CV_INLINE_ISINF_DBL(value) return isinf(value);
#endif
#if !defined(CV_INLINE_ISINF_FLT)
#define CV_INLINE_ISINF_FLT(value) return isinf(value);
#endif
#endif
#elif defined CV_ICC || defined __GNUC__
#define CV_INLINE_ROUND_DBL(value) return (int)(lrint(value));
#define CV_INLINE_ROUND_FLT(value) return (int)(lrintf(value));
#endif
#endif
#if defined __PPC64__ && !defined OPENCV_USE_FASTMATH_GCC_BUILTINS
/* Let GCC inline C math functions when available. Dedicated hardware is available to
round and covert FP values. */
#define OPENCV_USE_FASTMATH_GCC_BUILTINS
#endif
/* Enable GCC builtin math functions if possible, desired, and available.
Note, not all math functions inline equally. E.g lrint will not inline
without the -fno-math-errno option. */
#if defined OPENCV_USE_FASTMATH_GCC_BUILTINS && defined __GNUC__ && !defined __clang__ && !defined (__CUDACC__)
#define _OPENCV_FASTMATH_ENABLE_GCC_MATH_BUILTINS
#endif
/* Allow overrides for some functions which may benefit from tuning. Likewise,
note that isinf is not used as the return value is signed. */
#if defined _OPENCV_FASTMATH_ENABLE_GCC_MATH_BUILTINS && !defined CV_INLINE_ISNAN_DBL
#define CV_INLINE_ISNAN_DBL(value) return __builtin_isnan(value);
#endif
#if defined _OPENCV_FASTMATH_ENABLE_GCC_MATH_BUILTINS && !defined CV_INLINE_ISNAN_FLT
#define CV_INLINE_ISNAN_FLT(value) return __builtin_isnanf(value);
#endif
#endif // defined(__CUDACC__)
/** @brief Rounds floating-point number to the nearest integer
@ -146,8 +196,11 @@
CV_INLINE int
cvRound( double value )
{
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
&& defined __SSE2__ && !defined __APPLE__) || CV_SSE2) && !defined(__CUDACC__)
#if defined CV_INLINE_ROUND_DBL
CV_INLINE_ROUND_DBL(value);
#elif ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
&& defined __SSE2__ && !defined __APPLE__) || CV_SSE2) \
&& !defined(__CUDACC__)
__m128d t = _mm_set_sd( value );
return _mm_cvtsd_si32(t);
#elif defined _MSC_VER && defined _M_IX86
@ -158,10 +211,8 @@ cvRound( double value )
fistp t;
}
return t;
#elif defined CV_INLINE_ROUND_DBL
CV_INLINE_ROUND_DBL(value);
#elif defined CV_ICC || defined __GNUC__
return (int)lrint(value);
return (int)(lrint(value));
#else
/* it's ok if round does not comply with IEEE754 standard;
the tests should allow +/-1 difference when the tested functions use round */
@ -179,7 +230,10 @@ cvRound( double value )
*/
CV_INLINE int cvFloor( double value )
{
#if defined _OPENCV_FASTMATH_ENABLE_GCC_MATH_BUILTINS
#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \
&& ( \
defined(__PPC64__) \
)
return __builtin_floor(value);
#else
int i = (int)value;
@ -196,7 +250,10 @@ CV_INLINE int cvFloor( double value )
*/
CV_INLINE int cvCeil( double value )
{
#if defined _OPENCV_FASTMATH_ENABLE_GCC_MATH_BUILTINS
#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \
&& ( \
defined(__PPC64__) \
)
return __builtin_ceil(value);
#else
int i = (int)value;
@ -232,6 +289,11 @@ 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(__PPC64__)
Cv64suf ieee754;
ieee754.f = value;
return (ieee754.u & 0x7fffffff00000000) ==
0x7ff0000000000000;
#else
Cv64suf ieee754;
ieee754.f = value;
@ -245,8 +307,11 @@ CV_INLINE int cvIsInf( double value )
/** @overload */
CV_INLINE int cvRound(float value)
{
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
&& defined __SSE2__ && !defined __APPLE__) || CV_SSE2) && !defined(__CUDACC__)
#if defined CV_INLINE_ROUND_FLT
CV_INLINE_ROUND_FLT(value);
#elif ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
&& defined __SSE2__ && !defined __APPLE__) || CV_SSE2) \
&& !defined(__CUDACC__)
__m128 t = _mm_set_ss( value );
return _mm_cvtss_si32(t);
#elif defined _MSC_VER && defined _M_IX86
@ -257,10 +322,8 @@ CV_INLINE int cvRound(float value)
fistp t;
}
return t;
#elif defined CV_INLINE_ROUND_FLT
CV_INLINE_ROUND_FLT(value);
#elif defined CV_ICC || defined __GNUC__
return (int)lrintf(value);
return (int)(lrintf(value));
#else
/* it's ok if round does not comply with IEEE754 standard;
the tests should allow +/-1 difference when the tested functions use round */
@ -277,7 +340,10 @@ CV_INLINE int cvRound( int value )
/** @overload */
CV_INLINE int cvFloor( float value )
{
#if defined _OPENCV_FASTMATH_ENABLE_GCC_MATH_BUILTINS
#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \
&& ( \
defined(__PPC64__) \
)
return __builtin_floorf(value);
#else
int i = (int)value;
@ -294,7 +360,10 @@ CV_INLINE int cvFloor( int value )
/** @overload */
CV_INLINE int cvCeil( float value )
{
#if defined _OPENCV_FASTMATH_ENABLE_GCC_MATH_BUILTINS
#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \
&& ( \
defined(__PPC64__) \
)
return __builtin_ceilf(value);
#else
int i = (int)value;

View File

@ -1699,6 +1699,11 @@ Mat_<_Tp>::Mat_(const std::array<_Tp, _Nm>& arr, bool copyData)
template<typename _Tp> inline
Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m)
{
if (m.empty())
{
release();
return *this;
}
if( traits::Type<_Tp>::value == m.type() )
{
Mat::operator = (m);
@ -1764,7 +1769,7 @@ Mat_<_Tp> Mat_<_Tp>::cross(const Mat_& m) const
template<typename _Tp> template<typename T2> inline
Mat_<_Tp>::operator Mat_<T2>() const
{
return Mat_<T2>(*this);
return Mat_<T2>(static_cast<const Mat&>(*this));
}
template<typename _Tp> inline
@ -2054,7 +2059,7 @@ void Mat_<_Tp>::forEach(const Functor& operation) const {
template<typename _Tp> inline
Mat_<_Tp>::Mat_(Mat_&& m)
: Mat(m)
: Mat(std::move(m))
{
}
@ -2070,12 +2075,17 @@ Mat_<_Tp>::Mat_(Mat&& m)
: Mat()
{
flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
*this = m;
*this = std::move(m);
}
template<typename _Tp> inline
Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m)
{
if (m.empty())
{
release();
return *this;
}
if( traits::Type<_Tp>::value == m.type() )
{
Mat::operator = ((Mat&&)m);

View File

@ -110,7 +110,7 @@ int normHamming(const uchar* a, const uchar* b, int n)
{
v_uint64x2 t = v_setzero_u64();
for(; i <= n - v_uint8x16::nlanes; i += v_uint8x16::nlanes)
t += v_popcount(v_reinterpret_as_u64(vx_load(a + i) ^ vx_load(b + i)));
t += v_popcount(v_reinterpret_as_u64(v_load(a + i) ^ v_load(b + i)));
result += (int)v_reduce_sum(t);
}
#endif

View File

@ -1129,15 +1129,14 @@ void TFImporter::populateNet(Net dstNet)
if (value_id.find(layer.input(1)) != value_id.end())
{
Mat newShape = getTensorContent(getConstBlob(layer, value_id, 1));
if (newShape.total() == 4)
{
// NHWC->NCHW
std::swap(*newShape.ptr<int32_t>(0, 2), *newShape.ptr<int32_t>(0, 3));
std::swap(*newShape.ptr<int32_t>(0, 1), *newShape.ptr<int32_t>(0, 2));
}
if (inpLayout == DATA_LAYOUT_NHWC)
{
if (newShape.total() == 4)
{
// NHWC->NCHW
std::swap(*newShape.ptr<int32_t>(0, 2), *newShape.ptr<int32_t>(0, 3));
std::swap(*newShape.ptr<int32_t>(0, 1), *newShape.ptr<int32_t>(0, 2));
}
if (newShape.total() != 4 || newShape.at<int>(1) == 1)
{
LayerParams permLP;

View File

@ -279,7 +279,7 @@ TEST_P(Test_TensorFlow_layers, matmul)
// Reference output values are in range [-5.688, 4.484]
double l1 = target == DNN_TARGET_MYRIAD ? 6.1e-3 : default_l1;
runTensorFlowNet("nhwc_reshape_matmul", false, l1);
runTensorFlowNet("matmul_layout");
}
TEST_P(Test_TensorFlow_layers, reshape)

View File

@ -113,9 +113,9 @@ static void store_interleave(float* ptr, const __m256& a, const __m256& b, const
v_pack4x3to3x4(u0.val, u1.val, u2.val, u3.val, a1, b1, c1);
#if !defined(__GNUC__) || defined(__INTEL_COMPILER)
_mm256_storeu_ps(ptr, _mm256_setr_m128(_mm_castsi128_ps(a0), _mm_castsi128_ps(b0)));
_mm256_storeu_ps(ptr + 8, _mm256_setr_m128(_mm_castsi128_ps(c0), _mm_castsi128_ps(a1)));
_mm256_storeu_ps(ptr + 16, _mm256_setr_m128(_mm_castsi128_ps(b1), _mm_castsi128_ps(c1)));
_mm256_storeu_ps(ptr, _mm256_castsi256_ps(_mm256_setr_m128i(a0, b0)));
_mm256_storeu_ps(ptr + 8, _mm256_castsi256_ps(_mm256_setr_m128i(c0, a1)));
_mm256_storeu_ps(ptr + 16, _mm256_castsi256_ps(_mm256_setr_m128i(b1, c1)));
#else
// GCC: workaround for missing AVX intrinsic: "_mm256_setr_m128()"
_mm256_storeu_ps(ptr, _mm256_insertf128_ps(_mm256_castps128_ps256(_mm_castsi128_ps(a0)), _mm_castsi128_ps(b0), 1));

View File

@ -66,6 +66,7 @@ namespace cv
static int numPartsWithin(int size, int part_size, int stride)
{
CV_Assert(stride != 0);
return (size - part_size + stride) / stride;
}
@ -78,13 +79,17 @@ static Size numPartsWithin(cv::Size size, cv::Size part_size,
static size_t getBlockHistogramSize(Size block_size, Size cell_size, int nbins)
{
CV_Assert(!cell_size.empty());
Size cells_per_block = Size(block_size.width / cell_size.width,
block_size.height / cell_size.height);
block_size.height / cell_size.height);
return (size_t)(nbins * cells_per_block.area());
}
size_t HOGDescriptor::getDescriptorSize() const
{
CV_Assert(!cellSize.empty());
CV_Assert(!blockStride.empty());
CV_Assert(blockSize.width % cellSize.width == 0 &&
blockSize.height % cellSize.height == 0);
CV_Assert((winSize.width - blockSize.width) % blockStride.width == 0 &&
@ -142,20 +147,20 @@ bool HOGDescriptor::read(FileNode& obj)
if( !obj.isMap() )
return false;
FileNodeIterator it = obj["winSize"].begin();
it >> winSize.width >> winSize.height;
it >> winSize.width >> winSize.height; CV_Assert(!winSize.empty());
it = obj["blockSize"].begin();
it >> blockSize.width >> blockSize.height;
it >> blockSize.width >> blockSize.height; CV_Assert(!blockSize.empty());
it = obj["blockStride"].begin();
it >> blockStride.width >> blockStride.height;
it >> blockStride.width >> blockStride.height; CV_Assert(!blockStride.empty());
it = obj["cellSize"].begin();
it >> cellSize.width >> cellSize.height;
obj["nbins"] >> nbins;
it >> cellSize.width >> cellSize.height; CV_Assert(!cellSize.empty());
obj["nbins"] >> nbins; CV_Assert(nbins > 0);
obj["derivAperture"] >> derivAperture;
obj["winSigma"] >> winSigma;
obj["histogramNormType"] >> histogramNormType;
obj["L2HysThreshold"] >> L2HysThreshold;
obj["gammaCorrection"] >> gammaCorrection;
obj["nlevels"] >> nlevels;
obj["nlevels"] >> nlevels; CV_Assert(nlevels > 0);
if (obj["signedGradient"].empty())
signedGradient = false;
else

View File

@ -78,6 +78,7 @@ void cv::seamlessClone(InputArray _src, InputArray _dst, InputArray _mask, Point
copyMakeBorder(mask_inner, mask, 1, 1, 1, 1, BORDER_ISOLATED | BORDER_CONSTANT, Scalar(0));
Rect roi_s = boundingRect(mask);
if (roi_s.empty()) return;
Rect roi_d(p.x - roi_s.width / 2, p.y - roi_s.height / 2, roi_s.width, roi_s.height);
Mat destinationROI = dest(roi_d).clone();

View File

@ -86,6 +86,15 @@ TEST(Photo_SeamlessClone_normal, regression)
EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
mask = Scalar(0, 0, 0);
seamlessClone(source, destination, mask, p, result, 1);
reference = destination;
errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(errorINF, 1);
errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
}
TEST(Photo_SeamlessClone_mixed, regression)

View File

@ -21691,7 +21691,9 @@ class WithParamInterface {
return *GetParameterPtrRef_();
}
#ifndef __INTEL_COMPILER // compilation workaround, templated friend is not handled properly by ICC (perhaps due using of anonymous namespaces)
private:
#endif
// Sets parameter value. The caller is responsible for making sure the value
// remains alive and unchanged throughout the current test.
static void SetParam(const ParamType* parameter) {

View File

@ -49,7 +49,7 @@ def getXCodeMajor():
raise Exception("Failed to parse Xcode version")
class Builder:
def __init__(self, opencv, contrib, dynamic, bitcodedisabled, exclude, enablenonfree, targets):
def __init__(self, opencv, contrib, dynamic, bitcodedisabled, exclude, enablenonfree, targets, debug, debug_info):
self.opencv = os.path.abspath(opencv)
self.contrib = None
if contrib:
@ -63,6 +63,8 @@ class Builder:
self.exclude = exclude
self.enablenonfree = enablenonfree
self.targets = targets
self.debug = debug
self.debug_info = debug_info
def getBD(self, parent, t):
@ -125,6 +127,9 @@ class Builder:
def getToolchain(self, arch, target):
return None
def getConfiguration(self):
return "Debug" if self.debug else "Release"
def getCMakeArgs(self, arch, target):
args = [
@ -132,7 +137,7 @@ class Builder:
"-GXcode",
"-DAPPLE_FRAMEWORK=ON",
"-DCMAKE_INSTALL_PREFIX=install",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_BUILD_TYPE=%s" % self.getConfiguration(),
"-DOPENCV_INCLUDE_INSTALL_PATH=include",
"-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty"
] + ([
@ -141,7 +146,9 @@ class Builder:
"-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=NO",
] if self.dynamic else []) + ([
"-DOPENCV_ENABLE_NONFREE=ON"
] if self.enablenonfree else [])
] if self.enablenonfree else []) + ([
"-DBUILD_WITH_DEBUG_INFO=ON"
] if self.debug_info else [])
if len(self.exclude) > 0:
args += ["-DBUILD_opencv_world=OFF"] if not self.dynamic else []
@ -176,7 +183,7 @@ class Builder:
buildcmd += [
"-sdk", target.lower(),
"-configuration", "Release",
"-configuration", self.getConfiguration(),
"-parallelizeTargets",
"-jobs", str(multiprocessing.cpu_count()),
] + (["-target","ALL_BUILD"] if self.dynamic else [])
@ -203,10 +210,10 @@ class Builder:
shutil.rmtree(clean_dir)
buildcmd = self.getBuildCommand(arch, target)
execute(buildcmd + ["-target", "ALL_BUILD", "build"], cwd = builddir)
execute(["cmake", "-P", "cmake_install.cmake"], cwd = builddir)
execute(["cmake", "-DBUILD_TYPE=%s" % self.getConfiguration(), "-P", "cmake_install.cmake"], cwd = builddir)
def mergeLibs(self, builddir):
res = os.path.join(builddir, "lib", "Release", "libopencv_merged.a")
res = os.path.join(builddir, "lib", self.getConfiguration(), "libopencv_merged.a")
libs = glob.glob(os.path.join(builddir, "install", "lib", "*.a"))
libs3 = glob.glob(os.path.join(builddir, "install", "lib", "3rdparty", "*.a"))
print("Merging libraries:\n\t%s" % "\n\t".join(libs + libs3), file=sys.stderr)
@ -232,7 +239,7 @@ class Builder:
shutil.copytree(os.path.join(builddirs[0], "install", "include", "opencv2"), os.path.join(dstdir, "Headers"))
# make universal static lib
libs = [os.path.join(d, "lib", "Release", libname) for d in builddirs]
libs = [os.path.join(d, "lib", self.getConfiguration(), libname) for d in builddirs]
lipocmd = ["lipo", "-create"]
lipocmd.extend(libs)
lipocmd.extend(["-o", os.path.join(dstdir, name)])
@ -290,6 +297,8 @@ if __name__ == "__main__":
parser.add_argument('--iphoneos_archs', default='armv7,armv7s,arm64', help='select iPhoneOS target ARCHS')
parser.add_argument('--iphonesimulator_archs', default='i386,x86_64', help='select iPhoneSimulator target ARCHS')
parser.add_argument('--enable_nonfree', default=False, dest='enablenonfree', action='store_true', help='enable non-free modules (disabled by default)')
parser.add_argument('--debug', default=False, dest='debug', action='store_true', help='Build "Debug" binaries (disabled by default)')
parser.add_argument('--debug_info', default=False, dest='debug_info', action='store_true', help='Build with debug information (useful for Release mode: BUILD_WITH_DEBUG_INFO=ON)')
args = parser.parse_args()
os.environ['IPHONEOS_DEPLOYMENT_TARGET'] = args.iphoneos_deployment_target
@ -306,5 +315,5 @@ if __name__ == "__main__":
[
(iphoneos_archs, "iPhoneOS"),
(iphonesimulator_archs, "iPhoneSimulator"),
])
], args.debug, args.debug_info)
b.build(args.out)

15
platforms/osx/build_framework.py Normal file → Executable file
View File

@ -10,6 +10,8 @@ import os, os.path, sys, argparse, traceback, multiprocessing
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from build_framework import Builder
MACOSX_DEPLOYMENT_TARGET='10.12' # default, can be changed via command line options or environment variable
class OSXBuilder(Builder):
def getToolchain(self, arch, target):
@ -18,10 +20,10 @@ class OSXBuilder(Builder):
def getBuildCommand(self, archs, target):
buildcmd = [
"xcodebuild",
"MACOSX_DEPLOYMENT_TARGET=10.9",
"MACOSX_DEPLOYMENT_TARGET=" + os.environ['MACOSX_DEPLOYMENT_TARGET'],
"ARCHS=%s" % archs[0],
"-sdk", target.lower(),
"-configuration", "Release",
"-configuration", "Debug" if self.debug else "Release",
"-parallelizeTargets",
"-jobs", str(multiprocessing.cpu_count())
]
@ -39,10 +41,17 @@ if __name__ == "__main__":
parser.add_argument('--contrib', metavar='DIR', default=None, help='folder with opencv_contrib repository (default is "None" - build only main framework)')
parser.add_argument('--without', metavar='MODULE', default=[], action='append', help='OpenCV modules to exclude from the framework')
parser.add_argument('--enable_nonfree', default=False, dest='enablenonfree', action='store_true', help='enable non-free modules (disabled by default)')
parser.add_argument('--macosx_deployment_target', default=os.environ.get('MACOSX_DEPLOYMENT_TARGET', MACOSX_DEPLOYMENT_TARGET), help='specify MACOSX_DEPLOYMENT_TARGET')
parser.add_argument('--debug', action='store_true', help='Build "Debug" binaries (CMAKE_BUILD_TYPE=Debug)')
parser.add_argument('--debug_info', action='store_true', help='Build with debug information (useful for Release mode: BUILD_WITH_DEBUG_INFO=ON)')
args = parser.parse_args()
os.environ['MACOSX_DEPLOYMENT_TARGET'] = args.macosx_deployment_target
print('Using MACOSX_DEPLOYMENT_TARGET=' + os.environ['MACOSX_DEPLOYMENT_TARGET'])
b = OSXBuilder(args.opencv, args.contrib, False, False, args.without, args.enablenonfree,
[
(["x86_64"], "MacOSX")
])
], args.debug, args.debug_info)
b.build(args.out)

View File

@ -8,7 +8,7 @@ This is a demo that shows mean-shift based tracking
You select a color objects such as your face and it tracks it.
This reads from video camera (0 by default, or the camera number the user enters)
http://www.robinhewitt.com/research/track/camshift.html
[1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.14.7673
Usage:
------