node-native-win-utils 1.1.0 → 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.
Files changed (174) hide show
  1. package/README.md +144 -27
  2. package/binding.gyp +18 -5
  3. package/dist/index.d.ts +146 -4
  4. package/dist/index.js +107 -3
  5. package/include/opencv2/core/affine.hpp +678 -0
  6. package/include/opencv2/core/async.hpp +105 -0
  7. package/include/opencv2/core/base.hpp +664 -0
  8. package/include/opencv2/core/bindings_utils.hpp +325 -0
  9. package/include/opencv2/core/bufferpool.hpp +40 -0
  10. package/include/opencv2/core/check.hpp +170 -0
  11. package/include/opencv2/core/core.hpp +48 -0
  12. package/include/opencv2/core/core_c.h +3128 -0
  13. package/include/opencv2/core/cuda/block.hpp +211 -0
  14. package/include/opencv2/core/cuda/border_interpolate.hpp +722 -0
  15. package/include/opencv2/core/cuda/color.hpp +309 -0
  16. package/include/opencv2/core/cuda/common.hpp +131 -0
  17. package/include/opencv2/core/cuda/datamov_utils.hpp +113 -0
  18. package/include/opencv2/core/cuda/detail/color_detail.hpp +2018 -0
  19. package/include/opencv2/core/cuda/detail/reduce.hpp +365 -0
  20. package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +502 -0
  21. package/include/opencv2/core/cuda/detail/transform_detail.hpp +392 -0
  22. package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +191 -0
  23. package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +121 -0
  24. package/include/opencv2/core/cuda/dynamic_smem.hpp +88 -0
  25. package/include/opencv2/core/cuda/emulation.hpp +269 -0
  26. package/include/opencv2/core/cuda/filters.hpp +293 -0
  27. package/include/opencv2/core/cuda/funcattrib.hpp +79 -0
  28. package/include/opencv2/core/cuda/functional.hpp +805 -0
  29. package/include/opencv2/core/cuda/limits.hpp +128 -0
  30. package/include/opencv2/core/cuda/reduce.hpp +209 -0
  31. package/include/opencv2/core/cuda/saturate_cast.hpp +292 -0
  32. package/include/opencv2/core/cuda/scan.hpp +258 -0
  33. package/include/opencv2/core/cuda/simd_functions.hpp +869 -0
  34. package/include/opencv2/core/cuda/transform.hpp +75 -0
  35. package/include/opencv2/core/cuda/type_traits.hpp +90 -0
  36. package/include/opencv2/core/cuda/utility.hpp +230 -0
  37. package/include/opencv2/core/cuda/vec_distance.hpp +232 -0
  38. package/include/opencv2/core/cuda/vec_math.hpp +923 -0
  39. package/include/opencv2/core/cuda/vec_traits.hpp +288 -0
  40. package/include/opencv2/core/cuda/warp.hpp +139 -0
  41. package/include/opencv2/core/cuda/warp_reduce.hpp +76 -0
  42. package/include/opencv2/core/cuda/warp_shuffle.hpp +162 -0
  43. package/include/opencv2/core/cuda.hpp +1279 -0
  44. package/include/opencv2/core/cuda.inl.hpp +763 -0
  45. package/include/opencv2/core/cuda_stream_accessor.hpp +86 -0
  46. package/include/opencv2/core/cuda_types.hpp +144 -0
  47. package/include/opencv2/core/cv_cpu_dispatch.h +381 -0
  48. package/include/opencv2/core/cv_cpu_helper.h +550 -0
  49. package/include/opencv2/core/cvdef.h +973 -0
  50. package/include/opencv2/core/cvstd.hpp +190 -0
  51. package/include/opencv2/core/cvstd.inl.hpp +197 -0
  52. package/include/opencv2/core/cvstd_wrapper.hpp +154 -0
  53. package/include/opencv2/core/detail/async_promise.hpp +71 -0
  54. package/include/opencv2/core/detail/dispatch_helper.impl.hpp +49 -0
  55. package/include/opencv2/core/detail/exception_ptr.hpp +27 -0
  56. package/include/opencv2/core/directx.hpp +184 -0
  57. package/include/opencv2/core/dualquaternion.hpp +979 -0
  58. package/include/opencv2/core/dualquaternion.inl.hpp +487 -0
  59. package/include/opencv2/core/eigen.hpp +402 -0
  60. package/include/opencv2/core/fast_math.hpp +433 -0
  61. package/include/opencv2/core/hal/hal.hpp +256 -0
  62. package/include/opencv2/core/hal/interface.h +190 -0
  63. package/include/opencv2/core/hal/intrin.hpp +939 -0
  64. package/include/opencv2/core/hal/intrin_avx.hpp +3177 -0
  65. package/include/opencv2/core/hal/intrin_avx512.hpp +3090 -0
  66. package/include/opencv2/core/hal/intrin_cpp.hpp +3321 -0
  67. package/include/opencv2/core/hal/intrin_forward.hpp +191 -0
  68. package/include/opencv2/core/hal/intrin_lasx.hpp +3236 -0
  69. package/include/opencv2/core/hal/intrin_msa.hpp +1887 -0
  70. package/include/opencv2/core/hal/intrin_neon.hpp +2610 -0
  71. package/include/opencv2/core/hal/intrin_rvv.hpp +3320 -0
  72. package/include/opencv2/core/hal/intrin_rvv071.hpp +2545 -0
  73. package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +2080 -0
  74. package/include/opencv2/core/hal/intrin_sse.hpp +3467 -0
  75. package/include/opencv2/core/hal/intrin_sse_em.hpp +180 -0
  76. package/include/opencv2/core/hal/intrin_vsx.hpp +1608 -0
  77. package/include/opencv2/core/hal/intrin_wasm.hpp +2782 -0
  78. package/include/opencv2/core/hal/msa_macros.h +1558 -0
  79. package/include/opencv2/core/hal/simd_utils.impl.hpp +186 -0
  80. package/include/opencv2/core/llapi/llapi.h +102 -0
  81. package/include/opencv2/core/mat.hpp +3775 -0
  82. package/include/opencv2/core/mat.inl.hpp +3422 -0
  83. package/include/opencv2/core/matx.hpp +1536 -0
  84. package/include/opencv2/core/neon_utils.hpp +128 -0
  85. package/include/opencv2/core/ocl.hpp +917 -0
  86. package/include/opencv2/core/ocl_genbase.hpp +69 -0
  87. package/include/opencv2/core/opencl/ocl_defs.hpp +82 -0
  88. package/include/opencv2/core/opencl/opencl_info.hpp +212 -0
  89. package/include/opencv2/core/opencl/opencl_svm.hpp +81 -0
  90. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +602 -0
  91. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +146 -0
  92. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +371 -0
  93. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +272 -0
  94. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +62 -0
  95. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +42 -0
  96. package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +53 -0
  97. package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +53 -0
  98. package/include/opencv2/core/opencl/runtime/opencl_core.hpp +84 -0
  99. package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +47 -0
  100. package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +53 -0
  101. package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +47 -0
  102. package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +48 -0
  103. package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +42 -0
  104. package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +166 -0
  105. package/include/opencv2/core/opengl.hpp +733 -0
  106. package/include/opencv2/core/openvx/ovx_defs.hpp +48 -0
  107. package/include/opencv2/core/operations.hpp +610 -0
  108. package/include/opencv2/core/optim.hpp +302 -0
  109. package/include/opencv2/core/ovx.hpp +28 -0
  110. package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +72 -0
  111. package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +153 -0
  112. package/include/opencv2/core/parallel/parallel_backend.hpp +90 -0
  113. package/include/opencv2/core/persistence.hpp +1350 -0
  114. package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +30 -0
  115. package/include/opencv2/core/private.cuda.hpp +169 -0
  116. package/include/opencv2/core/private.hpp +896 -0
  117. package/include/opencv2/core/quaternion.hpp +1696 -0
  118. package/include/opencv2/core/quaternion.inl.hpp +1063 -0
  119. package/include/opencv2/core/saturate.hpp +180 -0
  120. package/include/opencv2/core/simd_intrinsics.hpp +87 -0
  121. package/include/opencv2/core/softfloat.hpp +514 -0
  122. package/include/opencv2/core/sse_utils.hpp +652 -0
  123. package/include/opencv2/core/traits.hpp +417 -0
  124. package/include/opencv2/core/types.hpp +2457 -0
  125. package/include/opencv2/core/types_c.h +2126 -0
  126. package/include/opencv2/core/utility.hpp +1229 -0
  127. package/include/opencv2/core/utils/allocator_stats.hpp +29 -0
  128. package/include/opencv2/core/utils/allocator_stats.impl.hpp +158 -0
  129. package/include/opencv2/core/utils/buffer_area.private.hpp +136 -0
  130. package/include/opencv2/core/utils/configuration.private.hpp +22 -0
  131. package/include/opencv2/core/utils/filesystem.hpp +82 -0
  132. package/include/opencv2/core/utils/filesystem.private.hpp +66 -0
  133. package/include/opencv2/core/utils/fp_control.private.hpp +29 -0
  134. package/include/opencv2/core/utils/fp_control_utils.hpp +69 -0
  135. package/include/opencv2/core/utils/instrumentation.hpp +125 -0
  136. package/include/opencv2/core/utils/lock.private.hpp +119 -0
  137. package/include/opencv2/core/utils/logger.defines.hpp +42 -0
  138. package/include/opencv2/core/utils/logger.hpp +218 -0
  139. package/include/opencv2/core/utils/logtag.hpp +28 -0
  140. package/include/opencv2/core/utils/plugin_loader.private.hpp +165 -0
  141. package/include/opencv2/core/utils/tls.hpp +235 -0
  142. package/include/opencv2/core/utils/trace.hpp +252 -0
  143. package/include/opencv2/core/utils/trace.private.hpp +421 -0
  144. package/include/opencv2/core/va_intel.hpp +75 -0
  145. package/include/opencv2/core/version.hpp +26 -0
  146. package/include/opencv2/core/vsx_utils.hpp +1047 -0
  147. package/include/opencv2/core.hpp +3365 -0
  148. package/include/opencv2/imgcodecs/imgcodecs.hpp +48 -0
  149. package/include/opencv2/imgcodecs/imgcodecs_c.h +1 -0
  150. package/include/opencv2/imgcodecs/ios.h +59 -0
  151. package/include/opencv2/imgcodecs/legacy/constants_c.h +54 -0
  152. package/include/opencv2/imgcodecs/macosx.h +20 -0
  153. package/include/opencv2/imgcodecs.hpp +407 -0
  154. package/include/opencv2/imgproc/bindings.hpp +34 -0
  155. package/include/opencv2/imgproc/detail/gcgraph.hpp +395 -0
  156. package/include/opencv2/imgproc/hal/hal.hpp +246 -0
  157. package/include/opencv2/imgproc/hal/interface.h +46 -0
  158. package/include/opencv2/imgproc/imgproc.hpp +48 -0
  159. package/include/opencv2/imgproc/imgproc_c.h +1177 -0
  160. package/include/opencv2/imgproc/segmentation.hpp +141 -0
  161. package/include/opencv2/imgproc/types_c.h +659 -0
  162. package/include/opencv2/imgproc.hpp +5035 -0
  163. package/include/opencv2/opencv_modules.hpp +17 -0
  164. package/libs/libjpeg-turbo.lib +0 -0
  165. package/libs/libpng.lib +0 -0
  166. package/libs/opencv_core470.lib +0 -0
  167. package/libs/opencv_imgcodecs470.lib +0 -0
  168. package/libs/opencv_imgproc470.lib +0 -0
  169. package/libs/zlib.lib +0 -0
  170. package/package.json +14 -3
  171. package/prebuilds/win32-x64/node.napi.node +0 -0
  172. package/src/cpp/capturewindow.cpp +36 -46
  173. package/src/cpp/main.cpp +10 -2
  174. package/src/cpp/opencv.cpp +425 -0
@@ -0,0 +1,733 @@
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
+ // Third party copyrights are property of their respective owners.
16
+ //
17
+ // Redistribution and use in source and binary forms, with or without modification,
18
+ // are permitted provided that the following conditions are met:
19
+ //
20
+ // * Redistribution's of source code must retain the above copyright notice,
21
+ // this list of conditions and the following disclaimer.
22
+ //
23
+ // * Redistribution's in binary form must reproduce the above copyright notice,
24
+ // this list of conditions and the following disclaimer in the documentation
25
+ // and/or other materials provided with the distribution.
26
+ //
27
+ // * The name of the copyright holders may not be used to endorse or promote products
28
+ // derived from this software without specific prior written permission.
29
+ //
30
+ // This software is provided by the copyright holders and contributors "as is" and
31
+ // any express or implied warranties, including, but not limited to, the implied
32
+ // warranties of merchantability and fitness for a particular purpose are disclaimed.
33
+ // In no event shall the Intel Corporation or contributors be liable for any direct,
34
+ // indirect, incidental, special, exemplary, or consequential damages
35
+ // (including, but not limited to, procurement of substitute goods or services;
36
+ // loss of use, data, or profits; or business interruption) however caused
37
+ // and on any theory of liability, whether in contract, strict liability,
38
+ // or tort (including negligence or otherwise) arising in any way out of
39
+ // the use of this software, even if advised of the possibility of such damage.
40
+ //
41
+ //M*/
42
+
43
+ #ifndef OPENCV_CORE_OPENGL_HPP
44
+ #define OPENCV_CORE_OPENGL_HPP
45
+
46
+ #ifndef __cplusplus
47
+ # error opengl.hpp header must be compiled as C++
48
+ #endif
49
+
50
+ #include "opencv2/core.hpp"
51
+ #include "ocl.hpp"
52
+
53
+ namespace cv { namespace ogl {
54
+
55
+ /** @addtogroup core_opengl
56
+ This section describes OpenGL interoperability.
57
+
58
+ To enable OpenGL support, configure OpenCV using CMake with WITH_OPENGL=ON . Currently OpenGL is
59
+ supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not
60
+ supported). For GTK backend gtkglext-1.0 library is required.
61
+
62
+ To use OpenGL functionality you should first create OpenGL context (window or frame buffer). You can
63
+ do this with namedWindow function or with other OpenGL toolkit (GLUT, for example).
64
+ */
65
+ //! @{
66
+
67
+ /////////////////// OpenGL Objects ///////////////////
68
+
69
+ /** @brief Smart pointer for OpenGL buffer object with reference counting.
70
+
71
+ Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL
72
+ context. These can be used to store vertex data, pixel data retrieved from images or the
73
+ framebuffer, and a variety of other things.
74
+
75
+ ogl::Buffer has interface similar with Mat interface and represents 2D array memory.
76
+
77
+ ogl::Buffer supports memory transfers between host and device and also can be mapped to CUDA memory.
78
+ */
79
+ class CV_EXPORTS Buffer
80
+ {
81
+ public:
82
+ /** @brief The target defines how you intend to use the buffer object.
83
+ */
84
+ enum Target
85
+ {
86
+ ARRAY_BUFFER = 0x8892, //!< The buffer will be used as a source for vertex data
87
+ ELEMENT_ARRAY_BUFFER = 0x8893, //!< The buffer will be used for indices (in glDrawElements, for example)
88
+ PIXEL_PACK_BUFFER = 0x88EB, //!< The buffer will be used for reading from OpenGL textures
89
+ PIXEL_UNPACK_BUFFER = 0x88EC //!< The buffer will be used for writing to OpenGL textures
90
+ };
91
+
92
+ enum Access
93
+ {
94
+ READ_ONLY = 0x88B8,
95
+ WRITE_ONLY = 0x88B9,
96
+ READ_WRITE = 0x88BA
97
+ };
98
+
99
+ /** @brief The constructors.
100
+
101
+ Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId
102
+ parameter), allocates memory for ogl::Buffer object or copies from host/device memory.
103
+ */
104
+ Buffer();
105
+
106
+ /** @overload
107
+ @param arows Number of rows in a 2D array.
108
+ @param acols Number of columns in a 2D array.
109
+ @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
110
+ @param abufId Buffer object name.
111
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
112
+ */
113
+ Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
114
+
115
+ /** @overload
116
+ @param asize 2D array size.
117
+ @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
118
+ @param abufId Buffer object name.
119
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
120
+ */
121
+ Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
122
+
123
+ /** @overload
124
+ @param arows Number of rows in a 2D array.
125
+ @param acols Number of columns in a 2D array.
126
+ @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
127
+ @param target Buffer usage. See cv::ogl::Buffer::Target .
128
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
129
+ */
130
+ Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
131
+
132
+ /** @overload
133
+ @param asize 2D array size.
134
+ @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
135
+ @param target Buffer usage. See cv::ogl::Buffer::Target .
136
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
137
+ */
138
+ Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
139
+
140
+ /** @overload
141
+ @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
142
+ @param target Buffer usage. See cv::ogl::Buffer::Target .
143
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
144
+ */
145
+ explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
146
+
147
+ /** @brief Allocates memory for ogl::Buffer object.
148
+
149
+ @param arows Number of rows in a 2D array.
150
+ @param acols Number of columns in a 2D array.
151
+ @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
152
+ @param target Buffer usage. See cv::ogl::Buffer::Target .
153
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
154
+ */
155
+ void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
156
+
157
+ /** @overload
158
+ @param asize 2D array size.
159
+ @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
160
+ @param target Buffer usage. See cv::ogl::Buffer::Target .
161
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
162
+ */
163
+ void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
164
+
165
+ /** @brief Decrements the reference counter and destroys the buffer object if needed.
166
+
167
+ The function will call setAutoRelease(true) .
168
+ */
169
+ void release();
170
+
171
+ /** @brief Sets auto release mode.
172
+
173
+ The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was
174
+ bound to a window it could be released at any time (user can close a window). If object's destructor
175
+ is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy
176
+ OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context).
177
+ This function can force ogl::Buffer destructor to destroy OpenGL object.
178
+ @param flag Auto release mode (if true, release will be called in object's destructor).
179
+ */
180
+ void setAutoRelease(bool flag);
181
+
182
+ /** @brief Copies from host/device memory to OpenGL buffer.
183
+ @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
184
+ @param target Buffer usage. See cv::ogl::Buffer::Target .
185
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
186
+ */
187
+ void copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
188
+
189
+ /** @overload */
190
+ void copyFrom(InputArray arr, cuda::Stream& stream, Target target = ARRAY_BUFFER, bool autoRelease = false);
191
+
192
+ /** @brief Copies from OpenGL buffer to host/device memory or another OpenGL buffer object.
193
+
194
+ @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or
195
+ ogl::Buffer ).
196
+ */
197
+ void copyTo(OutputArray arr) const;
198
+
199
+ /** @overload */
200
+ void copyTo(OutputArray arr, cuda::Stream& stream) const;
201
+
202
+ /** @brief Creates a full copy of the buffer object and the underlying data.
203
+
204
+ @param target Buffer usage for destination buffer.
205
+ @param autoRelease Auto release mode for destination buffer.
206
+ */
207
+ Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
208
+
209
+ /** @brief Binds OpenGL buffer to the specified buffer binding point.
210
+
211
+ @param target Binding point. See cv::ogl::Buffer::Target .
212
+ */
213
+ void bind(Target target) const;
214
+
215
+ /** @brief Unbind any buffers from the specified binding point.
216
+
217
+ @param target Binding point. See cv::ogl::Buffer::Target .
218
+ */
219
+ static void unbind(Target target);
220
+
221
+ /** @brief Maps OpenGL buffer to host memory.
222
+
223
+ mapHost maps to the client's address space the entire data store of the buffer object. The data can
224
+ then be directly read and/or written relative to the returned pointer, depending on the specified
225
+ access policy.
226
+
227
+ A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used.
228
+
229
+ This operation can lead to memory transfers between host and device.
230
+
231
+ Only one buffer object can be mapped at a time.
232
+ @param access Access policy, indicating whether it will be possible to read from, write to, or both
233
+ read from and write to the buffer object's mapped data store. The symbolic constant must be
234
+ ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE .
235
+ */
236
+ Mat mapHost(Access access);
237
+
238
+ /** @brief Unmaps OpenGL buffer.
239
+ */
240
+ void unmapHost();
241
+
242
+ //! map to device memory (blocking)
243
+ cuda::GpuMat mapDevice();
244
+ void unmapDevice();
245
+
246
+ /** @brief Maps OpenGL buffer to CUDA device memory.
247
+
248
+ This operation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time.
249
+
250
+ A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used.
251
+ */
252
+ cuda::GpuMat mapDevice(cuda::Stream& stream);
253
+
254
+ /** @brief Unmaps OpenGL buffer.
255
+ */
256
+ void unmapDevice(cuda::Stream& stream);
257
+
258
+ int rows() const;
259
+ int cols() const;
260
+ Size size() const;
261
+ bool empty() const;
262
+
263
+ int type() const;
264
+ int depth() const;
265
+ int channels() const;
266
+ int elemSize() const;
267
+ int elemSize1() const;
268
+
269
+ //! get OpenGL opject id
270
+ unsigned int bufId() const;
271
+
272
+ class Impl;
273
+
274
+ private:
275
+ Ptr<Impl> impl_;
276
+ int rows_;
277
+ int cols_;
278
+ int type_;
279
+ };
280
+
281
+ /** @brief Smart pointer for OpenGL 2D texture memory with reference counting.
282
+ */
283
+ class CV_EXPORTS Texture2D
284
+ {
285
+ public:
286
+ /** @brief An Image Format describes the way that the images in Textures store their data.
287
+ */
288
+ enum Format
289
+ {
290
+ NONE = 0,
291
+ DEPTH_COMPONENT = 0x1902, //!< Depth
292
+ RGB = 0x1907, //!< Red, Green, Blue
293
+ RGBA = 0x1908 //!< Red, Green, Blue, Alpha
294
+ };
295
+
296
+ /** @brief The constructors.
297
+
298
+ Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from
299
+ host/device memory.
300
+ */
301
+ Texture2D();
302
+
303
+ /** @overload */
304
+ Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
305
+
306
+ /** @overload */
307
+ Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
308
+
309
+ /** @overload
310
+ @param arows Number of rows.
311
+ @param acols Number of columns.
312
+ @param aformat Image format. See cv::ogl::Texture2D::Format .
313
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
314
+ */
315
+ Texture2D(int arows, int acols, Format aformat, bool autoRelease = false);
316
+
317
+ /** @overload
318
+ @param asize 2D array size.
319
+ @param aformat Image format. See cv::ogl::Texture2D::Format .
320
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
321
+ */
322
+ Texture2D(Size asize, Format aformat, bool autoRelease = false);
323
+
324
+ /** @overload
325
+ @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
326
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
327
+ */
328
+ explicit Texture2D(InputArray arr, bool autoRelease = false);
329
+
330
+ /** @brief Allocates memory for ogl::Texture2D object.
331
+
332
+ @param arows Number of rows.
333
+ @param acols Number of columns.
334
+ @param aformat Image format. See cv::ogl::Texture2D::Format .
335
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
336
+ */
337
+ void create(int arows, int acols, Format aformat, bool autoRelease = false);
338
+ /** @overload
339
+ @param asize 2D array size.
340
+ @param aformat Image format. See cv::ogl::Texture2D::Format .
341
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
342
+ */
343
+ void create(Size asize, Format aformat, bool autoRelease = false);
344
+
345
+ /** @brief Decrements the reference counter and destroys the texture object if needed.
346
+
347
+ The function will call setAutoRelease(true) .
348
+ */
349
+ void release();
350
+
351
+ /** @brief Sets auto release mode.
352
+
353
+ @param flag Auto release mode (if true, release will be called in object's destructor).
354
+
355
+ The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was
356
+ bound to a window it could be released at any time (user can close a window). If object's destructor
357
+ is called after destruction of the context it will cause an error. Thus ogl::Texture2D doesn't
358
+ destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL
359
+ context). This function can force ogl::Texture2D destructor to destroy OpenGL object.
360
+ */
361
+ void setAutoRelease(bool flag);
362
+
363
+ /** @brief Copies from host/device memory to OpenGL texture.
364
+
365
+ @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
366
+ @param autoRelease Auto release mode (if true, release will be called in object's destructor).
367
+ */
368
+ void copyFrom(InputArray arr, bool autoRelease = false);
369
+
370
+ /** @brief Copies from OpenGL texture to host/device memory or another OpenGL texture object.
371
+
372
+ @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or
373
+ ogl::Texture2D ).
374
+ @param ddepth Destination depth.
375
+ @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture).
376
+ */
377
+ void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const;
378
+
379
+ /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target.
380
+ */
381
+ void bind() const;
382
+
383
+ int rows() const;
384
+ int cols() const;
385
+ Size size() const;
386
+ bool empty() const;
387
+
388
+ Format format() const;
389
+
390
+ //! get OpenGL opject id
391
+ unsigned int texId() const;
392
+
393
+ class Impl;
394
+
395
+ private:
396
+ Ptr<Impl> impl_;
397
+ int rows_;
398
+ int cols_;
399
+ Format format_;
400
+ };
401
+
402
+ /** @brief Wrapper for OpenGL Client-Side Vertex arrays.
403
+
404
+ ogl::Arrays stores vertex data in ogl::Buffer objects.
405
+ */
406
+ class CV_EXPORTS Arrays
407
+ {
408
+ public:
409
+ /** @brief Default constructor
410
+ */
411
+ Arrays();
412
+
413
+ /** @brief Sets an array of vertex coordinates.
414
+ @param vertex array with vertex coordinates, can be both host and device memory.
415
+ */
416
+ void setVertexArray(InputArray vertex);
417
+
418
+ /** @brief Resets vertex coordinates.
419
+ */
420
+ void resetVertexArray();
421
+
422
+ /** @brief Sets an array of vertex colors.
423
+ @param color array with vertex colors, can be both host and device memory.
424
+ */
425
+ void setColorArray(InputArray color);
426
+
427
+ /** @brief Resets vertex colors.
428
+ */
429
+ void resetColorArray();
430
+
431
+ /** @brief Sets an array of vertex normals.
432
+ @param normal array with vertex normals, can be both host and device memory.
433
+ */
434
+ void setNormalArray(InputArray normal);
435
+
436
+ /** @brief Resets vertex normals.
437
+ */
438
+ void resetNormalArray();
439
+
440
+ /** @brief Sets an array of vertex texture coordinates.
441
+ @param texCoord array with vertex texture coordinates, can be both host and device memory.
442
+ */
443
+ void setTexCoordArray(InputArray texCoord);
444
+
445
+ /** @brief Resets vertex texture coordinates.
446
+ */
447
+ void resetTexCoordArray();
448
+
449
+ /** @brief Releases all inner buffers.
450
+ */
451
+ void release();
452
+
453
+ /** @brief Sets auto release mode all inner buffers.
454
+ @param flag Auto release mode.
455
+ */
456
+ void setAutoRelease(bool flag);
457
+
458
+ /** @brief Binds all vertex arrays.
459
+ */
460
+ void bind() const;
461
+
462
+ /** @brief Returns the vertex count.
463
+ */
464
+ int size() const;
465
+ bool empty() const;
466
+
467
+ private:
468
+ int size_;
469
+ Buffer vertex_;
470
+ Buffer color_;
471
+ Buffer normal_;
472
+ Buffer texCoord_;
473
+ };
474
+
475
+ /////////////////// Render Functions ///////////////////
476
+
477
+ //! render mode
478
+ enum RenderModes {
479
+ POINTS = 0x0000,
480
+ LINES = 0x0001,
481
+ LINE_LOOP = 0x0002,
482
+ LINE_STRIP = 0x0003,
483
+ TRIANGLES = 0x0004,
484
+ TRIANGLE_STRIP = 0x0005,
485
+ TRIANGLE_FAN = 0x0006,
486
+ QUADS = 0x0007,
487
+ QUAD_STRIP = 0x0008,
488
+ POLYGON = 0x0009
489
+ };
490
+
491
+ /** @brief Render OpenGL texture or primitives.
492
+ @param tex Texture to draw.
493
+ @param wndRect Region of window, where to draw a texture (normalized coordinates).
494
+ @param texRect Region of texture to draw (normalized coordinates).
495
+ */
496
+ CV_EXPORTS void render(const Texture2D& tex,
497
+ Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
498
+ Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
499
+
500
+ /** @overload
501
+ @param arr Array of privitives vertices.
502
+ @param mode Render mode. One of cv::ogl::RenderModes
503
+ @param color Color for all vertices. Will be used if arr doesn't contain color array.
504
+ */
505
+ CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255));
506
+
507
+ /** @overload
508
+ @param arr Array of privitives vertices.
509
+ @param indices Array of vertices indices (host or device memory).
510
+ @param mode Render mode. One of cv::ogl::RenderModes
511
+ @param color Color for all vertices. Will be used if arr doesn't contain color array.
512
+ */
513
+ CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255));
514
+
515
+ /////////////////// CL-GL Interoperability Functions ///////////////////
516
+
517
+ namespace ocl {
518
+ using namespace cv::ocl;
519
+
520
+ // TODO static functions in the Context class
521
+ /** @brief Creates OpenCL context from GL.
522
+ @return Returns reference to OpenCL Context
523
+ */
524
+ CV_EXPORTS Context& initializeContextFromGL();
525
+
526
+ } // namespace cv::ogl::ocl
527
+
528
+ /** @brief Converts InputArray to Texture2D object.
529
+ @param src - source InputArray.
530
+ @param texture - destination Texture2D object.
531
+ */
532
+ CV_EXPORTS void convertToGLTexture2D(InputArray src, Texture2D& texture);
533
+
534
+ /** @brief Converts Texture2D object to OutputArray.
535
+ @param texture - source Texture2D object.
536
+ @param dst - destination OutputArray.
537
+ */
538
+ CV_EXPORTS void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst);
539
+
540
+ /** @brief Maps Buffer object to process on CL side (convert to UMat).
541
+
542
+ Function creates CL buffer from GL one, and then constructs UMat that can be used
543
+ to process buffer data with OpenCV functions. Note that in current implementation
544
+ UMat constructed this way doesn't own corresponding GL buffer object, so it is
545
+ the user responsibility to close down CL/GL buffers relationships by explicitly
546
+ calling unmapGLBuffer() function.
547
+ @param buffer - source Buffer object.
548
+ @param accessFlags - data access flags (ACCESS_READ|ACCESS_WRITE).
549
+ @return Returns UMat object
550
+ */
551
+ CV_EXPORTS UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags = ACCESS_READ | ACCESS_WRITE);
552
+
553
+ /** @brief Unmaps Buffer object (releases UMat, previously mapped from Buffer).
554
+
555
+ Function must be called explicitly by the user for each UMat previously constructed
556
+ by the call to mapGLBuffer() function.
557
+ @param u - source UMat, created by mapGLBuffer().
558
+ */
559
+ CV_EXPORTS void unmapGLBuffer(UMat& u);
560
+
561
+ //! @}
562
+ }} // namespace cv::ogl
563
+
564
+ namespace cv { namespace cuda {
565
+
566
+ /** @brief Sets a CUDA device and initializes it for the current thread with OpenGL interoperability.
567
+
568
+ This function should be explicitly called after OpenGL context creation and before any CUDA calls.
569
+ @param device System index of a CUDA device starting with 0.
570
+ @ingroup core_opengl
571
+ */
572
+ CV_EXPORTS void setGlDevice(int device = 0);
573
+
574
+ }}
575
+
576
+ //! @cond IGNORED
577
+
578
+ ////////////////////////////////////////////////////////////////////////
579
+ ////////////////////////////////////////////////////////////////////////
580
+ ////////////////////////////////////////////////////////////////////////
581
+
582
+ inline
583
+ cv::ogl::Buffer::Buffer(int arows, int acols, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0)
584
+ {
585
+ create(arows, acols, atype, target, autoRelease);
586
+ }
587
+
588
+ inline
589
+ cv::ogl::Buffer::Buffer(Size asize, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0)
590
+ {
591
+ create(asize, atype, target, autoRelease);
592
+ }
593
+
594
+ inline
595
+ void cv::ogl::Buffer::create(Size asize, int atype, Target target, bool autoRelease)
596
+ {
597
+ create(asize.height, asize.width, atype, target, autoRelease);
598
+ }
599
+
600
+ inline
601
+ int cv::ogl::Buffer::rows() const
602
+ {
603
+ return rows_;
604
+ }
605
+
606
+ inline
607
+ int cv::ogl::Buffer::cols() const
608
+ {
609
+ return cols_;
610
+ }
611
+
612
+ inline
613
+ cv::Size cv::ogl::Buffer::size() const
614
+ {
615
+ return Size(cols_, rows_);
616
+ }
617
+
618
+ inline
619
+ bool cv::ogl::Buffer::empty() const
620
+ {
621
+ return rows_ == 0 || cols_ == 0;
622
+ }
623
+
624
+ inline
625
+ int cv::ogl::Buffer::type() const
626
+ {
627
+ return type_;
628
+ }
629
+
630
+ inline
631
+ int cv::ogl::Buffer::depth() const
632
+ {
633
+ return CV_MAT_DEPTH(type_);
634
+ }
635
+
636
+ inline
637
+ int cv::ogl::Buffer::channels() const
638
+ {
639
+ return CV_MAT_CN(type_);
640
+ }
641
+
642
+ inline
643
+ int cv::ogl::Buffer::elemSize() const
644
+ {
645
+ return CV_ELEM_SIZE(type_);
646
+ }
647
+
648
+ inline
649
+ int cv::ogl::Buffer::elemSize1() const
650
+ {
651
+ return CV_ELEM_SIZE1(type_);
652
+ }
653
+
654
+ ///////
655
+
656
+ inline
657
+ cv::ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE)
658
+ {
659
+ create(arows, acols, aformat, autoRelease);
660
+ }
661
+
662
+ inline
663
+ cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE)
664
+ {
665
+ create(asize, aformat, autoRelease);
666
+ }
667
+
668
+ inline
669
+ void cv::ogl::Texture2D::create(Size asize, Format aformat, bool autoRelease)
670
+ {
671
+ create(asize.height, asize.width, aformat, autoRelease);
672
+ }
673
+
674
+ inline
675
+ int cv::ogl::Texture2D::rows() const
676
+ {
677
+ return rows_;
678
+ }
679
+
680
+ inline
681
+ int cv::ogl::Texture2D::cols() const
682
+ {
683
+ return cols_;
684
+ }
685
+
686
+ inline
687
+ cv::Size cv::ogl::Texture2D::size() const
688
+ {
689
+ return Size(cols_, rows_);
690
+ }
691
+
692
+ inline
693
+ bool cv::ogl::Texture2D::empty() const
694
+ {
695
+ return rows_ == 0 || cols_ == 0;
696
+ }
697
+
698
+ inline
699
+ cv::ogl::Texture2D::Format cv::ogl::Texture2D::format() const
700
+ {
701
+ return format_;
702
+ }
703
+
704
+ ///////
705
+
706
+ // WARNING: unreachable code using Ninja
707
+ #if defined _MSC_VER && _MSC_VER >= 1920
708
+ #pragma warning(push)
709
+ #pragma warning(disable: 4702)
710
+ #endif
711
+ inline
712
+ cv::ogl::Arrays::Arrays() : size_(0)
713
+ {
714
+ }
715
+ #if defined _MSC_VER && _MSC_VER >= 1920
716
+ #pragma warning(pop)
717
+ #endif
718
+
719
+ inline
720
+ int cv::ogl::Arrays::size() const
721
+ {
722
+ return size_;
723
+ }
724
+
725
+ inline
726
+ bool cv::ogl::Arrays::empty() const
727
+ {
728
+ return size_ == 0;
729
+ }
730
+
731
+ //! @endcond
732
+
733
+ #endif /* OPENCV_CORE_OPENGL_HPP */