opencv 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
types_c.h
Go to the documentation of this file.
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_IMGPROC_TYPES_C_H__
44 #define __OPENCV_IMGPROC_TYPES_C_H__
45
46 #include "opencv2/core/core_c.h"
47 #include "opencv2/imgproc/types_c.h"
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 /* Connected component structure */
54 typedef struct CvConnectedComp
55 {
56 double area; /* area of the connected component */
57 CvScalar value; /* average color of the connected component */
58 CvRect rect; /* ROI of the component */
59 CvSeq* contour; /* optional component boundary
60 (the contour might have child contours corresponding to the holes)*/
61 }
62 CvConnectedComp;
63
64 /* Image smooth methods */
65 enum
66 {
67 CV_BLUR_NO_SCALE =0,
68 CV_BLUR =1,
69 CV_GAUSSIAN =2,
70 CV_MEDIAN =3,
71 CV_BILATERAL =4
72 };
73
74 /* Filters used in pyramid decomposition */
75 enum
76 {
77 CV_GAUSSIAN_5x5 = 7
78 };
79
80 /* Inpainting algorithms */
81 enum
82 {
83 CV_INPAINT_NS =0,
84 CV_INPAINT_TELEA =1
85 };
86
87 /* Special filters */
88 enum
89 {
90 CV_SCHARR =-1,
91 CV_MAX_SOBEL_KSIZE =7
92 };
93
94 /* Constants for color conversion */
95 enum
96 {
97 CV_BGR2BGRA =0,
98 CV_RGB2RGBA =CV_BGR2BGRA,
99
100 CV_BGRA2BGR =1,
101 CV_RGBA2RGB =CV_BGRA2BGR,
102
103 CV_BGR2RGBA =2,
104 CV_RGB2BGRA =CV_BGR2RGBA,
105
106 CV_RGBA2BGR =3,
107 CV_BGRA2RGB =CV_RGBA2BGR,
108
109 CV_BGR2RGB =4,
110 CV_RGB2BGR =CV_BGR2RGB,
111
112 CV_BGRA2RGBA =5,
113 CV_RGBA2BGRA =CV_BGRA2RGBA,
114
115 CV_BGR2GRAY =6,
116 CV_RGB2GRAY =7,
117 CV_GRAY2BGR =8,
118 CV_GRAY2RGB =CV_GRAY2BGR,
119 CV_GRAY2BGRA =9,
120 CV_GRAY2RGBA =CV_GRAY2BGRA,
121 CV_BGRA2GRAY =10,
122 CV_RGBA2GRAY =11,
123
124 CV_BGR2BGR565 =12,
125 CV_RGB2BGR565 =13,
126 CV_BGR5652BGR =14,
127 CV_BGR5652RGB =15,
128 CV_BGRA2BGR565 =16,
129 CV_RGBA2BGR565 =17,
130 CV_BGR5652BGRA =18,
131 CV_BGR5652RGBA =19,
132
133 CV_GRAY2BGR565 =20,
134 CV_BGR5652GRAY =21,
135
136 CV_BGR2BGR555 =22,
137 CV_RGB2BGR555 =23,
138 CV_BGR5552BGR =24,
139 CV_BGR5552RGB =25,
140 CV_BGRA2BGR555 =26,
141 CV_RGBA2BGR555 =27,
142 CV_BGR5552BGRA =28,
143 CV_BGR5552RGBA =29,
144
145 CV_GRAY2BGR555 =30,
146 CV_BGR5552GRAY =31,
147
148 CV_BGR2XYZ =32,
149 CV_RGB2XYZ =33,
150 CV_XYZ2BGR =34,
151 CV_XYZ2RGB =35,
152
153 CV_BGR2YCrCb =36,
154 CV_RGB2YCrCb =37,
155 CV_YCrCb2BGR =38,
156 CV_YCrCb2RGB =39,
157
158 CV_BGR2HSV =40,
159 CV_RGB2HSV =41,
160
161 CV_BGR2Lab =44,
162 CV_RGB2Lab =45,
163
164 CV_BayerBG2BGR =46,
165 CV_BayerGB2BGR =47,
166 CV_BayerRG2BGR =48,
167 CV_BayerGR2BGR =49,
168
169 CV_BayerBG2RGB =CV_BayerRG2BGR,
170 CV_BayerGB2RGB =CV_BayerGR2BGR,
171 CV_BayerRG2RGB =CV_BayerBG2BGR,
172 CV_BayerGR2RGB =CV_BayerGB2BGR,
173
174 CV_BGR2Luv =50,
175 CV_RGB2Luv =51,
176 CV_BGR2HLS =52,
177 CV_RGB2HLS =53,
178
179 CV_HSV2BGR =54,
180 CV_HSV2RGB =55,
181
182 CV_Lab2BGR =56,
183 CV_Lab2RGB =57,
184 CV_Luv2BGR =58,
185 CV_Luv2RGB =59,
186 CV_HLS2BGR =60,
187 CV_HLS2RGB =61,
188
189 CV_BayerBG2BGR_VNG =62,
190 CV_BayerGB2BGR_VNG =63,
191 CV_BayerRG2BGR_VNG =64,
192 CV_BayerGR2BGR_VNG =65,
193
194 CV_BayerBG2RGB_VNG =CV_BayerRG2BGR_VNG,
195 CV_BayerGB2RGB_VNG =CV_BayerGR2BGR_VNG,
196 CV_BayerRG2RGB_VNG =CV_BayerBG2BGR_VNG,
197 CV_BayerGR2RGB_VNG =CV_BayerGB2BGR_VNG,
198
199 CV_BGR2HSV_FULL = 66,
200 CV_RGB2HSV_FULL = 67,
201 CV_BGR2HLS_FULL = 68,
202 CV_RGB2HLS_FULL = 69,
203
204 CV_HSV2BGR_FULL = 70,
205 CV_HSV2RGB_FULL = 71,
206 CV_HLS2BGR_FULL = 72,
207 CV_HLS2RGB_FULL = 73,
208
209 CV_LBGR2Lab = 74,
210 CV_LRGB2Lab = 75,
211 CV_LBGR2Luv = 76,
212 CV_LRGB2Luv = 77,
213
214 CV_Lab2LBGR = 78,
215 CV_Lab2LRGB = 79,
216 CV_Luv2LBGR = 80,
217 CV_Luv2LRGB = 81,
218
219 CV_BGR2YUV = 82,
220 CV_RGB2YUV = 83,
221 CV_YUV2BGR = 84,
222 CV_YUV2RGB = 85,
223
224 CV_COLORCVT_MAX =100
225 };
226
227
228 /* Sub-pixel interpolation methods */
229 enum
230 {
231 CV_INTER_NN =0,
232 CV_INTER_LINEAR =1,
233 CV_INTER_CUBIC =2,
234 CV_INTER_AREA =3,
235 CV_INTER_LANCZOS4 =4
236 };
237
238 /* ... and other image warping flags */
239 enum
240 {
241 CV_WARP_FILL_OUTLIERS =8,
242 CV_WARP_INVERSE_MAP =16
243 };
244
245 /* Shapes of a structuring element for morphological operations */
246 enum
247 {
248 CV_SHAPE_RECT =0,
249 CV_SHAPE_CROSS =1,
250 CV_SHAPE_ELLIPSE =2,
251 CV_SHAPE_CUSTOM =100
252 };
253
254 /* Morphological operations */
255 enum
256 {
257 CV_MOP_ERODE =0,
258 CV_MOP_DILATE =1,
259 CV_MOP_OPEN =2,
260 CV_MOP_CLOSE =3,
261 CV_MOP_GRADIENT =4,
262 CV_MOP_TOPHAT =5,
263 CV_MOP_BLACKHAT =6
264 };
265
266 /* Spatial and central moments */
267 typedef struct CvMoments
268 {
269 double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; /* spatial moments */
270 double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /* central moments */
271 double inv_sqrt_m00; /* m00 != 0 ? 1/sqrt(m00) : 0 */
272 }
273 CvMoments;
274
275 /* Hu invariants */
276 typedef struct CvHuMoments
277 {
278 double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /* Hu invariants */
279 }
280 CvHuMoments;
281
282 /* Template matching methods */
283 enum
284 {
285 CV_TM_SQDIFF =0,
286 CV_TM_SQDIFF_NORMED =1,
287 CV_TM_CCORR =2,
288 CV_TM_CCORR_NORMED =3,
289 CV_TM_CCOEFF =4,
290 CV_TM_CCOEFF_NORMED =5
291 };
292
293 typedef float (CV_CDECL * CvDistanceFunction)( const float* a, const float* b, void* user_param );
294
295 /* Contour retrieval modes */
296 enum
297 {
298 CV_RETR_EXTERNAL=0,
299 CV_RETR_LIST=1,
300 CV_RETR_CCOMP=2,
301 CV_RETR_TREE=3
302 };
303
304 /* Contour approximation methods */
305 enum
306 {
307 CV_CHAIN_CODE=0,
308 CV_CHAIN_APPROX_NONE=1,
309 CV_CHAIN_APPROX_SIMPLE=2,
310 CV_CHAIN_APPROX_TC89_L1=3,
311 CV_CHAIN_APPROX_TC89_KCOS=4,
312 CV_LINK_RUNS=5
313 };
314
315 /*
316 Internal structure that is used for sequental retrieving contours from the image.
317 It supports both hierarchical and plane variants of Suzuki algorithm.
318 */
319 typedef struct _CvContourScanner* CvContourScanner;
320
321 /* Freeman chain reader state */
322 typedef struct CvChainPtReader
323 {
324 CV_SEQ_READER_FIELDS()
325 char code;
326 CvPoint pt;
327 schar deltas[8][2];
328 }
329 CvChainPtReader;
330
331 /* initializes 8-element array for fast access to 3x3 neighborhood of a pixel */
332 #define CV_INIT_3X3_DELTAS( deltas, step, nch ) \
333 ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
334 (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
335 (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
336 (deltas)[6] = (step), (deltas)[7] = (step) + (nch))
337
338
339 /****************************************************************************************\
340 * Planar subdivisions *
341 \****************************************************************************************/
342
343 typedef size_t CvSubdiv2DEdge;
344
345 #define CV_QUADEDGE2D_FIELDS() \
346 int flags; \
347 struct CvSubdiv2DPoint* pt[4]; \
348 CvSubdiv2DEdge next[4];
349
350 #define CV_SUBDIV2D_POINT_FIELDS()\
351 int flags; \
352 CvSubdiv2DEdge first; \
353 CvPoint2D32f pt; \
354 int id;
355
356 #define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30)
357
358 typedef struct CvQuadEdge2D
359 {
360 CV_QUADEDGE2D_FIELDS()
361 }
362 CvQuadEdge2D;
363
364 typedef struct CvSubdiv2DPoint
365 {
366 CV_SUBDIV2D_POINT_FIELDS()
367 }
368 CvSubdiv2DPoint;
369
370 #define CV_SUBDIV2D_FIELDS() \
371 CV_GRAPH_FIELDS() \
372 int quad_edges; \
373 int is_geometry_valid; \
374 CvSubdiv2DEdge recent_edge; \
375 CvPoint2D32f topleft; \
376 CvPoint2D32f bottomright;
377
378 typedef struct CvSubdiv2D
379 {
380 CV_SUBDIV2D_FIELDS()
381 }
382 CvSubdiv2D;
383
384
385 typedef enum CvSubdiv2DPointLocation
386 {
387 CV_PTLOC_ERROR = -2,
388 CV_PTLOC_OUTSIDE_RECT = -1,
389 CV_PTLOC_INSIDE = 0,
390 CV_PTLOC_VERTEX = 1,
391 CV_PTLOC_ON_EDGE = 2
392 }
393 CvSubdiv2DPointLocation;
394
395 typedef enum CvNextEdgeType
396 {
397 CV_NEXT_AROUND_ORG = 0x00,
398 CV_NEXT_AROUND_DST = 0x22,
399 CV_PREV_AROUND_ORG = 0x11,
400 CV_PREV_AROUND_DST = 0x33,
401 CV_NEXT_AROUND_LEFT = 0x13,
402 CV_NEXT_AROUND_RIGHT = 0x31,
403 CV_PREV_AROUND_LEFT = 0x20,
404 CV_PREV_AROUND_RIGHT = 0x02
405 }
406 CvNextEdgeType;
407
408 /* get the next edge with the same origin point (counterwise) */
409 #define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3])
410
411
412 /* Contour approximation algorithms */
413 enum
414 {
415 CV_POLY_APPROX_DP = 0
416 };
417
418 /* Shape matching methods */
419 enum
420 {
421 CV_CONTOURS_MATCH_I1 =1,
422 CV_CONTOURS_MATCH_I2 =2,
423 CV_CONTOURS_MATCH_I3 =3
424 };
425
426 /* Shape orientation */
427 enum
428 {
429 CV_CLOCKWISE =1,
430 CV_COUNTER_CLOCKWISE =2
431 };
432
433
434 /* Convexity defect */
435 typedef struct CvConvexityDefect
436 {
437 CvPoint* start; /* point of the contour where the defect begins */
438 CvPoint* end; /* point of the contour where the defect ends */
439 CvPoint* depth_point; /* the farthest from the convex hull point within the defect */
440 float depth; /* distance between the farthest point and the convex hull */
441 } CvConvexityDefect;
442
443
444 /* Histogram comparison methods */
445 enum
446 {
447 CV_COMP_CORREL =0,
448 CV_COMP_CHISQR =1,
449 CV_COMP_INTERSECT =2,
450 CV_COMP_BHATTACHARYYA =3
451 };
452
453 /* Mask size for distance transform */
454 enum
455 {
456 CV_DIST_MASK_3 =3,
457 CV_DIST_MASK_5 =5,
458 CV_DIST_MASK_PRECISE =0
459 };
460
461 /* Distance types for Distance Transform and M-estimators */
462 enum
463 {
464 CV_DIST_USER =-1, /* User defined distance */
465 CV_DIST_L1 =1, /* distance = |x1-x2| + |y1-y2| */
466 CV_DIST_L2 =2, /* the simple euclidean distance */
467 CV_DIST_C =3, /* distance = max(|x1-x2|,|y1-y2|) */
468 CV_DIST_L12 =4, /* L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */
469 CV_DIST_FAIR =5, /* distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */
470 CV_DIST_WELSCH =6, /* distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */
471 CV_DIST_HUBER =7 /* distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345 */
472 };
473
474
475 /* Threshold types */
476 enum
477 {
478 CV_THRESH_BINARY =0, /* value = value > threshold ? max_value : 0 */
479 CV_THRESH_BINARY_INV =1, /* value = value > threshold ? 0 : max_value */
480 CV_THRESH_TRUNC =2, /* value = value > threshold ? threshold : value */
481 CV_THRESH_TOZERO =3, /* value = value > threshold ? value : 0 */
482 CV_THRESH_TOZERO_INV =4, /* value = value > threshold ? 0 : value */
483 CV_THRESH_MASK =7,
484 CV_THRESH_OTSU =8 /* use Otsu algorithm to choose the optimal threshold value;
485 combine the flag with one of the above CV_THRESH_* values */
486 };
487
488 /* Adaptive threshold methods */
489 enum
490 {
491 CV_ADAPTIVE_THRESH_MEAN_C =0,
492 CV_ADAPTIVE_THRESH_GAUSSIAN_C =1
493 };
494
495 /* FloodFill flags */
496 enum
497 {
498 CV_FLOODFILL_FIXED_RANGE =(1 << 16),
499 CV_FLOODFILL_MASK_ONLY =(1 << 17)
500 };
501
502
503 /* Canny edge detector flags */
504 enum
505 {
506 CV_CANNY_L2_GRADIENT =(1 << 31)
507 };
508
509 /* Variants of a Hough transform */
510 enum
511 {
512 CV_HOUGH_STANDARD =0,
513 CV_HOUGH_PROBABILISTIC =1,
514 CV_HOUGH_MULTI_SCALE =2,
515 CV_HOUGH_GRADIENT =3
516 };
517
518
519 /* Fast search data structures */
520 struct CvFeatureTree;
521 struct CvLSH;
522 struct CvLSHOperations;
523
524 #ifdef __cplusplus
525 }
526 #endif
527
528 #endif