imagecore 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,1875 @@
|
|
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_TYPES_H__
|
44
|
+
#define __OPENCV_CORE_TYPES_H__
|
45
|
+
|
46
|
+
#if !defined _CRT_SECURE_NO_DEPRECATE && _MSC_VER > 1300
|
47
|
+
#define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio 2005 warnings */
|
48
|
+
#endif
|
49
|
+
|
50
|
+
|
51
|
+
#ifndef SKIP_INCLUDES
|
52
|
+
#include <assert.h>
|
53
|
+
#include <stdlib.h>
|
54
|
+
#include <string.h>
|
55
|
+
#include <float.h>
|
56
|
+
|
57
|
+
#if !defined _MSC_VER && !defined __BORLANDC__
|
58
|
+
#include <stdint.h>
|
59
|
+
#endif
|
60
|
+
|
61
|
+
#if defined __ICL
|
62
|
+
#define CV_ICC __ICL
|
63
|
+
#elif defined __ICC
|
64
|
+
#define CV_ICC __ICC
|
65
|
+
#elif defined __ECL
|
66
|
+
#define CV_ICC __ECL
|
67
|
+
#elif defined __ECC
|
68
|
+
#define CV_ICC __ECC
|
69
|
+
#elif defined __INTEL_COMPILER
|
70
|
+
#define CV_ICC __INTEL_COMPILER
|
71
|
+
#endif
|
72
|
+
|
73
|
+
#if (_MSC_VER >= 1400 && defined _M_X64) || (__GNUC__ >= 4 && defined __x86_64__)
|
74
|
+
#if defined WIN32
|
75
|
+
#include <intrin.h>
|
76
|
+
#endif
|
77
|
+
#include <emmintrin.h>
|
78
|
+
#endif
|
79
|
+
|
80
|
+
#if defined __BORLANDC__
|
81
|
+
#include <fastmath.h>
|
82
|
+
#else
|
83
|
+
#include <math.h>
|
84
|
+
#endif
|
85
|
+
|
86
|
+
#ifdef HAVE_IPL
|
87
|
+
#ifndef __IPL_H__
|
88
|
+
#if defined WIN32 || defined _WIN32
|
89
|
+
#include <ipl.h>
|
90
|
+
#else
|
91
|
+
#include <ipl/ipl.h>
|
92
|
+
#endif
|
93
|
+
#endif
|
94
|
+
#elif defined __IPL_H__
|
95
|
+
#define HAVE_IPL
|
96
|
+
#endif
|
97
|
+
#endif // SKIP_INCLUDES
|
98
|
+
|
99
|
+
#if defined WIN32 || defined _WIN32
|
100
|
+
#define CV_CDECL __cdecl
|
101
|
+
#define CV_STDCALL __stdcall
|
102
|
+
#else
|
103
|
+
#define CV_CDECL
|
104
|
+
#define CV_STDCALL
|
105
|
+
#endif
|
106
|
+
|
107
|
+
#ifndef CV_EXTERN_C
|
108
|
+
#ifdef __cplusplus
|
109
|
+
#define CV_EXTERN_C extern "C"
|
110
|
+
#define CV_DEFAULT(val) = val
|
111
|
+
#else
|
112
|
+
#define CV_EXTERN_C
|
113
|
+
#define CV_DEFAULT(val)
|
114
|
+
#endif
|
115
|
+
#endif
|
116
|
+
|
117
|
+
#ifndef CV_EXTERN_C_FUNCPTR
|
118
|
+
#ifdef __cplusplus
|
119
|
+
#define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; }
|
120
|
+
#else
|
121
|
+
#define CV_EXTERN_C_FUNCPTR(x) typedef x
|
122
|
+
#endif
|
123
|
+
#endif
|
124
|
+
|
125
|
+
#ifndef CV_INLINE
|
126
|
+
#if defined __cplusplus
|
127
|
+
#define CV_INLINE inline
|
128
|
+
#elif (defined WIN32 || defined _WIN32 || defined WINCE) && !defined __GNUC__
|
129
|
+
#define CV_INLINE __inline
|
130
|
+
#else
|
131
|
+
#define CV_INLINE static
|
132
|
+
#endif
|
133
|
+
#endif /* CV_INLINE */
|
134
|
+
|
135
|
+
#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS
|
136
|
+
#define CV_EXPORTS __declspec(dllexport)
|
137
|
+
#else
|
138
|
+
#define CV_EXPORTS
|
139
|
+
#endif
|
140
|
+
|
141
|
+
#ifndef CVAPI
|
142
|
+
#define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL
|
143
|
+
#endif
|
144
|
+
|
145
|
+
#if defined _MSC_VER || defined __BORLANDC__
|
146
|
+
typedef __int64 int64;
|
147
|
+
typedef unsigned __int64 uint64;
|
148
|
+
#define CV_BIG_INT(n) n##I64
|
149
|
+
#define CV_BIG_UINT(n) n##UI64
|
150
|
+
#else
|
151
|
+
typedef int64_t int64;
|
152
|
+
typedef uint64_t uint64;
|
153
|
+
#define CV_BIG_INT(n) n##LL
|
154
|
+
#define CV_BIG_UINT(n) n##ULL
|
155
|
+
#endif
|
156
|
+
|
157
|
+
#ifndef HAVE_IPL
|
158
|
+
typedef unsigned char uchar;
|
159
|
+
typedef unsigned short ushort;
|
160
|
+
#endif
|
161
|
+
|
162
|
+
typedef signed char schar;
|
163
|
+
|
164
|
+
/* special informative macros for wrapper generators */
|
165
|
+
#define CV_CARRAY(counter)
|
166
|
+
#define CV_CUSTOM_CARRAY(args)
|
167
|
+
#define CV_EXPORTS_W CV_EXPORTS
|
168
|
+
#define CV_EXPORTS_W_SIMPLE CV_EXPORTS
|
169
|
+
#define CV_EXPORTS_AS(synonym) CV_EXPORTS
|
170
|
+
#define CV_EXPORTS_W_MAP CV_EXPORTS
|
171
|
+
#define CV_IN_OUT
|
172
|
+
#define CV_OUT
|
173
|
+
#define CV_PROP
|
174
|
+
#define CV_PROP_RW
|
175
|
+
#define CV_WRAP
|
176
|
+
#define CV_WRAP_AS(synonym)
|
177
|
+
#define CV_WRAP_DEFAULT(value)
|
178
|
+
|
179
|
+
/* CvArr* is used to pass arbitrary
|
180
|
+
* array-like data structures
|
181
|
+
* into functions where the particular
|
182
|
+
* array type is recognized at runtime:
|
183
|
+
*/
|
184
|
+
typedef void CvArr;
|
185
|
+
|
186
|
+
typedef union Cv32suf
|
187
|
+
{
|
188
|
+
int i;
|
189
|
+
unsigned u;
|
190
|
+
float f;
|
191
|
+
}
|
192
|
+
Cv32suf;
|
193
|
+
|
194
|
+
typedef union Cv64suf
|
195
|
+
{
|
196
|
+
int64 i;
|
197
|
+
uint64 u;
|
198
|
+
double f;
|
199
|
+
}
|
200
|
+
Cv64suf;
|
201
|
+
|
202
|
+
typedef int CVStatus;
|
203
|
+
|
204
|
+
enum {
|
205
|
+
CV_StsOk= 0, /* everithing is ok */
|
206
|
+
CV_StsBackTrace= -1, /* pseudo error for back trace */
|
207
|
+
CV_StsError= -2, /* unknown /unspecified error */
|
208
|
+
CV_StsInternal= -3, /* internal error (bad state) */
|
209
|
+
CV_StsNoMem= -4, /* insufficient memory */
|
210
|
+
CV_StsBadArg= -5, /* function arg/param is bad */
|
211
|
+
CV_StsBadFunc= -6, /* unsupported function */
|
212
|
+
CV_StsNoConv= -7, /* iter. didn't converge */
|
213
|
+
CV_StsAutoTrace= -8, /* tracing */
|
214
|
+
CV_HeaderIsNull= -9, /* image header is NULL */
|
215
|
+
CV_BadImageSize= -10, /* image size is invalid */
|
216
|
+
CV_BadOffset= -11, /* offset is invalid */
|
217
|
+
CV_BadDataPtr= -12, /**/
|
218
|
+
CV_BadStep= -13, /**/
|
219
|
+
CV_BadModelOrChSeq= -14, /**/
|
220
|
+
CV_BadNumChannels= -15, /**/
|
221
|
+
CV_BadNumChannel1U= -16, /**/
|
222
|
+
CV_BadDepth= -17, /**/
|
223
|
+
CV_BadAlphaChannel= -18, /**/
|
224
|
+
CV_BadOrder= -19, /**/
|
225
|
+
CV_BadOrigin= -20, /**/
|
226
|
+
CV_BadAlign= -21, /**/
|
227
|
+
CV_BadCallBack= -22, /**/
|
228
|
+
CV_BadTileSize= -23, /**/
|
229
|
+
CV_BadCOI= -24, /**/
|
230
|
+
CV_BadROISize= -25, /**/
|
231
|
+
CV_MaskIsTiled= -26, /**/
|
232
|
+
CV_StsNullPtr= -27, /* null pointer */
|
233
|
+
CV_StsVecLengthErr= -28, /* incorrect vector length */
|
234
|
+
CV_StsFilterStructContentErr= -29, /* incorr. filter structure content */
|
235
|
+
CV_StsKernelStructContentErr= -30, /* incorr. transform kernel content */
|
236
|
+
CV_StsFilterOffsetErr= -31, /* incorrect filter ofset value */
|
237
|
+
CV_StsBadSize= -201, /* the input/output structure size is incorrect */
|
238
|
+
CV_StsDivByZero= -202, /* division by zero */
|
239
|
+
CV_StsInplaceNotSupported= -203, /* in-place operation is not supported */
|
240
|
+
CV_StsObjectNotFound= -204, /* request can't be completed */
|
241
|
+
CV_StsUnmatchedFormats= -205, /* formats of input/output arrays differ */
|
242
|
+
CV_StsBadFlag= -206, /* flag is wrong or not supported */
|
243
|
+
CV_StsBadPoint= -207, /* bad CvPoint */
|
244
|
+
CV_StsBadMask= -208, /* bad format of mask (neither 8uC1 nor 8sC1)*/
|
245
|
+
CV_StsUnmatchedSizes= -209, /* sizes of input/output structures do not match */
|
246
|
+
CV_StsUnsupportedFormat= -210, /* the data format/type is not supported by the function*/
|
247
|
+
CV_StsOutOfRange= -211, /* some of parameters are out of range */
|
248
|
+
CV_StsParseError= -212, /* invalid syntax/structure of the parsed file */
|
249
|
+
CV_StsNotImplemented= -213, /* the requested function/feature is not implemented */
|
250
|
+
CV_StsBadMemBlock= -214, /* an allocated block has been corrupted */
|
251
|
+
CV_StsAssert= -215, /* assertion failed */
|
252
|
+
CV_GpuNotSupported= -216,
|
253
|
+
CV_GpuApiCallError= -217,
|
254
|
+
CV_GpuNppCallError= -218,
|
255
|
+
CV_GpuCufftCallError= -219
|
256
|
+
};
|
257
|
+
|
258
|
+
/****************************************************************************************\
|
259
|
+
* Common macros and inline functions *
|
260
|
+
\****************************************************************************************/
|
261
|
+
|
262
|
+
#define CV_PI 3.1415926535897932384626433832795
|
263
|
+
#define CV_LOG2 0.69314718055994530941723212145818
|
264
|
+
|
265
|
+
#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t))
|
266
|
+
|
267
|
+
#ifndef MIN
|
268
|
+
#define MIN(a,b) ((a) > (b) ? (b) : (a))
|
269
|
+
#endif
|
270
|
+
|
271
|
+
#ifndef MAX
|
272
|
+
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
273
|
+
#endif
|
274
|
+
|
275
|
+
/* min & max without jumps */
|
276
|
+
#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1)))
|
277
|
+
|
278
|
+
#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1)))
|
279
|
+
|
280
|
+
/* absolute value without jumps */
|
281
|
+
#ifndef __cplusplus
|
282
|
+
#define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0))
|
283
|
+
#else
|
284
|
+
#define CV_IABS(a) abs(a)
|
285
|
+
#endif
|
286
|
+
#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b)))
|
287
|
+
#define CV_SIGN(a) CV_CMP((a),0)
|
288
|
+
|
289
|
+
CV_INLINE int cvRound( double value )
|
290
|
+
{
|
291
|
+
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ && !defined __APPLE__)
|
292
|
+
__m128d t = _mm_set_sd( value );
|
293
|
+
return _mm_cvtsd_si32(t);
|
294
|
+
#elif defined _MSC_VER && defined _M_IX86
|
295
|
+
int t;
|
296
|
+
__asm
|
297
|
+
{
|
298
|
+
fld value;
|
299
|
+
fistp t;
|
300
|
+
}
|
301
|
+
return t;
|
302
|
+
#elif defined HAVE_LRINT || defined CV_ICC || defined __GNUC__
|
303
|
+
return (int)lrint(value);
|
304
|
+
#else
|
305
|
+
// while this is not IEEE754-compliant rounding, it's usually a good enough approximation
|
306
|
+
return (int)(value + (value >= 0 ? 0.5 : -0.5));
|
307
|
+
#endif
|
308
|
+
}
|
309
|
+
|
310
|
+
|
311
|
+
CV_INLINE int cvFloor( double value )
|
312
|
+
{
|
313
|
+
#ifdef __GNUC__
|
314
|
+
int i = (int)value;
|
315
|
+
return i - (i > value);
|
316
|
+
#elif defined _MSC_VER && defined _M_X64
|
317
|
+
__m128d t = _mm_set_sd( value );
|
318
|
+
int i = _mm_cvtsd_si32(t);
|
319
|
+
return i - _mm_movemask_pd(_mm_cmplt_sd(t, _mm_cvtsi32_sd(t,i)));
|
320
|
+
#else
|
321
|
+
int i = cvRound(value);
|
322
|
+
Cv32suf diff;
|
323
|
+
diff.f = (float)(value - i);
|
324
|
+
return i - (diff.i < 0);
|
325
|
+
#endif
|
326
|
+
}
|
327
|
+
|
328
|
+
|
329
|
+
CV_INLINE int cvCeil( double value )
|
330
|
+
{
|
331
|
+
#ifdef __GNUC__
|
332
|
+
int i = (int)value;
|
333
|
+
return i + (i < value);
|
334
|
+
#elif defined _MSC_VER && defined _M_X64
|
335
|
+
__m128d t = _mm_set_sd( value );
|
336
|
+
int i = _mm_cvtsd_si32(t);
|
337
|
+
return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i), t));
|
338
|
+
#else
|
339
|
+
int i = cvRound(value);
|
340
|
+
Cv32suf diff;
|
341
|
+
diff.f = (float)(i - value);
|
342
|
+
return i + (diff.i < 0);
|
343
|
+
#endif
|
344
|
+
}
|
345
|
+
|
346
|
+
#define cvInvSqrt(value) ((float)(1./sqrt(value)))
|
347
|
+
#define cvSqrt(value) ((float)sqrt(value))
|
348
|
+
|
349
|
+
CV_INLINE int cvIsNaN( double value )
|
350
|
+
{
|
351
|
+
#if 1/*defined _MSC_VER || defined __BORLANDC__
|
352
|
+
return _isnan(value);
|
353
|
+
#elif defined __GNUC__
|
354
|
+
return isnan(value);
|
355
|
+
#else*/
|
356
|
+
Cv64suf ieee754;
|
357
|
+
ieee754.f = value;
|
358
|
+
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) +
|
359
|
+
((unsigned)ieee754.u != 0) > 0x7ff00000;
|
360
|
+
#endif
|
361
|
+
}
|
362
|
+
|
363
|
+
|
364
|
+
CV_INLINE int cvIsInf( double value )
|
365
|
+
{
|
366
|
+
#if 1/*defined _MSC_VER || defined __BORLANDC__
|
367
|
+
return !_finite(value);
|
368
|
+
#elif defined __GNUC__
|
369
|
+
return isinf(value);
|
370
|
+
#else*/
|
371
|
+
Cv64suf ieee754;
|
372
|
+
ieee754.f = value;
|
373
|
+
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
|
374
|
+
(unsigned)ieee754.u == 0;
|
375
|
+
#endif
|
376
|
+
}
|
377
|
+
|
378
|
+
|
379
|
+
/*************** Random number generation *******************/
|
380
|
+
|
381
|
+
typedef uint64 CvRNG;
|
382
|
+
|
383
|
+
#define CV_RNG_COEFF 4164903690U
|
384
|
+
|
385
|
+
CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1))
|
386
|
+
{
|
387
|
+
CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1;
|
388
|
+
return rng;
|
389
|
+
}
|
390
|
+
|
391
|
+
/* Return random 32-bit unsigned integer: */
|
392
|
+
CV_INLINE unsigned cvRandInt( CvRNG* rng )
|
393
|
+
{
|
394
|
+
uint64 temp = *rng;
|
395
|
+
temp = (uint64)(unsigned)temp*CV_RNG_COEFF + (temp >> 32);
|
396
|
+
*rng = temp;
|
397
|
+
return (unsigned)temp;
|
398
|
+
}
|
399
|
+
|
400
|
+
/* Returns random floating-point number between 0 and 1: */
|
401
|
+
CV_INLINE double cvRandReal( CvRNG* rng )
|
402
|
+
{
|
403
|
+
return cvRandInt(rng)*2.3283064365386962890625e-10 /* 2^-32 */;
|
404
|
+
}
|
405
|
+
|
406
|
+
/****************************************************************************************\
|
407
|
+
* Image type (IplImage) *
|
408
|
+
\****************************************************************************************/
|
409
|
+
|
410
|
+
#ifndef HAVE_IPL
|
411
|
+
|
412
|
+
/*
|
413
|
+
* The following definitions (until #endif)
|
414
|
+
* is an extract from IPL headers.
|
415
|
+
* Copyright (c) 1995 Intel Corporation.
|
416
|
+
*/
|
417
|
+
#define IPL_DEPTH_SIGN 0x80000000
|
418
|
+
|
419
|
+
#define IPL_DEPTH_1U 1
|
420
|
+
#define IPL_DEPTH_8U 8
|
421
|
+
#define IPL_DEPTH_16U 16
|
422
|
+
#define IPL_DEPTH_32F 32
|
423
|
+
|
424
|
+
#define IPL_DEPTH_8S (IPL_DEPTH_SIGN| 8)
|
425
|
+
#define IPL_DEPTH_16S (IPL_DEPTH_SIGN|16)
|
426
|
+
#define IPL_DEPTH_32S (IPL_DEPTH_SIGN|32)
|
427
|
+
|
428
|
+
#define IPL_DATA_ORDER_PIXEL 0
|
429
|
+
#define IPL_DATA_ORDER_PLANE 1
|
430
|
+
|
431
|
+
#define IPL_ORIGIN_TL 0
|
432
|
+
#define IPL_ORIGIN_BL 1
|
433
|
+
|
434
|
+
#define IPL_ALIGN_4BYTES 4
|
435
|
+
#define IPL_ALIGN_8BYTES 8
|
436
|
+
#define IPL_ALIGN_16BYTES 16
|
437
|
+
#define IPL_ALIGN_32BYTES 32
|
438
|
+
|
439
|
+
#define IPL_ALIGN_DWORD IPL_ALIGN_4BYTES
|
440
|
+
#define IPL_ALIGN_QWORD IPL_ALIGN_8BYTES
|
441
|
+
|
442
|
+
#define IPL_BORDER_CONSTANT 0
|
443
|
+
#define IPL_BORDER_REPLICATE 1
|
444
|
+
#define IPL_BORDER_REFLECT 2
|
445
|
+
#define IPL_BORDER_WRAP 3
|
446
|
+
|
447
|
+
typedef struct _IplImage
|
448
|
+
{
|
449
|
+
int nSize; /* sizeof(IplImage) */
|
450
|
+
int ID; /* version (=0)*/
|
451
|
+
int nChannels; /* Most of OpenCV functions support 1,2,3 or 4 channels */
|
452
|
+
int alphaChannel; /* Ignored by OpenCV */
|
453
|
+
int depth; /* Pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S,
|
454
|
+
IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported. */
|
455
|
+
char colorModel[4]; /* Ignored by OpenCV */
|
456
|
+
char channelSeq[4]; /* ditto */
|
457
|
+
int dataOrder; /* 0 - interleaved color channels, 1 - separate color channels.
|
458
|
+
cvCreateImage can only create interleaved images */
|
459
|
+
int origin; /* 0 - top-left origin,
|
460
|
+
1 - bottom-left origin (Windows bitmaps style). */
|
461
|
+
int align; /* Alignment of image rows (4 or 8).
|
462
|
+
OpenCV ignores it and uses widthStep instead. */
|
463
|
+
int width; /* Image width in pixels. */
|
464
|
+
int height; /* Image height in pixels. */
|
465
|
+
struct _IplROI *roi; /* Image ROI. If NULL, the whole image is selected. */
|
466
|
+
struct _IplImage *maskROI; /* Must be NULL. */
|
467
|
+
void *imageId; /* " " */
|
468
|
+
struct _IplTileInfo *tileInfo; /* " " */
|
469
|
+
int imageSize; /* Image data size in bytes
|
470
|
+
(==image->height*image->widthStep
|
471
|
+
in case of interleaved data)*/
|
472
|
+
char *imageData; /* Pointer to aligned image data. */
|
473
|
+
int widthStep; /* Size of aligned image row in bytes. */
|
474
|
+
int BorderMode[4]; /* Ignored by OpenCV. */
|
475
|
+
int BorderConst[4]; /* Ditto. */
|
476
|
+
char *imageDataOrigin; /* Pointer to very origin of image data
|
477
|
+
(not necessarily aligned) -
|
478
|
+
needed for correct deallocation */
|
479
|
+
}
|
480
|
+
IplImage;
|
481
|
+
|
482
|
+
typedef struct _IplTileInfo IplTileInfo;
|
483
|
+
|
484
|
+
typedef struct _IplROI
|
485
|
+
{
|
486
|
+
int coi; /* 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/
|
487
|
+
int xOffset;
|
488
|
+
int yOffset;
|
489
|
+
int width;
|
490
|
+
int height;
|
491
|
+
}
|
492
|
+
IplROI;
|
493
|
+
|
494
|
+
typedef struct _IplConvKernel
|
495
|
+
{
|
496
|
+
int nCols;
|
497
|
+
int nRows;
|
498
|
+
int anchorX;
|
499
|
+
int anchorY;
|
500
|
+
int *values;
|
501
|
+
int nShiftR;
|
502
|
+
}
|
503
|
+
IplConvKernel;
|
504
|
+
|
505
|
+
typedef struct _IplConvKernelFP
|
506
|
+
{
|
507
|
+
int nCols;
|
508
|
+
int nRows;
|
509
|
+
int anchorX;
|
510
|
+
int anchorY;
|
511
|
+
float *values;
|
512
|
+
}
|
513
|
+
IplConvKernelFP;
|
514
|
+
|
515
|
+
#define IPL_IMAGE_HEADER 1
|
516
|
+
#define IPL_IMAGE_DATA 2
|
517
|
+
#define IPL_IMAGE_ROI 4
|
518
|
+
|
519
|
+
#endif/*HAVE_IPL*/
|
520
|
+
|
521
|
+
/* extra border mode */
|
522
|
+
#define IPL_BORDER_REFLECT_101 4
|
523
|
+
#define IPL_BORDER_TRANSPARENT 5
|
524
|
+
|
525
|
+
#define IPL_IMAGE_MAGIC_VAL ((int)sizeof(IplImage))
|
526
|
+
#define CV_TYPE_NAME_IMAGE "opencv-image"
|
527
|
+
|
528
|
+
#define CV_IS_IMAGE_HDR(img) \
|
529
|
+
((img) != NULL && ((const IplImage*)(img))->nSize == sizeof(IplImage))
|
530
|
+
|
531
|
+
#define CV_IS_IMAGE(img) \
|
532
|
+
(CV_IS_IMAGE_HDR(img) && ((IplImage*)img)->imageData != NULL)
|
533
|
+
|
534
|
+
/* for storing double-precision
|
535
|
+
floating point data in IplImage's */
|
536
|
+
#define IPL_DEPTH_64F 64
|
537
|
+
|
538
|
+
/* get reference to pixel at (col,row),
|
539
|
+
for multi-channel images (col) should be multiplied by number of channels */
|
540
|
+
#define CV_IMAGE_ELEM( image, elemtype, row, col ) \
|
541
|
+
(((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)])
|
542
|
+
|
543
|
+
/****************************************************************************************\
|
544
|
+
* Matrix type (CvMat) *
|
545
|
+
\****************************************************************************************/
|
546
|
+
|
547
|
+
#define CV_CN_MAX 512
|
548
|
+
#define CV_CN_SHIFT 3
|
549
|
+
#define CV_DEPTH_MAX (1 << CV_CN_SHIFT)
|
550
|
+
|
551
|
+
#define CV_8U 0
|
552
|
+
#define CV_8S 1
|
553
|
+
#define CV_16U 2
|
554
|
+
#define CV_16S 3
|
555
|
+
#define CV_32S 4
|
556
|
+
#define CV_32F 5
|
557
|
+
#define CV_64F 6
|
558
|
+
#define CV_USRTYPE1 7
|
559
|
+
|
560
|
+
#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1)
|
561
|
+
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
|
562
|
+
|
563
|
+
#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT))
|
564
|
+
#define CV_MAKE_TYPE CV_MAKETYPE
|
565
|
+
|
566
|
+
#define CV_8UC1 CV_MAKETYPE(CV_8U,1)
|
567
|
+
#define CV_8UC2 CV_MAKETYPE(CV_8U,2)
|
568
|
+
#define CV_8UC3 CV_MAKETYPE(CV_8U,3)
|
569
|
+
#define CV_8UC4 CV_MAKETYPE(CV_8U,4)
|
570
|
+
#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n))
|
571
|
+
|
572
|
+
#define CV_8SC1 CV_MAKETYPE(CV_8S,1)
|
573
|
+
#define CV_8SC2 CV_MAKETYPE(CV_8S,2)
|
574
|
+
#define CV_8SC3 CV_MAKETYPE(CV_8S,3)
|
575
|
+
#define CV_8SC4 CV_MAKETYPE(CV_8S,4)
|
576
|
+
#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n))
|
577
|
+
|
578
|
+
#define CV_16UC1 CV_MAKETYPE(CV_16U,1)
|
579
|
+
#define CV_16UC2 CV_MAKETYPE(CV_16U,2)
|
580
|
+
#define CV_16UC3 CV_MAKETYPE(CV_16U,3)
|
581
|
+
#define CV_16UC4 CV_MAKETYPE(CV_16U,4)
|
582
|
+
#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n))
|
583
|
+
|
584
|
+
#define CV_16SC1 CV_MAKETYPE(CV_16S,1)
|
585
|
+
#define CV_16SC2 CV_MAKETYPE(CV_16S,2)
|
586
|
+
#define CV_16SC3 CV_MAKETYPE(CV_16S,3)
|
587
|
+
#define CV_16SC4 CV_MAKETYPE(CV_16S,4)
|
588
|
+
#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n))
|
589
|
+
|
590
|
+
#define CV_32SC1 CV_MAKETYPE(CV_32S,1)
|
591
|
+
#define CV_32SC2 CV_MAKETYPE(CV_32S,2)
|
592
|
+
#define CV_32SC3 CV_MAKETYPE(CV_32S,3)
|
593
|
+
#define CV_32SC4 CV_MAKETYPE(CV_32S,4)
|
594
|
+
#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n))
|
595
|
+
|
596
|
+
#define CV_32FC1 CV_MAKETYPE(CV_32F,1)
|
597
|
+
#define CV_32FC2 CV_MAKETYPE(CV_32F,2)
|
598
|
+
#define CV_32FC3 CV_MAKETYPE(CV_32F,3)
|
599
|
+
#define CV_32FC4 CV_MAKETYPE(CV_32F,4)
|
600
|
+
#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n))
|
601
|
+
|
602
|
+
#define CV_64FC1 CV_MAKETYPE(CV_64F,1)
|
603
|
+
#define CV_64FC2 CV_MAKETYPE(CV_64F,2)
|
604
|
+
#define CV_64FC3 CV_MAKETYPE(CV_64F,3)
|
605
|
+
#define CV_64FC4 CV_MAKETYPE(CV_64F,4)
|
606
|
+
#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n))
|
607
|
+
|
608
|
+
#define CV_AUTO_STEP 0x7fffffff
|
609
|
+
#define CV_WHOLE_ARR cvSlice( 0, 0x3fffffff )
|
610
|
+
|
611
|
+
#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
|
612
|
+
#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
|
613
|
+
#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
|
614
|
+
#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
|
615
|
+
#define CV_MAT_CONT_FLAG_SHIFT 14
|
616
|
+
#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT)
|
617
|
+
#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG)
|
618
|
+
#define CV_IS_CONT_MAT CV_IS_MAT_CONT
|
619
|
+
#define CV_SUBMAT_FLAG_SHIFT 15
|
620
|
+
#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT)
|
621
|
+
#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
|
622
|
+
|
623
|
+
#define CV_MAGIC_MASK 0xFFFF0000
|
624
|
+
#define CV_MAT_MAGIC_VAL 0x42420000
|
625
|
+
#define CV_TYPE_NAME_MAT "opencv-matrix"
|
626
|
+
|
627
|
+
typedef struct CvMat
|
628
|
+
{
|
629
|
+
int type;
|
630
|
+
int step;
|
631
|
+
|
632
|
+
/* for internal use only */
|
633
|
+
int* refcount;
|
634
|
+
int hdr_refcount;
|
635
|
+
|
636
|
+
union
|
637
|
+
{
|
638
|
+
uchar* ptr;
|
639
|
+
short* s;
|
640
|
+
int* i;
|
641
|
+
float* fl;
|
642
|
+
double* db;
|
643
|
+
} data;
|
644
|
+
|
645
|
+
#ifdef __cplusplus
|
646
|
+
union
|
647
|
+
{
|
648
|
+
int rows;
|
649
|
+
int height;
|
650
|
+
};
|
651
|
+
|
652
|
+
union
|
653
|
+
{
|
654
|
+
int cols;
|
655
|
+
int width;
|
656
|
+
};
|
657
|
+
#else
|
658
|
+
int rows;
|
659
|
+
int cols;
|
660
|
+
#endif
|
661
|
+
|
662
|
+
}
|
663
|
+
CvMat;
|
664
|
+
|
665
|
+
|
666
|
+
#define CV_IS_MAT_HDR(mat) \
|
667
|
+
((mat) != NULL && \
|
668
|
+
(((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \
|
669
|
+
((const CvMat*)(mat))->cols > 0 && ((const CvMat*)(mat))->rows > 0)
|
670
|
+
|
671
|
+
#define CV_IS_MAT_HDR_Z(mat) \
|
672
|
+
((mat) != NULL && \
|
673
|
+
(((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \
|
674
|
+
((const CvMat*)(mat))->cols >= 0 && ((const CvMat*)(mat))->rows >= 0)
|
675
|
+
|
676
|
+
#define CV_IS_MAT(mat) \
|
677
|
+
(CV_IS_MAT_HDR(mat) && ((const CvMat*)(mat))->data.ptr != NULL)
|
678
|
+
|
679
|
+
#define CV_IS_MASK_ARR(mat) \
|
680
|
+
(((mat)->type & (CV_MAT_TYPE_MASK & ~CV_8SC1)) == 0)
|
681
|
+
|
682
|
+
#define CV_ARE_TYPES_EQ(mat1, mat2) \
|
683
|
+
((((mat1)->type ^ (mat2)->type) & CV_MAT_TYPE_MASK) == 0)
|
684
|
+
|
685
|
+
#define CV_ARE_CNS_EQ(mat1, mat2) \
|
686
|
+
((((mat1)->type ^ (mat2)->type) & CV_MAT_CN_MASK) == 0)
|
687
|
+
|
688
|
+
#define CV_ARE_DEPTHS_EQ(mat1, mat2) \
|
689
|
+
((((mat1)->type ^ (mat2)->type) & CV_MAT_DEPTH_MASK) == 0)
|
690
|
+
|
691
|
+
#define CV_ARE_SIZES_EQ(mat1, mat2) \
|
692
|
+
((mat1)->rows == (mat2)->rows && (mat1)->cols == (mat2)->cols)
|
693
|
+
|
694
|
+
#define CV_IS_MAT_CONST(mat) \
|
695
|
+
(((mat)->rows|(mat)->cols) == 1)
|
696
|
+
|
697
|
+
/* Size of each channel item,
|
698
|
+
0x124489 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
|
699
|
+
#define CV_ELEM_SIZE1(type) \
|
700
|
+
((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15)
|
701
|
+
|
702
|
+
/* 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */
|
703
|
+
#define CV_ELEM_SIZE(type) \
|
704
|
+
(CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3))
|
705
|
+
|
706
|
+
#define IPL2CV_DEPTH(depth) \
|
707
|
+
((((CV_8U)+(CV_16U<<4)+(CV_32F<<8)+(CV_64F<<16)+(CV_8S<<20)+ \
|
708
|
+
(CV_16S<<24)+(CV_32S<<28)) >> ((((depth) & 0xF0) >> 2) + \
|
709
|
+
(((depth) & IPL_DEPTH_SIGN) ? 20 : 0))) & 15)
|
710
|
+
|
711
|
+
/* Inline constructor. No data is allocated internally!!!
|
712
|
+
* (Use together with cvCreateData, or use cvCreateMat instead to
|
713
|
+
* get a matrix with allocated data):
|
714
|
+
*/
|
715
|
+
CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL))
|
716
|
+
{
|
717
|
+
CvMat m;
|
718
|
+
|
719
|
+
assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F );
|
720
|
+
type = CV_MAT_TYPE(type);
|
721
|
+
m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type;
|
722
|
+
m.cols = cols;
|
723
|
+
m.rows = rows;
|
724
|
+
m.step = m.cols*CV_ELEM_SIZE(type);
|
725
|
+
m.data.ptr = (uchar*)data;
|
726
|
+
m.refcount = NULL;
|
727
|
+
m.hdr_refcount = 0;
|
728
|
+
|
729
|
+
return m;
|
730
|
+
}
|
731
|
+
|
732
|
+
|
733
|
+
#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \
|
734
|
+
(assert( (unsigned)(row) < (unsigned)(mat).rows && \
|
735
|
+
(unsigned)(col) < (unsigned)(mat).cols ), \
|
736
|
+
(mat).data.ptr + (size_t)(mat).step*(row) + (pix_size)*(col))
|
737
|
+
|
738
|
+
#define CV_MAT_ELEM_PTR( mat, row, col ) \
|
739
|
+
CV_MAT_ELEM_PTR_FAST( mat, row, col, CV_ELEM_SIZE((mat).type) )
|
740
|
+
|
741
|
+
#define CV_MAT_ELEM( mat, elemtype, row, col ) \
|
742
|
+
(*(elemtype*)CV_MAT_ELEM_PTR_FAST( mat, row, col, sizeof(elemtype)))
|
743
|
+
|
744
|
+
|
745
|
+
CV_INLINE double cvmGet( const CvMat* mat, int row, int col )
|
746
|
+
{
|
747
|
+
int type;
|
748
|
+
|
749
|
+
type = CV_MAT_TYPE(mat->type);
|
750
|
+
assert( (unsigned)row < (unsigned)mat->rows &&
|
751
|
+
(unsigned)col < (unsigned)mat->cols );
|
752
|
+
|
753
|
+
if( type == CV_32FC1 )
|
754
|
+
return ((float*)(mat->data.ptr + (size_t)mat->step*row))[col];
|
755
|
+
else
|
756
|
+
{
|
757
|
+
assert( type == CV_64FC1 );
|
758
|
+
return ((double*)(mat->data.ptr + (size_t)mat->step*row))[col];
|
759
|
+
}
|
760
|
+
}
|
761
|
+
|
762
|
+
|
763
|
+
CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value )
|
764
|
+
{
|
765
|
+
int type;
|
766
|
+
type = CV_MAT_TYPE(mat->type);
|
767
|
+
assert( (unsigned)row < (unsigned)mat->rows &&
|
768
|
+
(unsigned)col < (unsigned)mat->cols );
|
769
|
+
|
770
|
+
if( type == CV_32FC1 )
|
771
|
+
((float*)(mat->data.ptr + (size_t)mat->step*row))[col] = (float)value;
|
772
|
+
else
|
773
|
+
{
|
774
|
+
assert( type == CV_64FC1 );
|
775
|
+
((double*)(mat->data.ptr + (size_t)mat->step*row))[col] = (double)value;
|
776
|
+
}
|
777
|
+
}
|
778
|
+
|
779
|
+
|
780
|
+
CV_INLINE int cvIplDepth( int type )
|
781
|
+
{
|
782
|
+
int depth = CV_MAT_DEPTH(type);
|
783
|
+
return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S ||
|
784
|
+
depth == CV_32S ? IPL_DEPTH_SIGN : 0);
|
785
|
+
}
|
786
|
+
|
787
|
+
|
788
|
+
/****************************************************************************************\
|
789
|
+
* Multi-dimensional dense array (CvMatND) *
|
790
|
+
\****************************************************************************************/
|
791
|
+
|
792
|
+
#define CV_MATND_MAGIC_VAL 0x42430000
|
793
|
+
#define CV_TYPE_NAME_MATND "opencv-nd-matrix"
|
794
|
+
|
795
|
+
#define CV_MAX_DIM 32
|
796
|
+
#define CV_MAX_DIM_HEAP 1024
|
797
|
+
|
798
|
+
typedef struct CvMatND
|
799
|
+
{
|
800
|
+
int type;
|
801
|
+
int dims;
|
802
|
+
|
803
|
+
int* refcount;
|
804
|
+
int hdr_refcount;
|
805
|
+
|
806
|
+
union
|
807
|
+
{
|
808
|
+
uchar* ptr;
|
809
|
+
float* fl;
|
810
|
+
double* db;
|
811
|
+
int* i;
|
812
|
+
short* s;
|
813
|
+
} data;
|
814
|
+
|
815
|
+
struct
|
816
|
+
{
|
817
|
+
int size;
|
818
|
+
int step;
|
819
|
+
}
|
820
|
+
dim[CV_MAX_DIM];
|
821
|
+
}
|
822
|
+
CvMatND;
|
823
|
+
|
824
|
+
#define CV_IS_MATND_HDR(mat) \
|
825
|
+
((mat) != NULL && (((const CvMatND*)(mat))->type & CV_MAGIC_MASK) == CV_MATND_MAGIC_VAL)
|
826
|
+
|
827
|
+
#define CV_IS_MATND(mat) \
|
828
|
+
(CV_IS_MATND_HDR(mat) && ((const CvMatND*)(mat))->data.ptr != NULL)
|
829
|
+
|
830
|
+
|
831
|
+
/****************************************************************************************\
|
832
|
+
* Multi-dimensional sparse array (CvSparseMat) *
|
833
|
+
\****************************************************************************************/
|
834
|
+
|
835
|
+
#define CV_SPARSE_MAT_MAGIC_VAL 0x42440000
|
836
|
+
#define CV_TYPE_NAME_SPARSE_MAT "opencv-sparse-matrix"
|
837
|
+
|
838
|
+
struct CvSet;
|
839
|
+
|
840
|
+
typedef struct CvSparseMat
|
841
|
+
{
|
842
|
+
int type;
|
843
|
+
int dims;
|
844
|
+
int* refcount;
|
845
|
+
int hdr_refcount;
|
846
|
+
|
847
|
+
struct CvSet* heap;
|
848
|
+
void** hashtable;
|
849
|
+
int hashsize;
|
850
|
+
int valoffset;
|
851
|
+
int idxoffset;
|
852
|
+
int size[CV_MAX_DIM];
|
853
|
+
}
|
854
|
+
CvSparseMat;
|
855
|
+
|
856
|
+
#define CV_IS_SPARSE_MAT_HDR(mat) \
|
857
|
+
((mat) != NULL && \
|
858
|
+
(((const CvSparseMat*)(mat))->type & CV_MAGIC_MASK) == CV_SPARSE_MAT_MAGIC_VAL)
|
859
|
+
|
860
|
+
#define CV_IS_SPARSE_MAT(mat) \
|
861
|
+
CV_IS_SPARSE_MAT_HDR(mat)
|
862
|
+
|
863
|
+
/**************** iteration through a sparse array *****************/
|
864
|
+
|
865
|
+
typedef struct CvSparseNode
|
866
|
+
{
|
867
|
+
unsigned hashval;
|
868
|
+
struct CvSparseNode* next;
|
869
|
+
}
|
870
|
+
CvSparseNode;
|
871
|
+
|
872
|
+
typedef struct CvSparseMatIterator
|
873
|
+
{
|
874
|
+
CvSparseMat* mat;
|
875
|
+
CvSparseNode* node;
|
876
|
+
int curidx;
|
877
|
+
}
|
878
|
+
CvSparseMatIterator;
|
879
|
+
|
880
|
+
#define CV_NODE_VAL(mat,node) ((void*)((uchar*)(node) + (mat)->valoffset))
|
881
|
+
#define CV_NODE_IDX(mat,node) ((int*)((uchar*)(node) + (mat)->idxoffset))
|
882
|
+
|
883
|
+
/****************************************************************************************\
|
884
|
+
* Histogram *
|
885
|
+
\****************************************************************************************/
|
886
|
+
|
887
|
+
typedef int CvHistType;
|
888
|
+
|
889
|
+
#define CV_HIST_MAGIC_VAL 0x42450000
|
890
|
+
#define CV_HIST_UNIFORM_FLAG (1 << 10)
|
891
|
+
|
892
|
+
/* indicates whether bin ranges are set already or not */
|
893
|
+
#define CV_HIST_RANGES_FLAG (1 << 11)
|
894
|
+
|
895
|
+
#define CV_HIST_ARRAY 0
|
896
|
+
#define CV_HIST_SPARSE 1
|
897
|
+
#define CV_HIST_TREE CV_HIST_SPARSE
|
898
|
+
|
899
|
+
/* should be used as a parameter only,
|
900
|
+
it turns to CV_HIST_UNIFORM_FLAG of hist->type */
|
901
|
+
#define CV_HIST_UNIFORM 1
|
902
|
+
|
903
|
+
typedef struct CvHistogram
|
904
|
+
{
|
905
|
+
int type;
|
906
|
+
CvArr* bins;
|
907
|
+
float thresh[CV_MAX_DIM][2]; /* For uniform histograms. */
|
908
|
+
float** thresh2; /* For non-uniform histograms. */
|
909
|
+
CvMatND mat; /* Embedded matrix header for array histograms. */
|
910
|
+
}
|
911
|
+
CvHistogram;
|
912
|
+
|
913
|
+
#define CV_IS_HIST( hist ) \
|
914
|
+
((hist) != NULL && \
|
915
|
+
(((CvHistogram*)(hist))->type & CV_MAGIC_MASK) == CV_HIST_MAGIC_VAL && \
|
916
|
+
(hist)->bins != NULL)
|
917
|
+
|
918
|
+
#define CV_IS_UNIFORM_HIST( hist ) \
|
919
|
+
(((hist)->type & CV_HIST_UNIFORM_FLAG) != 0)
|
920
|
+
|
921
|
+
#define CV_IS_SPARSE_HIST( hist ) \
|
922
|
+
CV_IS_SPARSE_MAT((hist)->bins)
|
923
|
+
|
924
|
+
#define CV_HIST_HAS_RANGES( hist ) \
|
925
|
+
(((hist)->type & CV_HIST_RANGES_FLAG) != 0)
|
926
|
+
|
927
|
+
/****************************************************************************************\
|
928
|
+
* Other supplementary data type definitions *
|
929
|
+
\****************************************************************************************/
|
930
|
+
|
931
|
+
/*************************************** CvRect *****************************************/
|
932
|
+
|
933
|
+
typedef struct CvRect
|
934
|
+
{
|
935
|
+
int x;
|
936
|
+
int y;
|
937
|
+
int width;
|
938
|
+
int height;
|
939
|
+
}
|
940
|
+
CvRect;
|
941
|
+
|
942
|
+
CV_INLINE CvRect cvRect( int x, int y, int width, int height )
|
943
|
+
{
|
944
|
+
CvRect r;
|
945
|
+
|
946
|
+
r.x = x;
|
947
|
+
r.y = y;
|
948
|
+
r.width = width;
|
949
|
+
r.height = height;
|
950
|
+
|
951
|
+
return r;
|
952
|
+
}
|
953
|
+
|
954
|
+
|
955
|
+
CV_INLINE IplROI cvRectToROI( CvRect rect, int coi )
|
956
|
+
{
|
957
|
+
IplROI roi;
|
958
|
+
roi.xOffset = rect.x;
|
959
|
+
roi.yOffset = rect.y;
|
960
|
+
roi.width = rect.width;
|
961
|
+
roi.height = rect.height;
|
962
|
+
roi.coi = coi;
|
963
|
+
|
964
|
+
return roi;
|
965
|
+
}
|
966
|
+
|
967
|
+
|
968
|
+
CV_INLINE CvRect cvROIToRect( IplROI roi )
|
969
|
+
{
|
970
|
+
return cvRect( roi.xOffset, roi.yOffset, roi.width, roi.height );
|
971
|
+
}
|
972
|
+
|
973
|
+
/*********************************** CvTermCriteria *************************************/
|
974
|
+
|
975
|
+
#define CV_TERMCRIT_ITER 1
|
976
|
+
#define CV_TERMCRIT_NUMBER CV_TERMCRIT_ITER
|
977
|
+
#define CV_TERMCRIT_EPS 2
|
978
|
+
|
979
|
+
typedef struct CvTermCriteria
|
980
|
+
{
|
981
|
+
int type; /* may be combination of
|
982
|
+
CV_TERMCRIT_ITER
|
983
|
+
CV_TERMCRIT_EPS */
|
984
|
+
int max_iter;
|
985
|
+
double epsilon;
|
986
|
+
}
|
987
|
+
CvTermCriteria;
|
988
|
+
|
989
|
+
CV_INLINE CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon )
|
990
|
+
{
|
991
|
+
CvTermCriteria t;
|
992
|
+
|
993
|
+
t.type = type;
|
994
|
+
t.max_iter = max_iter;
|
995
|
+
t.epsilon = (float)epsilon;
|
996
|
+
|
997
|
+
return t;
|
998
|
+
}
|
999
|
+
|
1000
|
+
|
1001
|
+
/******************************* CvPoint and variants ***********************************/
|
1002
|
+
|
1003
|
+
typedef struct CvPoint
|
1004
|
+
{
|
1005
|
+
int x;
|
1006
|
+
int y;
|
1007
|
+
}
|
1008
|
+
CvPoint;
|
1009
|
+
|
1010
|
+
|
1011
|
+
CV_INLINE CvPoint cvPoint( int x, int y )
|
1012
|
+
{
|
1013
|
+
CvPoint p;
|
1014
|
+
|
1015
|
+
p.x = x;
|
1016
|
+
p.y = y;
|
1017
|
+
|
1018
|
+
return p;
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
|
1022
|
+
typedef struct CvPoint2D32f
|
1023
|
+
{
|
1024
|
+
float x;
|
1025
|
+
float y;
|
1026
|
+
}
|
1027
|
+
CvPoint2D32f;
|
1028
|
+
|
1029
|
+
|
1030
|
+
CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y )
|
1031
|
+
{
|
1032
|
+
CvPoint2D32f p;
|
1033
|
+
|
1034
|
+
p.x = (float)x;
|
1035
|
+
p.y = (float)y;
|
1036
|
+
|
1037
|
+
return p;
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
|
1041
|
+
CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint point )
|
1042
|
+
{
|
1043
|
+
return cvPoint2D32f( (float)point.x, (float)point.y );
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
|
1047
|
+
CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f point )
|
1048
|
+
{
|
1049
|
+
CvPoint ipt;
|
1050
|
+
ipt.x = cvRound(point.x);
|
1051
|
+
ipt.y = cvRound(point.y);
|
1052
|
+
|
1053
|
+
return ipt;
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
|
1057
|
+
typedef struct CvPoint3D32f
|
1058
|
+
{
|
1059
|
+
float x;
|
1060
|
+
float y;
|
1061
|
+
float z;
|
1062
|
+
}
|
1063
|
+
CvPoint3D32f;
|
1064
|
+
|
1065
|
+
|
1066
|
+
CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z )
|
1067
|
+
{
|
1068
|
+
CvPoint3D32f p;
|
1069
|
+
|
1070
|
+
p.x = (float)x;
|
1071
|
+
p.y = (float)y;
|
1072
|
+
p.z = (float)z;
|
1073
|
+
|
1074
|
+
return p;
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
|
1078
|
+
typedef struct CvPoint2D64f
|
1079
|
+
{
|
1080
|
+
double x;
|
1081
|
+
double y;
|
1082
|
+
}
|
1083
|
+
CvPoint2D64f;
|
1084
|
+
|
1085
|
+
|
1086
|
+
CV_INLINE CvPoint2D64f cvPoint2D64f( double x, double y )
|
1087
|
+
{
|
1088
|
+
CvPoint2D64f p;
|
1089
|
+
|
1090
|
+
p.x = x;
|
1091
|
+
p.y = y;
|
1092
|
+
|
1093
|
+
return p;
|
1094
|
+
}
|
1095
|
+
|
1096
|
+
|
1097
|
+
typedef struct CvPoint3D64f
|
1098
|
+
{
|
1099
|
+
double x;
|
1100
|
+
double y;
|
1101
|
+
double z;
|
1102
|
+
}
|
1103
|
+
CvPoint3D64f;
|
1104
|
+
|
1105
|
+
|
1106
|
+
CV_INLINE CvPoint3D64f cvPoint3D64f( double x, double y, double z )
|
1107
|
+
{
|
1108
|
+
CvPoint3D64f p;
|
1109
|
+
|
1110
|
+
p.x = x;
|
1111
|
+
p.y = y;
|
1112
|
+
p.z = z;
|
1113
|
+
|
1114
|
+
return p;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
|
1118
|
+
/******************************** CvSize's & CvBox **************************************/
|
1119
|
+
|
1120
|
+
typedef struct
|
1121
|
+
{
|
1122
|
+
int width;
|
1123
|
+
int height;
|
1124
|
+
}
|
1125
|
+
CvSize;
|
1126
|
+
|
1127
|
+
CV_INLINE CvSize cvSize( int width, int height )
|
1128
|
+
{
|
1129
|
+
CvSize s;
|
1130
|
+
|
1131
|
+
s.width = width;
|
1132
|
+
s.height = height;
|
1133
|
+
|
1134
|
+
return s;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
typedef struct CvSize2D32f
|
1138
|
+
{
|
1139
|
+
float width;
|
1140
|
+
float height;
|
1141
|
+
}
|
1142
|
+
CvSize2D32f;
|
1143
|
+
|
1144
|
+
|
1145
|
+
CV_INLINE CvSize2D32f cvSize2D32f( double width, double height )
|
1146
|
+
{
|
1147
|
+
CvSize2D32f s;
|
1148
|
+
|
1149
|
+
s.width = (float)width;
|
1150
|
+
s.height = (float)height;
|
1151
|
+
|
1152
|
+
return s;
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
typedef struct CvBox2D
|
1156
|
+
{
|
1157
|
+
CvPoint2D32f center; /* Center of the box. */
|
1158
|
+
CvSize2D32f size; /* Box width and length. */
|
1159
|
+
float angle; /* Angle between the horizontal axis */
|
1160
|
+
/* and the first side (i.e. length) in degrees */
|
1161
|
+
}
|
1162
|
+
CvBox2D;
|
1163
|
+
|
1164
|
+
|
1165
|
+
/* Line iterator state: */
|
1166
|
+
typedef struct CvLineIterator
|
1167
|
+
{
|
1168
|
+
/* Pointer to the current point: */
|
1169
|
+
uchar* ptr;
|
1170
|
+
|
1171
|
+
/* Bresenham algorithm state: */
|
1172
|
+
int err;
|
1173
|
+
int plus_delta;
|
1174
|
+
int minus_delta;
|
1175
|
+
int plus_step;
|
1176
|
+
int minus_step;
|
1177
|
+
}
|
1178
|
+
CvLineIterator;
|
1179
|
+
|
1180
|
+
|
1181
|
+
|
1182
|
+
/************************************* CvSlice ******************************************/
|
1183
|
+
|
1184
|
+
typedef struct CvSlice
|
1185
|
+
{
|
1186
|
+
int start_index, end_index;
|
1187
|
+
}
|
1188
|
+
CvSlice;
|
1189
|
+
|
1190
|
+
CV_INLINE CvSlice cvSlice( int start, int end )
|
1191
|
+
{
|
1192
|
+
CvSlice slice;
|
1193
|
+
slice.start_index = start;
|
1194
|
+
slice.end_index = end;
|
1195
|
+
|
1196
|
+
return slice;
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
#define CV_WHOLE_SEQ_END_INDEX 0x3fffffff
|
1200
|
+
#define CV_WHOLE_SEQ cvSlice(0, CV_WHOLE_SEQ_END_INDEX)
|
1201
|
+
|
1202
|
+
|
1203
|
+
/************************************* CvScalar *****************************************/
|
1204
|
+
|
1205
|
+
typedef struct CvScalar
|
1206
|
+
{
|
1207
|
+
double val[4];
|
1208
|
+
}
|
1209
|
+
CvScalar;
|
1210
|
+
|
1211
|
+
CV_INLINE CvScalar cvScalar( double val0, double val1 CV_DEFAULT(0),
|
1212
|
+
double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0))
|
1213
|
+
{
|
1214
|
+
CvScalar scalar;
|
1215
|
+
scalar.val[0] = val0; scalar.val[1] = val1;
|
1216
|
+
scalar.val[2] = val2; scalar.val[3] = val3;
|
1217
|
+
return scalar;
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
|
1221
|
+
CV_INLINE CvScalar cvRealScalar( double val0 )
|
1222
|
+
{
|
1223
|
+
CvScalar scalar;
|
1224
|
+
scalar.val[0] = val0;
|
1225
|
+
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
|
1226
|
+
return scalar;
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
CV_INLINE CvScalar cvScalarAll( double val0123 )
|
1230
|
+
{
|
1231
|
+
CvScalar scalar;
|
1232
|
+
scalar.val[0] = val0123;
|
1233
|
+
scalar.val[1] = val0123;
|
1234
|
+
scalar.val[2] = val0123;
|
1235
|
+
scalar.val[3] = val0123;
|
1236
|
+
return scalar;
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
/****************************************************************************************\
|
1240
|
+
* Dynamic Data structures *
|
1241
|
+
\****************************************************************************************/
|
1242
|
+
|
1243
|
+
/******************************** Memory storage ****************************************/
|
1244
|
+
|
1245
|
+
typedef struct CvMemBlock
|
1246
|
+
{
|
1247
|
+
struct CvMemBlock* prev;
|
1248
|
+
struct CvMemBlock* next;
|
1249
|
+
}
|
1250
|
+
CvMemBlock;
|
1251
|
+
|
1252
|
+
#define CV_STORAGE_MAGIC_VAL 0x42890000
|
1253
|
+
|
1254
|
+
typedef struct CvMemStorage
|
1255
|
+
{
|
1256
|
+
int signature;
|
1257
|
+
CvMemBlock* bottom; /* First allocated block. */
|
1258
|
+
CvMemBlock* top; /* Current memory block - top of the stack. */
|
1259
|
+
struct CvMemStorage* parent; /* We get new blocks from parent as needed. */
|
1260
|
+
int block_size; /* Block size. */
|
1261
|
+
int free_space; /* Remaining free space in current block. */
|
1262
|
+
}
|
1263
|
+
CvMemStorage;
|
1264
|
+
|
1265
|
+
#define CV_IS_STORAGE(storage) \
|
1266
|
+
((storage) != NULL && \
|
1267
|
+
(((CvMemStorage*)(storage))->signature & CV_MAGIC_MASK) == CV_STORAGE_MAGIC_VAL)
|
1268
|
+
|
1269
|
+
|
1270
|
+
typedef struct CvMemStoragePos
|
1271
|
+
{
|
1272
|
+
CvMemBlock* top;
|
1273
|
+
int free_space;
|
1274
|
+
}
|
1275
|
+
CvMemStoragePos;
|
1276
|
+
|
1277
|
+
|
1278
|
+
/*********************************** Sequence *******************************************/
|
1279
|
+
|
1280
|
+
typedef struct CvSeqBlock
|
1281
|
+
{
|
1282
|
+
struct CvSeqBlock* prev; /* Previous sequence block. */
|
1283
|
+
struct CvSeqBlock* next; /* Next sequence block. */
|
1284
|
+
int start_index; /* Index of the first element in the block + */
|
1285
|
+
/* sequence->first->start_index. */
|
1286
|
+
int count; /* Number of elements in the block. */
|
1287
|
+
schar* data; /* Pointer to the first element of the block. */
|
1288
|
+
}
|
1289
|
+
CvSeqBlock;
|
1290
|
+
|
1291
|
+
|
1292
|
+
#define CV_TREE_NODE_FIELDS(node_type) \
|
1293
|
+
int flags; /* Miscellaneous flags. */ \
|
1294
|
+
int header_size; /* Size of sequence header. */ \
|
1295
|
+
struct node_type* h_prev; /* Previous sequence. */ \
|
1296
|
+
struct node_type* h_next; /* Next sequence. */ \
|
1297
|
+
struct node_type* v_prev; /* 2nd previous sequence. */ \
|
1298
|
+
struct node_type* v_next /* 2nd next sequence. */
|
1299
|
+
|
1300
|
+
/*
|
1301
|
+
Read/Write sequence.
|
1302
|
+
Elements can be dynamically inserted to or deleted from the sequence.
|
1303
|
+
*/
|
1304
|
+
#define CV_SEQUENCE_FIELDS() \
|
1305
|
+
CV_TREE_NODE_FIELDS(CvSeq); \
|
1306
|
+
int total; /* Total number of elements. */ \
|
1307
|
+
int elem_size; /* Size of sequence element in bytes. */ \
|
1308
|
+
schar* block_max; /* Maximal bound of the last block. */ \
|
1309
|
+
schar* ptr; /* Current write pointer. */ \
|
1310
|
+
int delta_elems; /* Grow seq this many at a time. */ \
|
1311
|
+
CvMemStorage* storage; /* Where the seq is stored. */ \
|
1312
|
+
CvSeqBlock* free_blocks; /* Free blocks list. */ \
|
1313
|
+
CvSeqBlock* first; /* Pointer to the first sequence block. */
|
1314
|
+
|
1315
|
+
typedef struct CvSeq
|
1316
|
+
{
|
1317
|
+
CV_SEQUENCE_FIELDS()
|
1318
|
+
}
|
1319
|
+
CvSeq;
|
1320
|
+
|
1321
|
+
#define CV_TYPE_NAME_SEQ "opencv-sequence"
|
1322
|
+
#define CV_TYPE_NAME_SEQ_TREE "opencv-sequence-tree"
|
1323
|
+
|
1324
|
+
/*************************************** Set ********************************************/
|
1325
|
+
/*
|
1326
|
+
Set.
|
1327
|
+
Order is not preserved. There can be gaps between sequence elements.
|
1328
|
+
After the element has been inserted it stays in the same place all the time.
|
1329
|
+
The MSB(most-significant or sign bit) of the first field (flags) is 0 iff the element exists.
|
1330
|
+
*/
|
1331
|
+
#define CV_SET_ELEM_FIELDS(elem_type) \
|
1332
|
+
int flags; \
|
1333
|
+
struct elem_type* next_free;
|
1334
|
+
|
1335
|
+
typedef struct CvSetElem
|
1336
|
+
{
|
1337
|
+
CV_SET_ELEM_FIELDS(CvSetElem)
|
1338
|
+
}
|
1339
|
+
CvSetElem;
|
1340
|
+
|
1341
|
+
#define CV_SET_FIELDS() \
|
1342
|
+
CV_SEQUENCE_FIELDS() \
|
1343
|
+
CvSetElem* free_elems; \
|
1344
|
+
int active_count;
|
1345
|
+
|
1346
|
+
typedef struct CvSet
|
1347
|
+
{
|
1348
|
+
CV_SET_FIELDS()
|
1349
|
+
}
|
1350
|
+
CvSet;
|
1351
|
+
|
1352
|
+
|
1353
|
+
#define CV_SET_ELEM_IDX_MASK ((1 << 26) - 1)
|
1354
|
+
#define CV_SET_ELEM_FREE_FLAG (1 << (sizeof(int)*8-1))
|
1355
|
+
|
1356
|
+
/* Checks whether the element pointed by ptr belongs to a set or not */
|
1357
|
+
#define CV_IS_SET_ELEM( ptr ) (((CvSetElem*)(ptr))->flags >= 0)
|
1358
|
+
|
1359
|
+
/************************************* Graph ********************************************/
|
1360
|
+
|
1361
|
+
/*
|
1362
|
+
We represent a graph as a set of vertices.
|
1363
|
+
Vertices contain their adjacency lists (more exactly, pointers to first incoming or
|
1364
|
+
outcoming edge (or 0 if isolated vertex)). Edges are stored in another set.
|
1365
|
+
There is a singly-linked list of incoming/outcoming edges for each vertex.
|
1366
|
+
|
1367
|
+
Each edge consists of
|
1368
|
+
|
1369
|
+
o Two pointers to the starting and ending vertices
|
1370
|
+
(vtx[0] and vtx[1] respectively).
|
1371
|
+
|
1372
|
+
A graph may be oriented or not. In the latter case, edges between
|
1373
|
+
vertex i to vertex j are not distinguished during search operations.
|
1374
|
+
|
1375
|
+
o Two pointers to next edges for the starting and ending vertices, where
|
1376
|
+
next[0] points to the next edge in the vtx[0] adjacency list and
|
1377
|
+
next[1] points to the next edge in the vtx[1] adjacency list.
|
1378
|
+
*/
|
1379
|
+
#define CV_GRAPH_EDGE_FIELDS() \
|
1380
|
+
int flags; \
|
1381
|
+
float weight; \
|
1382
|
+
struct CvGraphEdge* next[2]; \
|
1383
|
+
struct CvGraphVtx* vtx[2];
|
1384
|
+
|
1385
|
+
|
1386
|
+
#define CV_GRAPH_VERTEX_FIELDS() \
|
1387
|
+
int flags; \
|
1388
|
+
struct CvGraphEdge* first;
|
1389
|
+
|
1390
|
+
|
1391
|
+
typedef struct CvGraphEdge
|
1392
|
+
{
|
1393
|
+
CV_GRAPH_EDGE_FIELDS()
|
1394
|
+
}
|
1395
|
+
CvGraphEdge;
|
1396
|
+
|
1397
|
+
typedef struct CvGraphVtx
|
1398
|
+
{
|
1399
|
+
CV_GRAPH_VERTEX_FIELDS()
|
1400
|
+
}
|
1401
|
+
CvGraphVtx;
|
1402
|
+
|
1403
|
+
typedef struct CvGraphVtx2D
|
1404
|
+
{
|
1405
|
+
CV_GRAPH_VERTEX_FIELDS()
|
1406
|
+
CvPoint2D32f* ptr;
|
1407
|
+
}
|
1408
|
+
CvGraphVtx2D;
|
1409
|
+
|
1410
|
+
/*
|
1411
|
+
Graph is "derived" from the set (this is set a of vertices)
|
1412
|
+
and includes another set (edges)
|
1413
|
+
*/
|
1414
|
+
#define CV_GRAPH_FIELDS() \
|
1415
|
+
CV_SET_FIELDS() \
|
1416
|
+
CvSet* edges;
|
1417
|
+
|
1418
|
+
typedef struct CvGraph
|
1419
|
+
{
|
1420
|
+
CV_GRAPH_FIELDS()
|
1421
|
+
}
|
1422
|
+
CvGraph;
|
1423
|
+
|
1424
|
+
#define CV_TYPE_NAME_GRAPH "opencv-graph"
|
1425
|
+
|
1426
|
+
/*********************************** Chain/Countour *************************************/
|
1427
|
+
|
1428
|
+
typedef struct CvChain
|
1429
|
+
{
|
1430
|
+
CV_SEQUENCE_FIELDS()
|
1431
|
+
CvPoint origin;
|
1432
|
+
}
|
1433
|
+
CvChain;
|
1434
|
+
|
1435
|
+
#define CV_CONTOUR_FIELDS() \
|
1436
|
+
CV_SEQUENCE_FIELDS() \
|
1437
|
+
CvRect rect; \
|
1438
|
+
int color; \
|
1439
|
+
int reserved[3];
|
1440
|
+
|
1441
|
+
typedef struct CvContour
|
1442
|
+
{
|
1443
|
+
CV_CONTOUR_FIELDS()
|
1444
|
+
}
|
1445
|
+
CvContour;
|
1446
|
+
|
1447
|
+
typedef CvContour CvPoint2DSeq;
|
1448
|
+
|
1449
|
+
/****************************************************************************************\
|
1450
|
+
* Sequence types *
|
1451
|
+
\****************************************************************************************/
|
1452
|
+
|
1453
|
+
#define CV_SEQ_MAGIC_VAL 0x42990000
|
1454
|
+
|
1455
|
+
#define CV_IS_SEQ(seq) \
|
1456
|
+
((seq) != NULL && (((CvSeq*)(seq))->flags & CV_MAGIC_MASK) == CV_SEQ_MAGIC_VAL)
|
1457
|
+
|
1458
|
+
#define CV_SET_MAGIC_VAL 0x42980000
|
1459
|
+
#define CV_IS_SET(set) \
|
1460
|
+
((set) != NULL && (((CvSeq*)(set))->flags & CV_MAGIC_MASK) == CV_SET_MAGIC_VAL)
|
1461
|
+
|
1462
|
+
#define CV_SEQ_ELTYPE_BITS 12
|
1463
|
+
#define CV_SEQ_ELTYPE_MASK ((1 << CV_SEQ_ELTYPE_BITS) - 1)
|
1464
|
+
|
1465
|
+
#define CV_SEQ_ELTYPE_POINT CV_32SC2 /* (x,y) */
|
1466
|
+
#define CV_SEQ_ELTYPE_CODE CV_8UC1 /* freeman code: 0..7 */
|
1467
|
+
#define CV_SEQ_ELTYPE_GENERIC 0
|
1468
|
+
#define CV_SEQ_ELTYPE_PTR CV_USRTYPE1
|
1469
|
+
#define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /* &(x,y) */
|
1470
|
+
#define CV_SEQ_ELTYPE_INDEX CV_32SC1 /* #(x,y) */
|
1471
|
+
#define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /* &next_o, &next_d, &vtx_o, &vtx_d */
|
1472
|
+
#define CV_SEQ_ELTYPE_GRAPH_VERTEX 0 /* first_edge, &(x,y) */
|
1473
|
+
#define CV_SEQ_ELTYPE_TRIAN_ATR 0 /* vertex of the binary tree */
|
1474
|
+
#define CV_SEQ_ELTYPE_CONNECTED_COMP 0 /* connected component */
|
1475
|
+
#define CV_SEQ_ELTYPE_POINT3D CV_32FC3 /* (x,y,z) */
|
1476
|
+
|
1477
|
+
#define CV_SEQ_KIND_BITS 2
|
1478
|
+
#define CV_SEQ_KIND_MASK (((1 << CV_SEQ_KIND_BITS) - 1)<<CV_SEQ_ELTYPE_BITS)
|
1479
|
+
|
1480
|
+
/* types of sequences */
|
1481
|
+
#define CV_SEQ_KIND_GENERIC (0 << CV_SEQ_ELTYPE_BITS)
|
1482
|
+
#define CV_SEQ_KIND_CURVE (1 << CV_SEQ_ELTYPE_BITS)
|
1483
|
+
#define CV_SEQ_KIND_BIN_TREE (2 << CV_SEQ_ELTYPE_BITS)
|
1484
|
+
|
1485
|
+
/* types of sparse sequences (sets) */
|
1486
|
+
#define CV_SEQ_KIND_GRAPH (1 << CV_SEQ_ELTYPE_BITS)
|
1487
|
+
#define CV_SEQ_KIND_SUBDIV2D (2 << CV_SEQ_ELTYPE_BITS)
|
1488
|
+
|
1489
|
+
#define CV_SEQ_FLAG_SHIFT (CV_SEQ_KIND_BITS + CV_SEQ_ELTYPE_BITS)
|
1490
|
+
|
1491
|
+
/* flags for curves */
|
1492
|
+
#define CV_SEQ_FLAG_CLOSED (1 << CV_SEQ_FLAG_SHIFT)
|
1493
|
+
#define CV_SEQ_FLAG_SIMPLE (0 << CV_SEQ_FLAG_SHIFT)
|
1494
|
+
#define CV_SEQ_FLAG_CONVEX (0 << CV_SEQ_FLAG_SHIFT)
|
1495
|
+
#define CV_SEQ_FLAG_HOLE (2 << CV_SEQ_FLAG_SHIFT)
|
1496
|
+
|
1497
|
+
/* flags for graphs */
|
1498
|
+
#define CV_GRAPH_FLAG_ORIENTED (1 << CV_SEQ_FLAG_SHIFT)
|
1499
|
+
|
1500
|
+
#define CV_GRAPH CV_SEQ_KIND_GRAPH
|
1501
|
+
#define CV_ORIENTED_GRAPH (CV_SEQ_KIND_GRAPH|CV_GRAPH_FLAG_ORIENTED)
|
1502
|
+
|
1503
|
+
/* point sets */
|
1504
|
+
#define CV_SEQ_POINT_SET (CV_SEQ_KIND_GENERIC| CV_SEQ_ELTYPE_POINT)
|
1505
|
+
#define CV_SEQ_POINT3D_SET (CV_SEQ_KIND_GENERIC| CV_SEQ_ELTYPE_POINT3D)
|
1506
|
+
#define CV_SEQ_POLYLINE (CV_SEQ_KIND_CURVE | CV_SEQ_ELTYPE_POINT)
|
1507
|
+
#define CV_SEQ_POLYGON (CV_SEQ_FLAG_CLOSED | CV_SEQ_POLYLINE )
|
1508
|
+
#define CV_SEQ_CONTOUR CV_SEQ_POLYGON
|
1509
|
+
#define CV_SEQ_SIMPLE_POLYGON (CV_SEQ_FLAG_SIMPLE | CV_SEQ_POLYGON )
|
1510
|
+
|
1511
|
+
/* chain-coded curves */
|
1512
|
+
#define CV_SEQ_CHAIN (CV_SEQ_KIND_CURVE | CV_SEQ_ELTYPE_CODE)
|
1513
|
+
#define CV_SEQ_CHAIN_CONTOUR (CV_SEQ_FLAG_CLOSED | CV_SEQ_CHAIN)
|
1514
|
+
|
1515
|
+
/* binary tree for the contour */
|
1516
|
+
#define CV_SEQ_POLYGON_TREE (CV_SEQ_KIND_BIN_TREE | CV_SEQ_ELTYPE_TRIAN_ATR)
|
1517
|
+
|
1518
|
+
/* sequence of the connected components */
|
1519
|
+
#define CV_SEQ_CONNECTED_COMP (CV_SEQ_KIND_GENERIC | CV_SEQ_ELTYPE_CONNECTED_COMP)
|
1520
|
+
|
1521
|
+
/* sequence of the integer numbers */
|
1522
|
+
#define CV_SEQ_INDEX (CV_SEQ_KIND_GENERIC | CV_SEQ_ELTYPE_INDEX)
|
1523
|
+
|
1524
|
+
#define CV_SEQ_ELTYPE( seq ) ((seq)->flags & CV_SEQ_ELTYPE_MASK)
|
1525
|
+
#define CV_SEQ_KIND( seq ) ((seq)->flags & CV_SEQ_KIND_MASK )
|
1526
|
+
|
1527
|
+
/* flag checking */
|
1528
|
+
#define CV_IS_SEQ_INDEX( seq ) ((CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_INDEX) && \
|
1529
|
+
(CV_SEQ_KIND(seq) == CV_SEQ_KIND_GENERIC))
|
1530
|
+
|
1531
|
+
#define CV_IS_SEQ_CURVE( seq ) (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE)
|
1532
|
+
#define CV_IS_SEQ_CLOSED( seq ) (((seq)->flags & CV_SEQ_FLAG_CLOSED) != 0)
|
1533
|
+
#define CV_IS_SEQ_CONVEX( seq ) 0
|
1534
|
+
#define CV_IS_SEQ_HOLE( seq ) (((seq)->flags & CV_SEQ_FLAG_HOLE) != 0)
|
1535
|
+
#define CV_IS_SEQ_SIMPLE( seq ) 1
|
1536
|
+
|
1537
|
+
/* type checking macros */
|
1538
|
+
#define CV_IS_SEQ_POINT_SET( seq ) \
|
1539
|
+
((CV_SEQ_ELTYPE(seq) == CV_32SC2 || CV_SEQ_ELTYPE(seq) == CV_32FC2))
|
1540
|
+
|
1541
|
+
#define CV_IS_SEQ_POINT_SUBSET( seq ) \
|
1542
|
+
(CV_IS_SEQ_INDEX( seq ) || CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_PPOINT)
|
1543
|
+
|
1544
|
+
#define CV_IS_SEQ_POLYLINE( seq ) \
|
1545
|
+
(CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && CV_IS_SEQ_POINT_SET(seq))
|
1546
|
+
|
1547
|
+
#define CV_IS_SEQ_POLYGON( seq ) \
|
1548
|
+
(CV_IS_SEQ_POLYLINE(seq) && CV_IS_SEQ_CLOSED(seq))
|
1549
|
+
|
1550
|
+
#define CV_IS_SEQ_CHAIN( seq ) \
|
1551
|
+
(CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && (seq)->elem_size == 1)
|
1552
|
+
|
1553
|
+
#define CV_IS_SEQ_CONTOUR( seq ) \
|
1554
|
+
(CV_IS_SEQ_CLOSED(seq) && (CV_IS_SEQ_POLYLINE(seq) || CV_IS_SEQ_CHAIN(seq)))
|
1555
|
+
|
1556
|
+
#define CV_IS_SEQ_CHAIN_CONTOUR( seq ) \
|
1557
|
+
(CV_IS_SEQ_CHAIN( seq ) && CV_IS_SEQ_CLOSED( seq ))
|
1558
|
+
|
1559
|
+
#define CV_IS_SEQ_POLYGON_TREE( seq ) \
|
1560
|
+
(CV_SEQ_ELTYPE (seq) == CV_SEQ_ELTYPE_TRIAN_ATR && \
|
1561
|
+
CV_SEQ_KIND( seq ) == CV_SEQ_KIND_BIN_TREE )
|
1562
|
+
|
1563
|
+
#define CV_IS_GRAPH( seq ) \
|
1564
|
+
(CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_GRAPH)
|
1565
|
+
|
1566
|
+
#define CV_IS_GRAPH_ORIENTED( seq ) \
|
1567
|
+
(((seq)->flags & CV_GRAPH_FLAG_ORIENTED) != 0)
|
1568
|
+
|
1569
|
+
#define CV_IS_SUBDIV2D( seq ) \
|
1570
|
+
(CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_SUBDIV2D)
|
1571
|
+
|
1572
|
+
/****************************************************************************************/
|
1573
|
+
/* Sequence writer & reader */
|
1574
|
+
/****************************************************************************************/
|
1575
|
+
|
1576
|
+
#define CV_SEQ_WRITER_FIELDS() \
|
1577
|
+
int header_size; \
|
1578
|
+
CvSeq* seq; /* the sequence written */ \
|
1579
|
+
CvSeqBlock* block; /* current block */ \
|
1580
|
+
schar* ptr; /* pointer to free space */ \
|
1581
|
+
schar* block_min; /* pointer to the beginning of block*/\
|
1582
|
+
schar* block_max; /* pointer to the end of block */
|
1583
|
+
|
1584
|
+
typedef struct CvSeqWriter
|
1585
|
+
{
|
1586
|
+
CV_SEQ_WRITER_FIELDS()
|
1587
|
+
}
|
1588
|
+
CvSeqWriter;
|
1589
|
+
|
1590
|
+
|
1591
|
+
#define CV_SEQ_READER_FIELDS() \
|
1592
|
+
int header_size; \
|
1593
|
+
CvSeq* seq; /* sequence, beign read */ \
|
1594
|
+
CvSeqBlock* block; /* current block */ \
|
1595
|
+
schar* ptr; /* pointer to element be read next */ \
|
1596
|
+
schar* block_min; /* pointer to the beginning of block */\
|
1597
|
+
schar* block_max; /* pointer to the end of block */ \
|
1598
|
+
int delta_index;/* = seq->first->start_index */ \
|
1599
|
+
schar* prev_elem; /* pointer to previous element */
|
1600
|
+
|
1601
|
+
|
1602
|
+
typedef struct CvSeqReader
|
1603
|
+
{
|
1604
|
+
CV_SEQ_READER_FIELDS()
|
1605
|
+
}
|
1606
|
+
CvSeqReader;
|
1607
|
+
|
1608
|
+
/****************************************************************************************/
|
1609
|
+
/* Operations on sequences */
|
1610
|
+
/****************************************************************************************/
|
1611
|
+
|
1612
|
+
#define CV_SEQ_ELEM( seq, elem_type, index ) \
|
1613
|
+
/* assert gives some guarantee that <seq> parameter is valid */ \
|
1614
|
+
( assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) && \
|
1615
|
+
(seq)->elem_size == sizeof(elem_type)), \
|
1616
|
+
(elem_type*)((seq)->first && (unsigned)index < \
|
1617
|
+
(unsigned)((seq)->first->count) ? \
|
1618
|
+
(seq)->first->data + (index) * sizeof(elem_type) : \
|
1619
|
+
cvGetSeqElem( (CvSeq*)(seq), (index) )))
|
1620
|
+
#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) )
|
1621
|
+
|
1622
|
+
/* Add element to sequence: */
|
1623
|
+
#define CV_WRITE_SEQ_ELEM_VAR( elem_ptr, writer ) \
|
1624
|
+
{ \
|
1625
|
+
if( (writer).ptr >= (writer).block_max ) \
|
1626
|
+
{ \
|
1627
|
+
cvCreateSeqBlock( &writer); \
|
1628
|
+
} \
|
1629
|
+
memcpy((writer).ptr, elem_ptr, (writer).seq->elem_size);\
|
1630
|
+
(writer).ptr += (writer).seq->elem_size; \
|
1631
|
+
}
|
1632
|
+
|
1633
|
+
#define CV_WRITE_SEQ_ELEM( elem, writer ) \
|
1634
|
+
{ \
|
1635
|
+
assert( (writer).seq->elem_size == sizeof(elem)); \
|
1636
|
+
if( (writer).ptr >= (writer).block_max ) \
|
1637
|
+
{ \
|
1638
|
+
cvCreateSeqBlock( &writer); \
|
1639
|
+
} \
|
1640
|
+
assert( (writer).ptr <= (writer).block_max - sizeof(elem));\
|
1641
|
+
memcpy((writer).ptr, &(elem), sizeof(elem)); \
|
1642
|
+
(writer).ptr += sizeof(elem); \
|
1643
|
+
}
|
1644
|
+
|
1645
|
+
|
1646
|
+
/* Move reader position forward: */
|
1647
|
+
#define CV_NEXT_SEQ_ELEM( elem_size, reader ) \
|
1648
|
+
{ \
|
1649
|
+
if( ((reader).ptr += (elem_size)) >= (reader).block_max ) \
|
1650
|
+
{ \
|
1651
|
+
cvChangeSeqBlock( &(reader), 1 ); \
|
1652
|
+
} \
|
1653
|
+
}
|
1654
|
+
|
1655
|
+
|
1656
|
+
/* Move reader position backward: */
|
1657
|
+
#define CV_PREV_SEQ_ELEM( elem_size, reader ) \
|
1658
|
+
{ \
|
1659
|
+
if( ((reader).ptr -= (elem_size)) < (reader).block_min ) \
|
1660
|
+
{ \
|
1661
|
+
cvChangeSeqBlock( &(reader), -1 ); \
|
1662
|
+
} \
|
1663
|
+
}
|
1664
|
+
|
1665
|
+
/* Read element and move read position forward: */
|
1666
|
+
#define CV_READ_SEQ_ELEM( elem, reader ) \
|
1667
|
+
{ \
|
1668
|
+
assert( (reader).seq->elem_size == sizeof(elem)); \
|
1669
|
+
memcpy( &(elem), (reader).ptr, sizeof((elem))); \
|
1670
|
+
CV_NEXT_SEQ_ELEM( sizeof(elem), reader ) \
|
1671
|
+
}
|
1672
|
+
|
1673
|
+
/* Read element and move read position backward: */
|
1674
|
+
#define CV_REV_READ_SEQ_ELEM( elem, reader ) \
|
1675
|
+
{ \
|
1676
|
+
assert( (reader).seq->elem_size == sizeof(elem)); \
|
1677
|
+
memcpy(&(elem), (reader).ptr, sizeof((elem))); \
|
1678
|
+
CV_PREV_SEQ_ELEM( sizeof(elem), reader ) \
|
1679
|
+
}
|
1680
|
+
|
1681
|
+
|
1682
|
+
#define CV_READ_CHAIN_POINT( _pt, reader ) \
|
1683
|
+
{ \
|
1684
|
+
(_pt) = (reader).pt; \
|
1685
|
+
if( (reader).ptr ) \
|
1686
|
+
{ \
|
1687
|
+
CV_READ_SEQ_ELEM( (reader).code, (reader)); \
|
1688
|
+
assert( ((reader).code & ~7) == 0 ); \
|
1689
|
+
(reader).pt.x += (reader).deltas[(int)(reader).code][0]; \
|
1690
|
+
(reader).pt.y += (reader).deltas[(int)(reader).code][1]; \
|
1691
|
+
} \
|
1692
|
+
}
|
1693
|
+
|
1694
|
+
#define CV_CURRENT_POINT( reader ) (*((CvPoint*)((reader).ptr)))
|
1695
|
+
#define CV_PREV_POINT( reader ) (*((CvPoint*)((reader).prev_elem)))
|
1696
|
+
|
1697
|
+
#define CV_READ_EDGE( pt1, pt2, reader ) \
|
1698
|
+
{ \
|
1699
|
+
assert( sizeof(pt1) == sizeof(CvPoint) && \
|
1700
|
+
sizeof(pt2) == sizeof(CvPoint) && \
|
1701
|
+
reader.seq->elem_size == sizeof(CvPoint)); \
|
1702
|
+
(pt1) = CV_PREV_POINT( reader ); \
|
1703
|
+
(pt2) = CV_CURRENT_POINT( reader ); \
|
1704
|
+
(reader).prev_elem = (reader).ptr; \
|
1705
|
+
CV_NEXT_SEQ_ELEM( sizeof(CvPoint), (reader)); \
|
1706
|
+
}
|
1707
|
+
|
1708
|
+
/************ Graph macros ************/
|
1709
|
+
|
1710
|
+
/* Return next graph edge for given vertex: */
|
1711
|
+
#define CV_NEXT_GRAPH_EDGE( edge, vertex ) \
|
1712
|
+
(assert((edge)->vtx[0] == (vertex) || (edge)->vtx[1] == (vertex)), \
|
1713
|
+
(edge)->next[(edge)->vtx[1] == (vertex)])
|
1714
|
+
|
1715
|
+
|
1716
|
+
|
1717
|
+
/****************************************************************************************\
|
1718
|
+
* Data structures for persistence (a.k.a serialization) functionality *
|
1719
|
+
\****************************************************************************************/
|
1720
|
+
|
1721
|
+
/* "black box" file storage */
|
1722
|
+
typedef struct CvFileStorage CvFileStorage;
|
1723
|
+
|
1724
|
+
/* Storage flags: */
|
1725
|
+
#define CV_STORAGE_READ 0
|
1726
|
+
#define CV_STORAGE_WRITE 1
|
1727
|
+
#define CV_STORAGE_WRITE_TEXT CV_STORAGE_WRITE
|
1728
|
+
#define CV_STORAGE_WRITE_BINARY CV_STORAGE_WRITE
|
1729
|
+
#define CV_STORAGE_APPEND 2
|
1730
|
+
|
1731
|
+
/* List of attributes: */
|
1732
|
+
typedef struct CvAttrList
|
1733
|
+
{
|
1734
|
+
const char** attr; /* NULL-terminated array of (attribute_name,attribute_value) pairs. */
|
1735
|
+
struct CvAttrList* next; /* Pointer to next chunk of the attributes list. */
|
1736
|
+
}
|
1737
|
+
CvAttrList;
|
1738
|
+
|
1739
|
+
CV_INLINE CvAttrList cvAttrList( const char** attr CV_DEFAULT(NULL),
|
1740
|
+
CvAttrList* next CV_DEFAULT(NULL) )
|
1741
|
+
{
|
1742
|
+
CvAttrList l;
|
1743
|
+
l.attr = attr;
|
1744
|
+
l.next = next;
|
1745
|
+
|
1746
|
+
return l;
|
1747
|
+
}
|
1748
|
+
|
1749
|
+
struct CvTypeInfo;
|
1750
|
+
|
1751
|
+
#define CV_NODE_NONE 0
|
1752
|
+
#define CV_NODE_INT 1
|
1753
|
+
#define CV_NODE_INTEGER CV_NODE_INT
|
1754
|
+
#define CV_NODE_REAL 2
|
1755
|
+
#define CV_NODE_FLOAT CV_NODE_REAL
|
1756
|
+
#define CV_NODE_STR 3
|
1757
|
+
#define CV_NODE_STRING CV_NODE_STR
|
1758
|
+
#define CV_NODE_REF 4 /* not used */
|
1759
|
+
#define CV_NODE_SEQ 5
|
1760
|
+
#define CV_NODE_MAP 6
|
1761
|
+
#define CV_NODE_TYPE_MASK 7
|
1762
|
+
|
1763
|
+
#define CV_NODE_TYPE(flags) ((flags) & CV_NODE_TYPE_MASK)
|
1764
|
+
|
1765
|
+
/* file node flags */
|
1766
|
+
#define CV_NODE_FLOW 8 /* Used only for writing structures in YAML format. */
|
1767
|
+
#define CV_NODE_USER 16
|
1768
|
+
#define CV_NODE_EMPTY 32
|
1769
|
+
#define CV_NODE_NAMED 64
|
1770
|
+
|
1771
|
+
#define CV_NODE_IS_INT(flags) (CV_NODE_TYPE(flags) == CV_NODE_INT)
|
1772
|
+
#define CV_NODE_IS_REAL(flags) (CV_NODE_TYPE(flags) == CV_NODE_REAL)
|
1773
|
+
#define CV_NODE_IS_STRING(flags) (CV_NODE_TYPE(flags) == CV_NODE_STRING)
|
1774
|
+
#define CV_NODE_IS_SEQ(flags) (CV_NODE_TYPE(flags) == CV_NODE_SEQ)
|
1775
|
+
#define CV_NODE_IS_MAP(flags) (CV_NODE_TYPE(flags) == CV_NODE_MAP)
|
1776
|
+
#define CV_NODE_IS_COLLECTION(flags) (CV_NODE_TYPE(flags) >= CV_NODE_SEQ)
|
1777
|
+
#define CV_NODE_IS_FLOW(flags) (((flags) & CV_NODE_FLOW) != 0)
|
1778
|
+
#define CV_NODE_IS_EMPTY(flags) (((flags) & CV_NODE_EMPTY) != 0)
|
1779
|
+
#define CV_NODE_IS_USER(flags) (((flags) & CV_NODE_USER) != 0)
|
1780
|
+
#define CV_NODE_HAS_NAME(flags) (((flags) & CV_NODE_NAMED) != 0)
|
1781
|
+
|
1782
|
+
#define CV_NODE_SEQ_SIMPLE 256
|
1783
|
+
#define CV_NODE_SEQ_IS_SIMPLE(seq) (((seq)->flags & CV_NODE_SEQ_SIMPLE) != 0)
|
1784
|
+
|
1785
|
+
typedef struct CvString
|
1786
|
+
{
|
1787
|
+
int len;
|
1788
|
+
char* ptr;
|
1789
|
+
}
|
1790
|
+
CvString;
|
1791
|
+
|
1792
|
+
/* All the keys (names) of elements in the readed file storage
|
1793
|
+
are stored in the hash to speed up the lookup operations: */
|
1794
|
+
typedef struct CvStringHashNode
|
1795
|
+
{
|
1796
|
+
unsigned hashval;
|
1797
|
+
CvString str;
|
1798
|
+
struct CvStringHashNode* next;
|
1799
|
+
}
|
1800
|
+
CvStringHashNode;
|
1801
|
+
|
1802
|
+
typedef struct CvGenericHash CvFileNodeHash;
|
1803
|
+
|
1804
|
+
/* Basic element of the file storage - scalar or collection: */
|
1805
|
+
typedef struct CvFileNode
|
1806
|
+
{
|
1807
|
+
int tag;
|
1808
|
+
struct CvTypeInfo* info; /* type information
|
1809
|
+
(only for user-defined object, for others it is 0) */
|
1810
|
+
union
|
1811
|
+
{
|
1812
|
+
double f; /* scalar floating-point number */
|
1813
|
+
int i; /* scalar integer number */
|
1814
|
+
CvString str; /* text string */
|
1815
|
+
CvSeq* seq; /* sequence (ordered collection of file nodes) */
|
1816
|
+
CvFileNodeHash* map; /* map (collection of named file nodes) */
|
1817
|
+
} data;
|
1818
|
+
}
|
1819
|
+
CvFileNode;
|
1820
|
+
|
1821
|
+
#ifdef __cplusplus
|
1822
|
+
extern "C" {
|
1823
|
+
#endif
|
1824
|
+
typedef int (CV_CDECL *CvIsInstanceFunc)( const void* struct_ptr );
|
1825
|
+
typedef void (CV_CDECL *CvReleaseFunc)( void** struct_dblptr );
|
1826
|
+
typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node );
|
1827
|
+
typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name,
|
1828
|
+
const void* struct_ptr, CvAttrList attributes );
|
1829
|
+
typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr );
|
1830
|
+
#ifdef __cplusplus
|
1831
|
+
}
|
1832
|
+
#endif
|
1833
|
+
|
1834
|
+
typedef struct CvTypeInfo
|
1835
|
+
{
|
1836
|
+
int flags;
|
1837
|
+
int header_size;
|
1838
|
+
struct CvTypeInfo* prev;
|
1839
|
+
struct CvTypeInfo* next;
|
1840
|
+
const char* type_name;
|
1841
|
+
CvIsInstanceFunc is_instance;
|
1842
|
+
CvReleaseFunc release;
|
1843
|
+
CvReadFunc read;
|
1844
|
+
CvWriteFunc write;
|
1845
|
+
CvCloneFunc clone;
|
1846
|
+
}
|
1847
|
+
CvTypeInfo;
|
1848
|
+
|
1849
|
+
|
1850
|
+
/**** System data types ******/
|
1851
|
+
|
1852
|
+
typedef struct CvPluginFuncInfo
|
1853
|
+
{
|
1854
|
+
void** func_addr;
|
1855
|
+
void* default_func_addr;
|
1856
|
+
const char* func_names;
|
1857
|
+
int search_modules;
|
1858
|
+
int loaded_from;
|
1859
|
+
}
|
1860
|
+
CvPluginFuncInfo;
|
1861
|
+
|
1862
|
+
typedef struct CvModuleInfo
|
1863
|
+
{
|
1864
|
+
struct CvModuleInfo* next;
|
1865
|
+
const char* name;
|
1866
|
+
const char* version;
|
1867
|
+
CvPluginFuncInfo* func_tab;
|
1868
|
+
}
|
1869
|
+
CvModuleInfo;
|
1870
|
+
|
1871
|
+
enum { CV_PARAM_TYPE_INT=0, CV_PARAM_TYPE_REAL=1, CV_PARAM_TYPE_STRING=2, CV_PARAM_TYPE_MAT=3 };
|
1872
|
+
|
1873
|
+
#endif /*_CXCORE_TYPES_H_*/
|
1874
|
+
|
1875
|
+
/* End of file. */
|