mirror of http://192.168.1.51:8099/lmh188/twain3.0
更新三方库
This commit is contained in:
parent
16814f6c6f
commit
86fc897645
|
@ -0,0 +1,71 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef OPENCV_CORE_ASYNC_PROMISE_HPP
|
||||||
|
#define OPENCV_CORE_ASYNC_PROMISE_HPP
|
||||||
|
|
||||||
|
#include "../async.hpp"
|
||||||
|
|
||||||
|
#include "exception_ptr.hpp"
|
||||||
|
|
||||||
|
namespace cv {
|
||||||
|
|
||||||
|
/** @addtogroup core_async
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Provides result of asynchronous operations
|
||||||
|
|
||||||
|
*/
|
||||||
|
class CV_EXPORTS AsyncPromise
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~AsyncPromise() CV_NOEXCEPT;
|
||||||
|
AsyncPromise() CV_NOEXCEPT;
|
||||||
|
explicit AsyncPromise(const AsyncPromise& o) CV_NOEXCEPT;
|
||||||
|
AsyncPromise& operator=(const AsyncPromise& o) CV_NOEXCEPT;
|
||||||
|
void release() CV_NOEXCEPT;
|
||||||
|
|
||||||
|
/** Returns associated AsyncArray
|
||||||
|
@note Can be called once
|
||||||
|
*/
|
||||||
|
AsyncArray getArrayResult();
|
||||||
|
|
||||||
|
/** Stores asynchronous result.
|
||||||
|
@param[in] value result
|
||||||
|
*/
|
||||||
|
void setValue(InputArray value);
|
||||||
|
|
||||||
|
// TODO "move" setters
|
||||||
|
|
||||||
|
#if CV__EXCEPTION_PTR
|
||||||
|
/** Stores exception.
|
||||||
|
@param[in] exception exception to be raised in AsyncArray
|
||||||
|
*/
|
||||||
|
void setException(std::exception_ptr exception);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Stores exception.
|
||||||
|
@param[in] exception exception to be raised in AsyncArray
|
||||||
|
*/
|
||||||
|
void setException(const cv::Exception& exception);
|
||||||
|
|
||||||
|
#ifdef CV_CXX11
|
||||||
|
explicit AsyncPromise(AsyncPromise&& o) { p = o.p; o.p = NULL; }
|
||||||
|
AsyncPromise& operator=(AsyncPromise&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// PImpl
|
||||||
|
typedef struct AsyncArray::Impl Impl; friend struct AsyncArray::Impl;
|
||||||
|
inline void* _getImpl() const CV_NOEXCEPT { return p; }
|
||||||
|
protected:
|
||||||
|
Impl* p;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
} // namespace
|
||||||
|
#endif // OPENCV_CORE_ASYNC_PROMISE_HPP
|
|
@ -0,0 +1,27 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef OPENCV_CORE_DETAILS_EXCEPTION_PTR_H
|
||||||
|
#define OPENCV_CORE_DETAILS_EXCEPTION_PTR_H
|
||||||
|
|
||||||
|
#ifndef CV__EXCEPTION_PTR
|
||||||
|
# if defined(__ANDROID__) && defined(ATOMIC_INT_LOCK_FREE) && ATOMIC_INT_LOCK_FREE < 2
|
||||||
|
# define CV__EXCEPTION_PTR 0 // Not supported, details: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58938
|
||||||
|
# elif defined(CV_CXX11)
|
||||||
|
# define CV__EXCEPTION_PTR 1
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
# define CV__EXCEPTION_PTR (_MSC_VER >= 1600)
|
||||||
|
# elif defined(__clang__)
|
||||||
|
# define CV__EXCEPTION_PTR 0 // C++11 only (see above)
|
||||||
|
# elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
|
# define CV__EXCEPTION_PTR (__GXX_EXPERIMENTAL_CXX0X__ > 0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef CV__EXCEPTION_PTR
|
||||||
|
# define CV__EXCEPTION_PTR 0
|
||||||
|
#elif CV__EXCEPTION_PTR
|
||||||
|
# include <exception> // std::exception_ptr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // OPENCV_CORE_DETAILS_EXCEPTION_PTR_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,146 @@
|
||||||
|
// 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 header is not standalone. Don't include directly, use "intrin.hpp" instead.
|
||||||
|
#ifdef OPENCV_HAL_INTRIN_HPP // defined in intrin.hpp
|
||||||
|
|
||||||
|
|
||||||
|
#if CV_SIMD128 || CV_SIMD128_CPP
|
||||||
|
|
||||||
|
template<typename _T> struct Type2Vec128_Traits;
|
||||||
|
#define CV_INTRIN_DEF_TYPE2VEC128_TRAITS(type_, vec_type_) \
|
||||||
|
template<> struct Type2Vec128_Traits<type_> \
|
||||||
|
{ \
|
||||||
|
typedef vec_type_ vec_type; \
|
||||||
|
}
|
||||||
|
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uchar, v_uint8x16);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(schar, v_int8x16);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(ushort, v_uint16x8);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(short, v_int16x8);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(unsigned, v_uint32x4);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int, v_int32x4);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(float, v_float32x4);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uint64, v_uint64x2);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int64, v_int64x2);
|
||||||
|
#if CV_SIMD128_64F
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC128_TRAITS(double, v_float64x2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<typename _T> static inline
|
||||||
|
typename Type2Vec128_Traits<_T>::vec_type v_setall(const _T& a);
|
||||||
|
|
||||||
|
template<> inline Type2Vec128_Traits< uchar>::vec_type v_setall< uchar>(const uchar& a) { return v_setall_u8(a); }
|
||||||
|
template<> inline Type2Vec128_Traits< schar>::vec_type v_setall< schar>(const schar& a) { return v_setall_s8(a); }
|
||||||
|
template<> inline Type2Vec128_Traits<ushort>::vec_type v_setall<ushort>(const ushort& a) { return v_setall_u16(a); }
|
||||||
|
template<> inline Type2Vec128_Traits< short>::vec_type v_setall< short>(const short& a) { return v_setall_s16(a); }
|
||||||
|
template<> inline Type2Vec128_Traits< uint>::vec_type v_setall< uint>(const uint& a) { return v_setall_u32(a); }
|
||||||
|
template<> inline Type2Vec128_Traits< int>::vec_type v_setall< int>(const int& a) { return v_setall_s32(a); }
|
||||||
|
template<> inline Type2Vec128_Traits<uint64>::vec_type v_setall<uint64>(const uint64& a) { return v_setall_u64(a); }
|
||||||
|
template<> inline Type2Vec128_Traits< int64>::vec_type v_setall< int64>(const int64& a) { return v_setall_s64(a); }
|
||||||
|
template<> inline Type2Vec128_Traits< float>::vec_type v_setall< float>(const float& a) { return v_setall_f32(a); }
|
||||||
|
#if CV_SIMD128_64F
|
||||||
|
template<> inline Type2Vec128_Traits<double>::vec_type v_setall<double>(const double& a) { return v_setall_f64(a); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SIMD128
|
||||||
|
|
||||||
|
|
||||||
|
#if CV_SIMD256
|
||||||
|
|
||||||
|
template<typename _T> struct Type2Vec256_Traits;
|
||||||
|
#define CV_INTRIN_DEF_TYPE2VEC256_TRAITS(type_, vec_type_) \
|
||||||
|
template<> struct Type2Vec256_Traits<type_> \
|
||||||
|
{ \
|
||||||
|
typedef vec_type_ vec_type; \
|
||||||
|
}
|
||||||
|
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uchar, v_uint8x32);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(schar, v_int8x32);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(ushort, v_uint16x16);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(short, v_int16x16);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(unsigned, v_uint32x8);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int, v_int32x8);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(float, v_float32x8);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uint64, v_uint64x4);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int64, v_int64x4);
|
||||||
|
#if CV_SIMD256_64F
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC256_TRAITS(double, v_float64x4);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<typename _T> static inline
|
||||||
|
typename Type2Vec256_Traits<_T>::vec_type v256_setall(const _T& a);
|
||||||
|
|
||||||
|
template<> inline Type2Vec256_Traits< uchar>::vec_type v256_setall< uchar>(const uchar& a) { return v256_setall_u8(a); }
|
||||||
|
template<> inline Type2Vec256_Traits< schar>::vec_type v256_setall< schar>(const schar& a) { return v256_setall_s8(a); }
|
||||||
|
template<> inline Type2Vec256_Traits<ushort>::vec_type v256_setall<ushort>(const ushort& a) { return v256_setall_u16(a); }
|
||||||
|
template<> inline Type2Vec256_Traits< short>::vec_type v256_setall< short>(const short& a) { return v256_setall_s16(a); }
|
||||||
|
template<> inline Type2Vec256_Traits< uint>::vec_type v256_setall< uint>(const uint& a) { return v256_setall_u32(a); }
|
||||||
|
template<> inline Type2Vec256_Traits< int>::vec_type v256_setall< int>(const int& a) { return v256_setall_s32(a); }
|
||||||
|
template<> inline Type2Vec256_Traits<uint64>::vec_type v256_setall<uint64>(const uint64& a) { return v256_setall_u64(a); }
|
||||||
|
template<> inline Type2Vec256_Traits< int64>::vec_type v256_setall< int64>(const int64& a) { return v256_setall_s64(a); }
|
||||||
|
template<> inline Type2Vec256_Traits< float>::vec_type v256_setall< float>(const float& a) { return v256_setall_f32(a); }
|
||||||
|
#if CV_SIMD256_64F
|
||||||
|
template<> inline Type2Vec256_Traits<double>::vec_type v256_setall<double>(const double& a) { return v256_setall_f64(a); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SIMD256
|
||||||
|
|
||||||
|
|
||||||
|
#if CV_SIMD512
|
||||||
|
|
||||||
|
template<typename _T> struct Type2Vec512_Traits;
|
||||||
|
#define CV_INTRIN_DEF_TYPE2VEC512_TRAITS(type_, vec_type_) \
|
||||||
|
template<> struct Type2Vec512_Traits<type_> \
|
||||||
|
{ \
|
||||||
|
typedef vec_type_ vec_type; \
|
||||||
|
}
|
||||||
|
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uchar, v_uint8x64);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(schar, v_int8x64);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(ushort, v_uint16x32);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(short, v_int16x32);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(unsigned, v_uint32x16);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int, v_int32x16);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(float, v_float32x16);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uint64, v_uint64x8);
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int64, v_int64x8);
|
||||||
|
#if CV_SIMD512_64F
|
||||||
|
CV_INTRIN_DEF_TYPE2VEC512_TRAITS(double, v_float64x8);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<typename _T> static inline
|
||||||
|
typename Type2Vec512_Traits<_T>::vec_type v512_setall(const _T& a);
|
||||||
|
|
||||||
|
template<> inline Type2Vec512_Traits< uchar>::vec_type v512_setall< uchar>(const uchar& a) { return v512_setall_u8(a); }
|
||||||
|
template<> inline Type2Vec512_Traits< schar>::vec_type v512_setall< schar>(const schar& a) { return v512_setall_s8(a); }
|
||||||
|
template<> inline Type2Vec512_Traits<ushort>::vec_type v512_setall<ushort>(const ushort& a) { return v512_setall_u16(a); }
|
||||||
|
template<> inline Type2Vec512_Traits< short>::vec_type v512_setall< short>(const short& a) { return v512_setall_s16(a); }
|
||||||
|
template<> inline Type2Vec512_Traits< uint>::vec_type v512_setall< uint>(const uint& a) { return v512_setall_u32(a); }
|
||||||
|
template<> inline Type2Vec512_Traits< int>::vec_type v512_setall< int>(const int& a) { return v512_setall_s32(a); }
|
||||||
|
template<> inline Type2Vec512_Traits<uint64>::vec_type v512_setall<uint64>(const uint64& a) { return v512_setall_u64(a); }
|
||||||
|
template<> inline Type2Vec512_Traits< int64>::vec_type v512_setall< int64>(const int64& a) { return v512_setall_s64(a); }
|
||||||
|
template<> inline Type2Vec512_Traits< float>::vec_type v512_setall< float>(const float& a) { return v512_setall_f32(a); }
|
||||||
|
#if CV_SIMD512_64F
|
||||||
|
template<> inline Type2Vec512_Traits<double>::vec_type v512_setall<double>(const double& a) { return v512_setall_f64(a); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SIMD512
|
||||||
|
|
||||||
|
|
||||||
|
#if CV_SIMD_WIDTH == 16
|
||||||
|
template<typename _T> static inline
|
||||||
|
typename Type2Vec128_Traits<_T>::vec_type vx_setall(const _T& a) { return v_setall(a); }
|
||||||
|
#elif CV_SIMD_WIDTH == 32
|
||||||
|
template<typename _T> static inline
|
||||||
|
typename Type2Vec256_Traits<_T>::vec_type vx_setall(const _T& a) { return v256_setall(a); }
|
||||||
|
#elif CV_SIMD_WIDTH == 64
|
||||||
|
template<typename _T> static inline
|
||||||
|
typename Type2Vec512_Traits<_T>::vec_type vx_setall(const _T& a) { return v512_setall(a); }
|
||||||
|
#else
|
||||||
|
#error "Build configuration error, unsupported CV_SIMD_WIDTH"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // OPENCV_HAL_INTRIN_HPP
|
|
@ -0,0 +1,87 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef OPENCV_CORE_SIMD_INTRINSICS_HPP
|
||||||
|
#define OPENCV_CORE_SIMD_INTRINSICS_HPP
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper header to support SIMD intrinsics (universal intrinsics) in user code.
|
||||||
|
Intrinsics documentation: https://docs.opencv.org/3.4/df/d91/group__core__hal__intrin.html
|
||||||
|
|
||||||
|
|
||||||
|
Checks of target CPU instruction set based on compiler definitions don't work well enough.
|
||||||
|
More reliable solutions require utilization of configuration systems (like CMake).
|
||||||
|
|
||||||
|
So, probably you need to specify your own configuration.
|
||||||
|
|
||||||
|
You can do that via CMake in this way:
|
||||||
|
add_definitions(/DOPENCV_SIMD_CONFIG_HEADER=opencv_simd_config_custom.hpp)
|
||||||
|
or
|
||||||
|
add_definitions(/DOPENCV_SIMD_CONFIG_INCLUDE_DIR=1)
|
||||||
|
|
||||||
|
Additionally you may need to add include directory to your files:
|
||||||
|
include_directories("${CMAKE_CURRENT_LIST_DIR}/opencv_config_${MYTARGET}")
|
||||||
|
|
||||||
|
These files can be pre-generated for target configurations of your application
|
||||||
|
or generated by CMake on the fly (use CMAKE_BINARY_DIR for that).
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- H/W capability checks are still responsibility of your application
|
||||||
|
- runtime dispatching is not covered by this helper header
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __OPENCV_BUILD
|
||||||
|
#error "Use core/hal/intrin.hpp during OpenCV build"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OPENCV_HAL_INTRIN_HPP
|
||||||
|
#error "core/simd_intrinsics.hpp must be included before core/hal/intrin.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "opencv2/core/cvdef.h"
|
||||||
|
|
||||||
|
#ifdef OPENCV_SIMD_CONFIG_HEADER
|
||||||
|
#include CVAUX_STR(OPENCV_SIMD_CONFIG_HEADER)
|
||||||
|
#elif defined(OPENCV_SIMD_CONFIG_INCLUDE_DIR)
|
||||||
|
#include "opencv_simd_config.hpp" // corresponding directory should be added via -I compiler parameter
|
||||||
|
#else // custom config headers
|
||||||
|
|
||||||
|
#if (!defined(CV_AVX_512F) || !CV_AVX_512F) && (defined(__AVX512__) || defined(__AVX512F__))
|
||||||
|
# include <immintrin.h>
|
||||||
|
# undef CV_AVX_512F
|
||||||
|
# define CV_AVX_512F 1
|
||||||
|
# ifndef OPENCV_SIMD_DONT_ASSUME_SKX // Skylake-X with AVX-512F/CD/BW/DQ/VL
|
||||||
|
# undef CV_AVX512_SKX
|
||||||
|
# define CV_AVX512_SKX 1
|
||||||
|
# undef CV_AVX_512CD
|
||||||
|
# define CV_AVX_512CD 1
|
||||||
|
# undef CV_AVX_512BW
|
||||||
|
# define CV_AVX_512BW 1
|
||||||
|
# undef CV_AVX_512DQ
|
||||||
|
# define CV_AVX_512DQ 1
|
||||||
|
# undef CV_AVX_512VL
|
||||||
|
# define CV_AVX_512VL 1
|
||||||
|
# endif
|
||||||
|
#endif // AVX512
|
||||||
|
|
||||||
|
// GCC/Clang: -mavx2
|
||||||
|
// MSVC: /arch:AVX2
|
||||||
|
#if defined __AVX2__
|
||||||
|
# include <immintrin.h>
|
||||||
|
# undef CV_AVX2
|
||||||
|
# define CV_AVX2 1
|
||||||
|
# if defined __F16C__
|
||||||
|
# undef CV_FP16
|
||||||
|
# define CV_FP16 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SSE / NEON / VSX is handled by cv_cpu_dispatch.h compatibility block
|
||||||
|
#include "cv_cpu_dispatch.h"
|
||||||
|
|
||||||
|
#include "hal/intrin.hpp"
|
||||||
|
|
||||||
|
#endif // OPENCV_CORE_SIMD_INTRINSICS_HPP
|
|
@ -0,0 +1,29 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef OPENCV_CORE_ALLOCATOR_STATS_HPP
|
||||||
|
#define OPENCV_CORE_ALLOCATOR_STATS_HPP
|
||||||
|
|
||||||
|
#include "../cvdef.h"
|
||||||
|
|
||||||
|
namespace cv { namespace utils {
|
||||||
|
|
||||||
|
class AllocatorStatisticsInterface
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
AllocatorStatisticsInterface() {}
|
||||||
|
virtual ~AllocatorStatisticsInterface() {}
|
||||||
|
public:
|
||||||
|
virtual uint64_t getCurrentUsage() const = 0;
|
||||||
|
virtual uint64_t getTotalUsage() const = 0;
|
||||||
|
virtual uint64_t getNumberOfAllocations() const = 0;
|
||||||
|
virtual uint64_t getPeakUsage() const = 0;
|
||||||
|
|
||||||
|
/** set peak usage = current usage */
|
||||||
|
virtual void resetPeakUsage() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}} // namespace
|
||||||
|
|
||||||
|
#endif // OPENCV_CORE_ALLOCATOR_STATS_HPP
|
|
@ -0,0 +1,158 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP
|
||||||
|
#define OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP
|
||||||
|
|
||||||
|
#include "./allocator_stats.hpp"
|
||||||
|
|
||||||
|
//#define OPENCV_DISABLE_ALLOCATOR_STATS
|
||||||
|
|
||||||
|
#ifdef CV_CXX11
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE
|
||||||
|
#if defined(__GNUC__) && (\
|
||||||
|
(defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4) || \
|
||||||
|
(defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)) \
|
||||||
|
)
|
||||||
|
#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE int
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE
|
||||||
|
#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE long long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else // CV_CXX11
|
||||||
|
|
||||||
|
#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE
|
||||||
|
#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE int // CV_XADD supports int only
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CV_CXX11
|
||||||
|
|
||||||
|
namespace cv { namespace utils {
|
||||||
|
|
||||||
|
#ifdef CV__ALLOCATOR_STATS_LOG
|
||||||
|
namespace {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class AllocatorStatistics : public AllocatorStatisticsInterface
|
||||||
|
{
|
||||||
|
#ifdef OPENCV_DISABLE_ALLOCATOR_STATS
|
||||||
|
|
||||||
|
public:
|
||||||
|
AllocatorStatistics() {}
|
||||||
|
~AllocatorStatistics() CV_OVERRIDE {}
|
||||||
|
|
||||||
|
uint64_t getCurrentUsage() const CV_OVERRIDE { return 0; }
|
||||||
|
uint64_t getTotalUsage() const CV_OVERRIDE { return 0; }
|
||||||
|
uint64_t getNumberOfAllocations() const CV_OVERRIDE { return 0; }
|
||||||
|
uint64_t getPeakUsage() const CV_OVERRIDE { return 0; }
|
||||||
|
|
||||||
|
/** set peak usage = current usage */
|
||||||
|
void resetPeakUsage() CV_OVERRIDE {};
|
||||||
|
|
||||||
|
void onAllocate(size_t /*sz*/) {}
|
||||||
|
void onFree(size_t /*sz*/) {}
|
||||||
|
|
||||||
|
#elif defined(CV_CXX11)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
typedef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE counter_t;
|
||||||
|
std::atomic<counter_t> curr, total, total_allocs, peak;
|
||||||
|
public:
|
||||||
|
AllocatorStatistics() {}
|
||||||
|
~AllocatorStatistics() CV_OVERRIDE {}
|
||||||
|
|
||||||
|
uint64_t getCurrentUsage() const CV_OVERRIDE { return (uint64_t)curr.load(); }
|
||||||
|
uint64_t getTotalUsage() const CV_OVERRIDE { return (uint64_t)total.load(); }
|
||||||
|
uint64_t getNumberOfAllocations() const CV_OVERRIDE { return (uint64_t)total_allocs.load(); }
|
||||||
|
uint64_t getPeakUsage() const CV_OVERRIDE { return (uint64_t)peak.load(); }
|
||||||
|
|
||||||
|
/** set peak usage = current usage */
|
||||||
|
void resetPeakUsage() CV_OVERRIDE { peak.store(curr.load()); }
|
||||||
|
|
||||||
|
// Controller interface
|
||||||
|
void onAllocate(size_t sz)
|
||||||
|
{
|
||||||
|
#ifdef CV__ALLOCATOR_STATS_LOG
|
||||||
|
CV__ALLOCATOR_STATS_LOG(cv::format("allocate: %lld (curr=%lld)", (long long int)sz, (long long int)curr.load()));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
counter_t new_curr = curr.fetch_add((counter_t)sz) + (counter_t)sz;
|
||||||
|
|
||||||
|
// peak = std::max((uint64_t)peak, new_curr);
|
||||||
|
auto prev_peak = peak.load();
|
||||||
|
while (prev_peak < new_curr)
|
||||||
|
{
|
||||||
|
if (peak.compare_exchange_weak(prev_peak, new_curr))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// end of peak = max(...)
|
||||||
|
|
||||||
|
total += (counter_t)sz;
|
||||||
|
total_allocs++;
|
||||||
|
}
|
||||||
|
void onFree(size_t sz)
|
||||||
|
{
|
||||||
|
#ifdef CV__ALLOCATOR_STATS_LOG
|
||||||
|
CV__ALLOCATOR_STATS_LOG(cv::format("free: %lld (curr=%lld)", (long long int)sz, (long long int)curr.load()));
|
||||||
|
#endif
|
||||||
|
curr -= (counter_t)sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // non C++11
|
||||||
|
|
||||||
|
protected:
|
||||||
|
typedef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE counter_t;
|
||||||
|
volatile counter_t curr, total, total_allocs, peak; // overflow is possible, CV_XADD operates with 'int' only
|
||||||
|
public:
|
||||||
|
AllocatorStatistics()
|
||||||
|
: curr(0), total(0), total_allocs(0), peak(0)
|
||||||
|
{}
|
||||||
|
~AllocatorStatistics() CV_OVERRIDE {}
|
||||||
|
|
||||||
|
uint64_t getCurrentUsage() const CV_OVERRIDE { return (uint64_t)curr; }
|
||||||
|
uint64_t getTotalUsage() const CV_OVERRIDE { return (uint64_t)total; }
|
||||||
|
uint64_t getNumberOfAllocations() const CV_OVERRIDE { return (uint64_t)total_allocs; }
|
||||||
|
uint64_t getPeakUsage() const CV_OVERRIDE { return (uint64_t)peak; }
|
||||||
|
|
||||||
|
void resetPeakUsage() CV_OVERRIDE { peak = curr; }
|
||||||
|
|
||||||
|
// Controller interface
|
||||||
|
void onAllocate(size_t sz)
|
||||||
|
{
|
||||||
|
#ifdef CV__ALLOCATOR_STATS_LOG
|
||||||
|
CV__ALLOCATOR_STATS_LOG(cv::format("allocate: %lld (curr=%lld)", (long long int)sz, (long long int)curr));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
counter_t new_curr = (counter_t)CV_XADD(&curr, (counter_t)sz) + (counter_t)sz;
|
||||||
|
|
||||||
|
peak = std::max((counter_t)peak, new_curr); // non-thread safe
|
||||||
|
|
||||||
|
//CV_XADD(&total, (uint64_t)sz); // overflow with int, non-reliable...
|
||||||
|
total += sz;
|
||||||
|
|
||||||
|
CV_XADD(&total_allocs, (counter_t)1);
|
||||||
|
}
|
||||||
|
void onFree(size_t sz)
|
||||||
|
{
|
||||||
|
#ifdef CV__ALLOCATOR_STATS_LOG
|
||||||
|
CV__ALLOCATOR_STATS_LOG(cv::format("free: %lld (curr=%lld)", (long long int)sz, (long long int)curr));
|
||||||
|
#endif
|
||||||
|
CV_XADD(&curr, (counter_t)-sz);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef CV__ALLOCATOR_STATS_LOG
|
||||||
|
} // namespace
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}} // namespace
|
||||||
|
|
||||||
|
#endif // OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP
|
|
@ -0,0 +1,125 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef OPENCV_UTILS_INSTR_HPP
|
||||||
|
#define OPENCV_UTILS_INSTR_HPP
|
||||||
|
|
||||||
|
#include <opencv2/core/utility.hpp>
|
||||||
|
#include <opencv2/core/utils/tls.hpp>
|
||||||
|
|
||||||
|
namespace cv {
|
||||||
|
|
||||||
|
//! @addtogroup core_utils
|
||||||
|
//! @{
|
||||||
|
|
||||||
|
#ifdef CV_COLLECT_IMPL_DATA
|
||||||
|
CV_EXPORTS void setImpl(int flags); // set implementation flags and reset storage arrays
|
||||||
|
CV_EXPORTS void addImpl(int flag, const char* func = 0); // add implementation and function name to storage arrays
|
||||||
|
// Get stored implementation flags and functions names arrays
|
||||||
|
// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which function
|
||||||
|
CV_EXPORTS int getImpl(std::vector<int> &impl, std::vector<String> &funName);
|
||||||
|
|
||||||
|
CV_EXPORTS bool useCollection(); // return implementation collection state
|
||||||
|
CV_EXPORTS void setUseCollection(bool flag); // set implementation collection state
|
||||||
|
|
||||||
|
#define CV_IMPL_PLAIN 0x01 // native CPU OpenCV implementation
|
||||||
|
#define CV_IMPL_OCL 0x02 // OpenCL implementation
|
||||||
|
#define CV_IMPL_IPP 0x04 // IPP implementation
|
||||||
|
#define CV_IMPL_MT 0x10 // multithreaded implementation
|
||||||
|
|
||||||
|
#undef CV_IMPL_ADD
|
||||||
|
#define CV_IMPL_ADD(impl) \
|
||||||
|
if(cv::useCollection()) \
|
||||||
|
{ \
|
||||||
|
cv::addImpl(impl, CV_Func); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Instrumentation external interface
|
||||||
|
namespace instr
|
||||||
|
{
|
||||||
|
|
||||||
|
#if !defined OPENCV_ABI_CHECK
|
||||||
|
|
||||||
|
enum TYPE
|
||||||
|
{
|
||||||
|
TYPE_GENERAL = 0, // OpenCV API function, e.g. exported function
|
||||||
|
TYPE_MARKER, // Information marker
|
||||||
|
TYPE_WRAPPER, // Wrapper function for implementation
|
||||||
|
TYPE_FUN, // Simple function call
|
||||||
|
};
|
||||||
|
|
||||||
|
enum IMPL
|
||||||
|
{
|
||||||
|
IMPL_PLAIN = 0,
|
||||||
|
IMPL_IPP,
|
||||||
|
IMPL_OPENCL,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NodeDataTls
|
||||||
|
{
|
||||||
|
NodeDataTls()
|
||||||
|
{
|
||||||
|
m_ticksTotal = 0;
|
||||||
|
}
|
||||||
|
uint64 m_ticksTotal;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS NodeData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NodeData(const char* funName = 0, const char* fileName = NULL, int lineNum = 0, void* retAddress = NULL, bool alwaysExpand = false, cv::instr::TYPE instrType = TYPE_GENERAL, cv::instr::IMPL implType = IMPL_PLAIN);
|
||||||
|
NodeData(NodeData &ref);
|
||||||
|
~NodeData();
|
||||||
|
NodeData& operator=(const NodeData&);
|
||||||
|
|
||||||
|
cv::String m_funName;
|
||||||
|
cv::instr::TYPE m_instrType;
|
||||||
|
cv::instr::IMPL m_implType;
|
||||||
|
const char* m_fileName;
|
||||||
|
int m_lineNum;
|
||||||
|
void* m_retAddress;
|
||||||
|
bool m_alwaysExpand;
|
||||||
|
bool m_funError;
|
||||||
|
|
||||||
|
volatile int m_counter;
|
||||||
|
volatile uint64 m_ticksTotal;
|
||||||
|
TLSDataAccumulator<NodeDataTls> m_tls;
|
||||||
|
int m_threads;
|
||||||
|
|
||||||
|
// No synchronization
|
||||||
|
double getTotalMs() const { return ((double)m_ticksTotal / cv::getTickFrequency()) * 1000; }
|
||||||
|
double getMeanMs() const { return (((double)m_ticksTotal/m_counter) / cv::getTickFrequency()) * 1000; }
|
||||||
|
};
|
||||||
|
bool operator==(const NodeData& lhs, const NodeData& rhs);
|
||||||
|
|
||||||
|
typedef Node<NodeData> InstrNode;
|
||||||
|
|
||||||
|
CV_EXPORTS InstrNode* getTrace();
|
||||||
|
|
||||||
|
#endif // !defined OPENCV_ABI_CHECK
|
||||||
|
|
||||||
|
|
||||||
|
CV_EXPORTS bool useInstrumentation();
|
||||||
|
CV_EXPORTS void setUseInstrumentation(bool flag);
|
||||||
|
CV_EXPORTS void resetTrace();
|
||||||
|
|
||||||
|
enum FLAGS
|
||||||
|
{
|
||||||
|
FLAGS_NONE = 0,
|
||||||
|
FLAGS_MAPPING = 0x01,
|
||||||
|
FLAGS_EXPAND_SAME_NAMES = 0x02,
|
||||||
|
};
|
||||||
|
|
||||||
|
CV_EXPORTS void setFlags(FLAGS modeFlags);
|
||||||
|
static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); }
|
||||||
|
CV_EXPORTS FLAGS getFlags();
|
||||||
|
|
||||||
|
} // namespace instr
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // OPENCV_UTILS_TLS_HPP
|
|
@ -0,0 +1,239 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef OPENCV_UTILS_TLS_HPP
|
||||||
|
#define OPENCV_UTILS_TLS_HPP
|
||||||
|
|
||||||
|
#ifndef OPENCV_CORE_UTILITY_H
|
||||||
|
#error "tls.hpp must be included after opencv2/core/utility.hpp or opencv2/core.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace cv {
|
||||||
|
|
||||||
|
//! @addtogroup core_utils
|
||||||
|
//! @{
|
||||||
|
|
||||||
|
namespace details { class TlsStorage; }
|
||||||
|
|
||||||
|
/** TLS container base implementation
|
||||||
|
*
|
||||||
|
* Don't use directly.
|
||||||
|
*
|
||||||
|
* @sa TLSData, TLSDataAccumulator templates
|
||||||
|
*/
|
||||||
|
class CV_EXPORTS TLSDataContainer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
TLSDataContainer();
|
||||||
|
virtual ~TLSDataContainer();
|
||||||
|
|
||||||
|
/// @deprecated use detachData() instead
|
||||||
|
void gatherData(std::vector<void*> &data) const;
|
||||||
|
/// get TLS data and detach all data from threads (similar to cleanup() call)
|
||||||
|
void detachData(std::vector<void*>& data);
|
||||||
|
|
||||||
|
void* getData() const;
|
||||||
|
void release();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void* createDataInstance() const = 0;
|
||||||
|
virtual void deleteDataInstance(void* pData) const = 0;
|
||||||
|
|
||||||
|
#if OPENCV_ABI_COMPATIBILITY > 300
|
||||||
|
private:
|
||||||
|
#else
|
||||||
|
public:
|
||||||
|
#endif
|
||||||
|
int key_;
|
||||||
|
|
||||||
|
friend class cv::details::TlsStorage; // core/src/system.cpp
|
||||||
|
|
||||||
|
public:
|
||||||
|
void cleanup(); //!< Release created TLS data container objects. It is similar to release() call, but it keeps TLS container valid.
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Disable copy/assign (noncopyable pattern)
|
||||||
|
TLSDataContainer(TLSDataContainer &);
|
||||||
|
TLSDataContainer& operator =(const TLSDataContainer &);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Simple TLS data class
|
||||||
|
*
|
||||||
|
* @sa TLSDataAccumulator
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
class TLSData : protected TLSDataContainer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline TLSData() {}
|
||||||
|
inline ~TLSData() { release(); }
|
||||||
|
|
||||||
|
inline T* get() const { return (T*)getData(); } //!< Get data associated with key
|
||||||
|
inline T& getRef() const { T* ptr = (T*)getData(); CV_DbgAssert(ptr); return *ptr; } //!< Get data associated with key
|
||||||
|
|
||||||
|
/// Release associated thread data
|
||||||
|
inline void cleanup()
|
||||||
|
{
|
||||||
|
TLSDataContainer::cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// Wrapper to allocate data by template
|
||||||
|
virtual void* createDataInstance() const CV_OVERRIDE { return new T; }
|
||||||
|
/// Wrapper to release data by template
|
||||||
|
virtual void deleteDataInstance(void* pData) const CV_OVERRIDE { delete (T*)pData; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// TLS data accumulator with gathering methods
|
||||||
|
template <typename T>
|
||||||
|
class TLSDataAccumulator : public TLSData<T>
|
||||||
|
{
|
||||||
|
mutable cv::Mutex mutex;
|
||||||
|
mutable std::vector<T*> dataFromTerminatedThreads;
|
||||||
|
std::vector<T*> detachedData;
|
||||||
|
bool cleanupMode;
|
||||||
|
public:
|
||||||
|
TLSDataAccumulator() : cleanupMode(false) {}
|
||||||
|
~TLSDataAccumulator()
|
||||||
|
{
|
||||||
|
release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Get data from all threads
|
||||||
|
* @deprecated replaced by detachData()
|
||||||
|
*
|
||||||
|
* Lifetime of vector data is valid until next detachData()/cleanup()/release() calls
|
||||||
|
*
|
||||||
|
* @param[out] data result buffer (should be empty)
|
||||||
|
*/
|
||||||
|
void gather(std::vector<T*> &data) const
|
||||||
|
{
|
||||||
|
CV_Assert(cleanupMode == false); // state is not valid
|
||||||
|
CV_Assert(data.empty());
|
||||||
|
{
|
||||||
|
std::vector<void*> &dataVoid = reinterpret_cast<std::vector<void*>&>(data);
|
||||||
|
TLSDataContainer::gatherData(dataVoid);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
AutoLock lock(mutex);
|
||||||
|
data.reserve(data.size() + dataFromTerminatedThreads.size());
|
||||||
|
for (typename std::vector<T*>::const_iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i)
|
||||||
|
{
|
||||||
|
data.push_back((T*)*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Get and detach data from all threads
|
||||||
|
*
|
||||||
|
* Call cleanupDetachedData() when returned vector is not needed anymore.
|
||||||
|
*
|
||||||
|
* @return Vector with associated data. Content is preserved (including lifetime of attached data pointers) until next detachData()/cleanupDetachedData()/cleanup()/release() calls
|
||||||
|
*/
|
||||||
|
std::vector<T*>& detachData()
|
||||||
|
{
|
||||||
|
CV_Assert(cleanupMode == false); // state is not valid
|
||||||
|
std::vector<void*> dataVoid;
|
||||||
|
{
|
||||||
|
TLSDataContainer::detachData(dataVoid);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
AutoLock lock(mutex);
|
||||||
|
detachedData.reserve(dataVoid.size() + dataFromTerminatedThreads.size());
|
||||||
|
for (typename std::vector<T*>::const_iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i)
|
||||||
|
{
|
||||||
|
detachedData.push_back((T*)*i);
|
||||||
|
}
|
||||||
|
dataFromTerminatedThreads.clear();
|
||||||
|
for (typename std::vector<void*>::const_iterator i = dataVoid.begin(); i != dataVoid.end(); ++i)
|
||||||
|
{
|
||||||
|
detachedData.push_back((T*)(void*)*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataVoid.clear();
|
||||||
|
return detachedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Release associated thread data returned by detachData() call
|
||||||
|
void cleanupDetachedData()
|
||||||
|
{
|
||||||
|
AutoLock lock(mutex);
|
||||||
|
cleanupMode = true;
|
||||||
|
_cleanupDetachedData();
|
||||||
|
cleanupMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Release associated thread data
|
||||||
|
void cleanup()
|
||||||
|
{
|
||||||
|
cleanupMode = true;
|
||||||
|
TLSDataContainer::cleanup();
|
||||||
|
|
||||||
|
AutoLock lock(mutex);
|
||||||
|
_cleanupDetachedData();
|
||||||
|
_cleanupTerminatedData();
|
||||||
|
cleanupMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Release associated thread data and free TLS key
|
||||||
|
void release()
|
||||||
|
{
|
||||||
|
cleanupMode = true;
|
||||||
|
TLSDataContainer::release();
|
||||||
|
{
|
||||||
|
AutoLock lock(mutex);
|
||||||
|
_cleanupDetachedData();
|
||||||
|
_cleanupTerminatedData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// synchronized
|
||||||
|
void _cleanupDetachedData()
|
||||||
|
{
|
||||||
|
for (typename std::vector<T*>::iterator i = detachedData.begin(); i != detachedData.end(); ++i)
|
||||||
|
{
|
||||||
|
deleteDataInstance((T*)*i);
|
||||||
|
}
|
||||||
|
detachedData.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// synchronized
|
||||||
|
void _cleanupTerminatedData()
|
||||||
|
{
|
||||||
|
for (typename std::vector<T*>::iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i)
|
||||||
|
{
|
||||||
|
deleteDataInstance((T*)*i);
|
||||||
|
}
|
||||||
|
dataFromTerminatedThreads.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void* createDataInstance() const CV_OVERRIDE
|
||||||
|
{
|
||||||
|
// Note: we can collect all allocated data here, but this would require raced mutex locks
|
||||||
|
return new T;
|
||||||
|
}
|
||||||
|
virtual void deleteDataInstance(void* pData) const CV_OVERRIDE
|
||||||
|
{
|
||||||
|
if (cleanupMode)
|
||||||
|
{
|
||||||
|
delete (T*)pData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AutoLock lock(mutex);
|
||||||
|
dataFromTerminatedThreads.push_back((T*)pData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // OPENCV_UTILS_TLS_HPP
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#ifndef OPENCV_WORLD_HPP
|
||||||
|
#define OPENCV_WORLD_HPP
|
||||||
|
|
||||||
|
#include "opencv2/core.hpp"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace cv
|
||||||
|
{
|
||||||
|
|
||||||
|
CV_EXPORTS_W bool initAll();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue