@techstark/opencv-js 4.8.0-release.6 → 4.8.0-release.8

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 (198) hide show
  1. package/README.md +127 -0
  2. package/dist/src/index.d.ts +1 -0
  3. package/dist/src/index.js +18 -0
  4. package/dist/src/index.js.map +1 -0
  5. package/dist/src/types/_cv.d.ts +7 -0
  6. package/dist/src/types/_cv.js +3 -0
  7. package/dist/src/types/_cv.js.map +1 -0
  8. package/dist/src/types/emscripten.d.ts +166 -0
  9. package/dist/src/types/emscripten.js +4 -0
  10. package/dist/src/types/emscripten.js.map +1 -0
  11. package/dist/src/types/opencv/Affine3.d.ts +183 -0
  12. package/dist/src/types/opencv/Affine3.js +3 -0
  13. package/dist/src/types/opencv/Affine3.js.map +1 -0
  14. package/dist/src/types/opencv/Algorithm.d.ts +105 -0
  15. package/dist/src/types/opencv/Algorithm.js +4 -0
  16. package/dist/src/types/opencv/Algorithm.js.map +1 -0
  17. package/dist/src/types/opencv/AutoBuffer.d.ts +41 -0
  18. package/dist/src/types/opencv/AutoBuffer.js +3 -0
  19. package/dist/src/types/opencv/AutoBuffer.js.map +1 -0
  20. package/dist/src/types/opencv/BFMatcher.d.ts +33 -0
  21. package/dist/src/types/opencv/BFMatcher.js +3 -0
  22. package/dist/src/types/opencv/BFMatcher.js.map +1 -0
  23. package/dist/src/types/opencv/BOWTrainer.d.ts +36 -0
  24. package/dist/src/types/opencv/BOWTrainer.js +3 -0
  25. package/dist/src/types/opencv/BOWTrainer.js.map +1 -0
  26. package/dist/src/types/opencv/CascadeClassifier.d.ts +100 -0
  27. package/dist/src/types/opencv/CascadeClassifier.js +4 -0
  28. package/dist/src/types/opencv/CascadeClassifier.js.map +1 -0
  29. package/dist/src/types/opencv/DescriptorMatcher.d.ts +172 -0
  30. package/dist/src/types/opencv/DescriptorMatcher.js +3 -0
  31. package/dist/src/types/opencv/DescriptorMatcher.js.map +1 -0
  32. package/dist/src/types/opencv/DynamicBitset.d.ts +57 -0
  33. package/dist/src/types/opencv/DynamicBitset.js +3 -0
  34. package/dist/src/types/opencv/DynamicBitset.js.map +1 -0
  35. package/dist/src/types/opencv/Exception.d.ts +38 -0
  36. package/dist/src/types/opencv/Exception.js +3 -0
  37. package/dist/src/types/opencv/Exception.js.map +1 -0
  38. package/dist/src/types/opencv/Feature2D.d.ts +14 -0
  39. package/dist/src/types/opencv/Feature2D.js +4 -0
  40. package/dist/src/types/opencv/Feature2D.js.map +1 -0
  41. package/dist/src/types/opencv/FlannBasedMatcher.d.ts +41 -0
  42. package/dist/src/types/opencv/FlannBasedMatcher.js +3 -0
  43. package/dist/src/types/opencv/FlannBasedMatcher.js.map +1 -0
  44. package/dist/src/types/opencv/HOGDescriptor.d.ts +265 -0
  45. package/dist/src/types/opencv/HOGDescriptor.js +3 -0
  46. package/dist/src/types/opencv/HOGDescriptor.js.map +1 -0
  47. package/dist/src/types/opencv/Logger.d.ts +27 -0
  48. package/dist/src/types/opencv/Logger.js +3 -0
  49. package/dist/src/types/opencv/Logger.js.map +1 -0
  50. package/dist/src/types/opencv/LshTable.d.ts +67 -0
  51. package/dist/src/types/opencv/LshTable.js +3 -0
  52. package/dist/src/types/opencv/LshTable.js.map +1 -0
  53. package/dist/src/types/opencv/Mat.d.ts +1589 -0
  54. package/dist/src/types/opencv/Mat.js +3 -0
  55. package/dist/src/types/opencv/Mat.js.map +1 -0
  56. package/dist/src/types/opencv/MatExpr.d.ts +78 -0
  57. package/dist/src/types/opencv/MatExpr.js +4 -0
  58. package/dist/src/types/opencv/MatExpr.js.map +1 -0
  59. package/dist/src/types/opencv/MatOp.d.ts +29 -0
  60. package/dist/src/types/opencv/MatOp.js +3 -0
  61. package/dist/src/types/opencv/MatOp.js.map +1 -0
  62. package/dist/src/types/opencv/Matx.d.ts +84 -0
  63. package/dist/src/types/opencv/Matx.js +3 -0
  64. package/dist/src/types/opencv/Matx.js.map +1 -0
  65. package/dist/src/types/opencv/Node.d.ts +25 -0
  66. package/dist/src/types/opencv/Node.js +3 -0
  67. package/dist/src/types/opencv/Node.js.map +1 -0
  68. package/dist/src/types/opencv/ORB.d.ts +11 -0
  69. package/dist/src/types/opencv/ORB.js +4 -0
  70. package/dist/src/types/opencv/ORB.js.map +1 -0
  71. package/dist/src/types/opencv/PCA.d.ts +170 -0
  72. package/dist/src/types/opencv/PCA.js +3 -0
  73. package/dist/src/types/opencv/PCA.js.map +1 -0
  74. package/dist/src/types/opencv/RotatedRect.d.ts +63 -0
  75. package/dist/src/types/opencv/RotatedRect.js +3 -0
  76. package/dist/src/types/opencv/RotatedRect.js.map +1 -0
  77. package/dist/src/types/opencv/_hacks.d.ts +267 -0
  78. package/dist/src/types/opencv/_hacks.js +15 -0
  79. package/dist/src/types/opencv/_hacks.js.map +1 -0
  80. package/dist/src/types/opencv/_types.d.ts +44 -0
  81. package/dist/src/types/opencv/_types.js +61 -0
  82. package/dist/src/types/opencv/_types.js.map +1 -0
  83. package/dist/src/types/opencv/calib3d.d.ts +2180 -0
  84. package/dist/src/types/opencv/calib3d.js +3 -0
  85. package/dist/src/types/opencv/calib3d.js.map +1 -0
  86. package/dist/src/types/opencv/core_array.d.ts +2513 -0
  87. package/dist/src/types/opencv/core_array.js +3 -0
  88. package/dist/src/types/opencv/core_array.js.map +1 -0
  89. package/dist/src/types/opencv/core_cluster.d.ts +54 -0
  90. package/dist/src/types/opencv/core_cluster.js +3 -0
  91. package/dist/src/types/opencv/core_cluster.js.map +1 -0
  92. package/dist/src/types/opencv/core_hal_interface.d.ts +92 -0
  93. package/dist/src/types/opencv/core_hal_interface.js +3 -0
  94. package/dist/src/types/opencv/core_hal_interface.js.map +1 -0
  95. package/dist/src/types/opencv/core_utils.d.ts +510 -0
  96. package/dist/src/types/opencv/core_utils.js +3 -0
  97. package/dist/src/types/opencv/core_utils.js.map +1 -0
  98. package/dist/src/types/opencv/dnn.d.ts +336 -0
  99. package/dist/src/types/opencv/dnn.js +3 -0
  100. package/dist/src/types/opencv/dnn.js.map +1 -0
  101. package/dist/src/types/opencv/features2d_draw.d.ts +75 -0
  102. package/dist/src/types/opencv/features2d_draw.js +3 -0
  103. package/dist/src/types/opencv/features2d_draw.js.map +1 -0
  104. package/dist/src/types/opencv/imgproc_color_conversions.d.ts +299 -0
  105. package/dist/src/types/opencv/imgproc_color_conversions.js +3 -0
  106. package/dist/src/types/opencv/imgproc_color_conversions.js.map +1 -0
  107. package/dist/src/types/opencv/imgproc_draw.d.ts +502 -0
  108. package/dist/src/types/opencv/imgproc_draw.js +3 -0
  109. package/dist/src/types/opencv/imgproc_draw.js.map +1 -0
  110. package/dist/src/types/opencv/imgproc_feature.d.ts +533 -0
  111. package/dist/src/types/opencv/imgproc_feature.js +3 -0
  112. package/dist/src/types/opencv/imgproc_feature.js.map +1 -0
  113. package/dist/src/types/opencv/imgproc_filter.d.ts +689 -0
  114. package/dist/src/types/opencv/imgproc_filter.js +3 -0
  115. package/dist/src/types/opencv/imgproc_filter.js.map +1 -0
  116. package/dist/src/types/opencv/imgproc_hist.d.ts +291 -0
  117. package/dist/src/types/opencv/imgproc_hist.js +3 -0
  118. package/dist/src/types/opencv/imgproc_hist.js.map +1 -0
  119. package/dist/src/types/opencv/imgproc_misc.d.ts +473 -0
  120. package/dist/src/types/opencv/imgproc_misc.js +3 -0
  121. package/dist/src/types/opencv/imgproc_misc.js.map +1 -0
  122. package/dist/src/types/opencv/imgproc_object.d.ts +41 -0
  123. package/dist/src/types/opencv/imgproc_object.js +3 -0
  124. package/dist/src/types/opencv/imgproc_object.js.map +1 -0
  125. package/dist/src/types/opencv/imgproc_shape.d.ts +570 -0
  126. package/dist/src/types/opencv/imgproc_shape.js +3 -0
  127. package/dist/src/types/opencv/imgproc_shape.js.map +1 -0
  128. package/dist/src/types/opencv/imgproc_transform.d.ts +430 -0
  129. package/dist/src/types/opencv/imgproc_transform.js +3 -0
  130. package/dist/src/types/opencv/imgproc_transform.js.map +1 -0
  131. package/dist/src/types/opencv/index.d.ts +4 -0
  132. package/dist/src/types/opencv/index.js +19 -0
  133. package/dist/src/types/opencv/index.js.map +1 -0
  134. package/dist/src/types/opencv/objdetect.d.ts +43 -0
  135. package/dist/src/types/opencv/objdetect.js +3 -0
  136. package/dist/src/types/opencv/objdetect.js.map +1 -0
  137. package/dist/src/types/opencv/photo_inpaint.d.ts +25 -0
  138. package/dist/src/types/opencv/photo_inpaint.js +3 -0
  139. package/dist/src/types/opencv/photo_inpaint.js.map +1 -0
  140. package/dist/src/types/opencv/softdouble.d.ts +38 -0
  141. package/dist/src/types/opencv/softdouble.js +3 -0
  142. package/dist/src/types/opencv/softdouble.js.map +1 -0
  143. package/dist/src/types/opencv/softfloat.d.ts +38 -0
  144. package/dist/src/types/opencv/softfloat.js +3 -0
  145. package/dist/src/types/opencv/softfloat.js.map +1 -0
  146. package/dist/src/types/opencv/video_track.d.ts +276 -0
  147. package/dist/src/types/opencv/video_track.js +3 -0
  148. package/dist/src/types/opencv/video_track.js.map +1 -0
  149. package/package.json +5 -3
  150. package/src/index.ts +1 -0
  151. package/src/types/_cv.ts +6 -0
  152. package/src/types/emscripten.ts +286 -0
  153. package/src/types/opencv/Affine3.ts +206 -0
  154. package/src/types/opencv/Algorithm.ts +126 -0
  155. package/src/types/opencv/AutoBuffer.ts +50 -0
  156. package/src/types/opencv/BFMatcher.ts +37 -0
  157. package/src/types/opencv/BOWTrainer.ts +43 -0
  158. package/src/types/opencv/CascadeClassifier.ts +153 -0
  159. package/src/types/opencv/DescriptorMatcher.ts +244 -0
  160. package/src/types/opencv/DynamicBitset.ts +68 -0
  161. package/src/types/opencv/Exception.ts +54 -0
  162. package/src/types/opencv/Feature2D.ts +20 -0
  163. package/src/types/opencv/FlannBasedMatcher.ts +50 -0
  164. package/src/types/opencv/HOGDescriptor.ts +401 -0
  165. package/src/types/opencv/Logger.ts +34 -0
  166. package/src/types/opencv/LshTable.ts +81 -0
  167. package/src/types/opencv/Mat.ts +1764 -0
  168. package/src/types/opencv/MatExpr.ts +107 -0
  169. package/src/types/opencv/MatOp.ts +70 -0
  170. package/src/types/opencv/Matx.ts +228 -0
  171. package/src/types/opencv/Node.ts +33 -0
  172. package/src/types/opencv/ORB.ts +22 -0
  173. package/src/types/opencv/PCA.ts +204 -0
  174. package/src/types/opencv/RotatedRect.ts +72 -0
  175. package/src/types/opencv/_hacks.ts +322 -0
  176. package/src/types/opencv/_types.ts +44 -0
  177. package/src/types/opencv/calib3d.ts +2937 -0
  178. package/src/types/opencv/core_array.ts +3102 -0
  179. package/src/types/opencv/core_cluster.ts +81 -0
  180. package/src/types/opencv/core_hal_interface.ts +159 -0
  181. package/src/types/opencv/core_utils.ts +748 -0
  182. package/src/types/opencv/dnn.ts +505 -0
  183. package/src/types/opencv/features2d_draw.ts +114 -0
  184. package/src/types/opencv/imgproc_color_conversions.ts +527 -0
  185. package/src/types/opencv/imgproc_draw.ts +733 -0
  186. package/src/types/opencv/imgproc_feature.ts +681 -0
  187. package/src/types/opencv/imgproc_filter.ts +918 -0
  188. package/src/types/opencv/imgproc_hist.ts +399 -0
  189. package/src/types/opencv/imgproc_misc.ts +616 -0
  190. package/src/types/opencv/imgproc_object.ts +58 -0
  191. package/src/types/opencv/imgproc_shape.ts +734 -0
  192. package/src/types/opencv/imgproc_transform.ts +574 -0
  193. package/src/types/opencv/index.ts +4 -0
  194. package/src/types/opencv/objdetect.ts +103 -0
  195. package/src/types/opencv/photo_inpaint.ts +37 -0
  196. package/src/types/opencv/softdouble.ts +64 -0
  197. package/src/types/opencv/softfloat.ts +64 -0
  198. package/src/types/opencv/video_track.ts +372 -0
