imagecore 0.0.1
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.
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/ext/imagecore/analyze_image.cxx +58 -0
- data/ext/imagecore/analyze_image.h +6 -0
- data/ext/imagecore/extconf.rb +9 -0
- data/ext/imagecore/imagecore.cxx +34 -0
- data/ext/opencv/core/___.c +3 -0
- data/ext/opencv/core/alloc.cpp +697 -0
- data/ext/opencv/core/array.cpp +3206 -0
- data/ext/opencv/core/datastructs.cpp +4064 -0
- data/ext/opencv/core/extconf.rb +22 -0
- data/ext/opencv/core/matrix.cpp +3777 -0
- data/ext/opencv/core/precomp.hpp +216 -0
- data/ext/opencv/core/system.cpp +832 -0
- data/ext/opencv/core/tables.cpp +3512 -0
- data/ext/opencv/highgui/___.c +3 -0
- data/ext/opencv/highgui/bitstrm.cpp +582 -0
- data/ext/opencv/highgui/bitstrm.hpp +182 -0
- data/ext/opencv/highgui/extconf.rb +28 -0
- data/ext/opencv/highgui/grfmt_base.cpp +128 -0
- data/ext/opencv/highgui/grfmt_base.hpp +113 -0
- data/ext/opencv/highgui/grfmt_bmp.cpp +564 -0
- data/ext/opencv/highgui/grfmt_bmp.hpp +99 -0
- data/ext/opencv/highgui/grfmt_exr.hpp +113 -0
- data/ext/opencv/highgui/grfmt_imageio.hpp +56 -0
- data/ext/opencv/highgui/grfmt_jpeg.cpp +622 -0
- data/ext/opencv/highgui/grfmt_jpeg.hpp +90 -0
- data/ext/opencv/highgui/grfmt_jpeg2000.cpp +529 -0
- data/ext/opencv/highgui/grfmt_jpeg2000.hpp +95 -0
- data/ext/opencv/highgui/grfmt_png.cpp +406 -0
- data/ext/opencv/highgui/grfmt_png.hpp +101 -0
- data/ext/opencv/highgui/grfmt_pxm.cpp +513 -0
- data/ext/opencv/highgui/grfmt_pxm.hpp +92 -0
- data/ext/opencv/highgui/grfmt_sunras.cpp +425 -0
- data/ext/opencv/highgui/grfmt_sunras.hpp +105 -0
- data/ext/opencv/highgui/grfmt_tiff.cpp +718 -0
- data/ext/opencv/highgui/grfmt_tiff.hpp +136 -0
- data/ext/opencv/highgui/grfmts.hpp +56 -0
- data/ext/opencv/highgui/loadsave.cpp +535 -0
- data/ext/opencv/highgui/precomp.hpp +223 -0
- data/ext/opencv/highgui/utils.cpp +689 -0
- data/ext/opencv/highgui/utils.hpp +128 -0
- data/ext/opencv/imgproc/___.c +3 -0
- data/ext/opencv/imgproc/_geom.h +72 -0
- data/ext/opencv/imgproc/color.cpp +3179 -0
- data/ext/opencv/imgproc/contours.cpp +1780 -0
- data/ext/opencv/imgproc/extconf.rb +11 -0
- data/ext/opencv/imgproc/filter.cpp +3063 -0
- data/ext/opencv/imgproc/precomp.hpp +159 -0
- data/ext/opencv/imgproc/shapedescr.cpp +1306 -0
- data/ext/opencv/imgproc/smooth.cpp +1566 -0
- data/ext/opencv/imgproc/tables.cpp +214 -0
- data/ext/opencv/imgproc/thresh.cpp +636 -0
- data/ext/opencv/imgproc/utils.cpp +242 -0
- data/ext/opencv/include/opencv2/core/core.hpp +4344 -0
- data/ext/opencv/include/opencv2/core/core_c.h +1885 -0
- data/ext/opencv/include/opencv2/core/internal.hpp +710 -0
- data/ext/opencv/include/opencv2/core/mat.hpp +2557 -0
- data/ext/opencv/include/opencv2/core/operations.hpp +3623 -0
- data/ext/opencv/include/opencv2/core/types_c.h +1875 -0
- data/ext/opencv/include/opencv2/core/version.hpp +58 -0
- data/ext/opencv/include/opencv2/highgui/highgui.hpp +198 -0
- data/ext/opencv/include/opencv2/highgui/highgui_c.h +506 -0
- data/ext/opencv/include/opencv2/imgproc/imgproc.hpp +1139 -0
- data/ext/opencv/include/opencv2/imgproc/imgproc_c.h +783 -0
- data/ext/opencv/include/opencv2/imgproc/types_c.h +538 -0
- data/imagecore.gemspec +20 -0
- data/lib/imagecore.rb +16 -0
- data/lib/imagecore/version.rb +3 -0
- metadata +119 -0
@@ -0,0 +1,2557 @@
|
|
1
|
+
/*M///////////////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
4
|
+
//
|
5
|
+
// By downloading, copying, installing or using the software you agree to this license.
|
6
|
+
// If you do not agree to this license, do not download, install,
|
7
|
+
// copy or use the software.
|
8
|
+
//
|
9
|
+
//
|
10
|
+
// License Agreement
|
11
|
+
// For Open Source Computer Vision Library
|
12
|
+
//
|
13
|
+
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
14
|
+
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
15
|
+
// Third party copyrights are property of their respective owners.
|
16
|
+
//
|
17
|
+
// Redistribution and use in source and binary forms, with or without modification,
|
18
|
+
// are permitted provided that the following conditions are met:
|
19
|
+
//
|
20
|
+
// * Redistribution's of source code must retain the above copyright notice,
|
21
|
+
// this list of conditions and the following disclaimer.
|
22
|
+
//
|
23
|
+
// * Redistribution's in binary form must reproduce the above copyright notice,
|
24
|
+
// this list of conditions and the following disclaimer in the documentation
|
25
|
+
// and/or other materials provided with the distribution.
|
26
|
+
//
|
27
|
+
// * The name of the copyright holders may not be used to endorse or promote products
|
28
|
+
// derived from this software without specific prior written permission.
|
29
|
+
//
|
30
|
+
// This software is provided by the copyright holders and contributors "as is" and
|
31
|
+
// any express or implied warranties, including, but not limited to, the implied
|
32
|
+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
33
|
+
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
34
|
+
// indirect, incidental, special, exemplary, or consequential damages
|
35
|
+
// (including, but not limited to, procurement of substitute goods or services;
|
36
|
+
// loss of use, data, or profits; or business interruption) however caused
|
37
|
+
// and on any theory of liability, whether in contract, strict liability,
|
38
|
+
// or tort (including negligence or otherwise) arising in any way out of
|
39
|
+
// the use of this software, even if advised of the possibility of such damage.
|
40
|
+
//
|
41
|
+
//M*/
|
42
|
+
|
43
|
+
#ifndef __OPENCV_CORE_MATRIX_OPERATIONS_HPP__
|
44
|
+
#define __OPENCV_CORE_MATRIX_OPERATIONS_HPP__
|
45
|
+
|
46
|
+
#ifndef SKIP_INCLUDES
|
47
|
+
#include <limits.h>
|
48
|
+
#include <string.h>
|
49
|
+
#endif // SKIP_INCLUDES
|
50
|
+
|
51
|
+
#ifdef __cplusplus
|
52
|
+
|
53
|
+
namespace cv
|
54
|
+
{
|
55
|
+
|
56
|
+
//////////////////////////////// Mat ////////////////////////////////
|
57
|
+
|
58
|
+
inline Mat::Mat()
|
59
|
+
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
|
60
|
+
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
61
|
+
{
|
62
|
+
}
|
63
|
+
|
64
|
+
inline Mat::Mat(int _rows, int _cols, int _type)
|
65
|
+
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
|
66
|
+
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
67
|
+
{
|
68
|
+
create(_rows, _cols, _type);
|
69
|
+
}
|
70
|
+
|
71
|
+
inline Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
|
72
|
+
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
|
73
|
+
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
74
|
+
{
|
75
|
+
create(_rows, _cols, _type);
|
76
|
+
*this = _s;
|
77
|
+
}
|
78
|
+
|
79
|
+
inline Mat::Mat(Size _sz, int _type)
|
80
|
+
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
|
81
|
+
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
82
|
+
{
|
83
|
+
create( _sz.height, _sz.width, _type );
|
84
|
+
}
|
85
|
+
|
86
|
+
inline Mat::Mat(Size _sz, int _type, const Scalar& _s)
|
87
|
+
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
|
88
|
+
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
89
|
+
{
|
90
|
+
create(_sz.height, _sz.width, _type);
|
91
|
+
*this = _s;
|
92
|
+
}
|
93
|
+
|
94
|
+
inline Mat::Mat(int _dims, const int* _sz, int _type)
|
95
|
+
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
|
96
|
+
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
97
|
+
{
|
98
|
+
create(_dims, _sz, _type);
|
99
|
+
}
|
100
|
+
|
101
|
+
inline Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
|
102
|
+
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
|
103
|
+
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
104
|
+
{
|
105
|
+
create(_dims, _sz, _type);
|
106
|
+
*this = _s;
|
107
|
+
}
|
108
|
+
|
109
|
+
inline Mat::Mat(const Mat& m)
|
110
|
+
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data),
|
111
|
+
refcount(m.refcount), datastart(m.datastart), dataend(m.dataend),
|
112
|
+
datalimit(m.datalimit), allocator(m.allocator), size(&rows)
|
113
|
+
{
|
114
|
+
if( refcount )
|
115
|
+
CV_XADD(refcount, 1);
|
116
|
+
if( m.dims <= 2 )
|
117
|
+
{
|
118
|
+
step[0] = m.step[0]; step[1] = m.step[1];
|
119
|
+
}
|
120
|
+
else
|
121
|
+
{
|
122
|
+
dims = 0;
|
123
|
+
copySize(m);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
inline Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
|
128
|
+
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols),
|
129
|
+
data((uchar*)_data), refcount(0), datastart((uchar*)_data), dataend(0),
|
130
|
+
datalimit(0), allocator(0), size(&rows)
|
131
|
+
{
|
132
|
+
size_t esz = CV_ELEM_SIZE(_type), minstep = cols*esz;
|
133
|
+
if( _step == AUTO_STEP )
|
134
|
+
{
|
135
|
+
_step = minstep;
|
136
|
+
flags |= CONTINUOUS_FLAG;
|
137
|
+
}
|
138
|
+
else
|
139
|
+
{
|
140
|
+
if( rows == 1 ) _step = minstep;
|
141
|
+
CV_DbgAssert( _step >= minstep );
|
142
|
+
flags |= _step == minstep ? CONTINUOUS_FLAG : 0;
|
143
|
+
}
|
144
|
+
step[0] = _step; step[1] = esz;
|
145
|
+
datalimit = datastart + _step*rows;
|
146
|
+
dataend = datalimit - _step + minstep;
|
147
|
+
}
|
148
|
+
|
149
|
+
inline Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
|
150
|
+
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width),
|
151
|
+
data((uchar*)_data), refcount(0), datastart((uchar*)_data), dataend(0),
|
152
|
+
datalimit(0), allocator(0), size(&rows)
|
153
|
+
{
|
154
|
+
size_t esz = CV_ELEM_SIZE(_type), minstep = cols*esz;
|
155
|
+
if( _step == AUTO_STEP )
|
156
|
+
{
|
157
|
+
_step = minstep;
|
158
|
+
flags |= CONTINUOUS_FLAG;
|
159
|
+
}
|
160
|
+
else
|
161
|
+
{
|
162
|
+
if( rows == 1 ) _step = minstep;
|
163
|
+
CV_DbgAssert( _step >= minstep );
|
164
|
+
flags |= _step == minstep ? CONTINUOUS_FLAG : 0;
|
165
|
+
}
|
166
|
+
step[0] = _step; step[1] = esz;
|
167
|
+
datalimit = datastart + _step*rows;
|
168
|
+
dataend = datalimit - _step + minstep;
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
inline Mat::Mat(const CvMat* m, bool copyData)
|
173
|
+
: flags(MAGIC_VAL + (m->type & (CV_MAT_TYPE_MASK|CV_MAT_CONT_FLAG))),
|
174
|
+
dims(2), rows(m->rows), cols(m->cols), data(m->data.ptr), refcount(0),
|
175
|
+
datastart(m->data.ptr), allocator(0), size(&rows)
|
176
|
+
{
|
177
|
+
if( !copyData )
|
178
|
+
{
|
179
|
+
size_t esz = CV_ELEM_SIZE(m->type), minstep = cols*esz, _step = m->step;
|
180
|
+
if( _step == 0 )
|
181
|
+
_step = minstep;
|
182
|
+
datalimit = datastart + _step*rows;
|
183
|
+
dataend = datalimit - _step + minstep;
|
184
|
+
step[0] = _step; step[1] = esz;
|
185
|
+
}
|
186
|
+
else
|
187
|
+
{
|
188
|
+
data = datastart = dataend = 0;
|
189
|
+
Mat(m->rows, m->cols, m->type, m->data.ptr, m->step).copyTo(*this);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
template<typename _Tp> inline Mat::Mat(const vector<_Tp>& vec, bool copyData)
|
194
|
+
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
|
195
|
+
dims(2), rows((int)vec.size()), cols(1), data(0), refcount(0),
|
196
|
+
datastart(0), dataend(0), allocator(0), size(&rows)
|
197
|
+
{
|
198
|
+
if(vec.empty())
|
199
|
+
return;
|
200
|
+
if( !copyData )
|
201
|
+
{
|
202
|
+
step[0] = step[1] = sizeof(_Tp);
|
203
|
+
data = datastart = (uchar*)&vec[0];
|
204
|
+
datalimit = dataend = datastart + rows*step[0];
|
205
|
+
}
|
206
|
+
else
|
207
|
+
Mat((int)vec.size(), 1, DataType<_Tp>::type, (uchar*)&vec[0]).copyTo(*this);
|
208
|
+
}
|
209
|
+
|
210
|
+
|
211
|
+
template<typename _Tp, int n> inline Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
|
212
|
+
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
|
213
|
+
dims(2), rows(n), cols(1), data(0), refcount(0),
|
214
|
+
datastart(0), dataend(0), allocator(0), size(&rows)
|
215
|
+
{
|
216
|
+
if( !copyData )
|
217
|
+
{
|
218
|
+
step[0] = step[1] = sizeof(_Tp);
|
219
|
+
data = datastart = (uchar*)vec.val;
|
220
|
+
datalimit = dataend = datastart + rows*step[0];
|
221
|
+
}
|
222
|
+
else
|
223
|
+
Mat(n, 1, DataType<_Tp>::type, (void*)vec.val).copyTo(*this);
|
224
|
+
}
|
225
|
+
|
226
|
+
|
227
|
+
template<typename _Tp, int m, int n> inline Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
|
228
|
+
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
|
229
|
+
dims(2), rows(m), cols(n), data(0), refcount(0),
|
230
|
+
datastart(0), dataend(0), allocator(0), size(&rows)
|
231
|
+
{
|
232
|
+
if( !copyData )
|
233
|
+
{
|
234
|
+
step[0] = cols*sizeof(_Tp);
|
235
|
+
step[1] = sizeof(_Tp);
|
236
|
+
data = datastart = (uchar*)M.val;
|
237
|
+
datalimit = dataend = datastart + rows*step[0];
|
238
|
+
}
|
239
|
+
else
|
240
|
+
Mat(m, n, DataType<_Tp>::type, (uchar*)M.val).copyTo(*this);
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
template<typename _Tp> inline Mat::Mat(const Point_<_Tp>& pt, bool copyData)
|
245
|
+
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
|
246
|
+
dims(2), rows(2), cols(1), data(0), refcount(0),
|
247
|
+
datastart(0), dataend(0), allocator(0), size(&rows)
|
248
|
+
{
|
249
|
+
if( !copyData )
|
250
|
+
{
|
251
|
+
step[0] = step[1] = sizeof(_Tp);
|
252
|
+
data = datastart = (uchar*)&pt.x;
|
253
|
+
datalimit = dataend = datastart + rows*step[0];
|
254
|
+
}
|
255
|
+
else
|
256
|
+
{
|
257
|
+
create(2, 1, DataType<_Tp>::type);
|
258
|
+
((_Tp*)data)[0] = pt.x;
|
259
|
+
((_Tp*)data)[1] = pt.y;
|
260
|
+
}
|
261
|
+
}
|
262
|
+
|
263
|
+
|
264
|
+
template<typename _Tp> inline Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
|
265
|
+
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
|
266
|
+
dims(2), rows(3), cols(1), data(0), refcount(0),
|
267
|
+
datastart(0), dataend(0), allocator(0), size(&rows)
|
268
|
+
{
|
269
|
+
if( !copyData )
|
270
|
+
{
|
271
|
+
step[0] = step[1] = sizeof(_Tp);
|
272
|
+
data = datastart = (uchar*)&pt.x;
|
273
|
+
datalimit = dataend = datastart + rows*step[0];
|
274
|
+
}
|
275
|
+
else
|
276
|
+
{
|
277
|
+
create(3, 1, DataType<_Tp>::type);
|
278
|
+
((_Tp*)data)[0] = pt.x;
|
279
|
+
((_Tp*)data)[1] = pt.y;
|
280
|
+
((_Tp*)data)[2] = pt.z;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
|
285
|
+
template<typename _Tp> inline Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer)
|
286
|
+
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
|
287
|
+
dims(0), rows(0), cols(0), data(0), refcount(0),
|
288
|
+
datastart(0), dataend(0), allocator(0), size(&rows)
|
289
|
+
{
|
290
|
+
*this = *commaInitializer;
|
291
|
+
}
|
292
|
+
|
293
|
+
inline Mat::~Mat()
|
294
|
+
{
|
295
|
+
release();
|
296
|
+
if( step.p != step.buf )
|
297
|
+
fastFree(step.p);
|
298
|
+
}
|
299
|
+
|
300
|
+
inline Mat& Mat::operator = (const Mat& m)
|
301
|
+
{
|
302
|
+
if( this != &m )
|
303
|
+
{
|
304
|
+
if( m.refcount )
|
305
|
+
CV_XADD(m.refcount, 1);
|
306
|
+
release();
|
307
|
+
flags = m.flags;
|
308
|
+
if( dims <= 2 && m.dims <= 2 )
|
309
|
+
{
|
310
|
+
dims = m.dims;
|
311
|
+
rows = m.rows;
|
312
|
+
cols = m.cols;
|
313
|
+
step[0] = m.step[0];
|
314
|
+
step[1] = m.step[1];
|
315
|
+
}
|
316
|
+
else
|
317
|
+
copySize(m);
|
318
|
+
data = m.data;
|
319
|
+
datastart = m.datastart;
|
320
|
+
dataend = m.dataend;
|
321
|
+
datalimit = m.datalimit;
|
322
|
+
refcount = m.refcount;
|
323
|
+
allocator = m.allocator;
|
324
|
+
}
|
325
|
+
return *this;
|
326
|
+
}
|
327
|
+
|
328
|
+
inline Mat Mat::row(int y) const { return Mat(*this, Range(y, y+1), Range::all()); }
|
329
|
+
inline Mat Mat::col(int x) const { return Mat(*this, Range::all(), Range(x, x+1)); }
|
330
|
+
inline Mat Mat::rowRange(int startrow, int endrow) const
|
331
|
+
{ return Mat(*this, Range(startrow, endrow), Range::all()); }
|
332
|
+
inline Mat Mat::rowRange(const Range& r) const
|
333
|
+
{ return Mat(*this, r, Range::all()); }
|
334
|
+
inline Mat Mat::colRange(int startcol, int endcol) const
|
335
|
+
{ return Mat(*this, Range::all(), Range(startcol, endcol)); }
|
336
|
+
inline Mat Mat::colRange(const Range& r) const
|
337
|
+
{ return Mat(*this, Range::all(), r); }
|
338
|
+
|
339
|
+
inline Mat Mat::diag(const Mat& d)
|
340
|
+
{
|
341
|
+
CV_Assert( d.cols == 1 );
|
342
|
+
Mat m(d.rows, d.rows, d.type(), Scalar(0)), md = m.diag();
|
343
|
+
d.copyTo(md);
|
344
|
+
return m;
|
345
|
+
}
|
346
|
+
|
347
|
+
inline Mat Mat::clone() const
|
348
|
+
{
|
349
|
+
Mat m;
|
350
|
+
copyTo(m);
|
351
|
+
return m;
|
352
|
+
}
|
353
|
+
|
354
|
+
inline void Mat::assignTo( Mat& m, int type ) const
|
355
|
+
{
|
356
|
+
if( type < 0 )
|
357
|
+
m = *this;
|
358
|
+
else
|
359
|
+
convertTo(m, type);
|
360
|
+
}
|
361
|
+
|
362
|
+
inline void Mat::create(int _rows, int _cols, int _type)
|
363
|
+
{
|
364
|
+
_type &= TYPE_MASK;
|
365
|
+
if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && data )
|
366
|
+
return;
|
367
|
+
int sz[] = {_rows, _cols};
|
368
|
+
create(2, sz, _type);
|
369
|
+
}
|
370
|
+
|
371
|
+
inline void Mat::create(Size _sz, int _type)
|
372
|
+
{
|
373
|
+
create(_sz.height, _sz.width, _type);
|
374
|
+
}
|
375
|
+
|
376
|
+
inline void Mat::addref()
|
377
|
+
{ if( refcount ) CV_XADD(refcount, 1); }
|
378
|
+
|
379
|
+
inline void Mat::release()
|
380
|
+
{
|
381
|
+
if( refcount && CV_XADD(refcount, -1) == 1 )
|
382
|
+
deallocate();
|
383
|
+
data = datastart = dataend = datalimit = 0;
|
384
|
+
size.p[0] = 0;
|
385
|
+
refcount = 0;
|
386
|
+
}
|
387
|
+
|
388
|
+
inline Mat Mat::operator()( Range rowRange, Range colRange ) const
|
389
|
+
{
|
390
|
+
return Mat(*this, rowRange, colRange);
|
391
|
+
}
|
392
|
+
|
393
|
+
inline Mat Mat::operator()( const Rect& roi ) const
|
394
|
+
{ return Mat(*this, roi); }
|
395
|
+
|
396
|
+
inline Mat Mat::operator()(const Range* ranges) const
|
397
|
+
{
|
398
|
+
return Mat(*this, ranges);
|
399
|
+
}
|
400
|
+
|
401
|
+
inline Mat::operator CvMat() const
|
402
|
+
{
|
403
|
+
CV_DbgAssert(dims <= 2);
|
404
|
+
CvMat m = cvMat(rows, dims == 1 ? 1 : cols, type(), data);
|
405
|
+
m.step = (int)step[0];
|
406
|
+
m.type = (m.type & ~CONTINUOUS_FLAG) | (flags & CONTINUOUS_FLAG);
|
407
|
+
return m;
|
408
|
+
}
|
409
|
+
|
410
|
+
inline bool Mat::isContinuous() const { return (flags & CONTINUOUS_FLAG) != 0; }
|
411
|
+
inline bool Mat::isSubmatrix() const { return (flags & SUBMATRIX_FLAG) != 0; }
|
412
|
+
inline size_t Mat::elemSize() const { return dims > 0 ? step.p[dims-1] : 0; }
|
413
|
+
inline size_t Mat::elemSize1() const { return CV_ELEM_SIZE1(flags); }
|
414
|
+
inline int Mat::type() const { return CV_MAT_TYPE(flags); }
|
415
|
+
inline int Mat::depth() const { return CV_MAT_DEPTH(flags); }
|
416
|
+
inline int Mat::channels() const { return CV_MAT_CN(flags); }
|
417
|
+
inline size_t Mat::step1(int i) const { return step.p[i]/elemSize1(); }
|
418
|
+
inline bool Mat::empty() const { return data == 0 || total() == 0; }
|
419
|
+
inline size_t Mat::total() const
|
420
|
+
{
|
421
|
+
if( dims <= 2 )
|
422
|
+
return rows*cols;
|
423
|
+
size_t p = 1;
|
424
|
+
for( int i = 0; i < dims; i++ )
|
425
|
+
p *= size[i];
|
426
|
+
return p;
|
427
|
+
}
|
428
|
+
|
429
|
+
inline uchar* Mat::ptr(int y)
|
430
|
+
{
|
431
|
+
CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) );
|
432
|
+
return data + step.p[0]*y;
|
433
|
+
}
|
434
|
+
|
435
|
+
inline const uchar* Mat::ptr(int y) const
|
436
|
+
{
|
437
|
+
CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) );
|
438
|
+
return data + step.p[0]*y;
|
439
|
+
}
|
440
|
+
|
441
|
+
template<typename _Tp> inline _Tp* Mat::ptr(int y)
|
442
|
+
{
|
443
|
+
CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) );
|
444
|
+
return (_Tp*)(data + step.p[0]*y);
|
445
|
+
}
|
446
|
+
|
447
|
+
template<typename _Tp> inline const _Tp* Mat::ptr(int y) const
|
448
|
+
{
|
449
|
+
CV_DbgAssert( y == 0 || (data && dims >= 1 && data && (unsigned)y < (unsigned)size.p[0]) );
|
450
|
+
return (const _Tp*)(data + step.p[0]*y);
|
451
|
+
}
|
452
|
+
|
453
|
+
|
454
|
+
inline uchar* Mat::ptr(int i0, int i1)
|
455
|
+
{
|
456
|
+
CV_DbgAssert( dims >= 2 && data &&
|
457
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
458
|
+
(unsigned)i1 < (unsigned)size.p[1] );
|
459
|
+
return data + i0*step.p[0] + i1*step.p[1];
|
460
|
+
}
|
461
|
+
|
462
|
+
inline const uchar* Mat::ptr(int i0, int i1) const
|
463
|
+
{
|
464
|
+
CV_DbgAssert( dims >= 2 && data &&
|
465
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
466
|
+
(unsigned)i1 < (unsigned)size.p[1] );
|
467
|
+
return data + i0*step.p[0] + i1*step.p[1];
|
468
|
+
}
|
469
|
+
|
470
|
+
template<typename _Tp> inline _Tp* Mat::ptr(int i0, int i1)
|
471
|
+
{
|
472
|
+
CV_DbgAssert( dims >= 2 && data &&
|
473
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
474
|
+
(unsigned)i1 < (unsigned)size.p[1] );
|
475
|
+
return (_Tp*)(data + i0*step.p[0] + i1*step.p[1]);
|
476
|
+
}
|
477
|
+
|
478
|
+
template<typename _Tp> inline const _Tp* Mat::ptr(int i0, int i1) const
|
479
|
+
{
|
480
|
+
CV_DbgAssert( dims >= 2 && data &&
|
481
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
482
|
+
(unsigned)i1 < (unsigned)size.p[1] );
|
483
|
+
return (const _Tp*)(data + i0*step.p[0] + i1*step.p[1]);
|
484
|
+
}
|
485
|
+
|
486
|
+
inline uchar* Mat::ptr(int i0, int i1, int i2)
|
487
|
+
{
|
488
|
+
CV_DbgAssert( dims >= 3 && data &&
|
489
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
490
|
+
(unsigned)i1 < (unsigned)size.p[1] &&
|
491
|
+
(unsigned)i2 < (unsigned)size.p[2] );
|
492
|
+
return data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2];
|
493
|
+
}
|
494
|
+
|
495
|
+
inline const uchar* Mat::ptr(int i0, int i1, int i2) const
|
496
|
+
{
|
497
|
+
CV_DbgAssert( dims >= 3 && data &&
|
498
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
499
|
+
(unsigned)i1 < (unsigned)size.p[1] &&
|
500
|
+
(unsigned)i2 < (unsigned)size.p[2] );
|
501
|
+
return data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2];
|
502
|
+
}
|
503
|
+
|
504
|
+
template<typename _Tp> inline _Tp* Mat::ptr(int i0, int i1, int i2)
|
505
|
+
{
|
506
|
+
CV_DbgAssert( dims >= 3 && data &&
|
507
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
508
|
+
(unsigned)i1 < (unsigned)size.p[1] &&
|
509
|
+
(unsigned)i2 < (unsigned)size.p[2] );
|
510
|
+
return (_Tp*)(data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2]);
|
511
|
+
}
|
512
|
+
|
513
|
+
template<typename _Tp> inline const _Tp* Mat::ptr(int i0, int i1, int i2) const
|
514
|
+
{
|
515
|
+
CV_DbgAssert( dims >= 3 && data &&
|
516
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
517
|
+
(unsigned)i1 < (unsigned)size.p[1] &&
|
518
|
+
(unsigned)i2 < (unsigned)size.p[2] );
|
519
|
+
return (const _Tp*)(data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2]);
|
520
|
+
}
|
521
|
+
|
522
|
+
inline uchar* Mat::ptr(const int* idx)
|
523
|
+
{
|
524
|
+
int i, d = dims;
|
525
|
+
uchar* p = data;
|
526
|
+
CV_DbgAssert( d >= 1 && p );
|
527
|
+
for( i = 0; i < d; i++ )
|
528
|
+
{
|
529
|
+
CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] );
|
530
|
+
p += idx[i]*step.p[i];
|
531
|
+
}
|
532
|
+
return p;
|
533
|
+
}
|
534
|
+
|
535
|
+
inline const uchar* Mat::ptr(const int* idx) const
|
536
|
+
{
|
537
|
+
int i, d = dims;
|
538
|
+
uchar* p = data;
|
539
|
+
CV_DbgAssert( d >= 1 && p );
|
540
|
+
for( i = 0; i < d; i++ )
|
541
|
+
{
|
542
|
+
CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] );
|
543
|
+
p += idx[i]*step.p[i];
|
544
|
+
}
|
545
|
+
return p;
|
546
|
+
}
|
547
|
+
|
548
|
+
template<typename _Tp> inline _Tp& Mat::at(int i0, int i1)
|
549
|
+
{
|
550
|
+
CV_DbgAssert( dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] &&
|
551
|
+
(unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) &&
|
552
|
+
CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1());
|
553
|
+
return ((_Tp*)(data + step.p[0]*i0))[i1];
|
554
|
+
}
|
555
|
+
|
556
|
+
template<typename _Tp> inline const _Tp& Mat::at(int i0, int i1) const
|
557
|
+
{
|
558
|
+
CV_DbgAssert( dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] &&
|
559
|
+
(unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) &&
|
560
|
+
CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1());
|
561
|
+
return ((const _Tp*)(data + step.p[0]*i0))[i1];
|
562
|
+
}
|
563
|
+
|
564
|
+
template<typename _Tp> inline _Tp& Mat::at(Point pt)
|
565
|
+
{
|
566
|
+
CV_DbgAssert( dims <= 2 && data && (unsigned)pt.y < (unsigned)size.p[0] &&
|
567
|
+
(unsigned)(pt.x*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) &&
|
568
|
+
CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1());
|
569
|
+
return ((_Tp*)(data + step.p[0]*pt.y))[pt.x];
|
570
|
+
}
|
571
|
+
|
572
|
+
template<typename _Tp> inline const _Tp& Mat::at(Point pt) const
|
573
|
+
{
|
574
|
+
CV_DbgAssert( dims <= 2 && data && (unsigned)pt.y < (unsigned)size.p[0] &&
|
575
|
+
(unsigned)(pt.x*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) &&
|
576
|
+
CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1());
|
577
|
+
return ((const _Tp*)(data + step.p[0]*pt.y))[pt.x];
|
578
|
+
}
|
579
|
+
|
580
|
+
template<typename _Tp> inline _Tp& Mat::at(int i0)
|
581
|
+
{
|
582
|
+
CV_DbgAssert( dims <= 2 && data && (size.p[0] == 1 || size.p[1] == 1) &&
|
583
|
+
(unsigned)i0 < (unsigned)(size.p[0] + size.p[1] - 1) &&
|
584
|
+
elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) );
|
585
|
+
return *(_Tp*)(data + step.p[size.p[0]==1]*i0);
|
586
|
+
}
|
587
|
+
|
588
|
+
template<typename _Tp> inline const _Tp& Mat::at(int i0) const
|
589
|
+
{
|
590
|
+
CV_DbgAssert( dims <= 2 && data && (size.p[0] == 1 || size.p[1] == 1) &&
|
591
|
+
(unsigned)i0 < (unsigned)(size.p[0] + size.p[1] - 1) &&
|
592
|
+
elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) );
|
593
|
+
return *(_Tp*)(data + step.p[size.p[0]==1]*i0);
|
594
|
+
}
|
595
|
+
|
596
|
+
template<typename _Tp> inline _Tp& Mat::at(int i0, int i1, int i2)
|
597
|
+
{
|
598
|
+
CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) );
|
599
|
+
return *(_Tp*)ptr(i0, i1, i2);
|
600
|
+
}
|
601
|
+
template<typename _Tp> inline const _Tp& Mat::at(int i0, int i1, int i2) const
|
602
|
+
{
|
603
|
+
CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) );
|
604
|
+
return *(const _Tp*)ptr(i0, i1, i2);
|
605
|
+
}
|
606
|
+
template<typename _Tp> inline _Tp& Mat::at(const int* idx)
|
607
|
+
{
|
608
|
+
CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) );
|
609
|
+
return *(_Tp*)ptr(idx);
|
610
|
+
}
|
611
|
+
template<typename _Tp> inline const _Tp& Mat::at(const int* idx) const
|
612
|
+
{
|
613
|
+
CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) );
|
614
|
+
return *(const _Tp*)ptr(idx);
|
615
|
+
}
|
616
|
+
|
617
|
+
|
618
|
+
template<typename _Tp> inline MatConstIterator_<_Tp> Mat::begin() const
|
619
|
+
{
|
620
|
+
CV_DbgAssert( elemSize() == sizeof(_Tp) );
|
621
|
+
return MatConstIterator_<_Tp>((const Mat_<_Tp>*)this);
|
622
|
+
}
|
623
|
+
|
624
|
+
template<typename _Tp> inline MatConstIterator_<_Tp> Mat::end() const
|
625
|
+
{
|
626
|
+
CV_DbgAssert( elemSize() == sizeof(_Tp) );
|
627
|
+
MatConstIterator_<_Tp> it((const Mat_<_Tp>*)this);
|
628
|
+
it += total();
|
629
|
+
return it;
|
630
|
+
}
|
631
|
+
|
632
|
+
template<typename _Tp> inline MatIterator_<_Tp> Mat::begin()
|
633
|
+
{
|
634
|
+
CV_DbgAssert( elemSize() == sizeof(_Tp) );
|
635
|
+
return MatIterator_<_Tp>((Mat_<_Tp>*)this);
|
636
|
+
}
|
637
|
+
|
638
|
+
template<typename _Tp> inline MatIterator_<_Tp> Mat::end()
|
639
|
+
{
|
640
|
+
CV_DbgAssert( elemSize() == sizeof(_Tp) );
|
641
|
+
MatIterator_<_Tp> it((Mat_<_Tp>*)this);
|
642
|
+
it += total();
|
643
|
+
return it;
|
644
|
+
}
|
645
|
+
|
646
|
+
template<typename _Tp> inline Mat::operator vector<_Tp>() const
|
647
|
+
{
|
648
|
+
vector<_Tp> v;
|
649
|
+
copyTo(v);
|
650
|
+
return v;
|
651
|
+
}
|
652
|
+
|
653
|
+
template<typename _Tp, int n> inline Mat::operator Vec<_Tp, n>() const
|
654
|
+
{
|
655
|
+
CV_Assert( data && dims <= 2 && (rows == 1 || cols == 1) &&
|
656
|
+
rows + cols - 1 == n && channels() == 1 );
|
657
|
+
|
658
|
+
if( isContinuous() && type() == DataType<_Tp>::type )
|
659
|
+
return Vec<_Tp, n>((_Tp*)data);
|
660
|
+
Vec<_Tp, n> v; Mat tmp(rows, cols, DataType<_Tp>::type, v.val);
|
661
|
+
convertTo(tmp, tmp.type());
|
662
|
+
return v;
|
663
|
+
}
|
664
|
+
|
665
|
+
template<typename _Tp, int m, int n> inline Mat::operator Matx<_Tp, m, n>() const
|
666
|
+
{
|
667
|
+
CV_Assert( data && dims <= 2 && rows == m && cols == n && channels() == 1 );
|
668
|
+
|
669
|
+
if( isContinuous() && type() == DataType<_Tp>::type )
|
670
|
+
return Matx<_Tp, m, n>((_Tp*)data);
|
671
|
+
Matx<_Tp, m, n> mtx; Mat tmp(rows, cols, DataType<_Tp>::type, mtx.val);
|
672
|
+
convertTo(tmp, tmp.type());
|
673
|
+
return mtx;
|
674
|
+
}
|
675
|
+
|
676
|
+
|
677
|
+
template<typename _Tp> inline void Mat::push_back(const _Tp& elem)
|
678
|
+
{
|
679
|
+
if( !data )
|
680
|
+
{
|
681
|
+
*this = Mat(1, 1, DataType<_Tp>::type, (void*)&elem).clone();
|
682
|
+
return;
|
683
|
+
}
|
684
|
+
CV_Assert(DataType<_Tp>::type == type() && cols == 1
|
685
|
+
/* && dims == 2 (cols == 1 implies dims == 2) */);
|
686
|
+
uchar* tmp = dataend + step[0];
|
687
|
+
if( !isSubmatrix() && isContinuous() && tmp <= datalimit )
|
688
|
+
{
|
689
|
+
*(_Tp*)(data + (size.p[0]++)*step.p[0]) = elem;
|
690
|
+
dataend = tmp;
|
691
|
+
}
|
692
|
+
else
|
693
|
+
push_back_(&elem);
|
694
|
+
}
|
695
|
+
|
696
|
+
template<typename _Tp> inline void Mat::push_back(const Mat_<_Tp>& m)
|
697
|
+
{
|
698
|
+
push_back((const Mat&)m);
|
699
|
+
}
|
700
|
+
|
701
|
+
inline Mat::MSize::MSize(int* _p) : p(_p) {}
|
702
|
+
inline Size Mat::MSize::operator()() const
|
703
|
+
{
|
704
|
+
CV_DbgAssert(p[-1] <= 2);
|
705
|
+
return Size(p[1], p[0]);
|
706
|
+
}
|
707
|
+
inline const int& Mat::MSize::operator[](int i) const { return p[i]; }
|
708
|
+
inline int& Mat::MSize::operator[](int i) { return p[i]; }
|
709
|
+
inline Mat::MSize::operator const int*() const { return p; }
|
710
|
+
|
711
|
+
inline bool Mat::MSize::operator == (const MSize& sz) const
|
712
|
+
{
|
713
|
+
int d = p[-1], dsz = sz.p[-1];
|
714
|
+
if( d != dsz )
|
715
|
+
return false;
|
716
|
+
if( d == 2 )
|
717
|
+
return p[0] == sz.p[0] && p[1] == sz.p[1];
|
718
|
+
|
719
|
+
for( int i = 0; i < d; i++ )
|
720
|
+
if( p[i] != sz.p[i] )
|
721
|
+
return false;
|
722
|
+
return true;
|
723
|
+
}
|
724
|
+
|
725
|
+
inline bool Mat::MSize::operator != (const MSize& sz) const
|
726
|
+
{
|
727
|
+
return !(*this == sz);
|
728
|
+
}
|
729
|
+
|
730
|
+
inline Mat::MStep::MStep() { p = buf; p[0] = p[1] = 0; }
|
731
|
+
inline Mat::MStep::MStep(size_t s) { p = buf; p[0] = s; p[1] = 0; }
|
732
|
+
inline const size_t& Mat::MStep::operator[](int i) const { return p[i]; }
|
733
|
+
inline size_t& Mat::MStep::operator[](int i) { return p[i]; }
|
734
|
+
inline Mat::MStep::operator size_t() const
|
735
|
+
{
|
736
|
+
CV_DbgAssert( p == buf );
|
737
|
+
return buf[0];
|
738
|
+
}
|
739
|
+
inline Mat::MStep& Mat::MStep::operator = (size_t s)
|
740
|
+
{
|
741
|
+
CV_DbgAssert( p == buf );
|
742
|
+
buf[0] = s;
|
743
|
+
return *this;
|
744
|
+
}
|
745
|
+
|
746
|
+
static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0)
|
747
|
+
{
|
748
|
+
return cvarrToMat(arr, copyData, true, coiMode);
|
749
|
+
}
|
750
|
+
|
751
|
+
///////////////////////////////////////////// SVD //////////////////////////////////////////////////////
|
752
|
+
|
753
|
+
inline SVD::SVD() {}
|
754
|
+
inline SVD::SVD( InputArray m, int flags ) { operator ()(m, flags); }
|
755
|
+
inline void SVD::solveZ( InputArray m, OutputArray _dst )
|
756
|
+
{
|
757
|
+
SVD svd(m);
|
758
|
+
_dst.create(svd.vt.cols, 1, svd.vt.type());
|
759
|
+
Mat dst = _dst.getMat();
|
760
|
+
svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst);
|
761
|
+
}
|
762
|
+
|
763
|
+
template<typename _Tp, int m, int n, int nm> inline void
|
764
|
+
SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt )
|
765
|
+
{
|
766
|
+
assert( nm == MIN(m, n));
|
767
|
+
Mat _a(a, false), _u(u, false), _w(w, false), _vt(vt, false);
|
768
|
+
SVD::compute(_a, _w, _u, _vt);
|
769
|
+
CV_Assert(_w.data == (uchar*)&w.val[0] && _u.data == (uchar*)&u.val[0] && _vt.data == (uchar*)&vt.val[0]);
|
770
|
+
}
|
771
|
+
|
772
|
+
template<typename _Tp, int m, int n, int nm> inline void
|
773
|
+
SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w )
|
774
|
+
{
|
775
|
+
assert( nm == MIN(m, n));
|
776
|
+
Mat _a(a, false), _w(w, false);
|
777
|
+
SVD::compute(_a, _w);
|
778
|
+
CV_Assert(_w.data == (uchar*)&w.val[0]);
|
779
|
+
}
|
780
|
+
|
781
|
+
template<typename _Tp, int m, int n, int nm, int nb> inline void
|
782
|
+
SVD::backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u,
|
783
|
+
const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs,
|
784
|
+
Matx<_Tp, n, nb>& dst )
|
785
|
+
{
|
786
|
+
assert( nm == MIN(m, n));
|
787
|
+
Mat _u(u, false), _w(w, false), _vt(vt, false), _rhs(rhs, false), _dst(dst, false);
|
788
|
+
SVD::backSubst(_w, _u, _vt, _rhs, _dst);
|
789
|
+
CV_Assert(_dst.data == (uchar*)&dst.val[0]);
|
790
|
+
}
|
791
|
+
|
792
|
+
///////////////////////////////// Mat_<_Tp> ////////////////////////////////////
|
793
|
+
|
794
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_()
|
795
|
+
: Mat() { flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type; }
|
796
|
+
|
797
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(int _rows, int _cols)
|
798
|
+
: Mat(_rows, _cols, DataType<_Tp>::type) {}
|
799
|
+
|
800
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(int _rows, int _cols, const _Tp& value)
|
801
|
+
: Mat(_rows, _cols, DataType<_Tp>::type) { *this = value; }
|
802
|
+
|
803
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(Size _sz)
|
804
|
+
: Mat(_sz.height, _sz.width, DataType<_Tp>::type) {}
|
805
|
+
|
806
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(Size _sz, const _Tp& value)
|
807
|
+
: Mat(_sz.height, _sz.width, DataType<_Tp>::type) { *this = value; }
|
808
|
+
|
809
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(int _dims, const int* _sz)
|
810
|
+
: Mat(_dims, _sz, DataType<_Tp>::type) {}
|
811
|
+
|
812
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(int _dims, const int* _sz, const _Tp& _s)
|
813
|
+
: Mat(_dims, _sz, DataType<_Tp>::type, Scalar(_s)) {}
|
814
|
+
|
815
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const Range* ranges)
|
816
|
+
: Mat(m, ranges) {}
|
817
|
+
|
818
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat& m)
|
819
|
+
: Mat() { flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type; *this = m; }
|
820
|
+
|
821
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m)
|
822
|
+
: Mat(m) {}
|
823
|
+
|
824
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(int _rows, int _cols, _Tp* _data, size_t steps)
|
825
|
+
: Mat(_rows, _cols, DataType<_Tp>::type, _data, steps) {}
|
826
|
+
|
827
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m, const Range& rowRange, const Range& colRange)
|
828
|
+
: Mat(m, rowRange, colRange) {}
|
829
|
+
|
830
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m, const Rect& roi)
|
831
|
+
: Mat(m, roi) {}
|
832
|
+
|
833
|
+
template<typename _Tp> template<int n> inline
|
834
|
+
Mat_<_Tp>::Mat_(const Vec<typename DataType<_Tp>::channel_type, n>& vec, bool copyData)
|
835
|
+
: Mat(n/DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&vec)
|
836
|
+
{
|
837
|
+
CV_Assert(n%DataType<_Tp>::channels == 0);
|
838
|
+
if( copyData )
|
839
|
+
*this = clone();
|
840
|
+
}
|
841
|
+
|
842
|
+
template<typename _Tp> template<int m, int n> inline
|
843
|
+
Mat_<_Tp>::Mat_(const Matx<typename DataType<_Tp>::channel_type,m,n>& M, bool copyData)
|
844
|
+
: Mat(m, n/DataType<_Tp>::channels, DataType<_Tp>::type, (void*)&M)
|
845
|
+
{
|
846
|
+
CV_Assert(n % DataType<_Tp>::channels == 0);
|
847
|
+
if( copyData )
|
848
|
+
*this = clone();
|
849
|
+
}
|
850
|
+
|
851
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Point_<typename DataType<_Tp>::channel_type>& pt, bool copyData)
|
852
|
+
: Mat(2/DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&pt)
|
853
|
+
{
|
854
|
+
CV_Assert(2 % DataType<_Tp>::channels == 0);
|
855
|
+
if( copyData )
|
856
|
+
*this = clone();
|
857
|
+
}
|
858
|
+
|
859
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData)
|
860
|
+
: Mat(3/DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&pt)
|
861
|
+
{
|
862
|
+
CV_Assert(3 % DataType<_Tp>::channels == 0);
|
863
|
+
if( copyData )
|
864
|
+
*this = clone();
|
865
|
+
}
|
866
|
+
|
867
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer)
|
868
|
+
: Mat(commaInitializer) {}
|
869
|
+
|
870
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const vector<_Tp>& vec, bool copyData)
|
871
|
+
: Mat(vec, copyData) {}
|
872
|
+
|
873
|
+
template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m)
|
874
|
+
{
|
875
|
+
if( DataType<_Tp>::type == m.type() )
|
876
|
+
{
|
877
|
+
Mat::operator = (m);
|
878
|
+
return *this;
|
879
|
+
}
|
880
|
+
if( DataType<_Tp>::depth == m.depth() )
|
881
|
+
{
|
882
|
+
return (*this = m.reshape(DataType<_Tp>::channels, m.dims, 0));
|
883
|
+
}
|
884
|
+
CV_DbgAssert(DataType<_Tp>::channels == m.channels());
|
885
|
+
m.convertTo(*this, type());
|
886
|
+
return *this;
|
887
|
+
}
|
888
|
+
|
889
|
+
template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat_& m)
|
890
|
+
{
|
891
|
+
Mat::operator=(m);
|
892
|
+
return *this;
|
893
|
+
}
|
894
|
+
|
895
|
+
template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::operator = (const _Tp& s)
|
896
|
+
{
|
897
|
+
typedef typename DataType<_Tp>::vec_type VT;
|
898
|
+
Mat::operator=(Scalar((const VT&)s));
|
899
|
+
return *this;
|
900
|
+
}
|
901
|
+
|
902
|
+
template<typename _Tp> inline void Mat_<_Tp>::create(int _rows, int _cols)
|
903
|
+
{
|
904
|
+
Mat::create(_rows, _cols, DataType<_Tp>::type);
|
905
|
+
}
|
906
|
+
|
907
|
+
template<typename _Tp> inline void Mat_<_Tp>::create(Size _sz)
|
908
|
+
{
|
909
|
+
Mat::create(_sz, DataType<_Tp>::type);
|
910
|
+
}
|
911
|
+
|
912
|
+
template<typename _Tp> inline void Mat_<_Tp>::create(int _dims, const int* _sz)
|
913
|
+
{
|
914
|
+
Mat::create(_dims, _sz, DataType<_Tp>::type);
|
915
|
+
}
|
916
|
+
|
917
|
+
|
918
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::cross(const Mat_& m) const
|
919
|
+
{ return Mat_<_Tp>(Mat::cross(m)); }
|
920
|
+
|
921
|
+
template<typename _Tp> template<typename T2> inline Mat_<_Tp>::operator Mat_<T2>() const
|
922
|
+
{ return Mat_<T2>(*this); }
|
923
|
+
|
924
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::row(int y) const
|
925
|
+
{ return Mat_(*this, Range(y, y+1), Range::all()); }
|
926
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::col(int x) const
|
927
|
+
{ return Mat_(*this, Range::all(), Range(x, x+1)); }
|
928
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::diag(int d) const
|
929
|
+
{ return Mat_(Mat::diag(d)); }
|
930
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::clone() const
|
931
|
+
{ return Mat_(Mat::clone()); }
|
932
|
+
|
933
|
+
template<typename _Tp> inline size_t Mat_<_Tp>::elemSize() const
|
934
|
+
{
|
935
|
+
CV_DbgAssert( Mat::elemSize() == sizeof(_Tp) );
|
936
|
+
return sizeof(_Tp);
|
937
|
+
}
|
938
|
+
|
939
|
+
template<typename _Tp> inline size_t Mat_<_Tp>::elemSize1() const
|
940
|
+
{
|
941
|
+
CV_DbgAssert( Mat::elemSize1() == sizeof(_Tp)/DataType<_Tp>::channels );
|
942
|
+
return sizeof(_Tp)/DataType<_Tp>::channels;
|
943
|
+
}
|
944
|
+
template<typename _Tp> inline int Mat_<_Tp>::type() const
|
945
|
+
{
|
946
|
+
CV_DbgAssert( Mat::type() == DataType<_Tp>::type );
|
947
|
+
return DataType<_Tp>::type;
|
948
|
+
}
|
949
|
+
template<typename _Tp> inline int Mat_<_Tp>::depth() const
|
950
|
+
{
|
951
|
+
CV_DbgAssert( Mat::depth() == DataType<_Tp>::depth );
|
952
|
+
return DataType<_Tp>::depth;
|
953
|
+
}
|
954
|
+
template<typename _Tp> inline int Mat_<_Tp>::channels() const
|
955
|
+
{
|
956
|
+
CV_DbgAssert( Mat::channels() == DataType<_Tp>::channels );
|
957
|
+
return DataType<_Tp>::channels;
|
958
|
+
}
|
959
|
+
template<typename _Tp> inline size_t Mat_<_Tp>::stepT(int i) const { return step.p[i]/elemSize(); }
|
960
|
+
template<typename _Tp> inline size_t Mat_<_Tp>::step1(int i) const { return step.p[i]/elemSize1(); }
|
961
|
+
|
962
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::reshape(int _rows) const
|
963
|
+
{ return Mat_<_Tp>(Mat::reshape(0,_rows)); }
|
964
|
+
|
965
|
+
template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::adjustROI( int dtop, int dbottom, int dleft, int dright )
|
966
|
+
{ return (Mat_<_Tp>&)(Mat::adjustROI(dtop, dbottom, dleft, dright)); }
|
967
|
+
|
968
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Range& rowRange, const Range& colRange ) const
|
969
|
+
{ return Mat_<_Tp>(*this, rowRange, colRange); }
|
970
|
+
|
971
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Rect& roi ) const
|
972
|
+
{ return Mat_<_Tp>(*this, roi); }
|
973
|
+
|
974
|
+
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Range* ranges ) const
|
975
|
+
{ return Mat_<_Tp>(*this, ranges); }
|
976
|
+
|
977
|
+
template<typename _Tp> inline _Tp* Mat_<_Tp>::operator [](int y)
|
978
|
+
{ return (_Tp*)ptr(y); }
|
979
|
+
template<typename _Tp> inline const _Tp* Mat_<_Tp>::operator [](int y) const
|
980
|
+
{ return (const _Tp*)ptr(y); }
|
981
|
+
|
982
|
+
template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(int i0, int i1)
|
983
|
+
{
|
984
|
+
CV_DbgAssert( dims <= 2 && data &&
|
985
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
986
|
+
(unsigned)i1 < (unsigned)size.p[1] &&
|
987
|
+
type() == DataType<_Tp>::type );
|
988
|
+
return ((_Tp*)(data + step.p[0]*i0))[i1];
|
989
|
+
}
|
990
|
+
|
991
|
+
template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(int i0, int i1) const
|
992
|
+
{
|
993
|
+
CV_DbgAssert( dims <= 2 && data &&
|
994
|
+
(unsigned)i0 < (unsigned)size.p[0] &&
|
995
|
+
(unsigned)i1 < (unsigned)size.p[1] &&
|
996
|
+
type() == DataType<_Tp>::type );
|
997
|
+
return ((const _Tp*)(data + step.p[0]*i0))[i1];
|
998
|
+
}
|
999
|
+
|
1000
|
+
template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(Point pt)
|
1001
|
+
{
|
1002
|
+
CV_DbgAssert( dims <= 2 && data &&
|
1003
|
+
(unsigned)pt.y < (unsigned)size.p[0] &&
|
1004
|
+
(unsigned)pt.x < (unsigned)size.p[1] &&
|
1005
|
+
type() == DataType<_Tp>::type );
|
1006
|
+
return ((_Tp*)(data + step.p[0]*pt.y))[pt.x];
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(Point pt) const
|
1010
|
+
{
|
1011
|
+
CV_DbgAssert( dims <= 2 && data &&
|
1012
|
+
(unsigned)pt.y < (unsigned)size.p[0] &&
|
1013
|
+
(unsigned)pt.x < (unsigned)size.p[1] &&
|
1014
|
+
type() == DataType<_Tp>::type );
|
1015
|
+
return ((const _Tp*)(data + step.p[0]*pt.y))[pt.x];
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(const int* idx)
|
1019
|
+
{
|
1020
|
+
return Mat::at<_Tp>(idx);
|
1021
|
+
}
|
1022
|
+
|
1023
|
+
template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(const int* idx) const
|
1024
|
+
{
|
1025
|
+
return Mat::at<_Tp>(idx);
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(int i0)
|
1029
|
+
{
|
1030
|
+
return this->at<_Tp>(i0);
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(int i0) const
|
1034
|
+
{
|
1035
|
+
return this->at<_Tp>(i0);
|
1036
|
+
}
|
1037
|
+
|
1038
|
+
template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2)
|
1039
|
+
{
|
1040
|
+
return this->at<_Tp>(i0, i1, i2);
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) const
|
1044
|
+
{
|
1045
|
+
return this->at<_Tp>(i0, i1, i2);
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
|
1049
|
+
template<typename _Tp> inline Mat_<_Tp>::operator vector<_Tp>() const
|
1050
|
+
{
|
1051
|
+
vector<_Tp> v;
|
1052
|
+
copyTo(v);
|
1053
|
+
return v;
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
template<typename _Tp> template<int n> inline Mat_<_Tp>::operator Vec<typename DataType<_Tp>::channel_type, n>() const
|
1057
|
+
{
|
1058
|
+
CV_Assert(n % DataType<_Tp>::channels == 0);
|
1059
|
+
return this->Mat::operator Vec<typename DataType<_Tp>::channel_type, n>();
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
template<typename _Tp> template<int m, int n> inline Mat_<_Tp>::operator Matx<typename DataType<_Tp>::channel_type, m, n>() const
|
1063
|
+
{
|
1064
|
+
CV_Assert(n % DataType<_Tp>::channels == 0);
|
1065
|
+
return this->Mat::operator Matx<typename DataType<_Tp>::channel_type, m, n>();
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
template<typename T1, typename T2, typename Op> inline void
|
1069
|
+
process( const Mat_<T1>& m1, Mat_<T2>& m2, Op op )
|
1070
|
+
{
|
1071
|
+
int y, x, rows = m1.rows, cols = m1.cols;
|
1072
|
+
int c1 = m1.channels(), c2 = m2.channels();
|
1073
|
+
|
1074
|
+
CV_DbgAssert( m1.size() == m2.size() );
|
1075
|
+
|
1076
|
+
for( y = 0; y < rows; y++ )
|
1077
|
+
{
|
1078
|
+
const T1* src = m1[y];
|
1079
|
+
T2* dst = m2[y];
|
1080
|
+
|
1081
|
+
for( x = 0; x < cols; x++ )
|
1082
|
+
dst[x] = op(src[x]);
|
1083
|
+
}
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
template<typename T1, typename T2, typename T3, typename Op> inline void
|
1087
|
+
process( const Mat_<T1>& m1, const Mat_<T2>& m2, Mat_<T3>& m3, Op op )
|
1088
|
+
{
|
1089
|
+
int y, x, rows = m1.rows, cols = m1.cols;
|
1090
|
+
|
1091
|
+
CV_DbgAssert( m1.size() == m2.size() );
|
1092
|
+
|
1093
|
+
for( y = 0; y < rows; y++ )
|
1094
|
+
{
|
1095
|
+
const T1* src1 = m1[y];
|
1096
|
+
const T2* src2 = m2[y];
|
1097
|
+
T3* dst = m3[y];
|
1098
|
+
|
1099
|
+
for( x = 0; x < cols; x++ )
|
1100
|
+
dst[x] = op( src1[x], src2[x] );
|
1101
|
+
}
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
|
1105
|
+
/////////////////////////////// Input/Output Arrays /////////////////////////////////
|
1106
|
+
|
1107
|
+
template<typename _Tp> inline _InputArray::_InputArray(const vector<_Tp>& vec)
|
1108
|
+
: flags(STD_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {}
|
1109
|
+
|
1110
|
+
template<typename _Tp> inline _InputArray::_InputArray(const vector<vector<_Tp> >& vec)
|
1111
|
+
: flags(STD_VECTOR_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {}
|
1112
|
+
|
1113
|
+
template<typename _Tp, int m, int n> inline _InputArray::_InputArray(const Matx<_Tp, m, n>& mtx)
|
1114
|
+
: flags(MATX + DataType<_Tp>::type), obj((void*)&mtx), sz(n, m) {}
|
1115
|
+
|
1116
|
+
inline _InputArray::_InputArray(const Scalar& s)
|
1117
|
+
: flags(MATX + CV_64F), obj((void*)&s), sz(1, 4) {}
|
1118
|
+
|
1119
|
+
template<typename _Tp> inline _OutputArray::_OutputArray(vector<_Tp>& vec) : _InputArray(vec) {}
|
1120
|
+
template<typename _Tp> inline _OutputArray::_OutputArray(vector<vector<_Tp> >& vec) : _InputArray(vec) {}
|
1121
|
+
template<typename _Tp, int m, int n> inline _OutputArray::_OutputArray(Matx<_Tp, m, n>& mtx) : _InputArray(mtx) {}
|
1122
|
+
|
1123
|
+
//////////////////////////////////// Matrix Expressions /////////////////////////////////////////
|
1124
|
+
|
1125
|
+
class CV_EXPORTS MatOp
|
1126
|
+
{
|
1127
|
+
public:
|
1128
|
+
MatOp() {};
|
1129
|
+
virtual ~MatOp() {};
|
1130
|
+
|
1131
|
+
virtual bool elementWise(const MatExpr& expr) const;
|
1132
|
+
virtual void assign(const MatExpr& expr, Mat& m, int type=-1) const = 0;
|
1133
|
+
virtual void roi(const MatExpr& expr, const Range& rowRange,
|
1134
|
+
const Range& colRange, MatExpr& res) const;
|
1135
|
+
virtual void diag(const MatExpr& expr, int d, MatExpr& res) const;
|
1136
|
+
virtual void augAssignAdd(const MatExpr& expr, Mat& m) const;
|
1137
|
+
virtual void augAssignSubtract(const MatExpr& expr, Mat& m) const;
|
1138
|
+
virtual void augAssignMultiply(const MatExpr& expr, Mat& m) const;
|
1139
|
+
virtual void augAssignDivide(const MatExpr& expr, Mat& m) const;
|
1140
|
+
virtual void augAssignAnd(const MatExpr& expr, Mat& m) const;
|
1141
|
+
virtual void augAssignOr(const MatExpr& expr, Mat& m) const;
|
1142
|
+
virtual void augAssignXor(const MatExpr& expr, Mat& m) const;
|
1143
|
+
|
1144
|
+
virtual void add(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const;
|
1145
|
+
virtual void add(const MatExpr& expr1, const Scalar& s, MatExpr& res) const;
|
1146
|
+
|
1147
|
+
virtual void subtract(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const;
|
1148
|
+
virtual void subtract(const Scalar& s, const MatExpr& expr, MatExpr& res) const;
|
1149
|
+
|
1150
|
+
virtual void multiply(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res, double scale=1) const;
|
1151
|
+
virtual void multiply(const MatExpr& expr1, double s, MatExpr& res) const;
|
1152
|
+
|
1153
|
+
virtual void divide(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res, double scale=1) const;
|
1154
|
+
virtual void divide(double s, const MatExpr& expr, MatExpr& res) const;
|
1155
|
+
|
1156
|
+
virtual void abs(const MatExpr& expr, MatExpr& res) const;
|
1157
|
+
|
1158
|
+
virtual void transpose(const MatExpr& expr, MatExpr& res) const;
|
1159
|
+
virtual void matmul(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const;
|
1160
|
+
virtual void invert(const MatExpr& expr, int method, MatExpr& res) const;
|
1161
|
+
|
1162
|
+
virtual Size size(const MatExpr& expr) const;
|
1163
|
+
virtual int type(const MatExpr& expr) const;
|
1164
|
+
};
|
1165
|
+
|
1166
|
+
|
1167
|
+
class CV_EXPORTS MatExpr
|
1168
|
+
{
|
1169
|
+
public:
|
1170
|
+
MatExpr() : op(0), flags(0), a(Mat()), b(Mat()), c(Mat()), alpha(0), beta(0), s(Scalar()) {}
|
1171
|
+
MatExpr(const MatOp* _op, int _flags, const Mat& _a=Mat(), const Mat& _b=Mat(),
|
1172
|
+
const Mat& _c=Mat(), double _alpha=1, double _beta=1, const Scalar& _s=Scalar())
|
1173
|
+
: op(_op), flags(_flags), a(_a), b(_b), c(_c), alpha(_alpha), beta(_beta), s(_s) {}
|
1174
|
+
explicit MatExpr(const Mat& m);
|
1175
|
+
operator Mat() const
|
1176
|
+
{
|
1177
|
+
Mat m;
|
1178
|
+
op->assign(*this, m);
|
1179
|
+
return m;
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
template<typename _Tp> operator Mat_<_Tp>() const
|
1183
|
+
{
|
1184
|
+
Mat_<_Tp> m;
|
1185
|
+
op->assign(*this, m, DataType<_Tp>::type);
|
1186
|
+
return m;
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
MatExpr row(int y) const;
|
1190
|
+
MatExpr col(int x) const;
|
1191
|
+
MatExpr diag(int d=0) const;
|
1192
|
+
MatExpr operator()( const Range& rowRange, const Range& colRange ) const;
|
1193
|
+
MatExpr operator()( const Rect& roi ) const;
|
1194
|
+
|
1195
|
+
Mat cross(const Mat& m) const;
|
1196
|
+
double dot(const Mat& m) const;
|
1197
|
+
|
1198
|
+
MatExpr t() const;
|
1199
|
+
MatExpr inv(int method = DECOMP_LU) const;
|
1200
|
+
MatExpr mul(const MatExpr& e, double scale=1) const;
|
1201
|
+
MatExpr mul(const Mat& m, double scale=1) const;
|
1202
|
+
|
1203
|
+
Size size() const;
|
1204
|
+
int type() const;
|
1205
|
+
|
1206
|
+
const MatOp* op;
|
1207
|
+
int flags;
|
1208
|
+
|
1209
|
+
Mat a, b, c;
|
1210
|
+
double alpha, beta;
|
1211
|
+
Scalar s;
|
1212
|
+
};
|
1213
|
+
|
1214
|
+
|
1215
|
+
CV_EXPORTS MatExpr operator + (const Mat& a, const Mat& b);
|
1216
|
+
CV_EXPORTS MatExpr operator + (const Mat& a, const Scalar& s);
|
1217
|
+
CV_EXPORTS MatExpr operator + (const Scalar& s, const Mat& a);
|
1218
|
+
CV_EXPORTS MatExpr operator + (const MatExpr& e, const Mat& m);
|
1219
|
+
CV_EXPORTS MatExpr operator + (const Mat& m, const MatExpr& e);
|
1220
|
+
CV_EXPORTS MatExpr operator + (const MatExpr& e, const Scalar& s);
|
1221
|
+
CV_EXPORTS MatExpr operator + (const Scalar& s, const MatExpr& e);
|
1222
|
+
CV_EXPORTS MatExpr operator + (const MatExpr& e1, const MatExpr& e2);
|
1223
|
+
|
1224
|
+
CV_EXPORTS MatExpr operator - (const Mat& a, const Mat& b);
|
1225
|
+
CV_EXPORTS MatExpr operator - (const Mat& a, const Scalar& s);
|
1226
|
+
CV_EXPORTS MatExpr operator - (const Scalar& s, const Mat& a);
|
1227
|
+
CV_EXPORTS MatExpr operator - (const MatExpr& e, const Mat& m);
|
1228
|
+
CV_EXPORTS MatExpr operator - (const Mat& m, const MatExpr& e);
|
1229
|
+
CV_EXPORTS MatExpr operator - (const MatExpr& e, const Scalar& s);
|
1230
|
+
CV_EXPORTS MatExpr operator - (const Scalar& s, const MatExpr& e);
|
1231
|
+
CV_EXPORTS MatExpr operator - (const MatExpr& e1, const MatExpr& e2);
|
1232
|
+
|
1233
|
+
CV_EXPORTS MatExpr operator - (const Mat& m);
|
1234
|
+
CV_EXPORTS MatExpr operator - (const MatExpr& e);
|
1235
|
+
|
1236
|
+
CV_EXPORTS MatExpr operator * (const Mat& a, const Mat& b);
|
1237
|
+
CV_EXPORTS MatExpr operator * (const Mat& a, double s);
|
1238
|
+
CV_EXPORTS MatExpr operator * (double s, const Mat& a);
|
1239
|
+
CV_EXPORTS MatExpr operator * (const MatExpr& e, const Mat& m);
|
1240
|
+
CV_EXPORTS MatExpr operator * (const Mat& m, const MatExpr& e);
|
1241
|
+
CV_EXPORTS MatExpr operator * (const MatExpr& e, double s);
|
1242
|
+
CV_EXPORTS MatExpr operator * (double s, const MatExpr& e);
|
1243
|
+
CV_EXPORTS MatExpr operator * (const MatExpr& e1, const MatExpr& e2);
|
1244
|
+
|
1245
|
+
CV_EXPORTS MatExpr operator / (const Mat& a, const Mat& b);
|
1246
|
+
CV_EXPORTS MatExpr operator / (const Mat& a, double s);
|
1247
|
+
CV_EXPORTS MatExpr operator / (double s, const Mat& a);
|
1248
|
+
CV_EXPORTS MatExpr operator / (const MatExpr& e, const Mat& m);
|
1249
|
+
CV_EXPORTS MatExpr operator / (const Mat& m, const MatExpr& e);
|
1250
|
+
CV_EXPORTS MatExpr operator / (const MatExpr& e, double s);
|
1251
|
+
CV_EXPORTS MatExpr operator / (double s, const MatExpr& e);
|
1252
|
+
CV_EXPORTS MatExpr operator / (const MatExpr& e1, const MatExpr& e2);
|
1253
|
+
|
1254
|
+
CV_EXPORTS MatExpr operator < (const Mat& a, const Mat& b);
|
1255
|
+
CV_EXPORTS MatExpr operator < (const Mat& a, double s);
|
1256
|
+
CV_EXPORTS MatExpr operator < (double s, const Mat& a);
|
1257
|
+
|
1258
|
+
CV_EXPORTS MatExpr operator <= (const Mat& a, const Mat& b);
|
1259
|
+
CV_EXPORTS MatExpr operator <= (const Mat& a, double s);
|
1260
|
+
CV_EXPORTS MatExpr operator <= (double s, const Mat& a);
|
1261
|
+
|
1262
|
+
CV_EXPORTS MatExpr operator == (const Mat& a, const Mat& b);
|
1263
|
+
CV_EXPORTS MatExpr operator == (const Mat& a, double s);
|
1264
|
+
CV_EXPORTS MatExpr operator == (double s, const Mat& a);
|
1265
|
+
|
1266
|
+
CV_EXPORTS MatExpr operator != (const Mat& a, const Mat& b);
|
1267
|
+
CV_EXPORTS MatExpr operator != (const Mat& a, double s);
|
1268
|
+
CV_EXPORTS MatExpr operator != (double s, const Mat& a);
|
1269
|
+
|
1270
|
+
CV_EXPORTS MatExpr operator >= (const Mat& a, const Mat& b);
|
1271
|
+
CV_EXPORTS MatExpr operator >= (const Mat& a, double s);
|
1272
|
+
CV_EXPORTS MatExpr operator >= (double s, const Mat& a);
|
1273
|
+
|
1274
|
+
CV_EXPORTS MatExpr operator > (const Mat& a, const Mat& b);
|
1275
|
+
CV_EXPORTS MatExpr operator > (const Mat& a, double s);
|
1276
|
+
CV_EXPORTS MatExpr operator > (double s, const Mat& a);
|
1277
|
+
|
1278
|
+
CV_EXPORTS MatExpr min(const Mat& a, const Mat& b);
|
1279
|
+
CV_EXPORTS MatExpr min(const Mat& a, double s);
|
1280
|
+
CV_EXPORTS MatExpr min(double s, const Mat& a);
|
1281
|
+
|
1282
|
+
CV_EXPORTS MatExpr max(const Mat& a, const Mat& b);
|
1283
|
+
CV_EXPORTS MatExpr max(const Mat& a, double s);
|
1284
|
+
CV_EXPORTS MatExpr max(double s, const Mat& a);
|
1285
|
+
|
1286
|
+
template<typename _Tp> static inline MatExpr min(const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1287
|
+
{
|
1288
|
+
return cv::min((const Mat&)a, (const Mat&)b);
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
template<typename _Tp> static inline MatExpr min(const Mat_<_Tp>& a, double s)
|
1292
|
+
{
|
1293
|
+
return cv::min((const Mat&)a, s);
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
template<typename _Tp> static inline MatExpr min(double s, const Mat_<_Tp>& a)
|
1297
|
+
{
|
1298
|
+
return cv::min((const Mat&)a, s);
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
template<typename _Tp> static inline MatExpr max(const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1302
|
+
{
|
1303
|
+
return cv::max((const Mat&)a, (const Mat&)b);
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
template<typename _Tp> static inline MatExpr max(const Mat_<_Tp>& a, double s)
|
1307
|
+
{
|
1308
|
+
return cv::max((const Mat&)a, s);
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
template<typename _Tp> static inline MatExpr max(double s, const Mat_<_Tp>& a)
|
1312
|
+
{
|
1313
|
+
return cv::max((const Mat&)a, s);
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
template<typename _Tp> static inline void min(const Mat_<_Tp>& a, const Mat_<_Tp>& b, Mat_<_Tp>& c)
|
1317
|
+
{
|
1318
|
+
cv::min((const Mat&)a, (const Mat&)b, (Mat&)c);
|
1319
|
+
}
|
1320
|
+
|
1321
|
+
template<typename _Tp> static inline void min(const Mat_<_Tp>& a, double s, Mat_<_Tp>& c)
|
1322
|
+
{
|
1323
|
+
cv::min((const Mat&)a, s, (Mat&)c);
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
template<typename _Tp> static inline void min(double s, const Mat_<_Tp>& a, Mat_<_Tp>& c)
|
1327
|
+
{
|
1328
|
+
cv::min((const Mat&)a, s, (Mat&)c);
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
template<typename _Tp> static inline void max(const Mat_<_Tp>& a, const Mat_<_Tp>& b, Mat_<_Tp>& c)
|
1332
|
+
{
|
1333
|
+
cv::min((const Mat&)a, (const Mat&)b, (Mat&)c);
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
template<typename _Tp> static inline void max(const Mat_<_Tp>& a, double s, Mat_<_Tp>& c)
|
1337
|
+
{
|
1338
|
+
cv::min((const Mat&)a, s, (Mat&)c);
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
template<typename _Tp> static inline void max(double s, const Mat_<_Tp>& a, Mat_<_Tp>& c)
|
1342
|
+
{
|
1343
|
+
cv::min((const Mat&)a, s, (Mat&)c);
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
|
1347
|
+
CV_EXPORTS MatExpr operator & (const Mat& a, const Mat& b);
|
1348
|
+
CV_EXPORTS MatExpr operator & (const Mat& a, const Scalar& s);
|
1349
|
+
CV_EXPORTS MatExpr operator & (const Scalar& s, const Mat& a);
|
1350
|
+
|
1351
|
+
CV_EXPORTS MatExpr operator | (const Mat& a, const Mat& b);
|
1352
|
+
CV_EXPORTS MatExpr operator | (const Mat& a, const Scalar& s);
|
1353
|
+
CV_EXPORTS MatExpr operator | (const Scalar& s, const Mat& a);
|
1354
|
+
|
1355
|
+
CV_EXPORTS MatExpr operator ^ (const Mat& a, const Mat& b);
|
1356
|
+
CV_EXPORTS MatExpr operator ^ (const Mat& a, const Scalar& s);
|
1357
|
+
CV_EXPORTS MatExpr operator ^ (const Scalar& s, const Mat& a);
|
1358
|
+
|
1359
|
+
CV_EXPORTS MatExpr operator ~(const Mat& m);
|
1360
|
+
|
1361
|
+
CV_EXPORTS MatExpr abs(const Mat& m);
|
1362
|
+
CV_EXPORTS MatExpr abs(const MatExpr& e);
|
1363
|
+
|
1364
|
+
template<typename _Tp> static inline MatExpr abs(const Mat_<_Tp>& m)
|
1365
|
+
{
|
1366
|
+
return cv::abs((const Mat&)m);
|
1367
|
+
}
|
1368
|
+
|
1369
|
+
////////////////////////////// Augmenting algebraic operations //////////////////////////////////
|
1370
|
+
|
1371
|
+
inline Mat& Mat::operator = (const MatExpr& e)
|
1372
|
+
{
|
1373
|
+
e.op->assign(e, *this);
|
1374
|
+
return *this;
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
template<typename _Tp> inline Mat_<_Tp>::Mat_(const MatExpr& e)
|
1378
|
+
{
|
1379
|
+
e.op->assign(e, *this, DataType<_Tp>::type);
|
1380
|
+
}
|
1381
|
+
|
1382
|
+
template<typename _Tp> Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e)
|
1383
|
+
{
|
1384
|
+
e.op->assign(e, *this, DataType<_Tp>::type);
|
1385
|
+
return *this;
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
static inline Mat& operator += (const Mat& a, const Mat& b)
|
1389
|
+
{
|
1390
|
+
add(a, b, (Mat&)a);
|
1391
|
+
return (Mat&)a;
|
1392
|
+
}
|
1393
|
+
|
1394
|
+
static inline Mat& operator += (const Mat& a, const Scalar& s)
|
1395
|
+
{
|
1396
|
+
add(a, s, (Mat&)a);
|
1397
|
+
return (Mat&)a;
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
template<typename _Tp> static inline
|
1401
|
+
Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1402
|
+
{
|
1403
|
+
add(a, b, (Mat&)a);
|
1404
|
+
return (Mat_<_Tp>&)a;
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
template<typename _Tp> static inline
|
1408
|
+
Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const Scalar& s)
|
1409
|
+
{
|
1410
|
+
add(a, s, (Mat&)a);
|
1411
|
+
return (Mat_<_Tp>&)a;
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
static inline Mat& operator += (const Mat& a, const MatExpr& b)
|
1415
|
+
{
|
1416
|
+
b.op->augAssignAdd(b, (Mat&)a);
|
1417
|
+
return (Mat&)a;
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
template<typename _Tp> static inline
|
1421
|
+
Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const MatExpr& b)
|
1422
|
+
{
|
1423
|
+
b.op->augAssignAdd(b, (Mat&)a);
|
1424
|
+
return (Mat_<_Tp>&)a;
|
1425
|
+
}
|
1426
|
+
|
1427
|
+
static inline Mat& operator -= (const Mat& a, const Mat& b)
|
1428
|
+
{
|
1429
|
+
subtract(a, b, (Mat&)a);
|
1430
|
+
return (Mat&)a;
|
1431
|
+
}
|
1432
|
+
|
1433
|
+
static inline Mat& operator -= (const Mat& a, const Scalar& s)
|
1434
|
+
{
|
1435
|
+
subtract(a, s, (Mat&)a);
|
1436
|
+
return (Mat&)a;
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
template<typename _Tp> static inline
|
1440
|
+
Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1441
|
+
{
|
1442
|
+
subtract(a, b, (Mat&)a);
|
1443
|
+
return (Mat_<_Tp>&)a;
|
1444
|
+
}
|
1445
|
+
|
1446
|
+
template<typename _Tp> static inline
|
1447
|
+
Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const Scalar& s)
|
1448
|
+
{
|
1449
|
+
subtract(a, s, (Mat&)a);
|
1450
|
+
return (Mat_<_Tp>&)a;
|
1451
|
+
}
|
1452
|
+
|
1453
|
+
static inline Mat& operator -= (const Mat& a, const MatExpr& b)
|
1454
|
+
{
|
1455
|
+
b.op->augAssignSubtract(b, (Mat&)a);
|
1456
|
+
return (Mat&)a;
|
1457
|
+
}
|
1458
|
+
|
1459
|
+
template<typename _Tp> static inline
|
1460
|
+
Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const MatExpr& b)
|
1461
|
+
{
|
1462
|
+
b.op->augAssignSubtract(b, (Mat&)a);
|
1463
|
+
return (Mat_<_Tp>&)a;
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
static inline Mat& operator *= (const Mat& a, const Mat& b)
|
1467
|
+
{
|
1468
|
+
gemm(a, b, 1, Mat(), 0, (Mat&)a, 0);
|
1469
|
+
return (Mat&)a;
|
1470
|
+
}
|
1471
|
+
|
1472
|
+
static inline Mat& operator *= (const Mat& a, double s)
|
1473
|
+
{
|
1474
|
+
a.convertTo((Mat&)a, -1, s);
|
1475
|
+
return (Mat&)a;
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
template<typename _Tp> static inline
|
1479
|
+
Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1480
|
+
{
|
1481
|
+
gemm(a, b, 1, Mat(), 0, (Mat&)a, 0);
|
1482
|
+
return (Mat_<_Tp>&)a;
|
1483
|
+
}
|
1484
|
+
|
1485
|
+
template<typename _Tp> static inline
|
1486
|
+
Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, double s)
|
1487
|
+
{
|
1488
|
+
a.convertTo((Mat&)a, -1, s);
|
1489
|
+
return (Mat_<_Tp>&)a;
|
1490
|
+
}
|
1491
|
+
|
1492
|
+
static inline Mat& operator *= (const Mat& a, const MatExpr& b)
|
1493
|
+
{
|
1494
|
+
b.op->augAssignMultiply(b, (Mat&)a);
|
1495
|
+
return (Mat&)a;
|
1496
|
+
}
|
1497
|
+
|
1498
|
+
template<typename _Tp> static inline
|
1499
|
+
Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, const MatExpr& b)
|
1500
|
+
{
|
1501
|
+
b.op->augAssignMultiply(b, (Mat&)a);
|
1502
|
+
return (Mat_<_Tp>&)a;
|
1503
|
+
}
|
1504
|
+
|
1505
|
+
static inline Mat& operator /= (const Mat& a, const Mat& b)
|
1506
|
+
{
|
1507
|
+
divide(a, b, (Mat&)a);
|
1508
|
+
return (Mat&)a;
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
static inline Mat& operator /= (const Mat& a, double s)
|
1512
|
+
{
|
1513
|
+
a.convertTo((Mat&)a, -1, 1./s);
|
1514
|
+
return (Mat&)a;
|
1515
|
+
}
|
1516
|
+
|
1517
|
+
template<typename _Tp> static inline
|
1518
|
+
Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1519
|
+
{
|
1520
|
+
divide(a, b, (Mat&)a);
|
1521
|
+
return (Mat_<_Tp>&)a;
|
1522
|
+
}
|
1523
|
+
|
1524
|
+
template<typename _Tp> static inline
|
1525
|
+
Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, double s)
|
1526
|
+
{
|
1527
|
+
a.convertTo((Mat&)a, -1, 1./s);
|
1528
|
+
return (Mat_<_Tp>&)a;
|
1529
|
+
}
|
1530
|
+
|
1531
|
+
static inline Mat& operator /= (const Mat& a, const MatExpr& b)
|
1532
|
+
{
|
1533
|
+
b.op->augAssignDivide(b, (Mat&)a);
|
1534
|
+
return (Mat&)a;
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
template<typename _Tp> static inline
|
1538
|
+
Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b)
|
1539
|
+
{
|
1540
|
+
b.op->augAssignDivide(b, (Mat&)a);
|
1541
|
+
return (Mat_<_Tp>&)a;
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
////////////////////////////// Logical operations ///////////////////////////////
|
1545
|
+
|
1546
|
+
static inline Mat& operator &= (const Mat& a, const Mat& b)
|
1547
|
+
{
|
1548
|
+
bitwise_and(a, b, (Mat&)a);
|
1549
|
+
return (Mat&)a;
|
1550
|
+
}
|
1551
|
+
|
1552
|
+
static inline Mat& operator &= (const Mat& a, const Scalar& s)
|
1553
|
+
{
|
1554
|
+
bitwise_and(a, s, (Mat&)a);
|
1555
|
+
return (Mat&)a;
|
1556
|
+
}
|
1557
|
+
|
1558
|
+
template<typename _Tp> static inline Mat_<_Tp>&
|
1559
|
+
operator &= (const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1560
|
+
{
|
1561
|
+
bitwise_and(a, b, (Mat&)a);
|
1562
|
+
return (Mat_<_Tp>&)a;
|
1563
|
+
}
|
1564
|
+
|
1565
|
+
template<typename _Tp> static inline Mat_<_Tp>&
|
1566
|
+
operator &= (const Mat_<_Tp>& a, const Scalar& s)
|
1567
|
+
{
|
1568
|
+
bitwise_and(a, s, (Mat&)a);
|
1569
|
+
return (Mat_<_Tp>&)a;
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
static inline Mat& operator |= (const Mat& a, const Mat& b)
|
1573
|
+
{
|
1574
|
+
bitwise_or(a, b, (Mat&)a);
|
1575
|
+
return (Mat&)a;
|
1576
|
+
}
|
1577
|
+
|
1578
|
+
static inline Mat& operator |= (const Mat& a, const Scalar& s)
|
1579
|
+
{
|
1580
|
+
bitwise_or(a, s, (Mat&)a);
|
1581
|
+
return (Mat&)a;
|
1582
|
+
}
|
1583
|
+
|
1584
|
+
template<typename _Tp> static inline Mat_<_Tp>&
|
1585
|
+
operator |= (const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1586
|
+
{
|
1587
|
+
bitwise_or(a, b, (Mat&)a);
|
1588
|
+
return (Mat_<_Tp>&)a;
|
1589
|
+
}
|
1590
|
+
|
1591
|
+
template<typename _Tp> static inline Mat_<_Tp>&
|
1592
|
+
operator |= (const Mat_<_Tp>& a, const Scalar& s)
|
1593
|
+
{
|
1594
|
+
bitwise_or(a, s, (Mat&)a);
|
1595
|
+
return (Mat_<_Tp>&)a;
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
static inline Mat& operator ^= (const Mat& a, const Mat& b)
|
1599
|
+
{
|
1600
|
+
bitwise_xor(a, b, (Mat&)a);
|
1601
|
+
return (Mat&)a;
|
1602
|
+
}
|
1603
|
+
|
1604
|
+
static inline Mat& operator ^= (const Mat& a, const Scalar& s)
|
1605
|
+
{
|
1606
|
+
bitwise_xor(a, s, (Mat&)a);
|
1607
|
+
return (Mat&)a;
|
1608
|
+
}
|
1609
|
+
|
1610
|
+
template<typename _Tp> static inline Mat_<_Tp>&
|
1611
|
+
operator ^= (const Mat_<_Tp>& a, const Mat_<_Tp>& b)
|
1612
|
+
{
|
1613
|
+
bitwise_xor(a, b, (Mat&)a);
|
1614
|
+
return (Mat_<_Tp>&)a;
|
1615
|
+
}
|
1616
|
+
|
1617
|
+
template<typename _Tp> static inline Mat_<_Tp>&
|
1618
|
+
operator ^= (const Mat_<_Tp>& a, const Scalar& s)
|
1619
|
+
{
|
1620
|
+
bitwise_xor(a, s, (Mat&)a);
|
1621
|
+
return (Mat_<_Tp>&)a;
|
1622
|
+
}
|
1623
|
+
|
1624
|
+
/////////////////////////////// Miscellaneous operations //////////////////////////////
|
1625
|
+
|
1626
|
+
template<typename _Tp> void split(const Mat& src, vector<Mat_<_Tp> >& mv)
|
1627
|
+
{ split(src, (vector<Mat>&)mv ); }
|
1628
|
+
|
1629
|
+
//////////////////////////////////////////////////////////////
|
1630
|
+
|
1631
|
+
template<typename _Tp> inline MatExpr Mat_<_Tp>::zeros(int rows, int cols)
|
1632
|
+
{
|
1633
|
+
return Mat::zeros(rows, cols, DataType<_Tp>::type);
|
1634
|
+
}
|
1635
|
+
|
1636
|
+
template<typename _Tp> inline MatExpr Mat_<_Tp>::zeros(Size sz)
|
1637
|
+
{
|
1638
|
+
return Mat::zeros(sz, DataType<_Tp>::type);
|
1639
|
+
}
|
1640
|
+
|
1641
|
+
template<typename _Tp> inline MatExpr Mat_<_Tp>::ones(int rows, int cols)
|
1642
|
+
{
|
1643
|
+
return Mat::ones(rows, cols, DataType<_Tp>::type);
|
1644
|
+
}
|
1645
|
+
|
1646
|
+
template<typename _Tp> inline MatExpr Mat_<_Tp>::ones(Size sz)
|
1647
|
+
{
|
1648
|
+
return Mat::ones(sz, DataType<_Tp>::type);
|
1649
|
+
}
|
1650
|
+
|
1651
|
+
template<typename _Tp> inline MatExpr Mat_<_Tp>::eye(int rows, int cols)
|
1652
|
+
{
|
1653
|
+
return Mat::eye(rows, cols, DataType<_Tp>::type);
|
1654
|
+
}
|
1655
|
+
|
1656
|
+
template<typename _Tp> inline MatExpr Mat_<_Tp>::eye(Size sz)
|
1657
|
+
{
|
1658
|
+
return Mat::eye(sz, DataType<_Tp>::type);
|
1659
|
+
}
|
1660
|
+
|
1661
|
+
//////////////////////////////// Iterators & Comma initializers //////////////////////////////////
|
1662
|
+
|
1663
|
+
inline MatConstIterator::MatConstIterator()
|
1664
|
+
: m(0), elemSize(0), ptr(0), sliceStart(0), sliceEnd(0) {}
|
1665
|
+
|
1666
|
+
inline MatConstIterator::MatConstIterator(const Mat* _m)
|
1667
|
+
: m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
|
1668
|
+
{
|
1669
|
+
if( m && m->isContinuous() )
|
1670
|
+
{
|
1671
|
+
sliceStart = m->data;
|
1672
|
+
sliceEnd = sliceStart + m->total()*elemSize;
|
1673
|
+
}
|
1674
|
+
seek((const int*)0);
|
1675
|
+
}
|
1676
|
+
|
1677
|
+
inline MatConstIterator::MatConstIterator(const Mat* _m, int _row, int _col)
|
1678
|
+
: m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
|
1679
|
+
{
|
1680
|
+
CV_Assert(m && m->dims <= 2);
|
1681
|
+
if( m->isContinuous() )
|
1682
|
+
{
|
1683
|
+
sliceStart = m->data;
|
1684
|
+
sliceEnd = sliceStart + m->total()*elemSize;
|
1685
|
+
}
|
1686
|
+
int idx[]={_row, _col};
|
1687
|
+
seek(idx);
|
1688
|
+
}
|
1689
|
+
|
1690
|
+
inline MatConstIterator::MatConstIterator(const Mat* _m, Point _pt)
|
1691
|
+
: m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
|
1692
|
+
{
|
1693
|
+
CV_Assert(m && m->dims <= 2);
|
1694
|
+
if( m->isContinuous() )
|
1695
|
+
{
|
1696
|
+
sliceStart = m->data;
|
1697
|
+
sliceEnd = sliceStart + m->total()*elemSize;
|
1698
|
+
}
|
1699
|
+
int idx[]={_pt.y, _pt.x};
|
1700
|
+
seek(idx);
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
inline MatConstIterator::MatConstIterator(const MatConstIterator& it)
|
1704
|
+
: m(it.m), elemSize(it.elemSize), ptr(it.ptr), sliceStart(it.sliceStart), sliceEnd(it.sliceEnd)
|
1705
|
+
{}
|
1706
|
+
|
1707
|
+
inline MatConstIterator& MatConstIterator::operator = (const MatConstIterator& it )
|
1708
|
+
{
|
1709
|
+
m = it.m; elemSize = it.elemSize; ptr = it.ptr;
|
1710
|
+
sliceStart = it.sliceStart; sliceEnd = it.sliceEnd;
|
1711
|
+
return *this;
|
1712
|
+
}
|
1713
|
+
|
1714
|
+
inline uchar* MatConstIterator::operator *() const { return ptr; }
|
1715
|
+
|
1716
|
+
inline MatConstIterator& MatConstIterator::operator += (ptrdiff_t ofs)
|
1717
|
+
{
|
1718
|
+
if( !m || ofs == 0 )
|
1719
|
+
return *this;
|
1720
|
+
ptrdiff_t ofsb = ofs*elemSize;
|
1721
|
+
ptr += ofsb;
|
1722
|
+
if( ptr < sliceStart || sliceEnd <= ptr )
|
1723
|
+
{
|
1724
|
+
ptr -= ofsb;
|
1725
|
+
seek(ofs, true);
|
1726
|
+
}
|
1727
|
+
return *this;
|
1728
|
+
}
|
1729
|
+
|
1730
|
+
inline MatConstIterator& MatConstIterator::operator -= (ptrdiff_t ofs)
|
1731
|
+
{ return (*this += -ofs); }
|
1732
|
+
|
1733
|
+
inline MatConstIterator& MatConstIterator::operator --()
|
1734
|
+
{
|
1735
|
+
if( m && (ptr -= elemSize) < sliceStart )
|
1736
|
+
{
|
1737
|
+
ptr += elemSize;
|
1738
|
+
seek(-1, true);
|
1739
|
+
}
|
1740
|
+
return *this;
|
1741
|
+
}
|
1742
|
+
|
1743
|
+
inline MatConstIterator MatConstIterator::operator --(int)
|
1744
|
+
{
|
1745
|
+
MatConstIterator b = *this;
|
1746
|
+
*this += -1;
|
1747
|
+
return b;
|
1748
|
+
}
|
1749
|
+
|
1750
|
+
inline MatConstIterator& MatConstIterator::operator ++()
|
1751
|
+
{
|
1752
|
+
if( m && (ptr += elemSize) >= sliceEnd )
|
1753
|
+
{
|
1754
|
+
ptr -= elemSize;
|
1755
|
+
seek(1, true);
|
1756
|
+
}
|
1757
|
+
return *this;
|
1758
|
+
}
|
1759
|
+
|
1760
|
+
inline MatConstIterator MatConstIterator::operator ++(int)
|
1761
|
+
{
|
1762
|
+
MatConstIterator b = *this;
|
1763
|
+
*this += 1;
|
1764
|
+
return b;
|
1765
|
+
}
|
1766
|
+
|
1767
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>::MatConstIterator_() {}
|
1768
|
+
|
1769
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m)
|
1770
|
+
: MatConstIterator(_m) {}
|
1771
|
+
|
1772
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>::
|
1773
|
+
MatConstIterator_(const Mat_<_Tp>* _m, int _row, int _col)
|
1774
|
+
: MatConstIterator(_m, _row, _col) {}
|
1775
|
+
|
1776
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>::
|
1777
|
+
MatConstIterator_(const Mat_<_Tp>* _m, Point _pt)
|
1778
|
+
: MatConstIterator(_m, _pt) {}
|
1779
|
+
|
1780
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>::
|
1781
|
+
MatConstIterator_(const MatConstIterator_& it)
|
1782
|
+
: MatConstIterator(it) {}
|
1783
|
+
|
1784
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>&
|
1785
|
+
MatConstIterator_<_Tp>::operator = (const MatConstIterator_& it )
|
1786
|
+
{
|
1787
|
+
MatConstIterator::operator = (it);
|
1788
|
+
return *this;
|
1789
|
+
}
|
1790
|
+
|
1791
|
+
template<typename _Tp> inline _Tp MatConstIterator_<_Tp>::operator *() const { return *(_Tp*)(this->ptr); }
|
1792
|
+
|
1793
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator += (ptrdiff_t ofs)
|
1794
|
+
{
|
1795
|
+
MatConstIterator::operator += (ofs);
|
1796
|
+
return *this;
|
1797
|
+
}
|
1798
|
+
|
1799
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator -= (ptrdiff_t ofs)
|
1800
|
+
{ return (*this += -ofs); }
|
1801
|
+
|
1802
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator --()
|
1803
|
+
{
|
1804
|
+
MatConstIterator::operator --();
|
1805
|
+
return *this;
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
template<typename _Tp> inline MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator --(int)
|
1809
|
+
{
|
1810
|
+
MatConstIterator_ b = *this;
|
1811
|
+
MatConstIterator::operator --();
|
1812
|
+
return b;
|
1813
|
+
}
|
1814
|
+
|
1815
|
+
template<typename _Tp> inline MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator ++()
|
1816
|
+
{
|
1817
|
+
MatConstIterator::operator ++();
|
1818
|
+
return *this;
|
1819
|
+
}
|
1820
|
+
|
1821
|
+
template<typename _Tp> inline MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator ++(int)
|
1822
|
+
{
|
1823
|
+
MatConstIterator_ b = *this;
|
1824
|
+
MatConstIterator::operator ++();
|
1825
|
+
return b;
|
1826
|
+
}
|
1827
|
+
|
1828
|
+
template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_() : MatConstIterator_<_Tp>() {}
|
1829
|
+
|
1830
|
+
template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m)
|
1831
|
+
: MatConstIterator_<_Tp>(_m) {}
|
1832
|
+
|
1833
|
+
template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, int _row, int _col)
|
1834
|
+
: MatConstIterator_<_Tp>(_m, _row, _col) {}
|
1835
|
+
|
1836
|
+
template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(const Mat_<_Tp>* _m, Point _pt)
|
1837
|
+
: MatConstIterator_<_Tp>(_m, _pt) {}
|
1838
|
+
|
1839
|
+
template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(const Mat_<_Tp>* _m, const int* _idx)
|
1840
|
+
: MatConstIterator_<_Tp>(_m, _idx) {}
|
1841
|
+
|
1842
|
+
template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(const MatIterator_& it)
|
1843
|
+
: MatConstIterator_<_Tp>(it) {}
|
1844
|
+
|
1845
|
+
template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator = (const MatIterator_<_Tp>& it )
|
1846
|
+
{
|
1847
|
+
MatConstIterator::operator = (it);
|
1848
|
+
return *this;
|
1849
|
+
}
|
1850
|
+
|
1851
|
+
template<typename _Tp> inline _Tp& MatIterator_<_Tp>::operator *() const { return *(_Tp*)(this->ptr); }
|
1852
|
+
|
1853
|
+
template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator += (ptrdiff_t ofs)
|
1854
|
+
{
|
1855
|
+
MatConstIterator::operator += (ofs);
|
1856
|
+
return *this;
|
1857
|
+
}
|
1858
|
+
|
1859
|
+
template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator -= (ptrdiff_t ofs)
|
1860
|
+
{
|
1861
|
+
MatConstIterator::operator += (-ofs);
|
1862
|
+
return *this;
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator --()
|
1866
|
+
{
|
1867
|
+
MatConstIterator::operator --();
|
1868
|
+
return *this;
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
template<typename _Tp> inline MatIterator_<_Tp> MatIterator_<_Tp>::operator --(int)
|
1872
|
+
{
|
1873
|
+
MatIterator_ b = *this;
|
1874
|
+
MatConstIterator::operator --();
|
1875
|
+
return b;
|
1876
|
+
}
|
1877
|
+
|
1878
|
+
template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator ++()
|
1879
|
+
{
|
1880
|
+
MatConstIterator::operator ++();
|
1881
|
+
return *this;
|
1882
|
+
}
|
1883
|
+
|
1884
|
+
template<typename _Tp> inline MatIterator_<_Tp> MatIterator_<_Tp>::operator ++(int)
|
1885
|
+
{
|
1886
|
+
MatIterator_ b = *this;
|
1887
|
+
MatConstIterator::operator ++();
|
1888
|
+
return b;
|
1889
|
+
}
|
1890
|
+
|
1891
|
+
template<typename _Tp> inline Point MatConstIterator_<_Tp>::pos() const
|
1892
|
+
{
|
1893
|
+
if( !m )
|
1894
|
+
return Point();
|
1895
|
+
CV_DbgAssert( m->dims <= 2 );
|
1896
|
+
if( m->isContinuous() )
|
1897
|
+
{
|
1898
|
+
ptrdiff_t ofs = (const _Tp*)ptr - (const _Tp*)m->data;
|
1899
|
+
int y = (int)(ofs / m->cols), x = (int)(ofs - (ptrdiff_t)y*m->cols);
|
1900
|
+
return Point(x, y);
|
1901
|
+
}
|
1902
|
+
else
|
1903
|
+
{
|
1904
|
+
ptrdiff_t ofs = (uchar*)ptr - m->data;
|
1905
|
+
int y = (int)(ofs / m->step), x = (int)((ofs - y*m->step)/sizeof(_Tp));
|
1906
|
+
return Point(x, y);
|
1907
|
+
}
|
1908
|
+
}
|
1909
|
+
|
1910
|
+
static inline bool
|
1911
|
+
operator == (const MatConstIterator& a, const MatConstIterator& b)
|
1912
|
+
{ return a.m == b.m && a.ptr == b.ptr; }
|
1913
|
+
|
1914
|
+
template<typename _Tp> static inline bool
|
1915
|
+
operator != (const MatConstIterator& a, const MatConstIterator& b)
|
1916
|
+
{ return !(a == b); }
|
1917
|
+
|
1918
|
+
template<typename _Tp> static inline bool
|
1919
|
+
operator == (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b)
|
1920
|
+
{ return a.m == b.m && a.ptr == b.ptr; }
|
1921
|
+
|
1922
|
+
template<typename _Tp> static inline bool
|
1923
|
+
operator != (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b)
|
1924
|
+
{ return a.m != b.m || a.ptr != b.ptr; }
|
1925
|
+
|
1926
|
+
template<typename _Tp> static inline bool
|
1927
|
+
operator == (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b)
|
1928
|
+
{ return a.m == b.m && a.ptr == b.ptr; }
|
1929
|
+
|
1930
|
+
template<typename _Tp> static inline bool
|
1931
|
+
operator != (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b)
|
1932
|
+
{ return a.m != b.m || a.ptr != b.ptr; }
|
1933
|
+
|
1934
|
+
static inline bool
|
1935
|
+
operator < (const MatConstIterator& a, const MatConstIterator& b)
|
1936
|
+
{ return a.ptr < b.ptr; }
|
1937
|
+
|
1938
|
+
static inline bool
|
1939
|
+
operator > (const MatConstIterator& a, const MatConstIterator& b)
|
1940
|
+
{ return a.ptr > b.ptr; }
|
1941
|
+
|
1942
|
+
static inline bool
|
1943
|
+
operator <= (const MatConstIterator& a, const MatConstIterator& b)
|
1944
|
+
{ return a.ptr <= b.ptr; }
|
1945
|
+
|
1946
|
+
static inline bool
|
1947
|
+
operator >= (const MatConstIterator& a, const MatConstIterator& b)
|
1948
|
+
{ return a.ptr >= b.ptr; }
|
1949
|
+
|
1950
|
+
CV_EXPORTS ptrdiff_t operator - (const MatConstIterator& b, const MatConstIterator& a);
|
1951
|
+
|
1952
|
+
static inline MatConstIterator operator + (const MatConstIterator& a, ptrdiff_t ofs)
|
1953
|
+
{ MatConstIterator b = a; return b += ofs; }
|
1954
|
+
|
1955
|
+
static inline MatConstIterator operator + (ptrdiff_t ofs, const MatConstIterator& a)
|
1956
|
+
{ MatConstIterator b = a; return b += ofs; }
|
1957
|
+
|
1958
|
+
static inline MatConstIterator operator - (const MatConstIterator& a, ptrdiff_t ofs)
|
1959
|
+
{ MatConstIterator b = a; return b += -ofs; }
|
1960
|
+
|
1961
|
+
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
1962
|
+
operator + (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
|
1963
|
+
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatConstIterator_<_Tp>&)t; }
|
1964
|
+
|
1965
|
+
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
1966
|
+
operator + (ptrdiff_t ofs, const MatConstIterator_<_Tp>& a)
|
1967
|
+
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatConstIterator_<_Tp>&)t; }
|
1968
|
+
|
1969
|
+
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
1970
|
+
operator - (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
|
1971
|
+
{ MatConstIterator t = (const MatConstIterator&)a - ofs; return (MatConstIterator_<_Tp>&)t; }
|
1972
|
+
|
1973
|
+
inline uchar* MatConstIterator::operator [](ptrdiff_t i) const
|
1974
|
+
{ return *(*this + i); }
|
1975
|
+
|
1976
|
+
template<typename _Tp> inline _Tp MatConstIterator_<_Tp>::operator [](ptrdiff_t i) const
|
1977
|
+
{ return *(_Tp*)MatConstIterator::operator [](i); }
|
1978
|
+
|
1979
|
+
template<typename _Tp> static inline MatIterator_<_Tp>
|
1980
|
+
operator + (const MatIterator_<_Tp>& a, ptrdiff_t ofs)
|
1981
|
+
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatIterator_<_Tp>&)t; }
|
1982
|
+
|
1983
|
+
template<typename _Tp> static inline MatIterator_<_Tp>
|
1984
|
+
operator + (ptrdiff_t ofs, const MatIterator_<_Tp>& a)
|
1985
|
+
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatIterator_<_Tp>&)t; }
|
1986
|
+
|
1987
|
+
template<typename _Tp> static inline MatIterator_<_Tp>
|
1988
|
+
operator - (const MatIterator_<_Tp>& a, ptrdiff_t ofs)
|
1989
|
+
{ MatConstIterator t = (const MatConstIterator&)a - ofs; return (MatIterator_<_Tp>&)t; }
|
1990
|
+
|
1991
|
+
template<typename _Tp> inline _Tp& MatIterator_<_Tp>::operator [](ptrdiff_t i) const
|
1992
|
+
{ return *(*this + i); }
|
1993
|
+
|
1994
|
+
template<typename _Tp> inline MatConstIterator_<_Tp> Mat_<_Tp>::begin() const
|
1995
|
+
{ return Mat::begin<_Tp>(); }
|
1996
|
+
|
1997
|
+
template<typename _Tp> inline MatConstIterator_<_Tp> Mat_<_Tp>::end() const
|
1998
|
+
{ return Mat::end<_Tp>(); }
|
1999
|
+
|
2000
|
+
template<typename _Tp> inline MatIterator_<_Tp> Mat_<_Tp>::begin()
|
2001
|
+
{ return Mat::begin<_Tp>(); }
|
2002
|
+
|
2003
|
+
template<typename _Tp> inline MatIterator_<_Tp> Mat_<_Tp>::end()
|
2004
|
+
{ return Mat::end<_Tp>(); }
|
2005
|
+
|
2006
|
+
template<typename _Tp> inline MatCommaInitializer_<_Tp>::MatCommaInitializer_(Mat_<_Tp>* _m) : it(_m) {}
|
2007
|
+
|
2008
|
+
template<typename _Tp> template<typename T2> inline MatCommaInitializer_<_Tp>&
|
2009
|
+
MatCommaInitializer_<_Tp>::operator , (T2 v)
|
2010
|
+
{
|
2011
|
+
CV_DbgAssert( this->it < ((const Mat_<_Tp>*)this->it.m)->end() );
|
2012
|
+
*this->it = _Tp(v); ++this->it;
|
2013
|
+
return *this;
|
2014
|
+
}
|
2015
|
+
|
2016
|
+
template<typename _Tp> inline Mat_<_Tp> MatCommaInitializer_<_Tp>::operator *() const
|
2017
|
+
{
|
2018
|
+
CV_DbgAssert( this->it == ((const Mat_<_Tp>*)this->it.m)->end() );
|
2019
|
+
return Mat_<_Tp>(*this->it.m);
|
2020
|
+
}
|
2021
|
+
|
2022
|
+
template<typename _Tp> inline MatCommaInitializer_<_Tp>::operator Mat_<_Tp>() const
|
2023
|
+
{
|
2024
|
+
CV_DbgAssert( this->it == ((const Mat_<_Tp>*)this->it.m)->end() );
|
2025
|
+
return Mat_<_Tp>(*this->it.m);
|
2026
|
+
}
|
2027
|
+
|
2028
|
+
template<typename _Tp, typename T2> static inline MatCommaInitializer_<_Tp>
|
2029
|
+
operator << (const Mat_<_Tp>& m, T2 val)
|
2030
|
+
{
|
2031
|
+
MatCommaInitializer_<_Tp> commaInitializer((Mat_<_Tp>*)&m);
|
2032
|
+
return (commaInitializer, val);
|
2033
|
+
}
|
2034
|
+
|
2035
|
+
//////////////////////////////// SparseMat ////////////////////////////////
|
2036
|
+
|
2037
|
+
inline SparseMat::SparseMat()
|
2038
|
+
: flags(MAGIC_VAL), hdr(0)
|
2039
|
+
{
|
2040
|
+
}
|
2041
|
+
|
2042
|
+
inline SparseMat::SparseMat(int _dims, const int* _sizes, int _type)
|
2043
|
+
: flags(MAGIC_VAL), hdr(0)
|
2044
|
+
{
|
2045
|
+
create(_dims, _sizes, _type);
|
2046
|
+
}
|
2047
|
+
|
2048
|
+
inline SparseMat::SparseMat(const SparseMat& m)
|
2049
|
+
: flags(m.flags), hdr(m.hdr)
|
2050
|
+
{
|
2051
|
+
addref();
|
2052
|
+
}
|
2053
|
+
|
2054
|
+
inline SparseMat::~SparseMat()
|
2055
|
+
{
|
2056
|
+
release();
|
2057
|
+
}
|
2058
|
+
|
2059
|
+
inline SparseMat& SparseMat::operator = (const SparseMat& m)
|
2060
|
+
{
|
2061
|
+
if( this != &m )
|
2062
|
+
{
|
2063
|
+
if( m.hdr )
|
2064
|
+
CV_XADD(&m.hdr->refcount, 1);
|
2065
|
+
release();
|
2066
|
+
flags = m.flags;
|
2067
|
+
hdr = m.hdr;
|
2068
|
+
}
|
2069
|
+
return *this;
|
2070
|
+
}
|
2071
|
+
|
2072
|
+
inline SparseMat& SparseMat::operator = (const Mat& m)
|
2073
|
+
{ return (*this = SparseMat(m)); }
|
2074
|
+
|
2075
|
+
inline SparseMat SparseMat::clone() const
|
2076
|
+
{
|
2077
|
+
SparseMat temp;
|
2078
|
+
this->copyTo(temp);
|
2079
|
+
return temp;
|
2080
|
+
}
|
2081
|
+
|
2082
|
+
|
2083
|
+
inline void SparseMat::assignTo( SparseMat& m, int type ) const
|
2084
|
+
{
|
2085
|
+
if( type < 0 )
|
2086
|
+
m = *this;
|
2087
|
+
else
|
2088
|
+
convertTo(m, type);
|
2089
|
+
}
|
2090
|
+
|
2091
|
+
inline void SparseMat::addref()
|
2092
|
+
{ if( hdr ) CV_XADD(&hdr->refcount, 1); }
|
2093
|
+
|
2094
|
+
inline void SparseMat::release()
|
2095
|
+
{
|
2096
|
+
if( hdr && CV_XADD(&hdr->refcount, -1) == 1 )
|
2097
|
+
delete hdr;
|
2098
|
+
hdr = 0;
|
2099
|
+
}
|
2100
|
+
|
2101
|
+
inline size_t SparseMat::elemSize() const
|
2102
|
+
{ return CV_ELEM_SIZE(flags); }
|
2103
|
+
|
2104
|
+
inline size_t SparseMat::elemSize1() const
|
2105
|
+
{ return CV_ELEM_SIZE1(flags); }
|
2106
|
+
|
2107
|
+
inline int SparseMat::type() const
|
2108
|
+
{ return CV_MAT_TYPE(flags); }
|
2109
|
+
|
2110
|
+
inline int SparseMat::depth() const
|
2111
|
+
{ return CV_MAT_DEPTH(flags); }
|
2112
|
+
|
2113
|
+
inline int SparseMat::channels() const
|
2114
|
+
{ return CV_MAT_CN(flags); }
|
2115
|
+
|
2116
|
+
inline const int* SparseMat::size() const
|
2117
|
+
{
|
2118
|
+
return hdr ? hdr->size : 0;
|
2119
|
+
}
|
2120
|
+
|
2121
|
+
inline int SparseMat::size(int i) const
|
2122
|
+
{
|
2123
|
+
if( hdr )
|
2124
|
+
{
|
2125
|
+
CV_DbgAssert((unsigned)i < (unsigned)hdr->dims);
|
2126
|
+
return hdr->size[i];
|
2127
|
+
}
|
2128
|
+
return 0;
|
2129
|
+
}
|
2130
|
+
|
2131
|
+
inline int SparseMat::dims() const
|
2132
|
+
{
|
2133
|
+
return hdr ? hdr->dims : 0;
|
2134
|
+
}
|
2135
|
+
|
2136
|
+
inline size_t SparseMat::nzcount() const
|
2137
|
+
{
|
2138
|
+
return hdr ? hdr->nodeCount : 0;
|
2139
|
+
}
|
2140
|
+
|
2141
|
+
inline size_t SparseMat::hash(int i0) const
|
2142
|
+
{
|
2143
|
+
return (size_t)i0;
|
2144
|
+
}
|
2145
|
+
|
2146
|
+
inline size_t SparseMat::hash(int i0, int i1) const
|
2147
|
+
{
|
2148
|
+
return (size_t)(unsigned)i0*HASH_SCALE + (unsigned)i1;
|
2149
|
+
}
|
2150
|
+
|
2151
|
+
inline size_t SparseMat::hash(int i0, int i1, int i2) const
|
2152
|
+
{
|
2153
|
+
return ((size_t)(unsigned)i0*HASH_SCALE + (unsigned)i1)*HASH_SCALE + (unsigned)i2;
|
2154
|
+
}
|
2155
|
+
|
2156
|
+
inline size_t SparseMat::hash(const int* idx) const
|
2157
|
+
{
|
2158
|
+
size_t h = (unsigned)idx[0];
|
2159
|
+
if( !hdr )
|
2160
|
+
return 0;
|
2161
|
+
int i, d = hdr->dims;
|
2162
|
+
for( i = 1; i < d; i++ )
|
2163
|
+
h = h*HASH_SCALE + (unsigned)idx[i];
|
2164
|
+
return h;
|
2165
|
+
}
|
2166
|
+
|
2167
|
+
template<typename _Tp> inline _Tp& SparseMat::ref(int i0, size_t* hashval)
|
2168
|
+
{ return *(_Tp*)((SparseMat*)this)->ptr(i0, true, hashval); }
|
2169
|
+
|
2170
|
+
template<typename _Tp> inline _Tp& SparseMat::ref(int i0, int i1, size_t* hashval)
|
2171
|
+
{ return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, true, hashval); }
|
2172
|
+
|
2173
|
+
template<typename _Tp> inline _Tp& SparseMat::ref(int i0, int i1, int i2, size_t* hashval)
|
2174
|
+
{ return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, i2, true, hashval); }
|
2175
|
+
|
2176
|
+
template<typename _Tp> inline _Tp& SparseMat::ref(const int* idx, size_t* hashval)
|
2177
|
+
{ return *(_Tp*)((SparseMat*)this)->ptr(idx, true, hashval); }
|
2178
|
+
|
2179
|
+
template<typename _Tp> inline _Tp SparseMat::value(int i0, size_t* hashval) const
|
2180
|
+
{
|
2181
|
+
const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval);
|
2182
|
+
return p ? *p : _Tp();
|
2183
|
+
}
|
2184
|
+
|
2185
|
+
template<typename _Tp> inline _Tp SparseMat::value(int i0, int i1, size_t* hashval) const
|
2186
|
+
{
|
2187
|
+
const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval);
|
2188
|
+
return p ? *p : _Tp();
|
2189
|
+
}
|
2190
|
+
|
2191
|
+
template<typename _Tp> inline _Tp SparseMat::value(int i0, int i1, int i2, size_t* hashval) const
|
2192
|
+
{
|
2193
|
+
const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval);
|
2194
|
+
return p ? *p : _Tp();
|
2195
|
+
}
|
2196
|
+
|
2197
|
+
template<typename _Tp> inline _Tp SparseMat::value(const int* idx, size_t* hashval) const
|
2198
|
+
{
|
2199
|
+
const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval);
|
2200
|
+
return p ? *p : _Tp();
|
2201
|
+
}
|
2202
|
+
|
2203
|
+
template<typename _Tp> inline const _Tp* SparseMat::find(int i0, size_t* hashval) const
|
2204
|
+
{ return (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); }
|
2205
|
+
|
2206
|
+
template<typename _Tp> inline const _Tp* SparseMat::find(int i0, int i1, size_t* hashval) const
|
2207
|
+
{ return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); }
|
2208
|
+
|
2209
|
+
template<typename _Tp> inline const _Tp* SparseMat::find(int i0, int i1, int i2, size_t* hashval) const
|
2210
|
+
{ return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); }
|
2211
|
+
|
2212
|
+
template<typename _Tp> inline const _Tp* SparseMat::find(const int* idx, size_t* hashval) const
|
2213
|
+
{ return (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); }
|
2214
|
+
|
2215
|
+
template<typename _Tp> inline _Tp& SparseMat::value(Node* n)
|
2216
|
+
{ return *(_Tp*)((uchar*)n + hdr->valueOffset); }
|
2217
|
+
|
2218
|
+
template<typename _Tp> inline const _Tp& SparseMat::value(const Node* n) const
|
2219
|
+
{ return *(const _Tp*)((const uchar*)n + hdr->valueOffset); }
|
2220
|
+
|
2221
|
+
inline SparseMat::Node* SparseMat::node(size_t nidx)
|
2222
|
+
{ return (Node*)&hdr->pool[nidx]; }
|
2223
|
+
|
2224
|
+
inline const SparseMat::Node* SparseMat::node(size_t nidx) const
|
2225
|
+
{ return (const Node*)&hdr->pool[nidx]; }
|
2226
|
+
|
2227
|
+
inline SparseMatIterator SparseMat::begin()
|
2228
|
+
{ return SparseMatIterator(this); }
|
2229
|
+
|
2230
|
+
inline SparseMatConstIterator SparseMat::begin() const
|
2231
|
+
{ return SparseMatConstIterator(this); }
|
2232
|
+
|
2233
|
+
inline SparseMatIterator SparseMat::end()
|
2234
|
+
{ SparseMatIterator it(this); it.seekEnd(); return it; }
|
2235
|
+
|
2236
|
+
inline SparseMatConstIterator SparseMat::end() const
|
2237
|
+
{ SparseMatConstIterator it(this); it.seekEnd(); return it; }
|
2238
|
+
|
2239
|
+
template<typename _Tp> inline SparseMatIterator_<_Tp> SparseMat::begin()
|
2240
|
+
{ return SparseMatIterator_<_Tp>(this); }
|
2241
|
+
|
2242
|
+
template<typename _Tp> inline SparseMatConstIterator_<_Tp> SparseMat::begin() const
|
2243
|
+
{ return SparseMatConstIterator_<_Tp>(this); }
|
2244
|
+
|
2245
|
+
template<typename _Tp> inline SparseMatIterator_<_Tp> SparseMat::end()
|
2246
|
+
{ SparseMatIterator_<_Tp> it(this); it.seekEnd(); return it; }
|
2247
|
+
|
2248
|
+
template<typename _Tp> inline SparseMatConstIterator_<_Tp> SparseMat::end() const
|
2249
|
+
{ SparseMatConstIterator_<_Tp> it(this); it.seekEnd(); return it; }
|
2250
|
+
|
2251
|
+
|
2252
|
+
inline SparseMatConstIterator::SparseMatConstIterator()
|
2253
|
+
: m(0), hashidx(0), ptr(0)
|
2254
|
+
{
|
2255
|
+
}
|
2256
|
+
|
2257
|
+
inline SparseMatConstIterator::SparseMatConstIterator(const SparseMatConstIterator& it)
|
2258
|
+
: m(it.m), hashidx(it.hashidx), ptr(it.ptr)
|
2259
|
+
{
|
2260
|
+
}
|
2261
|
+
|
2262
|
+
static inline bool operator == (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2)
|
2263
|
+
{ return it1.m == it2.m && it1.hashidx == it2.hashidx && it1.ptr == it2.ptr; }
|
2264
|
+
|
2265
|
+
static inline bool operator != (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2)
|
2266
|
+
{ return !(it1 == it2); }
|
2267
|
+
|
2268
|
+
|
2269
|
+
inline SparseMatConstIterator& SparseMatConstIterator::operator = (const SparseMatConstIterator& it)
|
2270
|
+
{
|
2271
|
+
if( this != &it )
|
2272
|
+
{
|
2273
|
+
m = it.m;
|
2274
|
+
hashidx = it.hashidx;
|
2275
|
+
ptr = it.ptr;
|
2276
|
+
}
|
2277
|
+
return *this;
|
2278
|
+
}
|
2279
|
+
|
2280
|
+
template<typename _Tp> inline const _Tp& SparseMatConstIterator::value() const
|
2281
|
+
{ return *(_Tp*)ptr; }
|
2282
|
+
|
2283
|
+
inline const SparseMat::Node* SparseMatConstIterator::node() const
|
2284
|
+
{
|
2285
|
+
return ptr && m && m->hdr ?
|
2286
|
+
(const SparseMat::Node*)(ptr - m->hdr->valueOffset) : 0;
|
2287
|
+
}
|
2288
|
+
|
2289
|
+
inline SparseMatConstIterator SparseMatConstIterator::operator ++(int)
|
2290
|
+
{
|
2291
|
+
SparseMatConstIterator it = *this;
|
2292
|
+
++*this;
|
2293
|
+
return it;
|
2294
|
+
}
|
2295
|
+
|
2296
|
+
|
2297
|
+
inline void SparseMatConstIterator::seekEnd()
|
2298
|
+
{
|
2299
|
+
if( m && m->hdr )
|
2300
|
+
{
|
2301
|
+
hashidx = m->hdr->hashtab.size();
|
2302
|
+
ptr = 0;
|
2303
|
+
}
|
2304
|
+
}
|
2305
|
+
|
2306
|
+
inline SparseMatIterator::SparseMatIterator()
|
2307
|
+
{}
|
2308
|
+
|
2309
|
+
inline SparseMatIterator::SparseMatIterator(SparseMat* _m)
|
2310
|
+
: SparseMatConstIterator(_m)
|
2311
|
+
{}
|
2312
|
+
|
2313
|
+
inline SparseMatIterator::SparseMatIterator(const SparseMatIterator& it)
|
2314
|
+
: SparseMatConstIterator(it)
|
2315
|
+
{
|
2316
|
+
}
|
2317
|
+
|
2318
|
+
inline SparseMatIterator& SparseMatIterator::operator = (const SparseMatIterator& it)
|
2319
|
+
{
|
2320
|
+
(SparseMatConstIterator&)*this = it;
|
2321
|
+
return *this;
|
2322
|
+
}
|
2323
|
+
|
2324
|
+
template<typename _Tp> inline _Tp& SparseMatIterator::value() const
|
2325
|
+
{ return *(_Tp*)ptr; }
|
2326
|
+
|
2327
|
+
inline SparseMat::Node* SparseMatIterator::node() const
|
2328
|
+
{
|
2329
|
+
return (SparseMat::Node*)SparseMatConstIterator::node();
|
2330
|
+
}
|
2331
|
+
|
2332
|
+
inline SparseMatIterator& SparseMatIterator::operator ++()
|
2333
|
+
{
|
2334
|
+
SparseMatConstIterator::operator ++();
|
2335
|
+
return *this;
|
2336
|
+
}
|
2337
|
+
|
2338
|
+
inline SparseMatIterator SparseMatIterator::operator ++(int)
|
2339
|
+
{
|
2340
|
+
SparseMatIterator it = *this;
|
2341
|
+
++*this;
|
2342
|
+
return it;
|
2343
|
+
}
|
2344
|
+
|
2345
|
+
|
2346
|
+
template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_()
|
2347
|
+
{ flags = MAGIC_VAL | DataType<_Tp>::type; }
|
2348
|
+
|
2349
|
+
template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(int _dims, const int* _sizes)
|
2350
|
+
: SparseMat(_dims, _sizes, DataType<_Tp>::type)
|
2351
|
+
{}
|
2352
|
+
|
2353
|
+
template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const SparseMat& m)
|
2354
|
+
{
|
2355
|
+
if( m.type() == DataType<_Tp>::type )
|
2356
|
+
*this = (const SparseMat_<_Tp>&)m;
|
2357
|
+
else
|
2358
|
+
m.convertTo(this, DataType<_Tp>::type);
|
2359
|
+
}
|
2360
|
+
|
2361
|
+
template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const SparseMat_<_Tp>& m)
|
2362
|
+
{
|
2363
|
+
this->flags = m.flags;
|
2364
|
+
this->hdr = m.hdr;
|
2365
|
+
if( this->hdr )
|
2366
|
+
CV_XADD(&this->hdr->refcount, 1);
|
2367
|
+
}
|
2368
|
+
|
2369
|
+
template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const Mat& m)
|
2370
|
+
{
|
2371
|
+
SparseMat sm(m);
|
2372
|
+
*this = sm;
|
2373
|
+
}
|
2374
|
+
|
2375
|
+
template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const CvSparseMat* m)
|
2376
|
+
{
|
2377
|
+
SparseMat sm(m);
|
2378
|
+
*this = sm;
|
2379
|
+
}
|
2380
|
+
|
2381
|
+
template<typename _Tp> inline SparseMat_<_Tp>&
|
2382
|
+
SparseMat_<_Tp>::operator = (const SparseMat_<_Tp>& m)
|
2383
|
+
{
|
2384
|
+
if( this != &m )
|
2385
|
+
{
|
2386
|
+
if( m.hdr ) CV_XADD(&m.hdr->refcount, 1);
|
2387
|
+
release();
|
2388
|
+
flags = m.flags;
|
2389
|
+
hdr = m.hdr;
|
2390
|
+
}
|
2391
|
+
return *this;
|
2392
|
+
}
|
2393
|
+
|
2394
|
+
template<typename _Tp> inline SparseMat_<_Tp>&
|
2395
|
+
SparseMat_<_Tp>::operator = (const SparseMat& m)
|
2396
|
+
{
|
2397
|
+
if( m.type() == DataType<_Tp>::type )
|
2398
|
+
return (*this = (const SparseMat_<_Tp>&)m);
|
2399
|
+
m.convertTo(*this, DataType<_Tp>::type);
|
2400
|
+
return *this;
|
2401
|
+
}
|
2402
|
+
|
2403
|
+
template<typename _Tp> inline SparseMat_<_Tp>&
|
2404
|
+
SparseMat_<_Tp>::operator = (const Mat& m)
|
2405
|
+
{ return (*this = SparseMat(m)); }
|
2406
|
+
|
2407
|
+
template<typename _Tp> inline SparseMat_<_Tp>
|
2408
|
+
SparseMat_<_Tp>::clone() const
|
2409
|
+
{
|
2410
|
+
SparseMat_<_Tp> m;
|
2411
|
+
this->copyTo(m);
|
2412
|
+
return m;
|
2413
|
+
}
|
2414
|
+
|
2415
|
+
template<typename _Tp> inline void
|
2416
|
+
SparseMat_<_Tp>::create(int _dims, const int* _sizes)
|
2417
|
+
{
|
2418
|
+
SparseMat::create(_dims, _sizes, DataType<_Tp>::type);
|
2419
|
+
}
|
2420
|
+
|
2421
|
+
template<typename _Tp> inline
|
2422
|
+
SparseMat_<_Tp>::operator CvSparseMat*() const
|
2423
|
+
{
|
2424
|
+
return SparseMat::operator CvSparseMat*();
|
2425
|
+
}
|
2426
|
+
|
2427
|
+
template<typename _Tp> inline int SparseMat_<_Tp>::type() const
|
2428
|
+
{ return DataType<_Tp>::type; }
|
2429
|
+
|
2430
|
+
template<typename _Tp> inline int SparseMat_<_Tp>::depth() const
|
2431
|
+
{ return DataType<_Tp>::depth; }
|
2432
|
+
|
2433
|
+
template<typename _Tp> inline int SparseMat_<_Tp>::channels() const
|
2434
|
+
{ return DataType<_Tp>::channels; }
|
2435
|
+
|
2436
|
+
template<typename _Tp> inline _Tp&
|
2437
|
+
SparseMat_<_Tp>::ref(int i0, size_t* hashval)
|
2438
|
+
{ return SparseMat::ref<_Tp>(i0, hashval); }
|
2439
|
+
|
2440
|
+
template<typename _Tp> inline _Tp
|
2441
|
+
SparseMat_<_Tp>::operator()(int i0, size_t* hashval) const
|
2442
|
+
{ return SparseMat::value<_Tp>(i0, hashval); }
|
2443
|
+
|
2444
|
+
template<typename _Tp> inline _Tp&
|
2445
|
+
SparseMat_<_Tp>::ref(int i0, int i1, size_t* hashval)
|
2446
|
+
{ return SparseMat::ref<_Tp>(i0, i1, hashval); }
|
2447
|
+
|
2448
|
+
template<typename _Tp> inline _Tp
|
2449
|
+
SparseMat_<_Tp>::operator()(int i0, int i1, size_t* hashval) const
|
2450
|
+
{ return SparseMat::value<_Tp>(i0, i1, hashval); }
|
2451
|
+
|
2452
|
+
template<typename _Tp> inline _Tp&
|
2453
|
+
SparseMat_<_Tp>::ref(int i0, int i1, int i2, size_t* hashval)
|
2454
|
+
{ return SparseMat::ref<_Tp>(i0, i1, i2, hashval); }
|
2455
|
+
|
2456
|
+
template<typename _Tp> inline _Tp
|
2457
|
+
SparseMat_<_Tp>::operator()(int i0, int i1, int i2, size_t* hashval) const
|
2458
|
+
{ return SparseMat::value<_Tp>(i0, i1, i2, hashval); }
|
2459
|
+
|
2460
|
+
template<typename _Tp> inline _Tp&
|
2461
|
+
SparseMat_<_Tp>::ref(const int* idx, size_t* hashval)
|
2462
|
+
{ return SparseMat::ref<_Tp>(idx, hashval); }
|
2463
|
+
|
2464
|
+
template<typename _Tp> inline _Tp
|
2465
|
+
SparseMat_<_Tp>::operator()(const int* idx, size_t* hashval) const
|
2466
|
+
{ return SparseMat::value<_Tp>(idx, hashval); }
|
2467
|
+
|
2468
|
+
template<typename _Tp> inline SparseMatIterator_<_Tp> SparseMat_<_Tp>::begin()
|
2469
|
+
{ return SparseMatIterator_<_Tp>(this); }
|
2470
|
+
|
2471
|
+
template<typename _Tp> inline SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::begin() const
|
2472
|
+
{ return SparseMatConstIterator_<_Tp>(this); }
|
2473
|
+
|
2474
|
+
template<typename _Tp> inline SparseMatIterator_<_Tp> SparseMat_<_Tp>::end()
|
2475
|
+
{ SparseMatIterator_<_Tp> it(this); it.seekEnd(); return it; }
|
2476
|
+
|
2477
|
+
template<typename _Tp> inline SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::end() const
|
2478
|
+
{ SparseMatConstIterator_<_Tp> it(this); it.seekEnd(); return it; }
|
2479
|
+
|
2480
|
+
template<typename _Tp> inline
|
2481
|
+
SparseMatConstIterator_<_Tp>::SparseMatConstIterator_()
|
2482
|
+
{}
|
2483
|
+
|
2484
|
+
template<typename _Tp> inline
|
2485
|
+
SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat_<_Tp>* _m)
|
2486
|
+
: SparseMatConstIterator(_m)
|
2487
|
+
{}
|
2488
|
+
|
2489
|
+
template<typename _Tp> inline
|
2490
|
+
SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMatConstIterator_<_Tp>& it)
|
2491
|
+
: SparseMatConstIterator(it)
|
2492
|
+
{}
|
2493
|
+
|
2494
|
+
template<typename _Tp> inline SparseMatConstIterator_<_Tp>&
|
2495
|
+
SparseMatConstIterator_<_Tp>::operator = (const SparseMatConstIterator_<_Tp>& it)
|
2496
|
+
{ return ((SparseMatConstIterator&)*this = it); }
|
2497
|
+
|
2498
|
+
template<typename _Tp> inline const _Tp&
|
2499
|
+
SparseMatConstIterator_<_Tp>::operator *() const
|
2500
|
+
{ return *(const _Tp*)this->ptr; }
|
2501
|
+
|
2502
|
+
template<typename _Tp> inline SparseMatConstIterator_<_Tp>&
|
2503
|
+
SparseMatConstIterator_<_Tp>::operator ++()
|
2504
|
+
{
|
2505
|
+
SparseMatConstIterator::operator ++();
|
2506
|
+
return *this;
|
2507
|
+
}
|
2508
|
+
|
2509
|
+
template<typename _Tp> inline SparseMatConstIterator_<_Tp>
|
2510
|
+
SparseMatConstIterator_<_Tp>::operator ++(int)
|
2511
|
+
{
|
2512
|
+
SparseMatConstIterator it = *this;
|
2513
|
+
SparseMatConstIterator::operator ++();
|
2514
|
+
return it;
|
2515
|
+
}
|
2516
|
+
|
2517
|
+
template<typename _Tp> inline
|
2518
|
+
SparseMatIterator_<_Tp>::SparseMatIterator_()
|
2519
|
+
{}
|
2520
|
+
|
2521
|
+
template<typename _Tp> inline
|
2522
|
+
SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat_<_Tp>* _m)
|
2523
|
+
: SparseMatConstIterator_<_Tp>(_m)
|
2524
|
+
{}
|
2525
|
+
|
2526
|
+
template<typename _Tp> inline
|
2527
|
+
SparseMatIterator_<_Tp>::SparseMatIterator_(const SparseMatIterator_<_Tp>& it)
|
2528
|
+
: SparseMatConstIterator_<_Tp>(it)
|
2529
|
+
{}
|
2530
|
+
|
2531
|
+
template<typename _Tp> inline SparseMatIterator_<_Tp>&
|
2532
|
+
SparseMatIterator_<_Tp>::operator = (const SparseMatIterator_<_Tp>& it)
|
2533
|
+
{ return ((SparseMatIterator&)*this = it); }
|
2534
|
+
|
2535
|
+
template<typename _Tp> inline _Tp&
|
2536
|
+
SparseMatIterator_<_Tp>::operator *() const
|
2537
|
+
{ return *(_Tp*)this->ptr; }
|
2538
|
+
|
2539
|
+
template<typename _Tp> inline SparseMatIterator_<_Tp>&
|
2540
|
+
SparseMatIterator_<_Tp>::operator ++()
|
2541
|
+
{
|
2542
|
+
SparseMatConstIterator::operator ++();
|
2543
|
+
return *this;
|
2544
|
+
}
|
2545
|
+
|
2546
|
+
template<typename _Tp> inline SparseMatIterator_<_Tp>
|
2547
|
+
SparseMatIterator_<_Tp>::operator ++(int)
|
2548
|
+
{
|
2549
|
+
SparseMatIterator it = *this;
|
2550
|
+
SparseMatConstIterator::operator ++();
|
2551
|
+
return it;
|
2552
|
+
}
|
2553
|
+
|
2554
|
+
}
|
2555
|
+
|
2556
|
+
#endif
|
2557
|
+
#endif
|