node-native-win-utils 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -27
- package/binding.gyp +18 -5
- package/dist/index.d.ts +146 -4
- package/dist/index.js +107 -3
- package/include/opencv2/core/affine.hpp +678 -0
- package/include/opencv2/core/async.hpp +105 -0
- package/include/opencv2/core/base.hpp +664 -0
- package/include/opencv2/core/bindings_utils.hpp +325 -0
- package/include/opencv2/core/bufferpool.hpp +40 -0
- package/include/opencv2/core/check.hpp +170 -0
- package/include/opencv2/core/core.hpp +48 -0
- package/include/opencv2/core/core_c.h +3128 -0
- package/include/opencv2/core/cuda/block.hpp +211 -0
- package/include/opencv2/core/cuda/border_interpolate.hpp +722 -0
- package/include/opencv2/core/cuda/color.hpp +309 -0
- package/include/opencv2/core/cuda/common.hpp +131 -0
- package/include/opencv2/core/cuda/datamov_utils.hpp +113 -0
- package/include/opencv2/core/cuda/detail/color_detail.hpp +2018 -0
- package/include/opencv2/core/cuda/detail/reduce.hpp +365 -0
- package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +502 -0
- package/include/opencv2/core/cuda/detail/transform_detail.hpp +392 -0
- package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +191 -0
- package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +121 -0
- package/include/opencv2/core/cuda/dynamic_smem.hpp +88 -0
- package/include/opencv2/core/cuda/emulation.hpp +269 -0
- package/include/opencv2/core/cuda/filters.hpp +293 -0
- package/include/opencv2/core/cuda/funcattrib.hpp +79 -0
- package/include/opencv2/core/cuda/functional.hpp +805 -0
- package/include/opencv2/core/cuda/limits.hpp +128 -0
- package/include/opencv2/core/cuda/reduce.hpp +209 -0
- package/include/opencv2/core/cuda/saturate_cast.hpp +292 -0
- package/include/opencv2/core/cuda/scan.hpp +258 -0
- package/include/opencv2/core/cuda/simd_functions.hpp +869 -0
- package/include/opencv2/core/cuda/transform.hpp +75 -0
- package/include/opencv2/core/cuda/type_traits.hpp +90 -0
- package/include/opencv2/core/cuda/utility.hpp +230 -0
- package/include/opencv2/core/cuda/vec_distance.hpp +232 -0
- package/include/opencv2/core/cuda/vec_math.hpp +923 -0
- package/include/opencv2/core/cuda/vec_traits.hpp +288 -0
- package/include/opencv2/core/cuda/warp.hpp +139 -0
- package/include/opencv2/core/cuda/warp_reduce.hpp +76 -0
- package/include/opencv2/core/cuda/warp_shuffle.hpp +162 -0
- package/include/opencv2/core/cuda.hpp +1279 -0
- package/include/opencv2/core/cuda.inl.hpp +763 -0
- package/include/opencv2/core/cuda_stream_accessor.hpp +86 -0
- package/include/opencv2/core/cuda_types.hpp +144 -0
- package/include/opencv2/core/cv_cpu_dispatch.h +381 -0
- package/include/opencv2/core/cv_cpu_helper.h +550 -0
- package/include/opencv2/core/cvdef.h +973 -0
- package/include/opencv2/core/cvstd.hpp +190 -0
- package/include/opencv2/core/cvstd.inl.hpp +197 -0
- package/include/opencv2/core/cvstd_wrapper.hpp +154 -0
- package/include/opencv2/core/detail/async_promise.hpp +71 -0
- package/include/opencv2/core/detail/dispatch_helper.impl.hpp +49 -0
- package/include/opencv2/core/detail/exception_ptr.hpp +27 -0
- package/include/opencv2/core/directx.hpp +184 -0
- package/include/opencv2/core/dualquaternion.hpp +979 -0
- package/include/opencv2/core/dualquaternion.inl.hpp +487 -0
- package/include/opencv2/core/eigen.hpp +402 -0
- package/include/opencv2/core/fast_math.hpp +433 -0
- package/include/opencv2/core/hal/hal.hpp +256 -0
- package/include/opencv2/core/hal/interface.h +190 -0
- package/include/opencv2/core/hal/intrin.hpp +939 -0
- package/include/opencv2/core/hal/intrin_avx.hpp +3177 -0
- package/include/opencv2/core/hal/intrin_avx512.hpp +3090 -0
- package/include/opencv2/core/hal/intrin_cpp.hpp +3321 -0
- package/include/opencv2/core/hal/intrin_forward.hpp +191 -0
- package/include/opencv2/core/hal/intrin_lasx.hpp +3236 -0
- package/include/opencv2/core/hal/intrin_msa.hpp +1887 -0
- package/include/opencv2/core/hal/intrin_neon.hpp +2610 -0
- package/include/opencv2/core/hal/intrin_rvv.hpp +3320 -0
- package/include/opencv2/core/hal/intrin_rvv071.hpp +2545 -0
- package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +2080 -0
- package/include/opencv2/core/hal/intrin_sse.hpp +3467 -0
- package/include/opencv2/core/hal/intrin_sse_em.hpp +180 -0
- package/include/opencv2/core/hal/intrin_vsx.hpp +1608 -0
- package/include/opencv2/core/hal/intrin_wasm.hpp +2782 -0
- package/include/opencv2/core/hal/msa_macros.h +1558 -0
- package/include/opencv2/core/hal/simd_utils.impl.hpp +186 -0
- package/include/opencv2/core/llapi/llapi.h +102 -0
- package/include/opencv2/core/mat.hpp +3775 -0
- package/include/opencv2/core/mat.inl.hpp +3422 -0
- package/include/opencv2/core/matx.hpp +1536 -0
- package/include/opencv2/core/neon_utils.hpp +128 -0
- package/include/opencv2/core/ocl.hpp +917 -0
- package/include/opencv2/core/ocl_genbase.hpp +69 -0
- package/include/opencv2/core/opencl/ocl_defs.hpp +82 -0
- package/include/opencv2/core/opencl/opencl_info.hpp +212 -0
- package/include/opencv2/core/opencl/opencl_svm.hpp +81 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +602 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +146 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +371 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +272 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +62 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +42 -0
- package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +53 -0
- package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +53 -0
- package/include/opencv2/core/opencl/runtime/opencl_core.hpp +84 -0
- package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +47 -0
- package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +53 -0
- package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +47 -0
- package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +48 -0
- package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +42 -0
- package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +166 -0
- package/include/opencv2/core/opengl.hpp +733 -0
- package/include/opencv2/core/openvx/ovx_defs.hpp +48 -0
- package/include/opencv2/core/operations.hpp +610 -0
- package/include/opencv2/core/optim.hpp +302 -0
- package/include/opencv2/core/ovx.hpp +28 -0
- package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +72 -0
- package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +153 -0
- package/include/opencv2/core/parallel/parallel_backend.hpp +90 -0
- package/include/opencv2/core/persistence.hpp +1350 -0
- package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +30 -0
- package/include/opencv2/core/private.cuda.hpp +169 -0
- package/include/opencv2/core/private.hpp +896 -0
- package/include/opencv2/core/quaternion.hpp +1696 -0
- package/include/opencv2/core/quaternion.inl.hpp +1063 -0
- package/include/opencv2/core/saturate.hpp +180 -0
- package/include/opencv2/core/simd_intrinsics.hpp +87 -0
- package/include/opencv2/core/softfloat.hpp +514 -0
- package/include/opencv2/core/sse_utils.hpp +652 -0
- package/include/opencv2/core/traits.hpp +417 -0
- package/include/opencv2/core/types.hpp +2457 -0
- package/include/opencv2/core/types_c.h +2126 -0
- package/include/opencv2/core/utility.hpp +1229 -0
- package/include/opencv2/core/utils/allocator_stats.hpp +29 -0
- package/include/opencv2/core/utils/allocator_stats.impl.hpp +158 -0
- package/include/opencv2/core/utils/buffer_area.private.hpp +136 -0
- package/include/opencv2/core/utils/configuration.private.hpp +22 -0
- package/include/opencv2/core/utils/filesystem.hpp +82 -0
- package/include/opencv2/core/utils/filesystem.private.hpp +66 -0
- package/include/opencv2/core/utils/fp_control.private.hpp +29 -0
- package/include/opencv2/core/utils/fp_control_utils.hpp +69 -0
- package/include/opencv2/core/utils/instrumentation.hpp +125 -0
- package/include/opencv2/core/utils/lock.private.hpp +119 -0
- package/include/opencv2/core/utils/logger.defines.hpp +42 -0
- package/include/opencv2/core/utils/logger.hpp +218 -0
- package/include/opencv2/core/utils/logtag.hpp +28 -0
- package/include/opencv2/core/utils/plugin_loader.private.hpp +165 -0
- package/include/opencv2/core/utils/tls.hpp +235 -0
- package/include/opencv2/core/utils/trace.hpp +252 -0
- package/include/opencv2/core/utils/trace.private.hpp +421 -0
- package/include/opencv2/core/va_intel.hpp +75 -0
- package/include/opencv2/core/version.hpp +26 -0
- package/include/opencv2/core/vsx_utils.hpp +1047 -0
- package/include/opencv2/core.hpp +3365 -0
- package/include/opencv2/imgcodecs/imgcodecs.hpp +48 -0
- package/include/opencv2/imgcodecs/imgcodecs_c.h +1 -0
- package/include/opencv2/imgcodecs/ios.h +59 -0
- package/include/opencv2/imgcodecs/legacy/constants_c.h +54 -0
- package/include/opencv2/imgcodecs/macosx.h +20 -0
- package/include/opencv2/imgcodecs.hpp +407 -0
- package/include/opencv2/imgproc/bindings.hpp +34 -0
- package/include/opencv2/imgproc/detail/gcgraph.hpp +395 -0
- package/include/opencv2/imgproc/hal/hal.hpp +246 -0
- package/include/opencv2/imgproc/hal/interface.h +46 -0
- package/include/opencv2/imgproc/imgproc.hpp +48 -0
- package/include/opencv2/imgproc/imgproc_c.h +1177 -0
- package/include/opencv2/imgproc/segmentation.hpp +141 -0
- package/include/opencv2/imgproc/types_c.h +659 -0
- package/include/opencv2/imgproc.hpp +5035 -0
- package/include/opencv2/opencv_modules.hpp +17 -0
- package/libs/libjpeg-turbo.lib +0 -0
- package/libs/libpng.lib +0 -0
- package/libs/opencv_core470.lib +0 -0
- package/libs/opencv_imgcodecs470.lib +0 -0
- package/libs/opencv_imgproc470.lib +0 -0
- package/libs/zlib.lib +0 -0
- package/package.json +8 -2
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/cpp/capturewindow.cpp +36 -46
- package/src/cpp/main.cpp +10 -2
- package/src/cpp/opencv.cpp +425 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// This file is part of OpenCV project.
|
|
2
|
+
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
+
// of this distribution and at http://opencv.org/license.html.
|
|
4
|
+
|
|
5
|
+
#ifndef OPENCV_UTILS_INSTR_HPP
|
|
6
|
+
#define OPENCV_UTILS_INSTR_HPP
|
|
7
|
+
|
|
8
|
+
#include <opencv2/core/utility.hpp>
|
|
9
|
+
#include <opencv2/core/utils/tls.hpp>
|
|
10
|
+
|
|
11
|
+
namespace cv {
|
|
12
|
+
|
|
13
|
+
//! @addtogroup core_utils
|
|
14
|
+
//! @{
|
|
15
|
+
|
|
16
|
+
#ifdef CV_COLLECT_IMPL_DATA
|
|
17
|
+
CV_EXPORTS void setImpl(int flags); // set implementation flags and reset storage arrays
|
|
18
|
+
CV_EXPORTS void addImpl(int flag, const char* func = 0); // add implementation and function name to storage arrays
|
|
19
|
+
// Get stored implementation flags and functions names arrays
|
|
20
|
+
// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which function
|
|
21
|
+
CV_EXPORTS int getImpl(std::vector<int> &impl, std::vector<String> &funName);
|
|
22
|
+
|
|
23
|
+
CV_EXPORTS bool useCollection(); // return implementation collection state
|
|
24
|
+
CV_EXPORTS void setUseCollection(bool flag); // set implementation collection state
|
|
25
|
+
|
|
26
|
+
#define CV_IMPL_PLAIN 0x01 // native CPU OpenCV implementation
|
|
27
|
+
#define CV_IMPL_OCL 0x02 // OpenCL implementation
|
|
28
|
+
#define CV_IMPL_IPP 0x04 // IPP implementation
|
|
29
|
+
#define CV_IMPL_MT 0x10 // multithreaded implementation
|
|
30
|
+
|
|
31
|
+
#undef CV_IMPL_ADD
|
|
32
|
+
#define CV_IMPL_ADD(impl) \
|
|
33
|
+
if(cv::useCollection()) \
|
|
34
|
+
{ \
|
|
35
|
+
cv::addImpl(impl, CV_Func); \
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
// Instrumentation external interface
|
|
40
|
+
namespace instr
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
#if !defined OPENCV_ABI_CHECK
|
|
44
|
+
|
|
45
|
+
enum TYPE
|
|
46
|
+
{
|
|
47
|
+
TYPE_GENERAL = 0, // OpenCV API function, e.g. exported function
|
|
48
|
+
TYPE_MARKER, // Information marker
|
|
49
|
+
TYPE_WRAPPER, // Wrapper function for implementation
|
|
50
|
+
TYPE_FUN, // Simple function call
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
enum IMPL
|
|
54
|
+
{
|
|
55
|
+
IMPL_PLAIN = 0,
|
|
56
|
+
IMPL_IPP,
|
|
57
|
+
IMPL_OPENCL,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
struct NodeDataTls
|
|
61
|
+
{
|
|
62
|
+
NodeDataTls()
|
|
63
|
+
{
|
|
64
|
+
m_ticksTotal = 0;
|
|
65
|
+
}
|
|
66
|
+
uint64 m_ticksTotal;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
class CV_EXPORTS NodeData
|
|
70
|
+
{
|
|
71
|
+
public:
|
|
72
|
+
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);
|
|
73
|
+
NodeData(NodeData &ref);
|
|
74
|
+
~NodeData();
|
|
75
|
+
NodeData& operator=(const NodeData&);
|
|
76
|
+
|
|
77
|
+
cv::String m_funName;
|
|
78
|
+
cv::instr::TYPE m_instrType;
|
|
79
|
+
cv::instr::IMPL m_implType;
|
|
80
|
+
const char* m_fileName;
|
|
81
|
+
int m_lineNum;
|
|
82
|
+
void* m_retAddress;
|
|
83
|
+
bool m_alwaysExpand;
|
|
84
|
+
bool m_funError;
|
|
85
|
+
|
|
86
|
+
volatile int m_counter;
|
|
87
|
+
volatile uint64 m_ticksTotal;
|
|
88
|
+
TLSDataAccumulator<NodeDataTls> m_tls;
|
|
89
|
+
int m_threads;
|
|
90
|
+
|
|
91
|
+
// No synchronization
|
|
92
|
+
double getTotalMs() const { return ((double)m_ticksTotal / cv::getTickFrequency()) * 1000; }
|
|
93
|
+
double getMeanMs() const { return (((double)m_ticksTotal/m_counter) / cv::getTickFrequency()) * 1000; }
|
|
94
|
+
};
|
|
95
|
+
bool operator==(const NodeData& lhs, const NodeData& rhs);
|
|
96
|
+
|
|
97
|
+
typedef Node<NodeData> InstrNode;
|
|
98
|
+
|
|
99
|
+
CV_EXPORTS InstrNode* getTrace();
|
|
100
|
+
|
|
101
|
+
#endif // !defined OPENCV_ABI_CHECK
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
CV_EXPORTS bool useInstrumentation();
|
|
105
|
+
CV_EXPORTS void setUseInstrumentation(bool flag);
|
|
106
|
+
CV_EXPORTS void resetTrace();
|
|
107
|
+
|
|
108
|
+
enum FLAGS
|
|
109
|
+
{
|
|
110
|
+
FLAGS_NONE = 0,
|
|
111
|
+
FLAGS_MAPPING = 0x01,
|
|
112
|
+
FLAGS_EXPAND_SAME_NAMES = 0x02,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
CV_EXPORTS void setFlags(FLAGS modeFlags);
|
|
116
|
+
static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); }
|
|
117
|
+
CV_EXPORTS FLAGS getFlags();
|
|
118
|
+
|
|
119
|
+
} // namespace instr
|
|
120
|
+
|
|
121
|
+
//! @}
|
|
122
|
+
|
|
123
|
+
} // namespace
|
|
124
|
+
|
|
125
|
+
#endif // OPENCV_UTILS_TLS_HPP
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// This file is part of OpenCV project.
|
|
2
|
+
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
+
// of this distribution and at http://opencv.org/license.html.
|
|
4
|
+
|
|
5
|
+
#ifndef OPENCV_UTILS_LOCK_HPP
|
|
6
|
+
#define OPENCV_UTILS_LOCK_HPP
|
|
7
|
+
|
|
8
|
+
namespace cv { namespace utils {
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/** @brief A simple scoped lock (RAII-style locking for exclusive/write access).
|
|
12
|
+
*
|
|
13
|
+
* Emulate std::lock_guard (C++11), partially std::unique_lock (C++11),
|
|
14
|
+
*/
|
|
15
|
+
template <class _Mutex>
|
|
16
|
+
class lock_guard {
|
|
17
|
+
public:
|
|
18
|
+
typedef _Mutex Mutex;
|
|
19
|
+
|
|
20
|
+
explicit inline lock_guard(Mutex &m) : mutex_(&m) { mutex_->lock(); }
|
|
21
|
+
|
|
22
|
+
inline ~lock_guard() { if (mutex_) mutex_->unlock(); }
|
|
23
|
+
|
|
24
|
+
inline void release()
|
|
25
|
+
{
|
|
26
|
+
CV_DbgAssert(mutex_);
|
|
27
|
+
mutex_->unlock();
|
|
28
|
+
mutex_ = NULL;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private:
|
|
32
|
+
Mutex* mutex_;
|
|
33
|
+
|
|
34
|
+
private:
|
|
35
|
+
lock_guard(const lock_guard&); // disabled
|
|
36
|
+
lock_guard& operator=(const lock_guard&); // disabled
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/** @brief A shared scoped lock (RAII-style locking for shared/reader access).
|
|
41
|
+
*
|
|
42
|
+
* Emulate boost::shared_lock_guard, subset of std::shared_lock (C++14),
|
|
43
|
+
*/
|
|
44
|
+
template <class _Mutex>
|
|
45
|
+
class shared_lock_guard {
|
|
46
|
+
public:
|
|
47
|
+
typedef _Mutex Mutex;
|
|
48
|
+
|
|
49
|
+
explicit inline shared_lock_guard(Mutex &m) : mutex_(&m) { mutex_->lock_shared(); }
|
|
50
|
+
|
|
51
|
+
inline ~shared_lock_guard() { if (mutex_) mutex_->unlock_shared(); }
|
|
52
|
+
|
|
53
|
+
inline void release()
|
|
54
|
+
{
|
|
55
|
+
CV_DbgAssert(mutex_);
|
|
56
|
+
mutex_->unlock_shared();
|
|
57
|
+
mutex_ = NULL;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected:
|
|
61
|
+
Mutex* mutex_;
|
|
62
|
+
|
|
63
|
+
private:
|
|
64
|
+
shared_lock_guard(const shared_lock_guard&); // disabled
|
|
65
|
+
shared_lock_guard& operator=(const shared_lock_guard&); // disabled
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/** @brief An optional simple scoped lock (RAII-style locking for exclusive/write access).
|
|
70
|
+
*
|
|
71
|
+
* Doesn't lock if mutex pointer is NULL.
|
|
72
|
+
*
|
|
73
|
+
* @sa lock_guard
|
|
74
|
+
*/
|
|
75
|
+
template <class _Mutex>
|
|
76
|
+
class optional_lock_guard {
|
|
77
|
+
public:
|
|
78
|
+
typedef _Mutex Mutex;
|
|
79
|
+
|
|
80
|
+
explicit inline optional_lock_guard(Mutex* m) : mutex_(m) { if (mutex_) mutex_->lock(); }
|
|
81
|
+
|
|
82
|
+
inline ~optional_lock_guard() { if (mutex_) mutex_->unlock(); }
|
|
83
|
+
|
|
84
|
+
private:
|
|
85
|
+
Mutex* mutex_;
|
|
86
|
+
|
|
87
|
+
private:
|
|
88
|
+
optional_lock_guard(const optional_lock_guard&); // disabled
|
|
89
|
+
optional_lock_guard& operator=(const optional_lock_guard&); // disabled
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
/** @brief An optional shared scoped lock (RAII-style locking for shared/reader access).
|
|
94
|
+
*
|
|
95
|
+
* Doesn't lock if mutex pointer is NULL.
|
|
96
|
+
*
|
|
97
|
+
* @sa shared_lock_guard
|
|
98
|
+
*/
|
|
99
|
+
template <class _Mutex>
|
|
100
|
+
class optional_shared_lock_guard {
|
|
101
|
+
public:
|
|
102
|
+
typedef _Mutex Mutex;
|
|
103
|
+
|
|
104
|
+
explicit inline optional_shared_lock_guard(Mutex* m) : mutex_(m) { if (mutex_) mutex_->lock_shared(); }
|
|
105
|
+
|
|
106
|
+
inline ~optional_shared_lock_guard() { if (mutex_) mutex_->unlock_shared(); }
|
|
107
|
+
|
|
108
|
+
protected:
|
|
109
|
+
Mutex* mutex_;
|
|
110
|
+
|
|
111
|
+
private:
|
|
112
|
+
optional_shared_lock_guard(const optional_shared_lock_guard&); // disabled
|
|
113
|
+
optional_shared_lock_guard& operator=(const optional_shared_lock_guard&); // disabled
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
}} // namespace
|
|
118
|
+
|
|
119
|
+
#endif // OPENCV_UTILS_LOCK_HPP
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// This file is part of OpenCV project.
|
|
2
|
+
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
+
// of this distribution and at http://opencv.org/license.html.
|
|
4
|
+
|
|
5
|
+
#ifndef OPENCV_LOGGER_DEFINES_HPP
|
|
6
|
+
#define OPENCV_LOGGER_DEFINES_HPP
|
|
7
|
+
|
|
8
|
+
//! @addtogroup core_logging
|
|
9
|
+
//! @{
|
|
10
|
+
|
|
11
|
+
// Supported logging levels and their semantic
|
|
12
|
+
#define CV_LOG_LEVEL_SILENT 0 //!< for using in setLogLevel() call
|
|
13
|
+
#define CV_LOG_LEVEL_FATAL 1 //!< Fatal (critical) error (unrecoverable internal error)
|
|
14
|
+
#define CV_LOG_LEVEL_ERROR 2 //!< Error message
|
|
15
|
+
#define CV_LOG_LEVEL_WARN 3 //!< Warning message
|
|
16
|
+
#define CV_LOG_LEVEL_INFO 4 //!< Info message
|
|
17
|
+
#define CV_LOG_LEVEL_DEBUG 5 //!< Debug message. Disabled in the "Release" build.
|
|
18
|
+
#define CV_LOG_LEVEL_VERBOSE 6 //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build.
|
|
19
|
+
|
|
20
|
+
namespace cv {
|
|
21
|
+
namespace utils {
|
|
22
|
+
namespace logging {
|
|
23
|
+
|
|
24
|
+
//! Supported logging levels and their semantic
|
|
25
|
+
enum LogLevel {
|
|
26
|
+
LOG_LEVEL_SILENT = 0, //!< for using in setLogVevel() call
|
|
27
|
+
LOG_LEVEL_FATAL = 1, //!< Fatal (critical) error (unrecoverable internal error)
|
|
28
|
+
LOG_LEVEL_ERROR = 2, //!< Error message
|
|
29
|
+
LOG_LEVEL_WARNING = 3, //!< Warning message
|
|
30
|
+
LOG_LEVEL_INFO = 4, //!< Info message
|
|
31
|
+
LOG_LEVEL_DEBUG = 5, //!< Debug message. Disabled in the "Release" build.
|
|
32
|
+
LOG_LEVEL_VERBOSE = 6, //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build.
|
|
33
|
+
#ifndef CV_DOXYGEN
|
|
34
|
+
ENUM_LOG_LEVEL_FORCE_INT = INT_MAX
|
|
35
|
+
#endif
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
}}} // namespace
|
|
39
|
+
|
|
40
|
+
//! @}
|
|
41
|
+
|
|
42
|
+
#endif // OPENCV_LOGGER_DEFINES_HPP
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// This file is part of OpenCV project.
|
|
2
|
+
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
+
// of this distribution and at http://opencv.org/license.html.
|
|
4
|
+
|
|
5
|
+
#ifndef OPENCV_LOGGER_HPP
|
|
6
|
+
#define OPENCV_LOGGER_HPP
|
|
7
|
+
|
|
8
|
+
#include <iostream>
|
|
9
|
+
#include <sstream>
|
|
10
|
+
#include <limits.h> // INT_MAX
|
|
11
|
+
|
|
12
|
+
#include "logger.defines.hpp"
|
|
13
|
+
#include "logtag.hpp"
|
|
14
|
+
|
|
15
|
+
namespace cv {
|
|
16
|
+
namespace utils {
|
|
17
|
+
namespace logging {
|
|
18
|
+
|
|
19
|
+
//! @addtogroup core_logging
|
|
20
|
+
//! @{
|
|
21
|
+
|
|
22
|
+
/** Set global logging level
|
|
23
|
+
@return previous logging level
|
|
24
|
+
*/
|
|
25
|
+
CV_EXPORTS LogLevel setLogLevel(LogLevel logLevel);
|
|
26
|
+
/** Get global logging level */
|
|
27
|
+
CV_EXPORTS LogLevel getLogLevel();
|
|
28
|
+
|
|
29
|
+
CV_EXPORTS void registerLogTag(cv::utils::logging::LogTag* plogtag);
|
|
30
|
+
|
|
31
|
+
CV_EXPORTS void setLogTagLevel(const char* tag, cv::utils::logging::LogLevel level);
|
|
32
|
+
|
|
33
|
+
CV_EXPORTS cv::utils::logging::LogLevel getLogTagLevel(const char* tag);
|
|
34
|
+
|
|
35
|
+
namespace internal {
|
|
36
|
+
|
|
37
|
+
/** Get global log tag */
|
|
38
|
+
CV_EXPORTS cv::utils::logging::LogTag* getGlobalLogTag();
|
|
39
|
+
|
|
40
|
+
/** Write log message */
|
|
41
|
+
CV_EXPORTS void writeLogMessage(LogLevel logLevel, const char* message);
|
|
42
|
+
|
|
43
|
+
/** Write log message */
|
|
44
|
+
CV_EXPORTS void writeLogMessageEx(LogLevel logLevel, const char* tag, const char* file, int line, const char* func, const char* message);
|
|
45
|
+
|
|
46
|
+
} // namespace
|
|
47
|
+
|
|
48
|
+
struct LogTagAuto
|
|
49
|
+
: public LogTag
|
|
50
|
+
{
|
|
51
|
+
inline LogTagAuto(const char* _name, LogLevel _level)
|
|
52
|
+
: LogTag(_name, _level)
|
|
53
|
+
{
|
|
54
|
+
registerLogTag(this);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* \def CV_LOG_STRIP_LEVEL
|
|
60
|
+
*
|
|
61
|
+
* Define CV_LOG_STRIP_LEVEL=CV_LOG_LEVEL_[DEBUG|INFO|WARN|ERROR|FATAL|SILENT] to compile out anything at that and before that logging level
|
|
62
|
+
*/
|
|
63
|
+
#ifndef CV_LOG_STRIP_LEVEL
|
|
64
|
+
# if defined NDEBUG
|
|
65
|
+
# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG
|
|
66
|
+
# else
|
|
67
|
+
# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE
|
|
68
|
+
# endif
|
|
69
|
+
#endif
|
|
70
|
+
|
|
71
|
+
#define CV_LOGTAG_PTR_CAST(expr) static_cast<const cv::utils::logging::LogTag*>(expr)
|
|
72
|
+
|
|
73
|
+
// CV_LOGTAG_EXPAND_NAME is intended to be re-defined (undef and then define again)
|
|
74
|
+
// to allows logging users to use a shorter name argument when calling
|
|
75
|
+
// CV_LOG_WITH_TAG or its related macros such as CV_LOG_INFO.
|
|
76
|
+
//
|
|
77
|
+
// This macro is intended to modify the tag argument as a string (token), via
|
|
78
|
+
// preprocessor token pasting or metaprogramming techniques. A typical usage
|
|
79
|
+
// is to apply a prefix, such as
|
|
80
|
+
// ...... #define CV_LOGTAG_EXPAND_NAME(tag) cv_logtag_##tag
|
|
81
|
+
//
|
|
82
|
+
// It is permitted to re-define to a hard-coded expression, ignoring the tag.
|
|
83
|
+
// This would work identically like the CV_LOGTAG_FALLBACK macro.
|
|
84
|
+
//
|
|
85
|
+
// Important: When the logging macro is called with tag being NULL, a user-defined
|
|
86
|
+
// CV_LOGTAG_EXPAND_NAME may expand it into cv_logtag_0, cv_logtag_NULL, or
|
|
87
|
+
// cv_logtag_nullptr. Use with care. Also be mindful of C++ symbol redefinitions.
|
|
88
|
+
//
|
|
89
|
+
// If there is significant amount of logging code with tag being NULL, it is
|
|
90
|
+
// recommended to use (re-define) CV_LOGTAG_FALLBACK to inject locally a default
|
|
91
|
+
// tag at the beginning of a compilation unit, to minimize lines of code changes.
|
|
92
|
+
//
|
|
93
|
+
#define CV_LOGTAG_EXPAND_NAME(tag) tag
|
|
94
|
+
|
|
95
|
+
// CV_LOGTAG_FALLBACK is intended to be re-defined (undef and then define again)
|
|
96
|
+
// by any other compilation units to provide a log tag when the logging statement
|
|
97
|
+
// does not specify one. The macro needs to expand into a C++ expression that can
|
|
98
|
+
// be static_cast into (cv::utils::logging::LogTag*). Null (nullptr) is permitted.
|
|
99
|
+
#define CV_LOGTAG_FALLBACK nullptr
|
|
100
|
+
|
|
101
|
+
// CV_LOGTAG_GLOBAL is the tag used when a log tag is not specified in the logging
|
|
102
|
+
// statement nor the compilation unit. The macro needs to expand into a C++
|
|
103
|
+
// expression that can be static_cast into (cv::utils::logging::LogTag*). Must be
|
|
104
|
+
// non-null. Do not re-define.
|
|
105
|
+
#define CV_LOGTAG_GLOBAL cv::utils::logging::internal::getGlobalLogTag()
|
|
106
|
+
|
|
107
|
+
#define CV_LOG_WITH_TAG(tag, msgLevel, extra_check0, extra_check1, ...) \
|
|
108
|
+
for(;;) { \
|
|
109
|
+
extra_check0; \
|
|
110
|
+
const auto cv_temp_msglevel = (cv::utils::logging::LogLevel)(msgLevel); \
|
|
111
|
+
if (cv_temp_msglevel >= (CV_LOG_STRIP_LEVEL)) break; \
|
|
112
|
+
auto cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_EXPAND_NAME(tag)); \
|
|
113
|
+
if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_FALLBACK); \
|
|
114
|
+
if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_GLOBAL); \
|
|
115
|
+
if (cv_temp_logtagptr && (cv_temp_msglevel > cv_temp_logtagptr->level)) break; \
|
|
116
|
+
extra_check1; \
|
|
117
|
+
std::stringstream cv_temp_logstream; \
|
|
118
|
+
cv_temp_logstream << __VA_ARGS__; \
|
|
119
|
+
cv::utils::logging::internal::writeLogMessageEx( \
|
|
120
|
+
cv_temp_msglevel, \
|
|
121
|
+
(cv_temp_logtagptr ? cv_temp_logtagptr->name : nullptr), \
|
|
122
|
+
__FILE__, \
|
|
123
|
+
__LINE__, \
|
|
124
|
+
CV_Func, \
|
|
125
|
+
cv_temp_logstream.str().c_str()); \
|
|
126
|
+
break; \
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#define CV_LOG_FATAL(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , , __VA_ARGS__)
|
|
130
|
+
#define CV_LOG_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , , __VA_ARGS__)
|
|
131
|
+
#define CV_LOG_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , , __VA_ARGS__)
|
|
132
|
+
#define CV_LOG_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , , __VA_ARGS__)
|
|
133
|
+
#define CV_LOG_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , , __VA_ARGS__)
|
|
134
|
+
#define CV_LOG_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , , __VA_ARGS__)
|
|
135
|
+
|
|
136
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
|
|
137
|
+
#undef CV_LOG_INFO
|
|
138
|
+
#define CV_LOG_INFO(tag, ...)
|
|
139
|
+
#endif
|
|
140
|
+
|
|
141
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
|
|
142
|
+
#undef CV_LOG_DEBUG
|
|
143
|
+
#define CV_LOG_DEBUG(tag, ...)
|
|
144
|
+
#endif
|
|
145
|
+
|
|
146
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
|
|
147
|
+
#undef CV_LOG_VERBOSE
|
|
148
|
+
#define CV_LOG_VERBOSE(tag, v, ...)
|
|
149
|
+
#endif
|
|
150
|
+
|
|
151
|
+
//! @cond IGNORED
|
|
152
|
+
#define CV__LOG_ONCE_CHECK_PRE \
|
|
153
|
+
static bool _cv_log_once_ ## __LINE__ = false; \
|
|
154
|
+
if (_cv_log_once_ ## __LINE__) break;
|
|
155
|
+
|
|
156
|
+
#define CV__LOG_ONCE_CHECK_POST \
|
|
157
|
+
_cv_log_once_ ## __LINE__ = true;
|
|
158
|
+
|
|
159
|
+
#define CV__LOG_IF_CHECK(logging_cond) \
|
|
160
|
+
if (!(logging_cond)) break;
|
|
161
|
+
|
|
162
|
+
//! @endcond
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
// CV_LOG_ONCE_XXX macros
|
|
166
|
+
|
|
167
|
+
#define CV_LOG_ONCE_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
|
168
|
+
#define CV_LOG_ONCE_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
|
169
|
+
#define CV_LOG_ONCE_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
|
170
|
+
#define CV_LOG_ONCE_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
|
171
|
+
#define CV_LOG_ONCE_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
|
172
|
+
|
|
173
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
|
|
174
|
+
#undef CV_LOG_ONCE_INFO
|
|
175
|
+
#define CV_LOG_ONCE_INFO(tag, ...)
|
|
176
|
+
#endif
|
|
177
|
+
|
|
178
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
|
|
179
|
+
#undef CV_LOG_ONCE_DEBUG
|
|
180
|
+
#define CV_LOG_ONCE_DEBUG(tag, ...)
|
|
181
|
+
#endif
|
|
182
|
+
|
|
183
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
|
|
184
|
+
#undef CV_LOG_ONCE_VERBOSE
|
|
185
|
+
#define CV_LOG_ONCE_VERBOSE(tag, v, ...)
|
|
186
|
+
#endif
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
// CV_LOG_IF_XXX macros
|
|
190
|
+
|
|
191
|
+
#define CV_LOG_IF_FATAL(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
|
192
|
+
#define CV_LOG_IF_ERROR(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
|
193
|
+
#define CV_LOG_IF_WARNING(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
|
194
|
+
#define CV_LOG_IF_INFO(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
|
195
|
+
#define CV_LOG_IF_DEBUG(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
|
196
|
+
#define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
|
197
|
+
|
|
198
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
|
|
199
|
+
#undef CV_LOG_IF_INFO
|
|
200
|
+
#define CV_LOG_IF_INFO(tag, logging_cond, ...)
|
|
201
|
+
#endif
|
|
202
|
+
|
|
203
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
|
|
204
|
+
#undef CV_LOG_IF_DEBUG
|
|
205
|
+
#define CV_LOG_IF_DEBUG(tag, logging_cond, ...)
|
|
206
|
+
#endif
|
|
207
|
+
|
|
208
|
+
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
|
|
209
|
+
#undef CV_LOG_IF_VERBOSE
|
|
210
|
+
#define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...)
|
|
211
|
+
#endif
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
//! @}
|
|
215
|
+
|
|
216
|
+
}}} // namespace
|
|
217
|
+
|
|
218
|
+
#endif // OPENCV_LOGGER_HPP
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// This file is part of OpenCV project.
|
|
2
|
+
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
+
// of this distribution and at http://opencv.org/license.html.
|
|
4
|
+
|
|
5
|
+
#ifndef OPENCV_CORE_LOGTAG_HPP
|
|
6
|
+
#define OPENCV_CORE_LOGTAG_HPP
|
|
7
|
+
|
|
8
|
+
#include "opencv2/core/cvstd.hpp"
|
|
9
|
+
#include "logger.defines.hpp"
|
|
10
|
+
|
|
11
|
+
namespace cv {
|
|
12
|
+
namespace utils {
|
|
13
|
+
namespace logging {
|
|
14
|
+
|
|
15
|
+
struct LogTag
|
|
16
|
+
{
|
|
17
|
+
const char* name;
|
|
18
|
+
LogLevel level;
|
|
19
|
+
|
|
20
|
+
inline LogTag(const char* _name, LogLevel _level)
|
|
21
|
+
: name(_name)
|
|
22
|
+
, level(_level)
|
|
23
|
+
{}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
}}}
|
|
27
|
+
|
|
28
|
+
#endif
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// This file is part of OpenCV project.
|
|
2
|
+
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
+
// of this distribution and at http://opencv.org/license.html.
|
|
4
|
+
|
|
5
|
+
#ifndef OPENCV_UTILS_PLUGIN_LOADER_HPP
|
|
6
|
+
#define OPENCV_UTILS_PLUGIN_LOADER_HPP
|
|
7
|
+
|
|
8
|
+
#include "opencv2/core/utils/filesystem.hpp"
|
|
9
|
+
#include "opencv2/core/utils/filesystem.private.hpp"
|
|
10
|
+
|
|
11
|
+
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
|
|
12
|
+
|
|
13
|
+
#if defined(_WIN32)
|
|
14
|
+
#include <windows.h>
|
|
15
|
+
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__)
|
|
16
|
+
#include <dlfcn.h>
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
namespace cv { namespace plugin { namespace impl {
|
|
20
|
+
|
|
21
|
+
#if defined(_WIN32)
|
|
22
|
+
typedef HMODULE LibHandle_t;
|
|
23
|
+
typedef wchar_t FileSystemChar_t;
|
|
24
|
+
typedef std::wstring FileSystemPath_t;
|
|
25
|
+
|
|
26
|
+
// TODO wchar_t <=> UTF-8
|
|
27
|
+
static inline
|
|
28
|
+
FileSystemPath_t toFileSystemPath(const std::string& p)
|
|
29
|
+
{
|
|
30
|
+
FileSystemPath_t result;
|
|
31
|
+
result.resize(p.size());
|
|
32
|
+
for (size_t i = 0; i < p.size(); i++)
|
|
33
|
+
result[i] = (wchar_t)p[i];
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// TODO wchar_t <=> UTF-8
|
|
38
|
+
static inline
|
|
39
|
+
std::string toPrintablePath(const FileSystemPath_t& p)
|
|
40
|
+
{
|
|
41
|
+
std::string result;
|
|
42
|
+
result.resize(p.size());
|
|
43
|
+
for (size_t i = 0; i < p.size(); i++)
|
|
44
|
+
{
|
|
45
|
+
wchar_t ch = p[i];
|
|
46
|
+
if ((int)ch >= ' ' && (int)ch < 128)
|
|
47
|
+
result[i] = (char)ch;
|
|
48
|
+
else
|
|
49
|
+
result[i] = '?';
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
#else // !_WIN32
|
|
54
|
+
typedef void* LibHandle_t;
|
|
55
|
+
typedef char FileSystemChar_t;
|
|
56
|
+
typedef std::string FileSystemPath_t;
|
|
57
|
+
|
|
58
|
+
static inline FileSystemPath_t toFileSystemPath(const std::string& p) { return p; }
|
|
59
|
+
static inline std::string toPrintablePath(const FileSystemPath_t& p) { return p; }
|
|
60
|
+
#endif
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
static inline
|
|
64
|
+
void* getSymbol_(LibHandle_t h, const char* symbolName)
|
|
65
|
+
{
|
|
66
|
+
#if defined(_WIN32)
|
|
67
|
+
return (void*)GetProcAddress(h, symbolName);
|
|
68
|
+
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__)
|
|
69
|
+
return dlsym(h, symbolName);
|
|
70
|
+
#endif
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static inline
|
|
74
|
+
LibHandle_t libraryLoad_(const FileSystemPath_t& filename)
|
|
75
|
+
{
|
|
76
|
+
#if defined(_WIN32)
|
|
77
|
+
# ifdef WINRT
|
|
78
|
+
return LoadPackagedLibrary(filename.c_str(), 0);
|
|
79
|
+
# else
|
|
80
|
+
return LoadLibraryW(filename.c_str());
|
|
81
|
+
#endif
|
|
82
|
+
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__)
|
|
83
|
+
void* handle = dlopen(filename.c_str(), RTLD_NOW);
|
|
84
|
+
CV_LOG_IF_DEBUG(NULL, !handle, "dlopen() error: " << dlerror());
|
|
85
|
+
return handle;
|
|
86
|
+
#endif
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static inline
|
|
90
|
+
void libraryRelease_(LibHandle_t h)
|
|
91
|
+
{
|
|
92
|
+
#if defined(_WIN32)
|
|
93
|
+
FreeLibrary(h);
|
|
94
|
+
#elif defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__GLIBC__)
|
|
95
|
+
dlclose(h);
|
|
96
|
+
#endif
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static inline
|
|
100
|
+
std::string libraryPrefix()
|
|
101
|
+
{
|
|
102
|
+
#if defined(_WIN32)
|
|
103
|
+
return "";
|
|
104
|
+
#else
|
|
105
|
+
return "lib";
|
|
106
|
+
#endif
|
|
107
|
+
}
|
|
108
|
+
static inline
|
|
109
|
+
std::string librarySuffix()
|
|
110
|
+
{
|
|
111
|
+
#if defined(_WIN32)
|
|
112
|
+
const char* suffix = ""
|
|
113
|
+
CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
|
|
114
|
+
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
|
|
115
|
+
"_64"
|
|
116
|
+
#endif
|
|
117
|
+
#if defined(_DEBUG) && defined(DEBUG_POSTFIX)
|
|
118
|
+
CVAUX_STR(DEBUG_POSTFIX)
|
|
119
|
+
#endif
|
|
120
|
+
".dll";
|
|
121
|
+
return suffix;
|
|
122
|
+
#else
|
|
123
|
+
return ".so";
|
|
124
|
+
#endif
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
//============================
|
|
129
|
+
|
|
130
|
+
class CV_EXPORTS DynamicLib
|
|
131
|
+
{
|
|
132
|
+
private:
|
|
133
|
+
LibHandle_t handle;
|
|
134
|
+
const FileSystemPath_t fname;
|
|
135
|
+
bool disableAutoUnloading_;
|
|
136
|
+
|
|
137
|
+
public:
|
|
138
|
+
DynamicLib(const FileSystemPath_t& filename);
|
|
139
|
+
~DynamicLib();
|
|
140
|
+
/** Do not automatically unload library in destructor */
|
|
141
|
+
inline void disableAutomaticLibraryUnloading()
|
|
142
|
+
{
|
|
143
|
+
disableAutoUnloading_ = true;
|
|
144
|
+
}
|
|
145
|
+
inline bool isLoaded() const
|
|
146
|
+
{
|
|
147
|
+
return handle != NULL;
|
|
148
|
+
}
|
|
149
|
+
void* getSymbol(const char* symbolName) const;
|
|
150
|
+
std::string getName() const;
|
|
151
|
+
private:
|
|
152
|
+
void libraryLoad(const FileSystemPath_t& filename);
|
|
153
|
+
void libraryRelease();
|
|
154
|
+
|
|
155
|
+
private:
|
|
156
|
+
DynamicLib(const DynamicLib &) = delete;
|
|
157
|
+
DynamicLib &operator=(const DynamicLib &) = delete;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
}}} // namespace
|
|
162
|
+
|
|
163
|
+
#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
|
|
164
|
+
|
|
165
|
+
#endif // OPENCV_UTILS_PLUGIN_LOADER_HPP
|