@@ -0,0 +1,1764 @@
1
+ import {
2
+ AccessFlag,
3
+ bool,
4
+ double,
5
+ InputArray,
6
+ int,
7
+ MatAllocator,
8
+ MatCommaInitializer_,
9
+ MatConstIterator_,
10
+ MatExpr,
11
+ MatIterator_,
12
+ MatSize,
13
+ MatStep,
14
+ Matx,
15
+ OutputArray,
16
+ Point,
17
+ Point3_,
18
+ Point_,
19
+ Rect,
20
+ Scalar,
21
+ Size,
22
+ size_t,
23
+ typename,
24
+ uchar,
25
+ UMat,
26
+ UMatData,
27
+ UMatUsageFlags,
28
+ Vec,
29
+ } from "./_types";
30
+
31
+ /**
32
+ * <a name="d3/d63/classcv_1_1Mat_1CVMat_Details"></a> The class [Mat](#d3/d63/classcv_1_1Mat})
33
+ * represents an n-dimensional dense numerical single-channel or multi-channel array. It can be used to
34
+ * store real or complex-valued vectors and matrices, grayscale or color images, voxel volumes, vector
35
+ * fields, point clouds, tensors, histograms (though, very high-dimensional histograms may be better
36
+ * stored in a [SparseMat](#dd/da9/classcv_1_1SparseMat}) ). The data layout of the array `M` is
37
+ * defined by the array `M.step[]`, so that the address of element `$(i_0,...,i_{M.dims-1})$`, where
38
+ * `$0\\leq i_k<M.size[k]$`, is computed as: `\\[addr(M_{i_0,...,i_{M.dims-1}}) = M.data +
39
+ * M.step[0]*i_0 + M.step[1]*i_1 + ... + M.step[M.dims-1]*i_{M.dims-1}\\]` In case of a 2-dimensional
40
+ * array, the above formula is reduced to: `\\[addr(M_{i,j}) = M.data + M.step[0]*i + M.step[1]*j\\]`
41
+ * Note that `M.step[i] >= M.step[i+1]` (in fact, `M.step[i] >= M.step[i+1]*M.size[i+1]` ). This means
42
+ * that 2-dimensional matrices are stored row-by-row, 3-dimensional matrices are stored plane-by-plane,
43
+ * and so on. M.step[M.dims-1] is minimal and always equal to the element size M.elemSize() .
44
+ *
45
+ * So, the data layout in [Mat](#d3/d63/classcv_1_1Mat}) is compatible with the majority of dense array
46
+ * types from the standard toolkits and SDKs, such as Numpy (ndarray), Win32 (independent device
47
+ * bitmaps), and others, that is, with any array that uses *steps* (or *strides*) to compute the
48
+ * position of a pixel. Due to this compatibility, it is possible to make a
49
+ * [Mat](#d3/d63/classcv_1_1Mat}) header for user-allocated data and process it in-place using OpenCV
50
+ * functions.
51
+ *
52
+ * There are many different ways to create a [Mat](#d3/d63/classcv_1_1Mat}) object. The most popular
53
+ * options are listed below:
54
+ *
55
+ * Use the create(nrows, ncols, type) method or the similar Mat(nrows, ncols, type[, fillValue])
56
+ * constructor. A new array of the specified size and type is allocated. type has the same meaning as
57
+ * in the cvCreateMat method. For example, CV_8UC1 means a 8-bit single-channel array, CV_32FC2 means a
58
+ * 2-channel (complex) floating-point array, and so on.
59
+ *
60
+ * ```cpp
61
+ * // make a 7x7 complex matrix filled with 1+3j.
62
+ * Mat M(7,7,CV_32FC2,Scalar(1,3));
63
+ * // and now turn M to a 100x60 15-channel 8-bit matrix.
64
+ * // The old content will be deallocated
65
+ * M.create(100,60,CV_8UC(15));
66
+ * ```
67
+ *
68
+ * As noted in the introduction to this chapter,
69
+ * [create()](#d3/d63/classcv_1_1Mat_1a55ced2c8d844d683ea9a725c60037ad0}) allocates only a new array
70
+ * when the shape or type of the current array are different from the specified ones.
71
+ * Create a multi-dimensional array:
72
+ *
73
+ * ```cpp
74
+ * // create a 100x100x100 8-bit array
75
+ * int sz[] = {100, 100, 100};
76
+ * Mat bigCube(3, sz, CV_8U, Scalar::all(0));
77
+ * ```
78
+ *
79
+ * It passes the number of dimensions =1 to the [Mat](#d3/d63/classcv_1_1Mat}) constructor but the
80
+ * created array will be 2-dimensional with the number of columns set to 1. So,
81
+ * [Mat::dims](#d3/d63/classcv_1_1Mat_1a39cf614aa52567e9a945cd2609bd767b}) is always >= 2 (can also be
82
+ * 0 when the array is empty).
83
+ * Use a copy constructor or assignment operator where there can be an array or expression on the right
84
+ * side (see below). As noted in the introduction, the array assignment is an O(1) operation because it
85
+ * only copies the header and increases the reference counter. The
86
+ * [Mat::clone()](#d3/d63/classcv_1_1Mat_1adff2ea98da45eae0833e73582dd4a660}) method can be used to get
87
+ * a full (deep) copy of the array when you need it.
88
+ * Construct a header for a part of another array. It can be a single row, single column, several rows,
89
+ * several columns, rectangular region in the array (called a *minor* in algebra) or a diagonal. Such
90
+ * operations are also O(1) because the new header references the same data. You can actually modify a
91
+ * part of the array using this feature, for example:
92
+ *
93
+ * ```cpp
94
+ * // add the 5-th row, multiplied by 3 to the 3rd row
95
+ * M.row(3) = M.row(3) + M.row(5)*3;
96
+ * // now copy the 7-th column to the 1-st column
97
+ * // M.col(1) = M.col(7); // this will not work
98
+ * Mat M1 = M.col(1);
99
+ * M.col(7).copyTo(M1);
100
+ * // create a new 320x240 image
101
+ * Mat img(Size(320,240),CV_8UC3);
102
+ * // select a ROI
103
+ * Mat roi(img, Rect(10,10,100,100));
104
+ * // fill the ROI with (0,255,0) (which is green in RGB space);
105
+ * // the original 320x240 image will be modified
106
+ * roi = Scalar(0,255,0);
107
+ * ```
108
+ *
109
+ * Due to the additional datastart and dataend members, it is possible to compute a relative sub-array
110
+ * position in the main *container* array using
111
+ * [locateROI()](#d3/d63/classcv_1_1Mat_1a40b5b3371a9c2a4b2b8ce0c8068d7c96}):
112
+ *
113
+ * ```cpp
114
+ * Mat A = Mat::eye(10, 10, CV_32S);
115
+ * // extracts A columns, 1 (inclusive) to 3 (exclusive).
116
+ * Mat B = A(Range::all(), Range(1, 3));
117
+ * // extracts B rows, 5 (inclusive) to 9 (exclusive).
118
+ * // that is, C \\~ A(Range(5, 9), Range(1, 3))
119
+ * Mat C = B(Range(5, 9), Range::all());
120
+ * Size size; Point ofs;
121
+ * C.locateROI(size, ofs);
122
+ * // size will be (width=10,height=10) and the ofs will be (x=1, y=5)
123
+ * ```
124
+ *
125
+ * As in case of whole matrices, if you need a deep copy, use the
126
+ * `[clone()](#d3/d63/classcv_1_1Mat_1adff2ea98da45eae0833e73582dd4a660})` method of the extracted
127
+ * sub-matrices.
128
+ * Make a header for user-allocated data. It can be useful to do the following:
129
+ *
130
+ * Process "foreign" data using OpenCV (for example, when you implement a DirectShow* filter or a
131
+ * processing module for gstreamer, and so on). For example:
132
+ *
133
+ * ```cpp
134
+ * void process_video_frame(const unsigned char* pixels,
135
+ * int width, int height, int step)
136
+ * {
137
+ * Mat img(height, width, CV_8UC3, pixels, step);
138
+ * GaussianBlur(img, img, Size(7,7), 1.5, 1.5);
139
+ * }
140
+ * ```
141
+ *
142
+ * Quickly initialize small matrices and/or get a super-fast element access.
143
+ *
144
+ * ```cpp
145
+ * double m[3][3] = {{a, b, c}, {d, e, f}, {g, h, i}};
146
+ * Mat M = Mat(3, 3, CV_64F, m).inv();
147
+ * ```
148
+ *
149
+ * Use MATLAB-style array initializers,
150
+ * [zeros()](#d3/d63/classcv_1_1Mat_1a0b57b6a326c8876d944d188a46e0f556}),
151
+ * [ones()](#d3/d63/classcv_1_1Mat_1a69ae0402d116fc9c71908d8508dc2f09}),
152
+ * [eye()](#d3/d63/classcv_1_1Mat_1a2cf9b9acde7a9852542bbc20ef851ed2}), for example:
153
+ *
154
+ * ```cpp
155
+ * // create a double-precision identity matrix and add it to M.
156
+ * M += Mat::eye(M.rows, M.cols, CV_64F);
157
+ * ```
158
+ *
159
+ * Use a comma-separated initializer:
160
+ *
161
+ * ```cpp
162
+ * // create a 3x3 double-precision identity matrix
163
+ * Mat M = (Mat_<double>(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);
164
+ * ```
165
+ *
166
+ * With this approach, you first call a constructor of the [Mat](#d3/d63/classcv_1_1Mat}) class with
167
+ * the proper parameters, and then you just put `<< operator` followed by comma-separated values that
168
+ * can be constants, variables, expressions, and so on. Also, note the extra parentheses required to
169
+ * avoid compilation errors.
170
+ *
171
+ * Once the array is created, it is automatically managed via a reference-counting mechanism. If the
172
+ * array header is built on top of user-allocated data, you should handle the data by yourself. The
173
+ * array data is deallocated when no one points to it. If you want to release the data pointed by a
174
+ * array header before the array destructor is called, use
175
+ * [Mat::release()](#d3/d63/classcv_1_1Mat_1ae48d4913285518e2c21a3457017e716e}).
176
+ *
177
+ * The next important thing to learn about the array class is element access. This manual already
178
+ * described how to compute an address of each array element. Normally, you are not required to use the
179
+ * formula directly in the code. If you know the array element type (which can be retrieved using the
180
+ * method [Mat::type()](#d3/d63/classcv_1_1Mat_1af2d2652e552d7de635988f18a84b53e5}) ), you can access
181
+ * the element `$M_{ij}$` of a 2-dimensional array as:
182
+ *
183
+ * ```cpp
184
+ * M.at<double>(i,j) += 1.f;
185
+ * ```
186
+ *
187
+ * assuming that `M` is a double-precision floating-point array. There are several variants of the
188
+ * method at for a different number of dimensions.
189
+ *
190
+ * If you need to process a whole row of a 2D array, the most efficient way is to get the pointer to
191
+ * the row first, and then just use the plain C operator [] :
192
+ *
193
+ * ```cpp
194
+ * // compute sum of positive matrix elements
195
+ * // (assuming that M is a double-precision matrix)
196
+ * double sum=0;
197
+ * for(int i = 0; i < M.rows; i++)
198
+ * {
199
+ * const double* Mi = M.ptr<double>(i);
200
+ * for(int j = 0; j < M.cols; j++)
201
+ * sum += std::max(Mi[j], 0.);
202
+ * }
203
+ * ```
204
+ *
205
+ * Some operations, like the one above, do not actually depend on the array shape. They just process
206
+ * elements of an array one by one (or elements from multiple arrays that have the same coordinates,
207
+ * for example, array addition). Such operations are called *element-wise*. It makes sense to check
208
+ * whether all the input/output arrays are continuous, namely, have no gaps at the end of each row. If
209
+ * yes, process them as a long single row:
210
+ *
211
+ * ```cpp
212
+ * // compute the sum of positive matrix elements, optimized variant
213
+ * double sum=0;
214
+ * int cols = M.cols, rows = M.rows;
215
+ * if(M.isContinuous())
216
+ * {
217
+ * cols *= rows;
218
+ * rows = 1;
219
+ * }
220
+ * for(int i = 0; i < rows; i++)
221
+ * {
222
+ * const double* Mi = M.ptr<double>(i);
223
+ * for(int j = 0; j < cols; j++)
224
+ * sum += std::max(Mi[j], 0.);
225
+ * }
226
+ * ```
227
+ *
228
+ * In case of the continuous matrix, the outer loop body is executed just once. So, the overhead is
229
+ * smaller, which is especially noticeable in case of small matrices.
230
+ *
231
+ * Finally, there are STL-style iterators that are smart enough to skip gaps between successive rows:
232
+ *
233
+ * ```cpp
234
+ * // compute sum of positive matrix elements, iterator-based variant
235
+ * double sum=0;
236
+ * MatConstIterator_<double> it = M.begin<double>(), it_end = M.end<double>();
237
+ * for(; it != it_end; ++it)
238
+ * sum += std::max(*it, 0.);
239
+ * ```
240
+ *
241
+ * The matrix iterators are random-access iterators, so they can be passed to any STL algorithm,
242
+ * including [std::sort()](#d2/de8/group__core__array_1ga45dd56da289494ce874be2324856898f}).
243
+ *
244
+ * Matrix Expressions and arithmetic see [MatExpr](#d1/d10/classcv_1_1MatExpr})
245
+ *
246
+ * Source:
247
+ * [opencv2/core/mat.hpp](https://github.com/opencv/opencv/tree/master/modules/core/include/opencv2/core/mat.hpp#L2073).
248
+ *
249
+ */
250
+ export declare class Mat {
251
+ public allocator: MatAllocator;
252
+
253
+ public cols: int;
254
+
255
+ public data: Uint8Array;
256
+ public data8S: Int8Array;
257
+ public data8U: Uint8Array;
258
+ public data16U: Uint16Array;
259
+ public data16S: Int16Array;
260
+ public data32U: Uint32Array;
261
+ public data32S: Int32Array;
262
+ public data32F: Float32Array;
263
+ public data64F: Float64Array;
264
+
265
+ public dataend: uchar;
266
+
267
+ public datalimit: uchar;
268
+
269
+ public datastart: uchar;
270
+
271
+ public dims: int;
272
+
273
+ /**
274
+ * includes several bit-fields:
275
+ *
276
+ * the magic signature
277
+ * continuity flag
278
+ * depth
279
+ * number of channels
280
+ *
281
+ */
282
+ public flags: int;
283
+
284
+ public rows: int;
285
+
286
+ public size: MatSize;
287
+
288
+ public step: MatStep;
289
+
290
+ public u: UMatData;
291
+
292
+ /**
293
+ * These are various constructors that form a matrix. As noted in the AutomaticAllocation, often the
294
+ * default constructor is enough, and the proper matrix will be allocated by an OpenCV function. The
295
+ * constructed matrix can further be assigned to another matrix or matrix expression or can be
296
+ * allocated with [Mat::create] . In the former case, the old content is de-referenced.
297
+ */
298
+ public constructor();
299
+
300
+ /**
301
+ * This is an overloaded member function, provided for convenience. It differs from the above
302
+ * function only in what argument(s) it accepts.
303
+ *
304
+ * @param rows Number of rows in a 2D array.
305
+ *
306
+ * @param cols Number of columns in a 2D array.
307
+ *
308
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
309
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
310
+ */
311
+ public constructor(rows: int, cols: int, type: int);
312
+
313
+ /**
314
+ * This is an overloaded member function, provided for convenience. It differs from the above
315
+ * function only in what argument(s) it accepts.
316
+ *
317
+ * @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and
318
+ * the number of columns go in the reverse order.
319
+ *
320
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
321
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
322
+ */
323
+ public constructor(size: Size, type: int);
324
+
325
+ /**
326
+ * This is an overloaded member function, provided for convenience. It differs from the above
327
+ * function only in what argument(s) it accepts.
328
+ *
329
+ * @param rows Number of rows in a 2D array.
330
+ *
331
+ * @param cols Number of columns in a 2D array.
332
+ *
333
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
334
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
335
+ *
336
+ * @param s An optional value to initialize each matrix element with. To set all the matrix elements
337
+ * to the particular value after the construction, use the assignment operator Mat::operator=(const
338
+ * Scalar& value) .
339
+ */
340
+ public constructor(rows: int, cols: int, type: int, s: Scalar);
341
+
342
+ /**
343
+ * This is an overloaded member function, provided for convenience. It differs from the above
344
+ * function only in what argument(s) it accepts.
345
+ *
346
+ * @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and
347
+ * the number of columns go in the reverse order.
348
+ *
349
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
350
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
351
+ *
352
+ * @param s An optional value to initialize each matrix element with. To set all the matrix elements
353
+ * to the particular value after the construction, use the assignment operator Mat::operator=(const
354
+ * Scalar& value) .
355
+ */
356
+ public constructor(size: Size, type: int, s: Scalar);
357
+
358
+ /**
359
+ * This is an overloaded member function, provided for convenience. It differs from the above
360
+ * function only in what argument(s) it accepts.
361
+ *
362
+ * @param ndims Array dimensionality.
363
+ *
364
+ * @param sizes Array of integers specifying an n-dimensional array shape.
365
+ *
366
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
367
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
368
+ */
369
+ public constructor(ndims: int, sizes: any, type: int);
370
+
371
+ /**
372
+ * This is an overloaded member function, provided for convenience. It differs from the above
373
+ * function only in what argument(s) it accepts.
374
+ *
375
+ * @param sizes Array of integers specifying an n-dimensional array shape.
376
+ *
377
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
378
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
379
+ */
380
+ public constructor(sizes: any, type: int);
381
+
382
+ /**
383
+ * This is an overloaded member function, provided for convenience. It differs from the above
384
+ * function only in what argument(s) it accepts.
385
+ *
386
+ * @param ndims Array dimensionality.
387
+ *
388
+ * @param sizes Array of integers specifying an n-dimensional array shape.
389
+ *
390
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
391
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
392
+ *
393
+ * @param s An optional value to initialize each matrix element with. To set all the matrix elements
394
+ * to the particular value after the construction, use the assignment operator Mat::operator=(const
395
+ * Scalar& value) .
396
+ */
397
+ public constructor(ndims: int, sizes: any, type: int, s: Scalar);
398
+
399
+ /**
400
+ * This is an overloaded member function, provided for convenience. It differs from the above
401
+ * function only in what argument(s) it accepts.
402
+ *
403
+ * @param sizes Array of integers specifying an n-dimensional array shape.
404
+ *
405
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
406
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
407
+ *
408
+ * @param s An optional value to initialize each matrix element with. To set all the matrix elements
409
+ * to the particular value after the construction, use the assignment operator Mat::operator=(const
410
+ * Scalar& value) .
411
+ */
412
+ public constructor(sizes: any, type: int, s: Scalar);
413
+
414
+ /**
415
+ * This is an overloaded member function, provided for convenience. It differs from the above
416
+ * function only in what argument(s) it accepts.
417
+ *
418
+ * @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is
419
+ * copied by these constructors. Instead, the header pointing to m data or its sub-array is constructed
420
+ * and associated with it. The reference counter, if any, is incremented. So, when you modify the
421
+ * matrix formed using such a constructor, you also modify the corresponding elements of m . If you
422
+ * want to have an independent copy of the sub-array, use Mat::clone() .
423
+ */
424
+ public constructor(m: Mat);
425
+
426
+ /**
427
+ * This is an overloaded member function, provided for convenience. It differs from the above
428
+ * function only in what argument(s) it accepts.
429
+ *
430
+ * @param rows Number of rows in a 2D array.
431
+ *
432
+ * @param cols Number of columns in a 2D array.
433
+ *
434
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
435
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
436
+ *
437
+ * @param data Pointer to the user data. Matrix constructors that take data and step parameters do
438
+ * not allocate matrix data. Instead, they just initialize the matrix header that points to the
439
+ * specified data, which means that no data is copied. This operation is very efficient and can be used
440
+ * to process external data using OpenCV functions. The external data is not automatically deallocated,
441
+ * so you should take care of it.
442
+ *
443
+ * @param step Number of bytes each matrix row occupies. The value should include the padding bytes
444
+ * at the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is
445
+ * assumed and the actual step is calculated as cols*elemSize(). See Mat::elemSize.
446
+ */
447
+ public constructor(rows: int, cols: int, type: int, data: any, step?: size_t);
448
+
449
+ /**
450
+ * This is an overloaded member function, provided for convenience. It differs from the above
451
+ * function only in what argument(s) it accepts.
452
+ *
453
+ * @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and
454
+ * the number of columns go in the reverse order.
455
+ *
456
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
457
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
458
+ *
459
+ * @param data Pointer to the user data. Matrix constructors that take data and step parameters do
460
+ * not allocate matrix data. Instead, they just initialize the matrix header that points to the
461
+ * specified data, which means that no data is copied. This operation is very efficient and can be used
462
+ * to process external data using OpenCV functions. The external data is not automatically deallocated,
463
+ * so you should take care of it.
464
+ *
465
+ * @param step Number of bytes each matrix row occupies. The value should include the padding bytes
466
+ * at the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is
467
+ * assumed and the actual step is calculated as cols*elemSize(). See Mat::elemSize.
468
+ */
469
+ public constructor(size: Size, type: int, data: any, step?: size_t);
470
+
471
+ /**
472
+ * This is an overloaded member function, provided for convenience. It differs from the above
473
+ * function only in what argument(s) it accepts.
474
+ *
475
+ * @param ndims Array dimensionality.
476
+ *
477
+ * @param sizes Array of integers specifying an n-dimensional array shape.
478
+ *
479
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
480
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
481
+ *
482
+ * @param data Pointer to the user data. Matrix constructors that take data and step parameters do
483
+ * not allocate matrix data. Instead, they just initialize the matrix header that points to the
484
+ * specified data, which means that no data is copied. This operation is very efficient and can be used
485
+ * to process external data using OpenCV functions. The external data is not automatically deallocated,
486
+ * so you should take care of it.
487
+ *
488
+ * @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always
489
+ * set to the element size). If not specified, the matrix is assumed to be continuous.
490
+ */
491
+ public constructor(ndims: int, sizes: any, type: int, data: any, steps?: any);
492
+
493
+ /**
494
+ * This is an overloaded member function, provided for convenience. It differs from the above
495
+ * function only in what argument(s) it accepts.
496
+ *
497
+ * @param sizes Array of integers specifying an n-dimensional array shape.
498
+ *
499
+ * @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n),
500
+ * ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
501
+ *
502
+ * @param data Pointer to the user data. Matrix constructors that take data and step parameters do
503
+ * not allocate matrix data. Instead, they just initialize the matrix header that points to the
504
+ * specified data, which means that no data is copied. This operation is very efficient and can be used
505
+ * to process external data using OpenCV functions. The external data is not automatically deallocated,
506
+ * so you should take care of it.
507
+ *
508
+ * @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always
509
+ * set to the element size). If not specified, the matrix is assumed to be continuous.
510
+ */
511
+ public constructor(sizes: any, type: int, data: any, steps?: any);
512
+
513
+ /**
514
+ * This is an overloaded member function, provided for convenience. It differs from the above
515
+ * function only in what argument(s) it accepts.
516
+ *
517
+ * @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is
518
+ * copied by these constructors. Instead, the header pointing to m data or its sub-array is constructed
519
+ * and associated with it. The reference counter, if any, is incremented. So, when you modify the
520
+ * matrix formed using such a constructor, you also modify the corresponding elements of m . If you
521
+ * want to have an independent copy of the sub-array, use Mat::clone() .
522
+ *
523
+ * @param rowRange Range of the m rows to take. As usual, the range start is inclusive and the range
524
+ * end is exclusive. Use Range::all() to take all the rows.
525
+ *
526
+ * @param colRange Range of the m columns to take. Use Range::all() to take all the columns.
527
+ */
528
+ public constructor(m: Mat, rowRange: Range, colRange?: Range);
529
+
530
+ /**
531
+ * This is an overloaded member function, provided for convenience. It differs from the above
532
+ * function only in what argument(s) it accepts.
533
+ *
534
+ * @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is
535
+ * copied by these constructors. Instead, the header pointing to m data or its sub-array is constructed
536
+ * and associated with it. The reference counter, if any, is incremented. So, when you modify the
537
+ * matrix formed using such a constructor, you also modify the corresponding elements of m . If you
538
+ * want to have an independent copy of the sub-array, use Mat::clone() .
539
+ *
540
+ * @param roi Region of interest.
541
+ */
542
+ public constructor(m: Mat, roi: Rect);
543
+
544
+ /**
545
+ * This is an overloaded member function, provided for convenience. It differs from the above
546
+ * function only in what argument(s) it accepts.
547
+ *
548
+ * @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is
549
+ * copied by these constructors. Instead, the header pointing to m data or its sub-array is constructed
550
+ * and associated with it. The reference counter, if any, is incremented. So, when you modify the
551
+ * matrix formed using such a constructor, you also modify the corresponding elements of m . If you
552
+ * want to have an independent copy of the sub-array, use Mat::clone() .
553
+ *
554
+ * @param ranges Array of selected ranges of m along each dimensionality.
555
+ */
556
+ public constructor(m: Mat, ranges: Range);
557
+
558
+ /**
559
+ * This is an overloaded member function, provided for convenience. It differs from the above
560
+ * function only in what argument(s) it accepts.
561
+ *
562
+ * @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is
563
+ * copied by these constructors. Instead, the header pointing to m data or its sub-array is constructed
564
+ * and associated with it. The reference counter, if any, is incremented. So, when you modify the
565
+ * matrix formed using such a constructor, you also modify the corresponding elements of m . If you
566
+ * want to have an independent copy of the sub-array, use Mat::clone() .
567
+ *
568
+ * @param ranges Array of selected ranges of m along each dimensionality.
569
+ */
570
+ public constructor(m: Mat, ranges: Range);
571
+
572
+ /**
573
+ * This is an overloaded member function, provided for convenience. It differs from the above
574
+ * function only in what argument(s) it accepts.
575
+ *
576
+ * @param vec STL vector whose elements form the matrix. The matrix has a single column and the
577
+ * number of rows equal to the number of vector elements. Type of the matrix matches the type of vector
578
+ * elements. The constructor can handle arbitrary types, for which there is a properly declared
579
+ * DataType . This means that the vector elements must be primitive numbers or uni-type numerical
580
+ * tuples of numbers. Mixed-type structures are not supported. The corresponding constructor is
581
+ * explicit. Since STL vectors are not automatically converted to Mat instances, you should write
582
+ * Mat(vec) explicitly. Unless you copy the data into the matrix ( copyData=true ), no new elements
583
+ * will be added to the vector because it can potentially yield vector data reallocation, and, thus,
584
+ * the matrix data pointer will be invalid.
585
+ *
586
+ * @param copyData Flag to specify whether the underlying data of the STL vector should be copied to
587
+ * (true) or shared with (false) the newly constructed matrix. When the data is copied, the allocated
588
+ * buffer is managed using Mat reference counting mechanism. While the data is shared, the reference
589
+ * counter is NULL, and you should not deallocate the data until the matrix is not destructed.
590
+ */
591
+ public constructor(arg3: any, vec: any, copyData?: bool);
592
+
593
+ /**
594
+ * This is an overloaded member function, provided for convenience. It differs from the above
595
+ * function only in what argument(s) it accepts.
596
+ */
597
+ public constructor(arg4: any, arg5?: typename, list?: any);
598
+
599
+ /**
600
+ * This is an overloaded member function, provided for convenience. It differs from the above
601
+ * function only in what argument(s) it accepts.
602
+ */
603
+ public constructor(arg6: any, sizes: any, list: any);
604
+
605
+ /**
606
+ * This is an overloaded member function, provided for convenience. It differs from the above
607
+ * function only in what argument(s) it accepts.
608
+ */
609
+ public constructor(arg7: any, _Nm: size_t, arr: any, copyData?: bool);
610
+
611
+ /**
612
+ * This is an overloaded member function, provided for convenience. It differs from the above
613
+ * function only in what argument(s) it accepts.
614
+ */
615
+ public constructor(arg8: any, n: int, vec: Vec, copyData?: bool);
616
+
617
+ /**
618
+ * This is an overloaded member function, provided for convenience. It differs from the above
619
+ * function only in what argument(s) it accepts.
620
+ */
621
+ public constructor(arg9: any, m: int, n: int, mtx: Matx, copyData?: bool);
622
+
623
+ /**
624
+ * This is an overloaded member function, provided for convenience. It differs from the above
625
+ * function only in what argument(s) it accepts.
626
+ */
627
+ public constructor(arg10: any, pt: Point_, copyData?: bool);
628
+
629
+ /**
630
+ * This is an overloaded member function, provided for convenience. It differs from the above
631
+ * function only in what argument(s) it accepts.
632
+ */
633
+ public constructor(arg11: any, pt: Point3_, copyData?: bool);
634
+
635
+ /**
636
+ * This is an overloaded member function, provided for convenience. It differs from the above
637
+ * function only in what argument(s) it accepts.
638
+ */
639
+ public constructor(arg12: any, commaInitializer: MatCommaInitializer_);
640
+
641
+ public constructor(m: any);
642
+
643
+ public constructor(m: Mat);
644
+
645
+ /**
646
+ * The method increments the reference counter associated with the matrix data. If the matrix header
647
+ * points to an external data set (see [Mat::Mat] ), the reference counter is NULL, and the method has
648
+ * no effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly.
649
+ * It is called implicitly by the matrix assignment operator. The reference counter increment is an
650
+ * atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices
651
+ * asynchronously in different threads.
652
+ */
653
+ public addref(): void;
654
+
655
+ /**
656
+ * The method is complimentary to [Mat::locateROI] . The typical use of these functions is to
657
+ * determine the submatrix position within the parent matrix and then shift the position somehow.
658
+ * Typically, it can be required for filtering operations when pixels outside of the ROI should be
659
+ * taken into account. When all the method parameters are positive, the ROI needs to grow in all
660
+ * directions by the specified amount, for example:
661
+ *
662
+ * ```cpp
663
+ * A.adjustROI(2, 2, 2, 2);
664
+ * ```
665
+ *
666
+ * In this example, the matrix size is increased by 4 elements in each direction. The matrix is
667
+ * shifted by 2 elements to the left and 2 elements up, which brings in all the necessary pixels for
668
+ * the filtering with the 5x5 kernel.
669
+ *
670
+ * adjustROI forces the adjusted ROI to be inside of the parent matrix that is boundaries of the
671
+ * adjusted ROI are constrained by boundaries of the parent matrix. For example, if the submatrix A is
672
+ * located in the first row of a parent matrix and you called A.adjustROI(2, 2, 2, 2) then A will not
673
+ * be increased in the upward direction.
674
+ *
675
+ * The function is used internally by the OpenCV filtering functions, like filter2D , morphological
676
+ * operations, and so on.
677
+ *
678
+ * [copyMakeBorder]
679
+ *
680
+ * @param dtop Shift of the top submatrix boundary upwards.
681
+ *
682
+ * @param dbottom Shift of the bottom submatrix boundary downwards.
683
+ *
684
+ * @param dleft Shift of the left submatrix boundary to the left.
685
+ *
686
+ * @param dright Shift of the right submatrix boundary to the right.
687
+ */
688
+ public adjustROI(dtop: int, dbottom: int, dleft: int, dright: int): Mat;
689
+ /**
690
+ * The methods return the matrix read-only or read-write iterators. The use of matrix iterators is
691
+ * very similar to the use of bi-directional STL iterators. In the example below, the alpha blending
692
+ * function is rewritten using the matrix iterators:
693
+ *
694
+ * ```cpp
695
+ * template<typename T>
696
+ * void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst)
697
+ * {
698
+ * typedef Vec<T, 4> VT;
699
+ *
700
+ * const float alpha_scale = (float)std::numeric_limits<T>::max(),
701
+ * inv_scale = 1.f/alpha_scale;
702
+ *
703
+ * CV_Assert( src1.type() == src2.type() &&
704
+ * src1.type() == traits::Type<VT>::value &&
705
+ * src1.size() == src2.size());
706
+ * Size size = src1.size();
707
+ * dst.create(size, src1.type());
708
+ *
709
+ * MatConstIterator_<VT> it1 = src1.begin<VT>(), it1_end = src1.end<VT>();
710
+ * MatConstIterator_<VT> it2 = src2.begin<VT>();
711
+ * MatIterator_<VT> dst_it = dst.begin<VT>();
712
+ *
713
+ * for( ; it1 != it1_end; ++it1, ++it2, ++dst_it )
714
+ * {
715
+ * VT pix1 = *it1, pix2 = *it2;
716
+ * float alpha = pix1[3]*inv_scale, beta = pix2[3]*inv_scale;
717
+ * dst_it = VT(saturate_cast<T>(pix1[0]*alpha + pix2[0]*beta),
718
+ * saturate_cast<T>(pix1[1]*alpha + pix2[1]*beta),
719
+ * saturate_cast<T>(pix1[2]*alpha + pix2[2]*beta),
720
+ * saturate_cast<T>((1 - (1-alpha)*(1-beta))*alpha_scale));
721
+ * }
722
+ * }
723
+ * ```
724
+ */
725
+ public begin(arg25: any): MatIterator_;
726
+
727
+ public begin(arg26: any): MatConstIterator_;
728
+
729
+ /**
730
+ * The method returns the number of matrix channels.
731
+ */
732
+ public channels(): int;
733
+
734
+ /**
735
+ * -1 if the requirement is not satisfied. Otherwise, it returns the number of elements in the
736
+ * matrix. Note that an element may have multiple channels.
737
+ * The following code demonstrates its usage for a 2-d matrix:
738
+ *
739
+ * ```cpp
740
+ * cv::Mat mat(20, 1, CV_32FC2);
741
+ * int n = mat.checkVector(2);
742
+ * CV_Assert(n == 20); // mat has 20 elements
743
+ *
744
+ * mat.create(20, 2, CV_32FC1);
745
+ * n = mat.checkVector(1);
746
+ * CV_Assert(n == -1); // mat is neither a column nor a row vector
747
+ *
748
+ * n = mat.checkVector(2);
749
+ * CV_Assert(n == 20); // the 2 columns are considered as 1 element
750
+ * ```
751
+ *
752
+ * The following code demonstrates its usage for a 3-d matrix:
753
+ *
754
+ * ```cpp
755
+ * int dims[] = {1, 3, 5}; // 1 plane, every plane has 3 rows and 5 columns
756
+ * mat.create(3, dims, CV_32FC1); // for 3-d mat, it MUST have only 1 channel
757
+ * n = mat.checkVector(5); // the 5 columns are considered as 1 element
758
+ * CV_Assert(n == 3);
759
+ *
760
+ * int dims2[] = {3, 1, 5}; // 3 planes, every plane has 1 row and 5 columns
761
+ * mat.create(3, dims2, CV_32FC1);
762
+ * n = mat.checkVector(5); // the 5 columns are considered as 1 element
763
+ * CV_Assert(n == 3);
764
+ * ```
765
+ *
766
+ * @param elemChannels Number of channels or number of columns the matrix should have. For a 2-D
767
+ * matrix, when the matrix has only 1 column, then it should have elemChannels channels; When the
768
+ * matrix has only 1 channel, then it should have elemChannels columns. For a 3-D matrix, it should
769
+ * have only one channel. Furthermore, if the number of planes is not one, then the number of rows
770
+ * within every plane has to be 1; if the number of rows within every plane is not 1, then the number
771
+ * of planes has to be 1.
772
+ *
773
+ * @param depth The depth the matrix should have. Set it to -1 when any depth is fine.
774
+ *
775
+ * @param requireContinuous Set it to true to require the matrix to be continuous
776
+ */
777
+ public checkVector(
778
+ elemChannels: int,
779
+ depth?: int,
780
+ requireContinuous?: bool,
781
+ ): int;
782
+
783
+ /**
784
+ * The method creates a full copy of the array. The original step[] is not taken into account. So,
785
+ * the array copy is a continuous array occupying [total()]*elemSize() bytes.
786
+ */
787
+ public clone(): Mat;
788
+
789
+ /**
790
+ * The method makes a new header for the specified matrix column and returns it. This is an O(1)
791
+ * operation, regardless of the matrix size. The underlying data of the new matrix is shared with the
792
+ * original matrix. See also the [Mat::row] description.
793
+ *
794
+ * @param x A 0-based column index.
795
+ */
796
+ public col(x: int): Mat;
797
+
798
+ /**
799
+ * The method makes a new header for the specified column span of the matrix. Similarly to [Mat::row]
800
+ * and [Mat::col] , this is an O(1) operation.
801
+ *
802
+ * @param startcol An inclusive 0-based start index of the column span.
803
+ *
804
+ * @param endcol An exclusive 0-based ending index of the column span.
805
+ */
806
+ public colRange(startcol: int, endcol: int): Mat;
807
+
808
+ /**
809
+ * This is an overloaded member function, provided for convenience. It differs from the above
810
+ * function only in what argument(s) it accepts.
811
+ *
812
+ * @param r Range structure containing both the start and the end indices.
813
+ */
814
+ public colRange(r: Range): Mat;
815
+
816
+ /**
817
+ * The method converts source pixel values to the target data type. saturate_cast<> is applied at the
818
+ * end to avoid possible overflows:
819
+ *
820
+ * `\\[m(x,y) = saturate \\_ cast<rType>( \\alpha (*this)(x,y) + \\beta )\\]`
821
+ *
822
+ * @param m output matrix; if it does not have a proper size or type before the operation, it is
823
+ * reallocated.
824
+ *
825
+ * @param rtype desired output matrix type or, rather, the depth since the number of channels are the
826
+ * same as the input has; if rtype is negative, the output matrix will have the same type as the input.
827
+ *
828
+ * @param alpha optional scale factor.
829
+ *
830
+ * @param beta optional delta added to the scaled values.
831
+ */
832
+ public convertTo(
833
+ m: OutputArray,
834
+ rtype: int,
835
+ alpha?: double,
836
+ beta?: double,
837
+ ): OutputArray;
838
+
839
+ public copySize(m: Mat): Mat;
840
+
841
+ /**
842
+ * The method copies the matrix data to another matrix. Before copying the data, the method invokes :
843
+ *
844
+ *
845
+ * ```cpp
846
+ * m.create(this->size(), this->type());
847
+ * ```
848
+ *
849
+ * so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the
850
+ * function does not handle the case of a partial overlap between the source and the destination
851
+ * matrices.
852
+ *
853
+ * When the operation mask is specified, if the [Mat::create] call shown above reallocates the
854
+ * matrix, the newly allocated matrix is initialized with all zeros before copying the data.
855
+ *
856
+ * @param m Destination matrix. If it does not have a proper size or type before the operation, it is
857
+ * reallocated.
858
+ */
859
+ public copyTo(m: OutputArray): OutputArray;
860
+
861
+ /**
862
+ * This is an overloaded member function, provided for convenience. It differs from the above
863
+ * function only in what argument(s) it accepts.
864
+ *
865
+ * @param m Destination matrix. If it does not have a proper size or type before the operation, it is
866
+ * reallocated.
867
+ *
868
+ * @param mask Operation mask of the same size as *this. Its non-zero elements indicate which matrix
869
+ * elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.
870
+ */
871
+ public copyTo(m: OutputArray, mask: InputArray): OutputArray;
872
+
873
+ /**
874
+ * This is one of the key [Mat] methods. Most new-style OpenCV functions and methods that produce
875
+ * arrays call this method for each output array. The method uses the following algorithm:
876
+ *
877
+ * If the current array shape and the type match the new ones, return immediately. Otherwise,
878
+ * de-reference the previous data by calling [Mat::release].
879
+ * Initialize the new header.
880
+ * Allocate the new data of [total()]*elemSize() bytes.
881
+ * Allocate the new, associated with the data, reference counter and set it to 1.
882
+ *
883
+ * Such a scheme makes the memory management robust and efficient at the same time and helps avoid
884
+ * extra typing for you. This means that usually there is no need to explicitly allocate output arrays.
885
+ * That is, instead of writing:
886
+ *
887
+ * ```cpp
888
+ * Mat color;
889
+ * ...
890
+ * Mat gray(color.rows, color.cols, color.depth());
891
+ * cvtColor(color, gray, COLOR_BGR2GRAY);
892
+ * ```
893
+ *
894
+ * you can simply write:
895
+ *
896
+ * ```cpp
897
+ * Mat color;
898
+ * ...
899
+ * Mat gray;
900
+ * cvtColor(color, gray, COLOR_BGR2GRAY);
901
+ * ```
902
+ *
903
+ * because cvtColor, as well as the most of OpenCV functions, calls [Mat::create()] for the output
904
+ * array internally.
905
+ *
906
+ * @param rows New number of rows.
907
+ *
908
+ * @param cols New number of columns.
909
+ *
910
+ * @param type New matrix type.
911
+ */
912
+ public create(rows: int, cols: int, type: int): void;
913
+
914
+ /**
915
+ * This is an overloaded member function, provided for convenience. It differs from the above
916
+ * function only in what argument(s) it accepts.
917
+ *
918
+ * @param size Alternative new matrix size specification: Size(cols, rows)
919
+ *
920
+ * @param type New matrix type.
921
+ */
922
+ public create(size: Size, type: int): Size;
923
+
924
+ /**
925
+ * This is an overloaded member function, provided for convenience. It differs from the above
926
+ * function only in what argument(s) it accepts.
927
+ *
928
+ * @param ndims New array dimensionality.
929
+ *
930
+ * @param sizes Array of integers specifying a new array shape.
931
+ *
932
+ * @param type New matrix type.
933
+ */
934
+ public create(ndims: int, sizes: any, type: int): void;
935
+
936
+ /**
937
+ * This is an overloaded member function, provided for convenience. It differs from the above
938
+ * function only in what argument(s) it accepts.
939
+ *
940
+ * @param sizes Array of integers specifying a new array shape.
941
+ *
942
+ * @param type New matrix type.
943
+ */
944
+ public create(sizes: any, type: int): void;
945
+
946
+ /**
947
+ * The method computes a cross-product of two 3-element vectors. The vectors must be 3-element
948
+ * floating-point vectors of the same shape and size. The result is another 3-element vector of the
949
+ * same shape and type as operands.
950
+ *
951
+ * @param m Another cross-product operand.
952
+ */
953
+ public cross(m: InputArray): Mat;
954
+
955
+ public deallocate(): void;
956
+
957
+ /**
958
+ * The method returns the identifier of the matrix element depth (the type of each individual
959
+ * channel). For example, for a 16-bit signed element array, the method returns CV_16S . A complete
960
+ * list of matrix types contains the following values:
961
+ *
962
+ * CV_8U - 8-bit unsigned integers ( 0..255 )
963
+ * CV_8S - 8-bit signed integers ( -128..127 )
964
+ * CV_16U - 16-bit unsigned integers ( 0..65535 )
965
+ * CV_16S - 16-bit signed integers ( -32768..32767 )
966
+ * CV_32S - 32-bit signed integers ( -2147483648..2147483647 )
967
+ * CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN )
968
+ * CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN )
969
+ */
970
+ public depth(): int;
971
+
972
+ /**
973
+ * The method makes a new header for the specified matrix diagonal. The new matrix is represented as
974
+ * a single-column matrix. Similarly to [Mat::row] and [Mat::col], this is an O(1) operation.
975
+ *
976
+ * @param d index of the diagonal, with the following values:
977
+ * d=0 is the main diagonal.d<0 is a diagonal from the lower half. For example, d=-1 means the
978
+ * diagonal is set immediately below the main one.d>0 is a diagonal from the upper half. For example,
979
+ * d=1 means the diagonal is set immediately above the main one. For example: Matm=(Mat_<int>(3,3)<<
980
+ * 1,2,3,
981
+ * 4,5,6,
982
+ * 7,8,9);
983
+ * Matd0=m.diag(0);
984
+ * Matd1=m.diag(1);
985
+ * Matd_1=m.diag(-1);
986
+ * The resulting matrices are d0=
987
+ * [1;
988
+ * 5;
989
+ * 9]
990
+ * d1=
991
+ * [2;
992
+ * 6]
993
+ * d_1=
994
+ * [4;
995
+ * 8]
996
+ */
997
+ public diag(d?: int): Mat;
998
+
999
+ /**
1000
+ * The method computes a dot-product of two matrices. If the matrices are not single-column or
1001
+ * single-row vectors, the top-to-bottom left-to-right scan ordering is used to treat them as 1D
1002
+ * vectors. The vectors must have the same size and type. If the matrices have more than one channel,
1003
+ * the dot products from all the channels are summed together.
1004
+ *
1005
+ * @param m another dot-product operand.
1006
+ */
1007
+ public dot(m: InputArray): InputArray;
1008
+
1009
+ /**
1010
+ * The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 ,
1011
+ * the method returns 3*sizeof(short) or 6.
1012
+ */
1013
+ public elemSize(): size_t;
1014
+
1015
+ /**
1016
+ * The method returns the matrix element channel size in bytes, that is, it ignores the number of
1017
+ * channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2.
1018
+ */
1019
+ public elemSize1(): size_t;
1020
+
1021
+ /**
1022
+ * The method returns true if [Mat::total()] is 0 or if [Mat::data] is NULL. Because of [pop_back()]
1023
+ * and [resize()] methods `[M.total()] == 0` does not imply that `M.data == NULL`.
1024
+ */
1025
+ public empty(): bool;
1026
+
1027
+ /**
1028
+ * The methods return the matrix read-only or read-write iterators, set to the point following the
1029
+ * last matrix element.
1030
+ */
1031
+ public end(arg27: any): MatIterator_;
1032
+
1033
+ public end(arg28: any): MatConstIterator_;
1034
+
1035
+ /**
1036
+ * The operation passed as argument has to be a function pointer, a function object or a
1037
+ * lambda(C++11).
1038
+ *
1039
+ * Example 1. All of the operations below put 0xFF the first channel of all matrix elements:
1040
+ *
1041
+ * ```cpp
1042
+ * Mat image(1920, 1080, CV_8UC3);
1043
+ * typedef cv::Point3_<uint8_t> Pixel;
1044
+ *
1045
+ * // first. raw pointer access.
1046
+ * for (int r = 0; r < image.rows; ++r) {
1047
+ * Pixel* ptr = image.ptr<Pixel>(r, 0);
1048
+ * const Pixel* ptr_end = ptr + image.cols;
1049
+ * for (; ptr != ptr_end; ++ptr) {
1050
+ * ptr->x = 255;
1051
+ * }
1052
+ * }
1053
+ *
1054
+ * // Using MatIterator. (Simple but there are a Iterator's overhead)
1055
+ * for (Pixel &p : cv::Mat_<Pixel>(image)) {
1056
+ * p.x = 255;
1057
+ * }
1058
+ *
1059
+ * // Parallel execution with function object.
1060
+ * struct Operator {
1061
+ * void operator ()(Pixel &pixel, const int * position) {
1062
+ * pixel.x = 255;
1063
+ * }
1064
+ * };
1065
+ * image.forEach<Pixel>(Operator());
1066
+ *
1067
+ * // Parallel execution using C++11 lambda.
1068
+ * image.forEach<Pixel>([](Pixel &p, const int * position) -> void {
1069
+ * p.x = 255;
1070
+ * });
1071
+ * ```
1072
+ *
1073
+ * Example 2. Using the pixel's position:
1074
+ *
1075
+ * ```cpp
1076
+ * // Creating 3D matrix (255 x 255 x 255) typed uint8_t
1077
+ * // and initialize all elements by the value which equals elements position.
1078
+ * // i.e. pixels (x,y,z) = (1,2,3) is (b,g,r) = (1,2,3).
1079
+ *
1080
+ * int sizes[] = { 255, 255, 255 };
1081
+ * typedef cv::Point3_<uint8_t> Pixel;
1082
+ *
1083
+ * Mat_<Pixel> image = Mat::zeros(3, sizes, CV_8UC3);
1084
+ *
1085
+ * image.forEach<Pixel>([&](Pixel& pixel, const int position[]) -> void {
1086
+ * pixel.x = position[0];
1087
+ * pixel.y = position[1];
1088
+ * pixel.z = position[2];
1089
+ * });
1090
+ * ```
1091
+ */
1092
+ public forEach(arg29: any, arg30: any, operation: any): any;
1093
+
1094
+ /**
1095
+ * This is an overloaded member function, provided for convenience. It differs from the above
1096
+ * function only in what argument(s) it accepts.
1097
+ */
1098
+ public forEach(arg31: any, arg32: any, operation: any): any;
1099
+
1100
+ public getUMat(accessFlags: AccessFlag, usageFlags?: UMatUsageFlags): UMat;
1101
+
1102
+ /**
1103
+ * The method performs a matrix inversion by means of matrix expressions. This means that a temporary
1104
+ * matrix inversion object is returned by the method and can be used further as a part of more complex
1105
+ * matrix expressions or can be assigned to a matrix.
1106
+ *
1107
+ * @param method Matrix inversion method. One of cv::DecompTypes
1108
+ */
1109
+ public inv(method?: int): MatExpr;
1110
+
1111
+ /**
1112
+ * The method returns true if the matrix elements are stored continuously without gaps at the end of
1113
+ * each row. Otherwise, it returns false. Obviously, 1x1 or 1xN matrices are always continuous.
1114
+ * Matrices created with [Mat::create] are always continuous. But if you extract a part of the matrix
1115
+ * using [Mat::col], [Mat::diag], and so on, or constructed a matrix header for externally allocated
1116
+ * data, such matrices may no longer have this property.
1117
+ *
1118
+ * The continuity flag is stored as a bit in the [Mat::flags] field and is computed automatically
1119
+ * when you construct a matrix header. Thus, the continuity check is a very fast operation, though
1120
+ * theoretically it could be done as follows:
1121
+ *
1122
+ * ```cpp
1123
+ * // alternative implementation of Mat::isContinuous()
1124
+ * bool myCheckMatContinuity(const Mat& m)
1125
+ * {
1126
+ * //return (m.flags & Mat::CONTINUOUS_FLAG) != 0;
1127
+ * return m.rows == 1 || m.step == m.cols*m.elemSize();
1128
+ * }
1129
+ * ```
1130
+ *
1131
+ * The method is used in quite a few of OpenCV functions. The point is that element-wise operations
1132
+ * (such as arithmetic and logical operations, math functions, alpha blending, color space
1133
+ * transformations, and others) do not depend on the image geometry. Thus, if all the input and output
1134
+ * arrays are continuous, the functions can process them as very long single-row vectors. The example
1135
+ * below illustrates how an alpha-blending function can be implemented:
1136
+ *
1137
+ * ```cpp
1138
+ * template<typename T>
1139
+ * void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst)
1140
+ * {
1141
+ * const float alpha_scale = (float)std::numeric_limits<T>::max(),
1142
+ * inv_scale = 1.f/alpha_scale;
1143
+ *
1144
+ * CV_Assert( src1.type() == src2.type() &&
1145
+ * src1.type() == CV_MAKETYPE(traits::Depth<T>::value, 4) &&
1146
+ * src1.size() == src2.size());
1147
+ * Size size = src1.size();
1148
+ * dst.create(size, src1.type());
1149
+ *
1150
+ * // here is the idiom: check the arrays for continuity and,
1151
+ * // if this is the case,
1152
+ * // treat the arrays as 1D vectors
1153
+ * if( src1.isContinuous() && src2.isContinuous() && dst.isContinuous() )
1154
+ * {
1155
+ * size.width *= size.height;
1156
+ * size.height = 1;
1157
+ * }
1158
+ * size.width *= 4;
1159
+ *
1160
+ * for( int i = 0; i < size.height; i++ )
1161
+ * {
1162
+ * // when the arrays are continuous,
1163
+ * // the outer loop is executed only once
1164
+ * const T* ptr1 = src1.ptr<T>(i);
1165
+ * const T* ptr2 = src2.ptr<T>(i);
1166
+ * T* dptr = dst.ptr<T>(i);
1167
+ *
1168
+ * for( int j = 0; j < size.width; j += 4 )
1169
+ * {
1170
+ * float alpha = ptr1[j+3]*inv_scale, beta = ptr2[j+3]*inv_scale;
1171
+ * dptr[j] = saturate_cast<T>(ptr1[j]*alpha + ptr2[j]*beta);
1172
+ * dptr[j+1] = saturate_cast<T>(ptr1[j+1]*alpha + ptr2[j+1]*beta);
1173
+ * dptr[j+2] = saturate_cast<T>(ptr1[j+2]*alpha + ptr2[j+2]*beta);
1174
+ * dptr[j+3] = saturate_cast<T>((1 - (1-alpha)*(1-beta))*alpha_scale);
1175
+ * }
1176
+ * }
1177
+ * }
1178
+ * ```
1179
+ *
1180
+ * This approach, while being very simple, can boost the performance of a simple element-operation
1181
+ * by 10-20 percents, especially if the image is rather small and the operation is quite simple.
1182
+ *
1183
+ * Another OpenCV idiom in this function, a call of [Mat::create] for the destination array, that
1184
+ * allocates the destination array unless it already has the proper size and type. And while the newly
1185
+ * allocated arrays are always continuous, you still need to check the destination array because
1186
+ * [Mat::create] does not always allocate a new matrix.
1187
+ */
1188
+ public isContinuous(): bool;
1189
+ /**
1190
+ * After you extracted a submatrix from a matrix using [Mat::row], [Mat::col], [Mat::rowRange],
1191
+ * [Mat::colRange], and others, the resultant submatrix points just to the part of the original big
1192
+ * matrix. However, each submatrix contains information (represented by datastart and dataend fields)
1193
+ * that helps reconstruct the original matrix size and the position of the extracted submatrix within
1194
+ * the original matrix. The method locateROI does exactly that.
1195
+ *
1196
+ * @param wholeSize Output parameter that contains the size of the whole matrix containing this as a
1197
+ * part.
1198
+ *
1199
+ * @param ofs Output parameter that contains an offset of this inside the whole matrix.
1200
+ */
1201
+ public locateROI(wholeSize: Size, ofs: Point): Size;
1202
+
1203
+ /**
1204
+ * The method returns a temporary object encoding per-element array multiplication, with optional
1205
+ * scale. Note that this is not a matrix multiplication that corresponds to a simpler "\\*" operator.
1206
+ *
1207
+ * Example:
1208
+ *
1209
+ * ```cpp
1210
+ * Mat C = A.mul(5/B); // equivalent to divide(A, B, C, 5)
1211
+ * ```
1212
+ *
1213
+ * @param m Another array of the same type and the same size as *this, or a matrix expression.
1214
+ *
1215
+ * @param scale Optional scale factor.
1216
+ */
1217
+ public mul(m: InputArray, scale?: double): MatExpr;
1218
+
1219
+ /**
1220
+ * The method removes one or more rows from the bottom of the matrix.
1221
+ *
1222
+ * @param nelems Number of removed rows. If it is greater than the total number of rows, an exception
1223
+ * is thrown.
1224
+ */
1225
+ public pop_back(nelems?: size_t): void;
1226
+
1227
+ /**
1228
+ * The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in
1229
+ * [Mat::isContinuous] to know how to use these methods.
1230
+ *
1231
+ * @param i0 A 0-based row index.
1232
+ */
1233
+ public ptr(i0?: int): uchar;
1234
+
1235
+ /**
1236
+ * This is an overloaded member function, provided for convenience. It differs from the above
1237
+ * function only in what argument(s) it accepts.
1238
+ */
1239
+ public ptr(i0?: int): uchar;
1240
+
1241
+ /**
1242
+ * This is an overloaded member function, provided for convenience. It differs from the above
1243
+ * function only in what argument(s) it accepts.
1244
+ *
1245
+ * @param row Index along the dimension 0
1246
+ *
1247
+ * @param col Index along the dimension 1
1248
+ */
1249
+ public ptr(row: int, col: int): uchar;
1250
+
1251
+ /**
1252
+ * This is an overloaded member function, provided for convenience. It differs from the above
1253
+ * function only in what argument(s) it accepts.
1254
+ *
1255
+ * @param row Index along the dimension 0
1256
+ *
1257
+ * @param col Index along the dimension 1
1258
+ */
1259
+ public ptr(row: int, col: int): uchar;
1260
+
1261
+ /**
1262
+ * This is an overloaded member function, provided for convenience. It differs from the above
1263
+ * function only in what argument(s) it accepts.
1264
+ */
1265
+ public ptr(i0: int, i1: int, i2: int): uchar;
1266
+
1267
+ /**
1268
+ * This is an overloaded member function, provided for convenience. It differs from the above
1269
+ * function only in what argument(s) it accepts.
1270
+ */
1271
+ public ptr(i0: int, i1: int, i2: int): uchar;
1272
+
1273
+ /**
1274
+ * This is an overloaded member function, provided for convenience. It differs from the above
1275
+ * function only in what argument(s) it accepts.
1276
+ */
1277
+ public ptr(idx: any): uchar;
1278
+
1279
+ /**
1280
+ * This is an overloaded member function, provided for convenience. It differs from the above
1281
+ * function only in what argument(s) it accepts.
1282
+ */
1283
+ public ptr(idx: any): uchar;
1284
+
1285
+ /**
1286
+ * This is an overloaded member function, provided for convenience. It differs from the above
1287
+ * function only in what argument(s) it accepts.
1288
+ */
1289
+ public ptr(n: int, idx: Vec): uchar;
1290
+
1291
+ /**
1292
+ * This is an overloaded member function, provided for convenience. It differs from the above
1293
+ * function only in what argument(s) it accepts.
1294
+ */
1295
+ public ptr(n: int, idx: Vec): uchar;
1296
+
1297
+ /**
1298
+ * This is an overloaded member function, provided for convenience. It differs from the above
1299
+ * function only in what argument(s) it accepts.
1300
+ */
1301
+ public ptr(arg37: any, i0?: int): any;
1302
+
1303
+ /**
1304
+ * This is an overloaded member function, provided for convenience. It differs from the above
1305
+ * function only in what argument(s) it accepts.
1306
+ */
1307
+ public ptr(arg38: any, i0?: int): any;
1308
+
1309
+ /**
1310
+ * This is an overloaded member function, provided for convenience. It differs from the above
1311
+ * function only in what argument(s) it accepts.
1312
+ *
1313
+ * @param row Index along the dimension 0
1314
+ *
1315
+ * @param col Index along the dimension 1
1316
+ */
1317
+ public ptr(arg39: any, row: int, col: int): any;
1318
+
1319
+ /**
1320
+ * This is an overloaded member function, provided for convenience. It differs from the above
1321
+ * function only in what argument(s) it accepts.
1322
+ *
1323
+ * @param row Index along the dimension 0
1324
+ *
1325
+ * @param col Index along the dimension 1
1326
+ */
1327
+ public ptr(arg40: any, row: int, col: int): any;
1328
+
1329
+ /**
1330
+ * This is an overloaded member function, provided for convenience. It differs from the above
1331
+ * function only in what argument(s) it accepts.
1332
+ */
1333
+ public ptr(arg41: any, i0: int, i1: int, i2: int): any;
1334
+
1335
+ /**
1336
+ * This is an overloaded member function, provided for convenience. It differs from the above
1337
+ * function only in what argument(s) it accepts.
1338
+ */
1339
+ public ptr(arg42: any, i0: int, i1: int, i2: int): any;
1340
+
1341
+ /**
1342
+ * This is an overloaded member function, provided for convenience. It differs from the above
1343
+ * function only in what argument(s) it accepts.
1344
+ */
1345
+ public ptr(arg43: any, idx: any): any;
1346
+
1347
+ /**
1348
+ * This is an overloaded member function, provided for convenience. It differs from the above
1349
+ * function only in what argument(s) it accepts.
1350
+ */
1351
+ public ptr(arg44: any, idx: any): any;
1352
+
1353
+ /**
1354
+ * This is an overloaded member function, provided for convenience. It differs from the above
1355
+ * function only in what argument(s) it accepts.
1356
+ */
1357
+ public ptr(arg45: any, n: int, idx: Vec): Vec;
1358
+
1359
+ /**
1360
+ * This is an overloaded member function, provided for convenience. It differs from the above
1361
+ * function only in what argument(s) it accepts.
1362
+ */
1363
+ public ptr(arg46: any, n: int, idx: Vec): Vec;
1364
+
1365
+ /**
1366
+ * The methods add one or more elements to the bottom of the matrix. They emulate the corresponding
1367
+ * method of the STL vector class. When elem is [Mat] , its type and the number of columns must be the
1368
+ * same as in the container matrix.
1369
+ *
1370
+ * @param elem Added element(s).
1371
+ */
1372
+ public push_back(arg47: any, elem: any): any;
1373
+
1374
+ /**
1375
+ * This is an overloaded member function, provided for convenience. It differs from the above
1376
+ * function only in what argument(s) it accepts.
1377
+ *
1378
+ * @param elem Added element(s).
1379
+ */
1380
+ public push_back(arg48: any, elem: Mat): Mat;
1381
+
1382
+ /**
1383
+ * This is an overloaded member function, provided for convenience. It differs from the above
1384
+ * function only in what argument(s) it accepts.
1385
+ *
1386
+ * @param elem Added element(s).
1387
+ */
1388
+ public push_back(arg49: any, elem: any): any;
1389
+
1390
+ /**
1391
+ * This is an overloaded member function, provided for convenience. It differs from the above
1392
+ * function only in what argument(s) it accepts.
1393
+ *
1394
+ * @param m Added line(s).
1395
+ */
1396
+ public push_back(m: Mat): Mat;
1397
+
1398
+ public push_back_(elem: any): void;
1399
+
1400
+ /**
1401
+ * The method decrements the reference counter associated with the matrix data. When the reference
1402
+ * counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers
1403
+ * are set to NULL's. If the matrix header points to an external data set (see [Mat::Mat] ), the
1404
+ * reference counter is NULL, and the method has no effect in this case.
1405
+ *
1406
+ * This method can be called manually to force the matrix data deallocation. But since this method is
1407
+ * automatically called in the destructor, or by any other method that changes the data pointer, it is
1408
+ * usually not needed. The reference counter decrement and check for 0 is an atomic operation on the
1409
+ * platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in
1410
+ * different threads.
1411
+ */
1412
+ public release(): void;
1413
+
1414
+ /**
1415
+ * The method reserves space for sz rows. If the matrix already has enough space to store sz rows,
1416
+ * nothing happens. If the matrix is reallocated, the first [Mat::rows] rows are preserved. The method
1417
+ * emulates the corresponding method of the STL vector class.
1418
+ *
1419
+ * @param sz Number of rows.
1420
+ */
1421
+ public reserve(sz: size_t): void;
1422
+
1423
+ /**
1424
+ * The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes,
1425
+ * nothing happens. If matrix has to be reallocated its previous content could be lost.
1426
+ *
1427
+ * @param sz Number of bytes.
1428
+ */
1429
+ public reserveBuffer(sz: size_t): void;
1430
+
1431
+ /**
1432
+ * The method makes a new matrix header for *this elements. The new matrix may have a different size
1433
+ * and/or different number of channels. Any combination is possible if:
1434
+ *
1435
+ * No extra elements are included into the new matrix and no elements are excluded. Consequently, the
1436
+ * product rows*cols*channels() must stay the same after the transformation.
1437
+ * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of
1438
+ * rows, or the operation changes the indices of elements row in some other way, the matrix must be
1439
+ * continuous. See [Mat::isContinuous] .
1440
+ *
1441
+ * For example, if there is a set of 3D points stored as an STL vector, and you want to represent the
1442
+ * points as a 3xN matrix, do the following:
1443
+ *
1444
+ * ```cpp
1445
+ * std::vector<Point3f> vec;
1446
+ * ...
1447
+ * Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation
1448
+ * reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel.
1449
+ * // Also, an O(1) operation
1450
+ * t(); // finally, transpose the Nx3 matrix.
1451
+ * // This involves copying all the elements
1452
+ * ```
1453
+ *
1454
+ * @param cn New number of channels. If the parameter is 0, the number of channels remains the same.
1455
+ *
1456
+ * @param rows New number of rows. If the parameter is 0, the number of rows remains the same.
1457
+ */
1458
+ public reshape(cn: int, rows?: int): Mat;
1459
+
1460
+ /**
1461
+ * This is an overloaded member function, provided for convenience. It differs from the above
1462
+ * function only in what argument(s) it accepts.
1463
+ */
1464
+ public reshape(cn: int, newndims: int, newsz: any): Mat;
1465
+
1466
+ /**
1467
+ * This is an overloaded member function, provided for convenience. It differs from the above
1468
+ * function only in what argument(s) it accepts.
1469
+ */
1470
+ public reshape(cn: int, newshape: any): Mat;
1471
+
1472
+ /**
1473
+ * The methods change the number of matrix rows. If the matrix is reallocated, the first
1474
+ * min(Mat::rows, sz) rows are preserved. The methods emulate the corresponding methods of the STL
1475
+ * vector class.
1476
+ *
1477
+ * @param sz New number of rows.
1478
+ */
1479
+ public resize(sz: size_t): void;
1480
+
1481
+ /**
1482
+ * This is an overloaded member function, provided for convenience. It differs from the above
1483
+ * function only in what argument(s) it accepts.
1484
+ *
1485
+ * @param sz New number of rows.
1486
+ *
1487
+ * @param s Value assigned to the newly added elements.
1488
+ */
1489
+ public resize(sz: size_t, s: Scalar): Scalar;
1490
+
1491
+ /**
1492
+ * The method makes a new header for the specified matrix row and returns it. This is an O(1)
1493
+ * operation, regardless of the matrix size. The underlying data of the new matrix is shared with the
1494
+ * original matrix. Here is the example of one of the classical basic matrix processing operations,
1495
+ * axpy, used by LU and many other algorithms:
1496
+ *
1497
+ * ```cpp
1498
+ * inline void matrix_axpy(Mat& A, int i, int j, double alpha)
1499
+ * {
1500
+ * A.row(i) += A.row(j)*alpha;
1501
+ * }
1502
+ * ```
1503
+ *
1504
+ * In the current implementation, the following code does not work as expected:
1505
+ *
1506
+ * ```cpp
1507
+ * Mat A;
1508
+ * ...
1509
+ * A.row(i) = A.row(j); // will not work
1510
+ * ```
1511
+ *
1512
+ * This happens because A.row(i) forms a temporary header that is further assigned to another
1513
+ * header. Remember that each of these operations is O(1), that is, no data is copied. Thus, the above
1514
+ * assignment is not true if you may have expected the j-th row to be copied to the i-th row. To
1515
+ * achieve that, you should either turn this simple assignment into an expression or use the
1516
+ * [Mat::copyTo] method:
1517
+ *
1518
+ * ```cpp
1519
+ * Mat A;
1520
+ * ...
1521
+ * // works, but looks a bit obscure.
1522
+ * A.row(i) = A.row(j) + 0;
1523
+ * // this is a bit longer, but the recommended method.
1524
+ * A.row(j).copyTo(A.row(i));
1525
+ * ```
1526
+ *
1527
+ * @param y A 0-based row index.
1528
+ */
1529
+ public row(y: int): Mat;
1530
+
1531
+ /**
1532
+ * The method makes a new header for the specified row span of the matrix. Similarly to [Mat::row]
1533
+ * and [Mat::col] , this is an O(1) operation.
1534
+ *
1535
+ * @param startrow An inclusive 0-based start index of the row span.
1536
+ *
1537
+ * @param endrow An exclusive 0-based ending index of the row span.
1538
+ */
1539
+ public rowRange(startrow: int, endrow: int): Mat;
1540
+
1541
+ /**
1542
+ * This is an overloaded member function, provided for convenience. It differs from the above
1543
+ * function only in what argument(s) it accepts.
1544
+ *
1545
+ * @param r Range structure containing both the start and the end indices.
1546
+ */
1547
+ public rowRange(r: Range): Mat;
1548
+
1549
+ /**
1550
+ * This is an advanced variant of the [Mat::operator=(const Scalar& s)] operator.
1551
+ *
1552
+ * @param value Assigned scalar converted to the actual array type.
1553
+ *
1554
+ * @param mask Operation mask of the same size as *this. Its non-zero elements indicate which matrix
1555
+ * elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels
1556
+ */
1557
+ public setTo(value: InputArray | Scalar, mask?: InputArray): Mat;
1558
+
1559
+ /**
1560
+ * The method returns a matrix step divided by [Mat::elemSize1()] . It can be useful to quickly
1561
+ * access an arbitrary matrix element.
1562
+ */
1563
+ public step1(i?: int): size_t;
1564
+
1565
+ /**
1566
+ * The method performs matrix transposition by means of matrix expressions. It does not perform the
1567
+ * actual transposition but returns a temporary matrix transposition object that can be further used as
1568
+ * a part of more complex matrix expressions or can be assigned to a matrix:
1569
+ *
1570
+ * ```cpp
1571
+ * Mat A1 = A + Mat::eye(A.size(), A.type())*lambda;
1572
+ * Mat C = A1.t()*A1; // compute (A + lambda*I)^t * (A + lamda*I)
1573
+ * ```
1574
+ */
1575
+ public t(): MatExpr;
1576
+
1577
+ /**
1578
+ * The method returns the number of array elements (a number of pixels if the array represents an
1579
+ * image).
1580
+ */
1581
+ public total(): size_t;
1582
+
1583
+ /**
1584
+ * The method returns the number of elements within a certain sub-array slice with startDim <= dim <
1585
+ * endDim
1586
+ */
1587
+ public total(startDim: int, endDim?: int): size_t;
1588
+
1589
+ /**
1590
+ * The method returns a matrix element type. This is an identifier compatible with the CvMat type
1591
+ * system, like CV_16SC3 or 16-bit signed 3-channel array, and so on.
1592
+ */
1593
+ public type(): int;
1594
+
1595
+ public updateContinuityFlag(): void;
1596
+
1597
+ public ucharPtr(i: any, j: any): any;
1598
+ public charPtr(i: any, j: any): any;
1599
+ public shortPtr(i: any, j: any): any;
1600
+ public ushortPtr(i: any, j: any): any;
1601
+ public intPtr(i: any, j: any): any;
1602
+ public ucharAt(i: any): any;
1603
+ public charAt(i: any): any;
1604
+ public floatPtr(i: any, j: any): any;
1605
+ public doubleAt(i: int, j: int): any;
1606
+ public doublePtr(i: any, j: any): any;
1607
+ public intPtr(i: any, j: any): any;
1608
+ public setTo(value: Mat | Scalar, mask?: Mat): Mat;
1609
+ /**
1610
+ * Sometimes, you will have to play with certain region of images.
1611
+ * For eye detection in images, first face detection is done all
1612
+ * over the image and when face is obtained, we select the face region alone and search for eyes inside it instead of searching whole image.
1613
+ * It improves accuracy (because eyes are always on faces) and performance (because we search for a small area).
1614
+ *
1615
+ * Heads up : in JS seems only one argument is expected.
1616
+ */
1617
+ public roi(expr: Rect | Mat): Mat;
1618
+
1619
+ /**
1620
+ * The method creates a square diagonal matrix from specified main diagonal.
1621
+ *
1622
+ * @param d One-dimensional matrix that represents the main diagonal.
1623
+ */
1624
+ public static diag(d: Mat): Mat;
1625
+
1626
+ /**
1627
+ * The method returns a Matlab-style identity matrix initializer, similarly to [Mat::zeros].
1628
+ * Similarly to [Mat::ones], you can use a scale operation to create a scaled identity matrix
1629
+ * efficiently:
1630
+ *
1631
+ * ```cpp
1632
+ * // make a 4x4 diagonal matrix with 0.1's on the diagonal.
1633
+ * Mat A = Mat::eye(4, 4, CV_32F)*0.1;
1634
+ * ```
1635
+ *
1636
+ * In case of multi-channels type, identity matrix will be initialized only for the first channel,
1637
+ * the others will be set to 0's
1638
+ *
1639
+ * @param rows Number of rows.
1640
+ *
1641
+ * @param cols Number of columns.
1642
+ *
1643
+ * @param type Created matrix type.
1644
+ */
1645
+ public static eye(rows: int, cols: int, type: int): MatExpr;
1646
+
1647
+ /**
1648
+ * This is an overloaded member function, provided for convenience. It differs from the above
1649
+ * function only in what argument(s) it accepts.
1650
+ *
1651
+ * @param size Alternative matrix size specification as Size(cols, rows) .
1652
+ *
1653
+ * @param type Created matrix type.
1654
+ */
1655
+ public static eye(size: Size, type: int): MatExpr;
1656
+
1657
+ public static getDefaultAllocator(): MatAllocator;
1658
+
1659
+ public static getStdAllocator(): MatAllocator;
1660
+
1661
+ /**
1662
+ * The method returns a Matlab-style 1's array initializer, similarly to [Mat::zeros]. Note that
1663
+ * using this method you can initialize an array with an arbitrary value, using the following Matlab
1664
+ * idiom:
1665
+ *
1666
+ * ```cpp
1667
+ * Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3.
1668
+ * ```
1669
+ *
1670
+ * The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it
1671
+ * just remembers the scale factor (3 in this case) and use it when actually invoking the matrix
1672
+ * initializer.
1673
+ *
1674
+ * In case of multi-channels type, only the first channel will be initialized with 1's, the others
1675
+ * will be set to 0's.
1676
+ *
1677
+ * @param rows Number of rows.
1678
+ *
1679
+ * @param cols Number of columns.
1680
+ *
1681
+ * @param type Created matrix type.
1682
+ */
1683
+ public static ones(rows: int, cols: int, type: int): MatExpr;
1684
+
1685
+ /**
1686
+ * This is an overloaded member function, provided for convenience. It differs from the above
1687
+ * function only in what argument(s) it accepts.
1688
+ *
1689
+ * @param size Alternative to the matrix size specification Size(cols, rows) .
1690
+ *
1691
+ * @param type Created matrix type.
1692
+ */
1693
+ public static ones(size: Size, type: int): MatExpr;
1694
+
1695
+ /**
1696
+ * This is an overloaded member function, provided for convenience. It differs from the above
1697
+ * function only in what argument(s) it accepts.
1698
+ *
1699
+ * @param ndims Array dimensionality.
1700
+ *
1701
+ * @param sz Array of integers specifying the array shape.
1702
+ *
1703
+ * @param type Created matrix type.
1704
+ */
1705
+ public static ones(ndims: int, sz: any, type: int): MatExpr;
1706
+
1707
+ public static setDefaultAllocator(allocator: MatAllocator): MatAllocator;
1708
+
1709
+ /**
1710
+ * The method returns a Matlab-style zero array initializer. It can be used to quickly form a
1711
+ * constant array as a function parameter, part of a matrix expression, or as a matrix initializer:
1712
+ *
1713
+ * ```cpp
1714
+ * Mat A;
1715
+ * A = Mat::zeros(3, 3, CV_32F);
1716
+ * ```
1717
+ *
1718
+ * In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix.
1719
+ * Otherwise, the existing matrix A is filled with zeros.
1720
+ *
1721
+ * @param rows Number of rows.
1722
+ *
1723
+ * @param cols Number of columns.
1724
+ *
1725
+ * @param type Created matrix type.
1726
+ */
1727
+ public static zeros(rows: int, cols: int, type: int): MatExpr;
1728
+
1729
+ /**
1730
+ * This is an overloaded member function, provided for convenience. It differs from the above
1731
+ * function only in what argument(s) it accepts.
1732
+ *
1733
+ * @param size Alternative to the matrix size specification Size(cols, rows) .
1734
+ *
1735
+ * @param type Created matrix type.
1736
+ */
1737
+ public static zeros(size: Size, type: int): MatExpr;
1738
+
1739
+ /**
1740
+ * This is an overloaded member function, provided for convenience. It differs from the above
1741
+ * function only in what argument(s) it accepts.
1742
+ *
1743
+ * @param ndims Array dimensionality.
1744
+ *
1745
+ * @param sz Array of integers specifying the array shape.
1746
+ *
1747
+ * @param type Created matrix type.
1748
+ */
1749
+ public static zeros(ndims: int, sz: any, type: int): MatExpr;
1750
+ }
1751
+
1752
+ export declare const MAGIC_VAL: any; // initializer: = 0x42FF0000
1753
+
1754
+ export declare const AUTO_STEP: any; // initializer: = 0
1755
+
1756
+ export declare const CONTINUOUS_FLAG: any; // initializer: = CV_MAT_CONT_FLAG
1757
+
1758
+ export declare const SUBMATRIX_FLAG: any; // initializer: = CV_SUBMAT_FLAG
1759
+
1760
+ export declare const MAGIC_MASK: any; // initializer: = 0xFFFF0000
1761
+
1762
+ export declare const TYPE_MASK: any; // initializer: = 0x00000FFF
1763
+
1764
+ export declare const DEPTH_MASK: any; // initializer: = 7