node-native-win-utils 1.3.4 → 2.1.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.
Files changed (191) hide show
  1. package/README.md +30 -83
  2. package/binding.gyp +3 -0
  3. package/dist/dirnameLocal.cjs +4 -0
  4. package/dist/dirnameLocal.d.cts +1 -0
  5. package/dist/dirnameLocal.d.mts +1 -0
  6. package/dist/dirnameLocal.mjs +2 -0
  7. package/dist/{index.js → index.cjs} +49 -17
  8. package/dist/{index.d.ts → index.d.cts} +25 -12
  9. package/dist/index.d.mts +191 -0
  10. package/dist/index.mjs +177 -0
  11. package/dist/keyCodes.d.mts +101 -0
  12. package/dist/keyCodes.mjs +201 -0
  13. package/node22.json +16 -0
  14. package/package.json +22 -9
  15. package/prebuilds/win32-x64/node-native-win-utils.node +0 -0
  16. package/prebuilds/win32-x64/tesseract.dll +0 -0
  17. package/prebuilds/win32-x64/tiff.dll +0 -0
  18. package/src/cpp/keyboard.cpp +141 -140
  19. package/src/cpp/main.cpp +11 -3
  20. package/src/cpp/{capturewindow.cpp → screenshot.cpp} +174 -2
  21. package/src/cpp/tesseract.cpp +49 -0
  22. package/src/dirnameLocal.mts +3 -0
  23. package/src/index.mts +454 -0
  24. package/src/keyCodes.mts +203 -0
  25. package/include/opencv2/core/affine.hpp +0 -678
  26. package/include/opencv2/core/async.hpp +0 -105
  27. package/include/opencv2/core/base.hpp +0 -664
  28. package/include/opencv2/core/bindings_utils.hpp +0 -325
  29. package/include/opencv2/core/bufferpool.hpp +0 -40
  30. package/include/opencv2/core/check.hpp +0 -170
  31. package/include/opencv2/core/core.hpp +0 -48
  32. package/include/opencv2/core/core_c.h +0 -3128
  33. package/include/opencv2/core/cuda/block.hpp +0 -211
  34. package/include/opencv2/core/cuda/border_interpolate.hpp +0 -722
  35. package/include/opencv2/core/cuda/color.hpp +0 -309
  36. package/include/opencv2/core/cuda/common.hpp +0 -131
  37. package/include/opencv2/core/cuda/datamov_utils.hpp +0 -113
  38. package/include/opencv2/core/cuda/detail/color_detail.hpp +0 -2018
  39. package/include/opencv2/core/cuda/detail/reduce.hpp +0 -365
  40. package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +0 -502
  41. package/include/opencv2/core/cuda/detail/transform_detail.hpp +0 -392
  42. package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +0 -191
  43. package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +0 -121
  44. package/include/opencv2/core/cuda/dynamic_smem.hpp +0 -88
  45. package/include/opencv2/core/cuda/emulation.hpp +0 -269
  46. package/include/opencv2/core/cuda/filters.hpp +0 -293
  47. package/include/opencv2/core/cuda/funcattrib.hpp +0 -79
  48. package/include/opencv2/core/cuda/functional.hpp +0 -805
  49. package/include/opencv2/core/cuda/limits.hpp +0 -128
  50. package/include/opencv2/core/cuda/reduce.hpp +0 -209
  51. package/include/opencv2/core/cuda/saturate_cast.hpp +0 -292
  52. package/include/opencv2/core/cuda/scan.hpp +0 -258
  53. package/include/opencv2/core/cuda/simd_functions.hpp +0 -869
  54. package/include/opencv2/core/cuda/transform.hpp +0 -75
  55. package/include/opencv2/core/cuda/type_traits.hpp +0 -90
  56. package/include/opencv2/core/cuda/utility.hpp +0 -230
  57. package/include/opencv2/core/cuda/vec_distance.hpp +0 -232
  58. package/include/opencv2/core/cuda/vec_math.hpp +0 -923
  59. package/include/opencv2/core/cuda/vec_traits.hpp +0 -288
  60. package/include/opencv2/core/cuda/warp.hpp +0 -139
  61. package/include/opencv2/core/cuda/warp_reduce.hpp +0 -76
  62. package/include/opencv2/core/cuda/warp_shuffle.hpp +0 -162
  63. package/include/opencv2/core/cuda.hpp +0 -1279
  64. package/include/opencv2/core/cuda.inl.hpp +0 -763
  65. package/include/opencv2/core/cuda_stream_accessor.hpp +0 -86
  66. package/include/opencv2/core/cuda_types.hpp +0 -144
  67. package/include/opencv2/core/cv_cpu_dispatch.h +0 -381
  68. package/include/opencv2/core/cv_cpu_helper.h +0 -550
  69. package/include/opencv2/core/cvdef.h +0 -973
  70. package/include/opencv2/core/cvstd.hpp +0 -190
  71. package/include/opencv2/core/cvstd.inl.hpp +0 -197
  72. package/include/opencv2/core/cvstd_wrapper.hpp +0 -154
  73. package/include/opencv2/core/detail/async_promise.hpp +0 -71
  74. package/include/opencv2/core/detail/dispatch_helper.impl.hpp +0 -49
  75. package/include/opencv2/core/detail/exception_ptr.hpp +0 -27
  76. package/include/opencv2/core/directx.hpp +0 -184
  77. package/include/opencv2/core/dualquaternion.hpp +0 -979
  78. package/include/opencv2/core/dualquaternion.inl.hpp +0 -487
  79. package/include/opencv2/core/eigen.hpp +0 -402
  80. package/include/opencv2/core/fast_math.hpp +0 -433
  81. package/include/opencv2/core/hal/hal.hpp +0 -256
  82. package/include/opencv2/core/hal/interface.h +0 -190
  83. package/include/opencv2/core/hal/intrin.hpp +0 -939
  84. package/include/opencv2/core/hal/intrin_avx.hpp +0 -3177
  85. package/include/opencv2/core/hal/intrin_avx512.hpp +0 -3090
  86. package/include/opencv2/core/hal/intrin_cpp.hpp +0 -3321
  87. package/include/opencv2/core/hal/intrin_forward.hpp +0 -191
  88. package/include/opencv2/core/hal/intrin_lasx.hpp +0 -3236
  89. package/include/opencv2/core/hal/intrin_msa.hpp +0 -1887
  90. package/include/opencv2/core/hal/intrin_neon.hpp +0 -2610
  91. package/include/opencv2/core/hal/intrin_rvv.hpp +0 -3320
  92. package/include/opencv2/core/hal/intrin_rvv071.hpp +0 -2545
  93. package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +0 -2080
  94. package/include/opencv2/core/hal/intrin_sse.hpp +0 -3467
  95. package/include/opencv2/core/hal/intrin_sse_em.hpp +0 -180
  96. package/include/opencv2/core/hal/intrin_vsx.hpp +0 -1608
  97. package/include/opencv2/core/hal/intrin_wasm.hpp +0 -2782
  98. package/include/opencv2/core/hal/msa_macros.h +0 -1558
  99. package/include/opencv2/core/hal/simd_utils.impl.hpp +0 -186
  100. package/include/opencv2/core/llapi/llapi.h +0 -102
  101. package/include/opencv2/core/mat.hpp +0 -3775
  102. package/include/opencv2/core/mat.inl.hpp +0 -3422
  103. package/include/opencv2/core/matx.hpp +0 -1536
  104. package/include/opencv2/core/neon_utils.hpp +0 -128
  105. package/include/opencv2/core/ocl.hpp +0 -917
  106. package/include/opencv2/core/ocl_genbase.hpp +0 -69
  107. package/include/opencv2/core/opencl/ocl_defs.hpp +0 -82
  108. package/include/opencv2/core/opencl/opencl_info.hpp +0 -212
  109. package/include/opencv2/core/opencl/opencl_svm.hpp +0 -81
  110. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +0 -602
  111. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +0 -146
  112. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +0 -371
  113. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +0 -272
  114. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +0 -62
  115. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +0 -42
  116. package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +0 -53
  117. package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +0 -53
  118. package/include/opencv2/core/opencl/runtime/opencl_core.hpp +0 -84
  119. package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +0 -47
  120. package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +0 -53
  121. package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +0 -47
  122. package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +0 -48
  123. package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +0 -42
  124. package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +0 -166
  125. package/include/opencv2/core/opengl.hpp +0 -733
  126. package/include/opencv2/core/openvx/ovx_defs.hpp +0 -48
  127. package/include/opencv2/core/operations.hpp +0 -610
  128. package/include/opencv2/core/optim.hpp +0 -302
  129. package/include/opencv2/core/ovx.hpp +0 -28
  130. package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +0 -72
  131. package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +0 -153
  132. package/include/opencv2/core/parallel/parallel_backend.hpp +0 -90
  133. package/include/opencv2/core/persistence.hpp +0 -1350
  134. package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +0 -30
  135. package/include/opencv2/core/private.cuda.hpp +0 -169
  136. package/include/opencv2/core/private.hpp +0 -896
  137. package/include/opencv2/core/quaternion.hpp +0 -1696
  138. package/include/opencv2/core/quaternion.inl.hpp +0 -1063
  139. package/include/opencv2/core/saturate.hpp +0 -180
  140. package/include/opencv2/core/simd_intrinsics.hpp +0 -87
  141. package/include/opencv2/core/softfloat.hpp +0 -514
  142. package/include/opencv2/core/sse_utils.hpp +0 -652
  143. package/include/opencv2/core/traits.hpp +0 -417
  144. package/include/opencv2/core/types.hpp +0 -2457
  145. package/include/opencv2/core/types_c.h +0 -2126
  146. package/include/opencv2/core/utility.hpp +0 -1229
  147. package/include/opencv2/core/utils/allocator_stats.hpp +0 -29
  148. package/include/opencv2/core/utils/allocator_stats.impl.hpp +0 -158
  149. package/include/opencv2/core/utils/buffer_area.private.hpp +0 -136
  150. package/include/opencv2/core/utils/configuration.private.hpp +0 -22
  151. package/include/opencv2/core/utils/filesystem.hpp +0 -82
  152. package/include/opencv2/core/utils/filesystem.private.hpp +0 -66
  153. package/include/opencv2/core/utils/fp_control.private.hpp +0 -29
  154. package/include/opencv2/core/utils/fp_control_utils.hpp +0 -69
  155. package/include/opencv2/core/utils/instrumentation.hpp +0 -125
  156. package/include/opencv2/core/utils/lock.private.hpp +0 -119
  157. package/include/opencv2/core/utils/logger.defines.hpp +0 -42
  158. package/include/opencv2/core/utils/logger.hpp +0 -218
  159. package/include/opencv2/core/utils/logtag.hpp +0 -28
  160. package/include/opencv2/core/utils/plugin_loader.private.hpp +0 -165
  161. package/include/opencv2/core/utils/tls.hpp +0 -235
  162. package/include/opencv2/core/utils/trace.hpp +0 -252
  163. package/include/opencv2/core/utils/trace.private.hpp +0 -421
  164. package/include/opencv2/core/va_intel.hpp +0 -75
  165. package/include/opencv2/core/version.hpp +0 -26
  166. package/include/opencv2/core/vsx_utils.hpp +0 -1047
  167. package/include/opencv2/core.hpp +0 -3365
  168. package/include/opencv2/imgcodecs/imgcodecs.hpp +0 -48
  169. package/include/opencv2/imgcodecs/imgcodecs_c.h +0 -1
  170. package/include/opencv2/imgcodecs/ios.h +0 -59
  171. package/include/opencv2/imgcodecs/legacy/constants_c.h +0 -54
  172. package/include/opencv2/imgcodecs/macosx.h +0 -20
  173. package/include/opencv2/imgcodecs.hpp +0 -407
  174. package/include/opencv2/imgproc/bindings.hpp +0 -34
  175. package/include/opencv2/imgproc/detail/gcgraph.hpp +0 -395
  176. package/include/opencv2/imgproc/hal/hal.hpp +0 -246
  177. package/include/opencv2/imgproc/hal/interface.h +0 -46
  178. package/include/opencv2/imgproc/imgproc.hpp +0 -48
  179. package/include/opencv2/imgproc/imgproc_c.h +0 -1177
  180. package/include/opencv2/imgproc/segmentation.hpp +0 -141
  181. package/include/opencv2/imgproc/types_c.h +0 -659
  182. package/include/opencv2/imgproc.hpp +0 -5035
  183. package/include/opencv2/opencv_modules.hpp +0 -17
  184. package/libs/libjpeg-turbo.lib +0 -0
  185. package/libs/libpng.lib +0 -0
  186. package/libs/opencv_core470.lib +0 -0
  187. package/libs/opencv_imgcodecs470.lib +0 -0
  188. package/libs/opencv_imgproc470.lib +0 -0
  189. package/libs/zlib.lib +0 -0
  190. /package/dist/{keyCodes.js → keyCodes.cjs} +0 -0
  191. /package/dist/{keyCodes.d.ts → keyCodes.d.cts} +0 -0
