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