@@ -1,48 +0,0 @@
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
- // Copyright (C) 2016, Intel Corporation, all rights reserved.
6
- // Third party copyrights are property of their respective owners.
7
-
8
- // OpenVX related definitions and declarations
9
-
10
- #pragma once
11
- #ifndef OPENCV_OVX_DEFS_HPP
12
- #define OPENCV_OVX_DEFS_HPP
13
-
14
- #include "cvconfig.h"
15
-
16
- // utility macro for running OpenVX-based implementations
17
- #ifdef HAVE_OPENVX
18
-
19
- #define IVX_HIDE_INFO_WARNINGS
20
- #define IVX_USE_OPENCV
21
- #include "ivx.hpp"
22
-
23
- namespace cv{
24
- namespace ovx{
25
- // Get common thread local OpenVX context
26
- CV_EXPORTS_W ivx::Context& getOpenVXContext();
27
-
28
- template <int kernel_id> inline bool skipSmallImages(int w, int h) { return w*h < 3840 * 2160; }
29
- }}
30
-
31
- #define CV_OVX_RUN(condition, func, ...) \
32
- if (cv::useOpenVX() && (condition) && func) \
33
- { \
34
- return __VA_ARGS__; \
35
- }
36
-
37
- #else
38
- #define CV_OVX_RUN(condition, func, ...)
39
- #endif // HAVE_OPENVX
40
-
41
- // Throw an error in debug mode or try another implementation in release
42
- #ifdef _DEBUG
43
- #define VX_DbgThrow(s) CV_Error(cv::Error::StsInternal, (s))
44
- #else
45
- #define VX_DbgThrow(s) return false
46
- #endif
47
-
48
- #endif // OPENCV_OVX_DEFS_HPP
@@ -1,610 +0,0 @@
1
- /*M///////////////////////////////////////////////////////////////////////////////////////
2
- //
3
- // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
- //
5
- // By downloading, copying, installing or using the software you agree to this license.
6
- // If you do not agree to this license, do not download, install,
7
- // copy or use the software.
8
- //
9
- //
10
- // License Agreement
11
- // For Open Source Computer Vision Library
12
- //
13
- // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14
- // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
- // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
16
- // Copyright (C) 2015, Itseez Inc., all rights reserved.
17
- // Third party copyrights are property of their respective owners.
18
- //
19
- // Redistribution and use in source and binary forms, with or without modification,
20
- // are permitted provided that the following conditions are met:
21
- //
22
- // * Redistribution's of source code must retain the above copyright notice,
23
- // this list of conditions and the following disclaimer.
24
- //
25
- // * Redistribution's in binary form must reproduce the above copyright notice,
26
- // this list of conditions and the following disclaimer in the documentation
27
- // and/or other materials provided with the distribution.
28
- //
29
- // * The name of the copyright holders may not be used to endorse or promote products
30
- // derived from this software without specific prior written permission.
31
- //
32
- // This software is provided by the copyright holders and contributors "as is" and
33
- // any express or implied warranties, including, but not limited to, the implied
34
- // warranties of merchantability and fitness for a particular purpose are disclaimed.
35
- // In no event shall the Intel Corporation or contributors be liable for any direct,
36
- // indirect, incidental, special, exemplary, or consequential damages
37
- // (including, but not limited to, procurement of substitute goods or services;
38
- // loss of use, data, or profits; or business interruption) however caused
39
- // and on any theory of liability, whether in contract, strict liability,
40
- // or tort (including negligence or otherwise) arising in any way out of
41
- // the use of this software, even if advised of the possibility of such damage.
42
- //
43
- //M*/
44
-
45
- #ifndef OPENCV_CORE_OPERATIONS_HPP
46
- #define OPENCV_CORE_OPERATIONS_HPP
47
-
48
- #ifndef __cplusplus
49
- # error operations.hpp header must be compiled as C++
50
- #endif
51
-
52
- #include <cstdio>
53
-
54
- #if defined(__GNUC__) || defined(__clang__) // at least GCC 3.1+, clang 3.5+
55
- # if defined(__MINGW_PRINTF_FORMAT) // https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/.
56
- # define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (__MINGW_PRINTF_FORMAT, string_idx, first_to_check)))
57
- # else
58
- # define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (printf, string_idx, first_to_check)))
59
- # endif
60
- #else
61
- # define CV_FORMAT_PRINTF(A, B)
62
- #endif
63
-
64
- //! @cond IGNORED
65
-
66
- namespace cv
67
- {
68
-
69
- ////////////////////////////// Matx methods depending on core API /////////////////////////////
70
-
71
- namespace internal
72
- {
73
-
74
- template<typename _Tp, int m, int n> struct Matx_FastInvOp
75
- {
76
- bool operator()(const Matx<_Tp, m, n>& a, Matx<_Tp, n, m>& b, int method) const
77
- {
78
- return invert(a, b, method) != 0;
79
- }
80
- };
81
-
82
- template<typename _Tp, int m> struct Matx_FastInvOp<_Tp, m, m>
83
- {
84
- bool operator()(const Matx<_Tp, m, m>& a, Matx<_Tp, m, m>& b, int method) const
85
- {
86
- if (method == DECOMP_LU || method == DECOMP_CHOLESKY)
87
- {
88
- Matx<_Tp, m, m> temp = a;
89
-
90
- // assume that b is all 0's on input => make it a unity matrix
91
- for (int i = 0; i < m; i++)
92
- b(i, i) = (_Tp)1;
93
-
94
- if (method == DECOMP_CHOLESKY)
95
- return Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m);
96
-
97
- return LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0;
98
- }
99
- else
100
- {
101
- return invert(a, b, method) != 0;
102
- }
103
- }
104
- };
105
-
106
- template<typename _Tp> struct Matx_FastInvOp<_Tp, 2, 2>
107
- {
108
- bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int /*method*/) const
109
- {
110
- _Tp d = (_Tp)determinant(a);
111
- if (d == 0)
112
- return false;
113
- d = 1/d;
114
- b(1,1) = a(0,0)*d;
115
- b(0,0) = a(1,1)*d;
116
- b(0,1) = -a(0,1)*d;
117
- b(1,0) = -a(1,0)*d;
118
- return true;
119
- }
120
- };
121
-
122
- template<typename _Tp> struct Matx_FastInvOp<_Tp, 3, 3>
123
- {
124
- bool operator()(const Matx<_Tp, 3, 3>& a, Matx<_Tp, 3, 3>& b, int /*method*/) const
125
- {
126
- _Tp d = (_Tp)determinant(a);
127
- if (d == 0)
128
- return false;
129
- d = 1/d;
130
- b(0,0) = (a(1,1) * a(2,2) - a(1,2) * a(2,1)) * d;
131
- b(0,1) = (a(0,2) * a(2,1) - a(0,1) * a(2,2)) * d;
132
- b(0,2) = (a(0,1) * a(1,2) - a(0,2) * a(1,1)) * d;
133
-
134
- b(1,0) = (a(1,2) * a(2,0) - a(1,0) * a(2,2)) * d;
135
- b(1,1) = (a(0,0) * a(2,2) - a(0,2) * a(2,0)) * d;
136
- b(1,2) = (a(0,2) * a(1,0) - a(0,0) * a(1,2)) * d;
137
-
138
- b(2,0) = (a(1,0) * a(2,1) - a(1,1) * a(2,0)) * d;
139
- b(2,1) = (a(0,1) * a(2,0) - a(0,0) * a(2,1)) * d;
140
- b(2,2) = (a(0,0) * a(1,1) - a(0,1) * a(1,0)) * d;
141
- return true;
142
- }
143
- };
144
-
145
-
146
- template<typename _Tp, int m, int l, int n> struct Matx_FastSolveOp
147
- {
148
- bool operator()(const Matx<_Tp, m, l>& a, const Matx<_Tp, m, n>& b,
149
- Matx<_Tp, l, n>& x, int method) const
150
- {
151
- return cv::solve(a, b, x, method);
152
- }
153
- };
154
-
155
- template<typename _Tp, int m, int n> struct Matx_FastSolveOp<_Tp, m, m, n>
156
- {
157
- bool operator()(const Matx<_Tp, m, m>& a, const Matx<_Tp, m, n>& b,
158
- Matx<_Tp, m, n>& x, int method) const
159
- {
160
- if (method == DECOMP_LU || method == DECOMP_CHOLESKY)
161
- {
162
- Matx<_Tp, m, m> temp = a;
163
- x = b;
164
- if( method == DECOMP_CHOLESKY )
165
- return Cholesky(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n);
166
-
167
- return LU(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n) != 0;
168
- }
169
- else
170
- {
171
- return cv::solve(a, b, x, method);
172
- }
173
- }
174
- };
175
-
176
- template<typename _Tp> struct Matx_FastSolveOp<_Tp, 2, 2, 1>
177
- {
178
- bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b,
179
- Matx<_Tp, 2, 1>& x, int) const
180
- {
181
- _Tp d = (_Tp)determinant(a);
182
- if (d == 0)
183
- return false;
184
- d = 1/d;
185
- x(0) = (b(0)*a(1,1) - b(1)*a(0,1))*d;
186
- x(1) = (b(1)*a(0,0) - b(0)*a(1,0))*d;
187
- return true;
188
- }
189
- };
190
-
191
- template<typename _Tp> struct Matx_FastSolveOp<_Tp, 3, 3, 1>
192
- {
193
- bool operator()(const Matx<_Tp, 3, 3>& a, const Matx<_Tp, 3, 1>& b,
194
- Matx<_Tp, 3, 1>& x, int) const
195
- {
196
- _Tp d = (_Tp)determinant(a);
197
- if (d == 0)
198
- return false;
199
- d = 1/d;
200
- x(0) = d*(b(0)*(a(1,1)*a(2,2) - a(1,2)*a(2,1)) -
201
- a(0,1)*(b(1)*a(2,2) - a(1,2)*b(2)) +
202
- a(0,2)*(b(1)*a(2,1) - a(1,1)*b(2)));
203
-
204
- x(1) = d*(a(0,0)*(b(1)*a(2,2) - a(1,2)*b(2)) -
205
- b(0)*(a(1,0)*a(2,2) - a(1,2)*a(2,0)) +
206
- a(0,2)*(a(1,0)*b(2) - b(1)*a(2,0)));
207
-
208
- x(2) = d*(a(0,0)*(a(1,1)*b(2) - b(1)*a(2,1)) -
209
- a(0,1)*(a(1,0)*b(2) - b(1)*a(2,0)) +
210
- b(0)*(a(1,0)*a(2,1) - a(1,1)*a(2,0)));
211
- return true;
212
- }
213
- };
214
-
215
- } // internal
216
-
217
- template<typename _Tp, int m, int n> inline
218
- Matx<_Tp,m,n> Matx<_Tp,m,n>::randu(_Tp a, _Tp b)
219
- {
220
- Matx<_Tp,m,n> M;
221
- cv::randu(M, Scalar(a), Scalar(b));
222
- return M;
223
- }
224
-
225
- template<typename _Tp, int m, int n> inline
226
- Matx<_Tp,m,n> Matx<_Tp,m,n>::randn(_Tp a, _Tp b)
227
- {
228
- Matx<_Tp,m,n> M;
229
- cv::randn(M, Scalar(a), Scalar(b));
230
- return M;
231
- }
232
-
233
- template<typename _Tp, int cn> inline
234
- Vec<_Tp, cn> Vec<_Tp, cn>::randu(_Tp a, _Tp b)
235
- {
236
- Vec<_Tp,cn> V;
237
- cv::randu(V, Scalar(a), Scalar(b));
238
- return V;
239
- }
240
-
241
- template<typename _Tp, int cn> inline
242
- Vec<_Tp, cn> Vec<_Tp, cn>::randn(_Tp a, _Tp b)
243
- {
244
- Vec<_Tp,cn> V;
245
- cv::randn(V, Scalar(a), Scalar(b));
246
- return V;
247
- }
248
-
249
- template<typename _Tp, int m, int n> inline
250
- Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const
251
- {
252
- Matx<_Tp, n, m> b;
253
- bool ok = cv::internal::Matx_FastInvOp<_Tp, m, n>()(*this, b, method);
254
- if (p_is_ok) *p_is_ok = ok;
255
- return ok ? b : Matx<_Tp, n, m>::zeros();
256
- }
257
-
258
- template<typename _Tp, int m, int n> template<int l> inline
259
- Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) const
260
- {
261
- Matx<_Tp, n, l> x;
262
- bool ok = cv::internal::Matx_FastSolveOp<_Tp, m, n, l>()(*this, rhs, x, method);
263
- return ok ? x : Matx<_Tp, n, l>::zeros();
264
- }
265
-
266
-
267
-
268
- ////////////////////////// Augmenting algebraic & logical operations //////////////////////////
269
-
270
- #define CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \
271
- static inline A& operator op (A& a, const B& b) { cvop; return a; }
272
-
273
- #define CV_MAT_AUG_OPERATOR(op, cvop, A, B) \
274
- CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \
275
- CV_MAT_AUG_OPERATOR1(op, cvop, const A, B)
276
-
277
- #define CV_MAT_AUG_OPERATOR_T(op, cvop, A, B) \
278
- template<typename _Tp> CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \
279
- template<typename _Tp> CV_MAT_AUG_OPERATOR1(op, cvop, const A, B)
280
-
281
- #define CV_MAT_AUG_OPERATOR_TN(op, cvop, A) \
282
- template<typename _Tp, int m, int n> static inline A& operator op (A& a, const Matx<_Tp,m,n>& b) { cvop; return a; } \
283
- template<typename _Tp, int m, int n> static inline const A& operator op (const A& a, const Matx<_Tp,m,n>& b) { cvop; return a; }
284
-
285
- CV_MAT_AUG_OPERATOR (+=, cv::add(a, b, (const Mat&)a), Mat, Mat)
286
- CV_MAT_AUG_OPERATOR (+=, cv::add(a, b, (const Mat&)a), Mat, Scalar)
287
- CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
288
- CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
289
- CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
290
- CV_MAT_AUG_OPERATOR_TN(+=, cv::add(a, Mat(b), (const Mat&)a), Mat)
291
- CV_MAT_AUG_OPERATOR_TN(+=, cv::add(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
292
-
293
- CV_MAT_AUG_OPERATOR (-=, cv::subtract(a, b, (const Mat&)a), Mat, Mat)
294
- CV_MAT_AUG_OPERATOR (-=, cv::subtract(a, b, (const Mat&)a), Mat, Scalar)
295
- CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
296
- CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
297
- CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
298
- CV_MAT_AUG_OPERATOR_TN(-=, cv::subtract(a, Mat(b), (const Mat&)a), Mat)
299
- CV_MAT_AUG_OPERATOR_TN(-=, cv::subtract(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
300
-
301
- CV_MAT_AUG_OPERATOR (*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat, Mat)
302
- CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat)
303
- CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat_<_Tp>)
304
- CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, -1, b), Mat, double)
305
- CV_MAT_AUG_OPERATOR_T(*=, a.convertTo(a, -1, b), Mat_<_Tp>, double)
306
- CV_MAT_AUG_OPERATOR_TN(*=, cv::gemm(a, Mat(b), 1, Mat(), 0, a, 0), Mat)
307
- CV_MAT_AUG_OPERATOR_TN(*=, cv::gemm(a, Mat(b), 1, Mat(), 0, a, 0), Mat_<_Tp>)
308
-
309
- CV_MAT_AUG_OPERATOR (/=, cv::divide(a, b, (const Mat&)a), Mat, Mat)
310
- CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
311
- CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
312
- CV_MAT_AUG_OPERATOR (/=, a.convertTo((Mat&)a, -1, 1./b), Mat, double)
313
- CV_MAT_AUG_OPERATOR_T(/=, a.convertTo((Mat&)a, -1, 1./b), Mat_<_Tp>, double)
314
- CV_MAT_AUG_OPERATOR_TN(/=, cv::divide(a, Mat(b), (const Mat&)a), Mat)
315
- CV_MAT_AUG_OPERATOR_TN(/=, cv::divide(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
316
-
317
- CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a, b, (const Mat&)a), Mat, Mat)
318
- CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a, b, (const Mat&)a), Mat, Scalar)
319
- CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
320
- CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
321
- CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
322
- CV_MAT_AUG_OPERATOR_TN(&=, cv::bitwise_and(a, Mat(b), (const Mat&)a), Mat)
323
- CV_MAT_AUG_OPERATOR_TN(&=, cv::bitwise_and(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
324
-
325
- CV_MAT_AUG_OPERATOR (|=, cv::bitwise_or(a, b, (const Mat&)a), Mat, Mat)
326
- CV_MAT_AUG_OPERATOR (|=, cv::bitwise_or(a, b, (const Mat&)a), Mat, Scalar)
327
- CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
328
- CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
329
- CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
330
- CV_MAT_AUG_OPERATOR_TN(|=, cv::bitwise_or(a, Mat(b), (const Mat&)a), Mat)
331
- CV_MAT_AUG_OPERATOR_TN(|=, cv::bitwise_or(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
332
-
333
- CV_MAT_AUG_OPERATOR (^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat, Mat)
334
- CV_MAT_AUG_OPERATOR (^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat, Scalar)
335
- CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
336
- CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
337
- CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
338
- CV_MAT_AUG_OPERATOR_TN(^=, cv::bitwise_xor(a, Mat(b), (const Mat&)a), Mat)
339
- CV_MAT_AUG_OPERATOR_TN(^=, cv::bitwise_xor(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
340
-
341
- #undef CV_MAT_AUG_OPERATOR_TN
342
- #undef CV_MAT_AUG_OPERATOR_T
343
- #undef CV_MAT_AUG_OPERATOR
344
- #undef CV_MAT_AUG_OPERATOR1
345
-
346
-
347
-
348
- ///////////////////////////////////////////// SVD /////////////////////////////////////////////
349
-
350
- inline SVD::SVD() {}
351
- inline SVD::SVD( InputArray m, int flags ) { operator ()(m, flags); }
352
- inline void SVD::solveZ( InputArray m, OutputArray _dst )
353
- {
354
- Mat mtx = m.getMat();
355
- SVD svd(mtx, (mtx.rows >= mtx.cols ? 0 : SVD::FULL_UV));
356
- _dst.create(svd.vt.cols, 1, svd.vt.type());
357
- Mat dst = _dst.getMat();
358
- svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst);
359
- }
360
-
361
- template<typename _Tp, int m, int n, int nm> inline void
362
- SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt )
363
- {
364
- CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector.");
365
- Mat _a(a, false), _u(u, false), _w(w, false), _vt(vt, false);
366
- SVD::compute(_a, _w, _u, _vt);
367
- CV_Assert(_w.data == (uchar*)&w.val[0] && _u.data == (uchar*)&u.val[0] && _vt.data == (uchar*)&vt.val[0]);
368
- }
369
-
370
- template<typename _Tp, int m, int n, int nm> inline void
371
- SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w )
372
- {
373
- CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector.");
374
- Mat _a(a, false), _w(w, false);
375
- SVD::compute(_a, _w);
376
- CV_Assert(_w.data == (uchar*)&w.val[0]);
377
- }
378
-
379
- template<typename _Tp, int m, int n, int nm, int nb> inline void
380
- SVD::backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u,
381
- const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs,
382
- Matx<_Tp, n, nb>& dst )
383
- {
384
- CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector.");
385
- Mat _u(u, false), _w(w, false), _vt(vt, false), _rhs(rhs, false), _dst(dst, false);
386
- SVD::backSubst(_w, _u, _vt, _rhs, _dst);
387
- CV_Assert(_dst.data == (uchar*)&dst.val[0]);
388
- }
389
-
390
-
391
-
392
- /////////////////////////////////// Multiply-with-Carry RNG ///////////////////////////////////
393
-
394
- inline RNG::RNG() { state = 0xffffffff; }
395
- inline RNG::RNG(uint64 _state) { state = _state ? _state : 0xffffffff; }
396
-
397
- inline RNG::operator uchar() { return (uchar)next(); }
398
- inline RNG::operator schar() { return (schar)next(); }
399
- inline RNG::operator ushort() { return (ushort)next(); }
400
- inline RNG::operator short() { return (short)next(); }
401
- inline RNG::operator int() { return (int)next(); }
402
- inline RNG::operator unsigned() { return next(); }
403
- inline RNG::operator float() { return next()*2.3283064365386962890625e-10f; }
404
- inline RNG::operator double() { unsigned t = next(); return (((uint64)t << 32) | next()) * 5.4210108624275221700372640043497e-20; }
405
-
406
- inline unsigned RNG::operator ()(unsigned N) { return (unsigned)uniform(0,N); }
407
- inline unsigned RNG::operator ()() { return next(); }
408
-
409
- inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next() % (b - a) + a); }
410
- inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; }
411
- inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; }
412
-
413
- inline bool RNG::operator ==(const RNG& other) const { return state == other.state; }
414
-
415
- inline unsigned RNG::next()
416
- {
417
- state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32);
418
- return (unsigned)state;
419
- }
420
-
421
- //! returns the next uniformly-distributed random number of the specified type
422
- template<typename _Tp> static inline _Tp randu()
423
- {
424
- return (_Tp)theRNG();
425
- }
426
-
427
- ///////////////////////////////// Formatted string generation /////////////////////////////////
428
-
429
- /** @brief Returns a text string formatted using the printf-like expression.
430
-
431
- The function acts like sprintf but forms and returns an STL string. It can be used to form an error
432
- message in the Exception constructor.
433
- @param fmt printf-compatible formatting specifiers.
434
-
435
- **Note**:
436
- |Type|Specifier|
437
- |-|-|
438
- |`const char*`|`%s`|
439
- |`char`|`%c`|
440
- |`float` / `double`|`%f`,`%g`|
441
- |`int`, `long`, `long long`|`%d`, `%ld`, ``%lld`|
442
- |`unsigned`, `unsigned long`, `unsigned long long`|`%u`, `%lu`, `%llu`|
443
- |`uint64` -> `uintmax_t`, `int64` -> `intmax_t`|`%ju`, `%jd`|
444
- |`size_t`|`%zu`|
445
- */
446
- CV_EXPORTS String format( const char* fmt, ... ) CV_FORMAT_PRINTF(1, 2);
447
-
448
- ///////////////////////////////// Formatted output of cv::Mat /////////////////////////////////
449
-
450
- static inline
451
- Ptr<Formatted> format(InputArray mtx, Formatter::FormatType fmt)
452
- {
453
- return Formatter::get(fmt)->format(mtx.getMat());
454
- }
455
-
456
- static inline
457
- int print(Ptr<Formatted> fmtd, FILE* stream = stdout)
458
- {
459
- int written = 0;
460
- fmtd->reset();
461
- for(const char* str = fmtd->next(); str; str = fmtd->next())
462
- written += fputs(str, stream);
463
-
464
- return written;
465
- }
466
-
467
- static inline
468
- int print(const Mat& mtx, FILE* stream = stdout)
469
- {
470
- return print(Formatter::get()->format(mtx), stream);
471
- }
472
-
473
- static inline
474
- int print(const UMat& mtx, FILE* stream = stdout)
475
- {
476
- return print(Formatter::get()->format(mtx.getMat(ACCESS_READ)), stream);
477
- }
478
-
479
- template<typename _Tp> static inline
480
- int print(const std::vector<Point_<_Tp> >& vec, FILE* stream = stdout)
481
- {
482
- return print(Formatter::get()->format(Mat(vec)), stream);
483
- }
484
-
485
- template<typename _Tp> static inline
486
- int print(const std::vector<Point3_<_Tp> >& vec, FILE* stream = stdout)
487
- {
488
- return print(Formatter::get()->format(Mat(vec)), stream);
489
- }
490
-
491
- template<typename _Tp, int m, int n> static inline
492
- int print(const Matx<_Tp, m, n>& matx, FILE* stream = stdout)
493
- {
494
- return print(Formatter::get()->format(cv::Mat(matx)), stream);
495
- }
496
-
497
- //! @endcond
498
-
499
- /****************************************************************************************\
500
- * Auxiliary algorithms *
501
- \****************************************************************************************/
502
-
503
- /** @brief Splits an element set into equivalency classes.
504
-
505
- The generic function partition implements an \f$O(N^2)\f$ algorithm for splitting a set of \f$N\f$ elements
506
- into one or more equivalency classes, as described in
507
- <http://en.wikipedia.org/wiki/Disjoint-set_data_structure> . The function returns the number of
508
- equivalency classes.
509
- @param _vec Set of elements stored as a vector.
510
- @param labels Output vector of labels. It contains as many elements as vec. Each label labels[i] is
511
- a 0-based cluster index of `vec[i]`.
512
- @param predicate Equivalence predicate (pointer to a boolean function of two arguments or an
513
- instance of the class that has the method bool operator()(const _Tp& a, const _Tp& b) ). The
514
- predicate returns true when the elements are certainly in the same class, and returns false if they
515
- may or may not be in the same class.
516
- @ingroup core_cluster
517
- */
518
- template<typename _Tp, class _EqPredicate> int
519
- partition( const std::vector<_Tp>& _vec, std::vector<int>& labels,
520
- _EqPredicate predicate=_EqPredicate())
521
- {
522
- int i, j, N = (int)_vec.size();
523
- const _Tp* vec = &_vec[0];
524
-
525
- const int PARENT=0;
526
- const int RANK=1;
527
-
528
- std::vector<int> _nodes(N*2);
529
- int (*nodes)[2] = (int(*)[2])&_nodes[0];
530
-
531
- // The first O(N) pass: create N single-vertex trees
532
- for(i = 0; i < N; i++)
533
- {
534
- nodes[i][PARENT]=-1;
535
- nodes[i][RANK] = 0;
536
- }
537
-
538
- // The main O(N^2) pass: merge connected components
539
- for( i = 0; i < N; i++ )
540
- {
541
- int root = i;
542
-
543
- // find root
544
- while( nodes[root][PARENT] >= 0 )
545
- root = nodes[root][PARENT];
546
-
547
- for( j = 0; j < N; j++ )
548
- {
549
- if( i == j || !predicate(vec[i], vec[j]))
550
- continue;
551
- int root2 = j;
552
-
553
- while( nodes[root2][PARENT] >= 0 )
554
- root2 = nodes[root2][PARENT];
555
-
556
- if( root2 != root )
557
- {
558
- // unite both trees
559
- int rank = nodes[root][RANK], rank2 = nodes[root2][RANK];
560
- if( rank > rank2 )
561
- nodes[root2][PARENT] = root;
562
- else
563
- {
564
- nodes[root][PARENT] = root2;
565
- nodes[root2][RANK] += rank == rank2;
566
- root = root2;
567
- }
568
- CV_Assert( nodes[root][PARENT] < 0 );
569
-
570
- int k = j, parent;
571
-
572
- // compress the path from node2 to root
573
- while( (parent = nodes[k][PARENT]) >= 0 )
574
- {
575
- nodes[k][PARENT] = root;
576
- k = parent;
577
- }
578
-
579
- // compress the path from node to root
580
- k = i;
581
- while( (parent = nodes[k][PARENT]) >= 0 )
582
- {
583
- nodes[k][PARENT] = root;
584
- k = parent;
585
- }
586
- }
587
- }
588
- }
589
-
590
- // Final O(N) pass: enumerate classes
591
- labels.resize(N);
592
- int nclasses = 0;
593
-
594
- for( i = 0; i < N; i++ )
595
- {
596
- int root = i;
597
- while( nodes[root][PARENT] >= 0 )
598
- root = nodes[root][PARENT];
599
- // re-use the rank as the class label
600
- if( nodes[root][RANK] >= 0 )
601
- nodes[root][RANK] = ~nclasses++;
602
- labels[i] = ~nodes[root][RANK];
603
- }
604
-
605
- return nclasses;
606
- }
607
-
608
- } // cv
609
-
610
- #endif