Basic doxygen documentation support
[profile/ivi/opencv.git] / modules / imgproc / include / opencv2 / imgproc.hpp
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_HPP__
44 #define __OPENCV_IMGPROC_HPP__
45
46 #include "opencv2/core.hpp"
47
48 /*! \namespace cv
49  Namespace where all the C++ OpenCV functionality resides
50  */
51 namespace cv
52 {
53
54 //! type of morphological operation
55 enum { MORPH_ERODE    = 0,
56        MORPH_DILATE   = 1,
57        MORPH_OPEN     = 2,
58        MORPH_CLOSE    = 3,
59        MORPH_GRADIENT = 4,
60        MORPH_TOPHAT   = 5,
61        MORPH_BLACKHAT = 6
62      };
63
64 //! shape of the structuring element
65 enum { MORPH_RECT    = 0,
66        MORPH_CROSS   = 1,
67        MORPH_ELLIPSE = 2
68      };
69
70 //! interpolation algorithm
71 enum { INTER_NEAREST        = 0, //!< nearest neighbor interpolation
72        INTER_LINEAR         = 1, //!< bilinear interpolation
73        INTER_CUBIC          = 2, //!< bicubic interpolation
74        INTER_AREA           = 3, //!< area-based (or super) interpolation
75        INTER_LANCZOS4       = 4, //!< Lanczos interpolation over 8x8 neighborhood
76
77        INTER_MAX            = 7, //!< mask for interpolation codes
78        WARP_FILL_OUTLIERS   = 8,
79        WARP_INVERSE_MAP     = 16
80      };
81
82 enum { INTER_BITS      = 5,
83        INTER_BITS2     = INTER_BITS * 2,
84        INTER_TAB_SIZE  = 1 << INTER_BITS,
85        INTER_TAB_SIZE2 = INTER_TAB_SIZE * INTER_TAB_SIZE
86      };
87
88 //! Distance types for Distance Transform and M-estimators
89 enum { DIST_USER    = -1,  // User defined distance
90        DIST_L1      = 1,   // distance = |x1-x2| + |y1-y2|
91        DIST_L2      = 2,   // the simple euclidean distance
92        DIST_C       = 3,   // distance = max(|x1-x2|,|y1-y2|)
93        DIST_L12     = 4,   // L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1))
94        DIST_FAIR    = 5,   // distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998
95        DIST_WELSCH  = 6,   // distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846
96        DIST_HUBER   = 7    // distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345
97 };
98
99 //! Mask size for distance transform
100 enum { DIST_MASK_3       = 3,
101        DIST_MASK_5       = 5,
102        DIST_MASK_PRECISE = 0
103      };
104
105 //! type of the threshold operation
106 enum { THRESH_BINARY     = 0, // value = value > threshold ? max_value : 0
107        THRESH_BINARY_INV = 1, // value = value > threshold ? 0 : max_value
108        THRESH_TRUNC      = 2, // value = value > threshold ? threshold : value
109        THRESH_TOZERO     = 3, // value = value > threshold ? value : 0
110        THRESH_TOZERO_INV = 4, // value = value > threshold ? 0 : value
111        THRESH_MASK       = 7,
112        THRESH_OTSU       = 8  // use Otsu algorithm to choose the optimal threshold value
113      };
114
115 //! adaptive threshold algorithm
116 enum { ADAPTIVE_THRESH_MEAN_C     = 0,
117        ADAPTIVE_THRESH_GAUSSIAN_C = 1
118      };
119
120 enum { PROJ_SPHERICAL_ORTHO  = 0,
121        PROJ_SPHERICAL_EQRECT = 1
122      };
123
124 //! class of the pixel in GrabCut algorithm
125 enum { GC_BGD    = 0,  //!< background
126        GC_FGD    = 1,  //!< foreground
127        GC_PR_BGD = 2,  //!< most probably background
128        GC_PR_FGD = 3   //!< most probably foreground
129      };
130
131 //! GrabCut algorithm flags
132 enum { GC_INIT_WITH_RECT  = 0,
133        GC_INIT_WITH_MASK  = 1,
134        GC_EVAL            = 2
135 };
136
137 //! distanceTransform algorithm flags
138 enum { DIST_LABEL_CCOMP = 0,
139        DIST_LABEL_PIXEL = 1
140      };
141
142 //! floodfill algorithm flags
143 enum { FLOODFILL_FIXED_RANGE = 1 << 16,
144        FLOODFILL_MASK_ONLY   = 1 << 17
145      };
146
147 //! type of the template matching operation
148 enum { TM_SQDIFF        = 0,
149        TM_SQDIFF_NORMED = 1,
150        TM_CCORR         = 2,
151        TM_CCORR_NORMED  = 3,
152        TM_CCOEFF        = 4,
153        TM_CCOEFF_NORMED = 5
154      };
155
156 //! connected components algorithm output formats
157 enum { CC_STAT_LEFT   = 0,
158        CC_STAT_TOP    = 1,
159        CC_STAT_WIDTH  = 2,
160        CC_STAT_HEIGHT = 3,
161        CC_STAT_AREA   = 4,
162        CC_STAT_MAX    = 5
163      };
164
165 //! mode of the contour retrieval algorithm
166 enum { RETR_EXTERNAL  = 0, //!< retrieve only the most external (top-level) contours
167        RETR_LIST      = 1, //!< retrieve all the contours without any hierarchical information
168        RETR_CCOMP     = 2, //!< retrieve the connected components (that can possibly be nested)
169        RETR_TREE      = 3, //!< retrieve all the contours and the whole hierarchy
170        RETR_FLOODFILL = 4
171      };
172
173 //! the contour approximation algorithm
174 enum { CHAIN_APPROX_NONE      = 1,
175        CHAIN_APPROX_SIMPLE    = 2,
176        CHAIN_APPROX_TC89_L1   = 3,
177        CHAIN_APPROX_TC89_KCOS = 4
178      };
179
180 //! Variants of a Hough transform
181 enum { HOUGH_STANDARD      = 0,
182        HOUGH_PROBABILISTIC = 1,
183        HOUGH_MULTI_SCALE   = 2,
184        HOUGH_GRADIENT      = 3
185      };
186
187 //! Variants of Line Segment Detector
188 enum { LSD_REFINE_NONE = 0,
189        LSD_REFINE_STD  = 1,
190        LSD_REFINE_ADV  = 2
191      };
192
193 //! Histogram comparison methods
194 enum { HISTCMP_CORREL        = 0,
195        HISTCMP_CHISQR        = 1,
196        HISTCMP_INTERSECT     = 2,
197        HISTCMP_BHATTACHARYYA = 3,
198        HISTCMP_HELLINGER     = HISTCMP_BHATTACHARYYA,
199        HISTCMP_CHISQR_ALT    = 4,
200        HISTCMP_KL_DIV        = 5
201      };
202
203 //! the color conversion code
204 enum { COLOR_BGR2BGRA     = 0,
205        COLOR_RGB2RGBA     = COLOR_BGR2BGRA,
206
207        COLOR_BGRA2BGR     = 1,
208        COLOR_RGBA2RGB     = COLOR_BGRA2BGR,
209
210        COLOR_BGR2RGBA     = 2,
211        COLOR_RGB2BGRA     = COLOR_BGR2RGBA,
212
213        COLOR_RGBA2BGR     = 3,
214        COLOR_BGRA2RGB     = COLOR_RGBA2BGR,
215
216        COLOR_BGR2RGB      = 4,
217        COLOR_RGB2BGR      = COLOR_BGR2RGB,
218
219        COLOR_BGRA2RGBA    = 5,
220        COLOR_RGBA2BGRA    = COLOR_BGRA2RGBA,
221
222        COLOR_BGR2GRAY     = 6,
223        COLOR_RGB2GRAY     = 7,
224        COLOR_GRAY2BGR     = 8,
225        COLOR_GRAY2RGB     = COLOR_GRAY2BGR,
226        COLOR_GRAY2BGRA    = 9,
227        COLOR_GRAY2RGBA    = COLOR_GRAY2BGRA,
228        COLOR_BGRA2GRAY    = 10,
229        COLOR_RGBA2GRAY    = 11,
230
231        COLOR_BGR2BGR565   = 12,
232        COLOR_RGB2BGR565   = 13,
233        COLOR_BGR5652BGR   = 14,
234        COLOR_BGR5652RGB   = 15,
235        COLOR_BGRA2BGR565  = 16,
236        COLOR_RGBA2BGR565  = 17,
237        COLOR_BGR5652BGRA  = 18,
238        COLOR_BGR5652RGBA  = 19,
239
240        COLOR_GRAY2BGR565  = 20,
241        COLOR_BGR5652GRAY  = 21,
242
243        COLOR_BGR2BGR555   = 22,
244        COLOR_RGB2BGR555   = 23,
245        COLOR_BGR5552BGR   = 24,
246        COLOR_BGR5552RGB   = 25,
247        COLOR_BGRA2BGR555  = 26,
248        COLOR_RGBA2BGR555  = 27,
249        COLOR_BGR5552BGRA  = 28,
250        COLOR_BGR5552RGBA  = 29,
251
252        COLOR_GRAY2BGR555  = 30,
253        COLOR_BGR5552GRAY  = 31,
254
255        COLOR_BGR2XYZ      = 32,
256        COLOR_RGB2XYZ      = 33,
257        COLOR_XYZ2BGR      = 34,
258        COLOR_XYZ2RGB      = 35,
259
260        COLOR_BGR2YCrCb    = 36,
261        COLOR_RGB2YCrCb    = 37,
262        COLOR_YCrCb2BGR    = 38,
263        COLOR_YCrCb2RGB    = 39,
264
265        COLOR_BGR2HSV      = 40,
266        COLOR_RGB2HSV      = 41,
267
268        COLOR_BGR2Lab      = 44,
269        COLOR_RGB2Lab      = 45,
270
271        COLOR_BGR2Luv      = 50,
272        COLOR_RGB2Luv      = 51,
273        COLOR_BGR2HLS      = 52,
274        COLOR_RGB2HLS      = 53,
275
276        COLOR_HSV2BGR      = 54,
277        COLOR_HSV2RGB      = 55,
278
279        COLOR_Lab2BGR      = 56,
280        COLOR_Lab2RGB      = 57,
281        COLOR_Luv2BGR      = 58,
282        COLOR_Luv2RGB      = 59,
283        COLOR_HLS2BGR      = 60,
284        COLOR_HLS2RGB      = 61,
285
286        COLOR_BGR2HSV_FULL = 66,
287        COLOR_RGB2HSV_FULL = 67,
288        COLOR_BGR2HLS_FULL = 68,
289        COLOR_RGB2HLS_FULL = 69,
290
291        COLOR_HSV2BGR_FULL = 70,
292        COLOR_HSV2RGB_FULL = 71,
293        COLOR_HLS2BGR_FULL = 72,
294        COLOR_HLS2RGB_FULL = 73,
295
296        COLOR_LBGR2Lab     = 74,
297        COLOR_LRGB2Lab     = 75,
298        COLOR_LBGR2Luv     = 76,
299        COLOR_LRGB2Luv     = 77,
300
301        COLOR_Lab2LBGR     = 78,
302        COLOR_Lab2LRGB     = 79,
303        COLOR_Luv2LBGR     = 80,
304        COLOR_Luv2LRGB     = 81,
305
306        COLOR_BGR2YUV      = 82,
307        COLOR_RGB2YUV      = 83,
308        COLOR_YUV2BGR      = 84,
309        COLOR_YUV2RGB      = 85,
310
311        // YUV 4:2:0 family to RGB
312        COLOR_YUV2RGB_NV12  = 90,
313        COLOR_YUV2BGR_NV12  = 91,
314        COLOR_YUV2RGB_NV21  = 92,
315        COLOR_YUV2BGR_NV21  = 93,
316        COLOR_YUV420sp2RGB  = COLOR_YUV2RGB_NV21,
317        COLOR_YUV420sp2BGR  = COLOR_YUV2BGR_NV21,
318
319        COLOR_YUV2RGBA_NV12 = 94,
320        COLOR_YUV2BGRA_NV12 = 95,
321        COLOR_YUV2RGBA_NV21 = 96,
322        COLOR_YUV2BGRA_NV21 = 97,
323        COLOR_YUV420sp2RGBA = COLOR_YUV2RGBA_NV21,
324        COLOR_YUV420sp2BGRA = COLOR_YUV2BGRA_NV21,
325
326        COLOR_YUV2RGB_YV12  = 98,
327        COLOR_YUV2BGR_YV12  = 99,
328        COLOR_YUV2RGB_IYUV  = 100,
329        COLOR_YUV2BGR_IYUV  = 101,
330        COLOR_YUV2RGB_I420  = COLOR_YUV2RGB_IYUV,
331        COLOR_YUV2BGR_I420  = COLOR_YUV2BGR_IYUV,
332        COLOR_YUV420p2RGB   = COLOR_YUV2RGB_YV12,
333        COLOR_YUV420p2BGR   = COLOR_YUV2BGR_YV12,
334
335        COLOR_YUV2RGBA_YV12 = 102,
336        COLOR_YUV2BGRA_YV12 = 103,
337        COLOR_YUV2RGBA_IYUV = 104,
338        COLOR_YUV2BGRA_IYUV = 105,
339        COLOR_YUV2RGBA_I420 = COLOR_YUV2RGBA_IYUV,
340        COLOR_YUV2BGRA_I420 = COLOR_YUV2BGRA_IYUV,
341        COLOR_YUV420p2RGBA  = COLOR_YUV2RGBA_YV12,
342        COLOR_YUV420p2BGRA  = COLOR_YUV2BGRA_YV12,
343
344        COLOR_YUV2GRAY_420  = 106,
345        COLOR_YUV2GRAY_NV21 = COLOR_YUV2GRAY_420,
346        COLOR_YUV2GRAY_NV12 = COLOR_YUV2GRAY_420,
347        COLOR_YUV2GRAY_YV12 = COLOR_YUV2GRAY_420,
348        COLOR_YUV2GRAY_IYUV = COLOR_YUV2GRAY_420,
349        COLOR_YUV2GRAY_I420 = COLOR_YUV2GRAY_420,
350        COLOR_YUV420sp2GRAY = COLOR_YUV2GRAY_420,
351        COLOR_YUV420p2GRAY  = COLOR_YUV2GRAY_420,
352
353        // YUV 4:2:2 family to RGB
354        COLOR_YUV2RGB_UYVY = 107,
355        COLOR_YUV2BGR_UYVY = 108,
356      //COLOR_YUV2RGB_VYUY = 109,
357      //COLOR_YUV2BGR_VYUY = 110,
358        COLOR_YUV2RGB_Y422 = COLOR_YUV2RGB_UYVY,
359        COLOR_YUV2BGR_Y422 = COLOR_YUV2BGR_UYVY,
360        COLOR_YUV2RGB_UYNV = COLOR_YUV2RGB_UYVY,
361        COLOR_YUV2BGR_UYNV = COLOR_YUV2BGR_UYVY,
362
363        COLOR_YUV2RGBA_UYVY = 111,
364        COLOR_YUV2BGRA_UYVY = 112,
365      //COLOR_YUV2RGBA_VYUY = 113,
366      //COLOR_YUV2BGRA_VYUY = 114,
367        COLOR_YUV2RGBA_Y422 = COLOR_YUV2RGBA_UYVY,
368        COLOR_YUV2BGRA_Y422 = COLOR_YUV2BGRA_UYVY,
369        COLOR_YUV2RGBA_UYNV = COLOR_YUV2RGBA_UYVY,
370        COLOR_YUV2BGRA_UYNV = COLOR_YUV2BGRA_UYVY,
371
372        COLOR_YUV2RGB_YUY2 = 115,
373        COLOR_YUV2BGR_YUY2 = 116,
374        COLOR_YUV2RGB_YVYU = 117,
375        COLOR_YUV2BGR_YVYU = 118,
376        COLOR_YUV2RGB_YUYV = COLOR_YUV2RGB_YUY2,
377        COLOR_YUV2BGR_YUYV = COLOR_YUV2BGR_YUY2,
378        COLOR_YUV2RGB_YUNV = COLOR_YUV2RGB_YUY2,
379        COLOR_YUV2BGR_YUNV = COLOR_YUV2BGR_YUY2,
380
381        COLOR_YUV2RGBA_YUY2 = 119,
382        COLOR_YUV2BGRA_YUY2 = 120,
383        COLOR_YUV2RGBA_YVYU = 121,
384        COLOR_YUV2BGRA_YVYU = 122,
385        COLOR_YUV2RGBA_YUYV = COLOR_YUV2RGBA_YUY2,
386        COLOR_YUV2BGRA_YUYV = COLOR_YUV2BGRA_YUY2,
387        COLOR_YUV2RGBA_YUNV = COLOR_YUV2RGBA_YUY2,
388        COLOR_YUV2BGRA_YUNV = COLOR_YUV2BGRA_YUY2,
389
390        COLOR_YUV2GRAY_UYVY = 123,
391        COLOR_YUV2GRAY_YUY2 = 124,
392      //CV_YUV2GRAY_VYUY    = CV_YUV2GRAY_UYVY,
393        COLOR_YUV2GRAY_Y422 = COLOR_YUV2GRAY_UYVY,
394        COLOR_YUV2GRAY_UYNV = COLOR_YUV2GRAY_UYVY,
395        COLOR_YUV2GRAY_YVYU = COLOR_YUV2GRAY_YUY2,
396        COLOR_YUV2GRAY_YUYV = COLOR_YUV2GRAY_YUY2,
397        COLOR_YUV2GRAY_YUNV = COLOR_YUV2GRAY_YUY2,
398
399        // alpha premultiplication
400        COLOR_RGBA2mRGBA    = 125,
401        COLOR_mRGBA2RGBA    = 126,
402
403        // RGB to YUV 4:2:0 family
404        COLOR_RGB2YUV_I420  = 127,
405        COLOR_BGR2YUV_I420  = 128,
406        COLOR_RGB2YUV_IYUV  = COLOR_RGB2YUV_I420,
407        COLOR_BGR2YUV_IYUV  = COLOR_BGR2YUV_I420,
408
409        COLOR_RGBA2YUV_I420 = 129,
410        COLOR_BGRA2YUV_I420 = 130,
411        COLOR_RGBA2YUV_IYUV = COLOR_RGBA2YUV_I420,
412        COLOR_BGRA2YUV_IYUV = COLOR_BGRA2YUV_I420,
413        COLOR_RGB2YUV_YV12  = 131,
414        COLOR_BGR2YUV_YV12  = 132,
415        COLOR_RGBA2YUV_YV12 = 133,
416        COLOR_BGRA2YUV_YV12 = 134,
417
418        // Demosaicing
419        COLOR_BayerBG2BGR = 46,
420        COLOR_BayerGB2BGR = 47,
421        COLOR_BayerRG2BGR = 48,
422        COLOR_BayerGR2BGR = 49,
423
424        COLOR_BayerBG2RGB = COLOR_BayerRG2BGR,
425        COLOR_BayerGB2RGB = COLOR_BayerGR2BGR,
426        COLOR_BayerRG2RGB = COLOR_BayerBG2BGR,
427        COLOR_BayerGR2RGB = COLOR_BayerGB2BGR,
428
429        COLOR_BayerBG2GRAY = 86,
430        COLOR_BayerGB2GRAY = 87,
431        COLOR_BayerRG2GRAY = 88,
432        COLOR_BayerGR2GRAY = 89,
433
434        // Demosaicing using Variable Number of Gradients
435        COLOR_BayerBG2BGR_VNG = 62,
436        COLOR_BayerGB2BGR_VNG = 63,
437        COLOR_BayerRG2BGR_VNG = 64,
438        COLOR_BayerGR2BGR_VNG = 65,
439
440        COLOR_BayerBG2RGB_VNG = COLOR_BayerRG2BGR_VNG,
441        COLOR_BayerGB2RGB_VNG = COLOR_BayerGR2BGR_VNG,
442        COLOR_BayerRG2RGB_VNG = COLOR_BayerBG2BGR_VNG,
443        COLOR_BayerGR2RGB_VNG = COLOR_BayerGB2BGR_VNG,
444
445        // Edge-Aware Demosaicing
446        COLOR_BayerBG2BGR_EA  = 135,
447        COLOR_BayerGB2BGR_EA  = 136,
448        COLOR_BayerRG2BGR_EA  = 137,
449        COLOR_BayerGR2BGR_EA  = 138,
450
451        COLOR_BayerBG2RGB_EA  = COLOR_BayerRG2BGR_EA,
452        COLOR_BayerGB2RGB_EA  = COLOR_BayerGR2BGR_EA,
453        COLOR_BayerRG2RGB_EA  = COLOR_BayerBG2BGR_EA,
454        COLOR_BayerGR2RGB_EA  = COLOR_BayerGB2BGR_EA,
455
456
457        COLOR_COLORCVT_MAX  = 139
458 };
459
460 //! types of intersection between rectangles
461 enum { INTERSECT_NONE = 0,
462        INTERSECT_PARTIAL  = 1,
463        INTERSECT_FULL  = 2
464      };
465
466 //! finds arbitrary template in the grayscale image using Generalized Hough Transform
467 class CV_EXPORTS GeneralizedHough : public Algorithm
468 {
469 public:
470     //! set template to search
471     virtual void setTemplate(InputArray templ, Point templCenter = Point(-1, -1)) = 0;
472     virtual void setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) = 0;
473
474     //! find template on image
475     virtual void detect(InputArray image, OutputArray positions, OutputArray votes = noArray()) = 0;
476     virtual void detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions, OutputArray votes = noArray()) = 0;
477
478     //! Canny low threshold.
479     virtual void setCannyLowThresh(int cannyLowThresh) = 0;
480     virtual int getCannyLowThresh() const = 0;
481
482     //! Canny high threshold.
483     virtual void setCannyHighThresh(int cannyHighThresh) = 0;
484     virtual int getCannyHighThresh() const = 0;
485
486     //! Minimum distance between the centers of the detected objects.
487     virtual void setMinDist(double minDist) = 0;
488     virtual double getMinDist() const = 0;
489
490     //! Inverse ratio of the accumulator resolution to the image resolution.
491     virtual void setDp(double dp) = 0;
492     virtual double getDp() const = 0;
493
494     //! Maximal size of inner buffers.
495     virtual void setMaxBufferSize(int maxBufferSize) = 0;
496     virtual int getMaxBufferSize() const = 0;
497 };
498
499 //! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
500 //! Detects position only without traslation and rotation
501 class CV_EXPORTS GeneralizedHoughBallard : public GeneralizedHough
502 {
503 public:
504     //! R-Table levels.
505     virtual void setLevels(int levels) = 0;
506     virtual int getLevels() const = 0;
507
508     //! The accumulator threshold for the template centers at the detection stage. The smaller it is, the more false positions may be detected.
509     virtual void setVotesThreshold(int votesThreshold) = 0;
510     virtual int getVotesThreshold() const = 0;
511 };
512
513 //! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
514 //! Detects position, traslation and rotation
515 class CV_EXPORTS GeneralizedHoughGuil : public GeneralizedHough
516 {
517 public:
518     //! Angle difference in degrees between two points in feature.
519     virtual void setXi(double xi) = 0;
520     virtual double getXi() const = 0;
521
522     //! Feature table levels.
523     virtual void setLevels(int levels) = 0;
524     virtual int getLevels() const = 0;
525
526     //! Maximal difference between angles that treated as equal.
527     virtual void setAngleEpsilon(double angleEpsilon) = 0;
528     virtual double getAngleEpsilon() const = 0;
529
530     //! Minimal rotation angle to detect in degrees.
531     virtual void setMinAngle(double minAngle) = 0;
532     virtual double getMinAngle() const = 0;
533
534     //! Maximal rotation angle to detect in degrees.
535     virtual void setMaxAngle(double maxAngle) = 0;
536     virtual double getMaxAngle() const = 0;
537
538     //! Angle step in degrees.
539     virtual void setAngleStep(double angleStep) = 0;
540     virtual double getAngleStep() const = 0;
541
542     //! Angle votes threshold.
543     virtual void setAngleThresh(int angleThresh) = 0;
544     virtual int getAngleThresh() const = 0;
545
546     //! Minimal scale to detect.
547     virtual void setMinScale(double minScale) = 0;
548     virtual double getMinScale() const = 0;
549
550     //! Maximal scale to detect.
551     virtual void setMaxScale(double maxScale) = 0;
552     virtual double getMaxScale() const = 0;
553
554     //! Scale step.
555     virtual void setScaleStep(double scaleStep) = 0;
556     virtual double getScaleStep() const = 0;
557
558     //! Scale votes threshold.
559     virtual void setScaleThresh(int scaleThresh) = 0;
560     virtual int getScaleThresh() const = 0;
561
562     //! Position votes threshold.
563     virtual void setPosThresh(int posThresh) = 0;
564     virtual int getPosThresh() const = 0;
565 };
566
567
568 class CV_EXPORTS_W CLAHE : public Algorithm
569 {
570 public:
571     CV_WRAP virtual void apply(InputArray src, OutputArray dst) = 0;
572
573     CV_WRAP virtual void setClipLimit(double clipLimit) = 0;
574     CV_WRAP virtual double getClipLimit() const = 0;
575
576     CV_WRAP virtual void setTilesGridSize(Size tileGridSize) = 0;
577     CV_WRAP virtual Size getTilesGridSize() const = 0;
578
579     CV_WRAP virtual void collectGarbage() = 0;
580 };
581
582
583 class CV_EXPORTS_W Subdiv2D
584 {
585 public:
586     enum { PTLOC_ERROR        = -2,
587            PTLOC_OUTSIDE_RECT = -1,
588            PTLOC_INSIDE       = 0,
589            PTLOC_VERTEX       = 1,
590            PTLOC_ON_EDGE      = 2
591          };
592
593     enum { NEXT_AROUND_ORG   = 0x00,
594            NEXT_AROUND_DST   = 0x22,
595            PREV_AROUND_ORG   = 0x11,
596            PREV_AROUND_DST   = 0x33,
597            NEXT_AROUND_LEFT  = 0x13,
598            NEXT_AROUND_RIGHT = 0x31,
599            PREV_AROUND_LEFT  = 0x20,
600            PREV_AROUND_RIGHT = 0x02
601          };
602
603     CV_WRAP Subdiv2D();
604     CV_WRAP Subdiv2D(Rect rect);
605     CV_WRAP void initDelaunay(Rect rect);
606
607     CV_WRAP int insert(Point2f pt);
608     CV_WRAP void insert(const std::vector<Point2f>& ptvec);
609     CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex);
610
611     CV_WRAP int findNearest(Point2f pt, CV_OUT Point2f* nearestPt = 0);
612     CV_WRAP void getEdgeList(CV_OUT std::vector<Vec4f>& edgeList) const;
613     CV_WRAP void getTriangleList(CV_OUT std::vector<Vec6f>& triangleList) const;
614     CV_WRAP void getVoronoiFacetList(const std::vector<int>& idx, CV_OUT std::vector<std::vector<Point2f> >& facetList,
615                                      CV_OUT std::vector<Point2f>& facetCenters);
616
617     CV_WRAP Point2f getVertex(int vertex, CV_OUT int* firstEdge = 0) const;
618
619     CV_WRAP int getEdge( int edge, int nextEdgeType ) const;
620     CV_WRAP int nextEdge(int edge) const;
621     CV_WRAP int rotateEdge(int edge, int rotate) const;
622     CV_WRAP int symEdge(int edge) const;
623     CV_WRAP int edgeOrg(int edge, CV_OUT Point2f* orgpt = 0) const;
624     CV_WRAP int edgeDst(int edge, CV_OUT Point2f* dstpt = 0) const;
625
626 protected:
627     int newEdge();
628     void deleteEdge(int edge);
629     int newPoint(Point2f pt, bool isvirtual, int firstEdge = 0);
630     void deletePoint(int vtx);
631     void setEdgePoints( int edge, int orgPt, int dstPt );
632     void splice( int edgeA, int edgeB );
633     int connectEdges( int edgeA, int edgeB );
634     void swapEdges( int edge );
635     int isRightOf(Point2f pt, int edge) const;
636     void calcVoronoi();
637     void clearVoronoi();
638     void checkSubdiv() const;
639
640     struct CV_EXPORTS Vertex
641     {
642         Vertex();
643         Vertex(Point2f pt, bool _isvirtual, int _firstEdge=0);
644         bool isvirtual() const;
645         bool isfree() const;
646
647         int firstEdge;
648         int type;
649         Point2f pt;
650     };
651
652     struct CV_EXPORTS QuadEdge
653     {
654         QuadEdge();
655         QuadEdge(int edgeidx);
656         bool isfree() const;
657
658         int next[4];
659         int pt[4];
660     };
661
662     std::vector<Vertex> vtx;
663     std::vector<QuadEdge> qedges;
664     int freeQEdge;
665     int freePoint;
666     bool validGeometry;
667
668     int recentEdge;
669     Point2f topLeft;
670     Point2f bottomRight;
671 };
672
673 class CV_EXPORTS_W LineSegmentDetector : public Algorithm
674 {
675 public:
676 /**
677  * Detect lines in the input image.
678  *
679  * @param _image    A grayscale(CV_8UC1) input image.
680  *                  If only a roi needs to be selected, use
681  *                  lsd_ptr->detect(image(roi), ..., lines);
682  *                  lines += Scalar(roi.x, roi.y, roi.x, roi.y);
683  * @param _lines    Return: A vector of Vec4i elements specifying the beginning and ending point of a line.
684  *                          Where Vec4i is (x1, y1, x2, y2), point 1 is the start, point 2 - end.
685  *                          Returned lines are strictly oriented depending on the gradient.
686  * @param width     Return: Vector of widths of the regions, where the lines are found. E.g. Width of line.
687  * @param prec      Return: Vector of precisions with which the lines are found.
688  * @param nfa       Return: Vector containing number of false alarms in the line region, with precision of 10%.
689  *                          The bigger the value, logarithmically better the detection.
690  *                              * -1 corresponds to 10 mean false alarms
691  *                              * 0 corresponds to 1 mean false alarm
692  *                              * 1 corresponds to 0.1 mean false alarms
693  *                          This vector will be calculated _only_ when the objects type is REFINE_ADV
694  */
695     CV_WRAP virtual void detect(InputArray _image, OutputArray _lines,
696                         OutputArray width = noArray(), OutputArray prec = noArray(),
697                         OutputArray nfa = noArray()) = 0;
698
699 /**
700  * Draw lines on the given canvas.
701  * @param _image    The image, where lines will be drawn.
702  *                  Should have the size of the image, where the lines were found
703  * @param lines     The lines that need to be drawn
704  */
705     CV_WRAP virtual void drawSegments(InputOutputArray _image, InputArray lines) = 0;
706
707 /**
708  * Draw both vectors on the image canvas. Uses blue for lines 1 and red for lines 2.
709  * @param size      The size of the image, where lines were found.
710  * @param lines1    The first lines that need to be drawn. Color - Blue.
711  * @param lines2    The second lines that need to be drawn. Color - Red.
712  * @param _image    Optional image, where lines will be drawn.
713  *                  Should have the size of the image, where the lines were found
714  * @return          The number of mismatching pixels between lines1 and lines2.
715  */
716     CV_WRAP virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray _image = noArray()) = 0;
717
718     virtual ~LineSegmentDetector() { }
719 };
720
721 //! Returns a pointer to a LineSegmentDetector class.
722 CV_EXPORTS_W Ptr<LineSegmentDetector> createLineSegmentDetector(
723     int _refine = LSD_REFINE_STD, double _scale = 0.8,
724     double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5,
725     double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024);
726
727 //! returns the Gaussian kernel with the specified parameters
728 CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype = CV_64F );
729
730 //! initializes kernels of the generalized Sobel operator
731 CV_EXPORTS_W void getDerivKernels( OutputArray kx, OutputArray ky,
732                                    int dx, int dy, int ksize,
733                                    bool normalize = false, int ktype = CV_32F );
734
735 //! returns the Gabor kernel with the specified parameters
736 CV_EXPORTS_W Mat getGaborKernel( Size ksize, double sigma, double theta, double lambd,
737                                  double gamma, double psi = CV_PI*0.5, int ktype = CV_64F );
738
739 //! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation.
740 static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); }
741
742 //! returns structuring element of the specified shape and size
743 CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor = Point(-1,-1));
744
745 //! smooths the image using median filter.
746 CV_EXPORTS_W void medianBlur( InputArray src, OutputArray dst, int ksize );
747
748 //! smooths the image using Gaussian filter.
749 CV_EXPORTS_W void GaussianBlur( InputArray src, OutputArray dst, Size ksize,
750                                 double sigmaX, double sigmaY = 0,
751                                 int borderType = BORDER_DEFAULT );
752
753 //! smooths the image using bilateral filter
754 CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d,
755                                    double sigmaColor, double sigmaSpace,
756                                    int borderType = BORDER_DEFAULT );
757
758 //! smooths the image using the box filter. Each pixel is processed in O(1) time
759 CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth,
760                              Size ksize, Point anchor = Point(-1,-1),
761                              bool normalize = true,
762                              int borderType = BORDER_DEFAULT );
763
764 CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
765                                 Size ksize, Point anchor = Point(-1, -1),
766                                 bool normalize = true,
767                                 int borderType = BORDER_DEFAULT );
768
769 //! a synonym for normalized box filter
770 CV_EXPORTS_W void blur( InputArray src, OutputArray dst,
771                         Size ksize, Point anchor = Point(-1,-1),
772                         int borderType = BORDER_DEFAULT );
773
774 //! applies non-separable 2D linear filter to the image
775 CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth,
776                             InputArray kernel, Point anchor = Point(-1,-1),
777                             double delta = 0, int borderType = BORDER_DEFAULT );
778
779 //! applies separable 2D linear filter to the image
780 CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth,
781                                InputArray kernelX, InputArray kernelY,
782                                Point anchor = Point(-1,-1),
783                                double delta = 0, int borderType = BORDER_DEFAULT );
784
785 //! applies generalized Sobel operator to the image
786 CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth,
787                          int dx, int dy, int ksize = 3,
788                          double scale = 1, double delta = 0,
789                          int borderType = BORDER_DEFAULT );
790
791 //! applies the vertical or horizontal Scharr operator to the image
792 CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth,
793                           int dx, int dy, double scale = 1, double delta = 0,
794                           int borderType = BORDER_DEFAULT );
795
796 //! applies Laplacian operator to the image
797 CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
798                              int ksize = 1, double scale = 1, double delta = 0,
799                              int borderType = BORDER_DEFAULT );
800
801 //! applies Canny edge detector and produces the edge map.
802 CV_EXPORTS_W void Canny( InputArray image, OutputArray edges,
803                          double threshold1, double threshold2,
804                          int apertureSize = 3, bool L2gradient = false );
805
806 //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
807 CV_EXPORTS_W void cornerMinEigenVal( InputArray src, OutputArray dst,
808                                      int blockSize, int ksize = 3,
809                                      int borderType = BORDER_DEFAULT );
810
811 //! computes Harris cornerness criteria at each image pixel
812 CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize,
813                                 int ksize, double k,
814                                 int borderType = BORDER_DEFAULT );
815
816 //! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix  at each pixel. The output is stored as 6-channel matrix.
817 CV_EXPORTS_W void cornerEigenValsAndVecs( InputArray src, OutputArray dst,
818                                           int blockSize, int ksize,
819                                           int borderType = BORDER_DEFAULT );
820
821 //! computes another complex cornerness criteria at each pixel
822 CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize,
823                                    int borderType = BORDER_DEFAULT );
824
825 //! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria
826 CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners,
827                                 Size winSize, Size zeroZone,
828                                 TermCriteria criteria );
829
830 //! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima
831 CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
832                                      int maxCorners, double qualityLevel, double minDistance,
833                                      InputArray mask = noArray(), int blockSize = 3,
834                                      bool useHarrisDetector = false, double k = 0.04 );
835
836 //! finds lines in the black-n-white image using the standard or pyramid Hough transform
837 CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines,
838                               double rho, double theta, int threshold,
839                               double srn = 0, double stn = 0,
840                               double min_theta = 0, double max_theta = CV_PI );
841
842 //! finds line segments in the black-n-white image using probabilistic Hough transform
843 CV_EXPORTS_W void HoughLinesP( InputArray image, OutputArray lines,
844                                double rho, double theta, int threshold,
845                                double minLineLength = 0, double maxLineGap = 0 );
846
847 //! finds circles in the grayscale image using 2+1 gradient Hough transform
848 CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles,
849                                int method, double dp, double minDist,
850                                double param1 = 100, double param2 = 100,
851                                int minRadius = 0, int maxRadius = 0 );
852
853 //! erodes the image (applies the local minimum operator)
854 CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel,
855                          Point anchor = Point(-1,-1), int iterations = 1,
856                          int borderType = BORDER_CONSTANT,
857                          const Scalar& borderValue = morphologyDefaultBorderValue() );
858
859 //! dilates the image (applies the local maximum operator)
860 CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel,
861                           Point anchor = Point(-1,-1), int iterations = 1,
862                           int borderType = BORDER_CONSTANT,
863                           const Scalar& borderValue = morphologyDefaultBorderValue() );
864
865 //! applies an advanced morphological operation to the image
866 CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst,
867                                 int op, InputArray kernel,
868                                 Point anchor = Point(-1,-1), int iterations = 1,
869                                 int borderType = BORDER_CONSTANT,
870                                 const Scalar& borderValue = morphologyDefaultBorderValue() );
871
872 //! resizes the image
873 CV_EXPORTS_W void resize( InputArray src, OutputArray dst,
874                           Size dsize, double fx = 0, double fy = 0,
875                           int interpolation = INTER_LINEAR );
876
877 //! warps the image using affine transformation
878 CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst,
879                               InputArray M, Size dsize,
880                               int flags = INTER_LINEAR,
881                               int borderMode = BORDER_CONSTANT,
882                               const Scalar& borderValue = Scalar());
883
884 //! warps the image using perspective transformation
885 CV_EXPORTS_W void warpPerspective( InputArray src, OutputArray dst,
886                                    InputArray M, Size dsize,
887                                    int flags = INTER_LINEAR,
888                                    int borderMode = BORDER_CONSTANT,
889                                    const Scalar& borderValue = Scalar());
890
891 //! warps the image using the precomputed maps. The maps are stored in either floating-point or integer fixed-point format
892 CV_EXPORTS_W void remap( InputArray src, OutputArray dst,
893                          InputArray map1, InputArray map2,
894                          int interpolation, int borderMode = BORDER_CONSTANT,
895                          const Scalar& borderValue = Scalar());
896
897 //! converts maps for remap from floating-point to fixed-point format or backwards
898 CV_EXPORTS_W void convertMaps( InputArray map1, InputArray map2,
899                                OutputArray dstmap1, OutputArray dstmap2,
900                                int dstmap1type, bool nninterpolation = false );
901
902 //! returns 2x3 affine transformation matrix for the planar rotation.
903 CV_EXPORTS_W Mat getRotationMatrix2D( Point2f center, double angle, double scale );
904
905 //! returns 3x3 perspective transformation for the corresponding 4 point pairs.
906 CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] );
907
908 //! returns 2x3 affine transformation for the corresponding 3 point pairs.
909 CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] );
910
911 //! computes 2x3 affine transformation matrix that is inverse to the specified 2x3 affine transformation.
912 CV_EXPORTS_W void invertAffineTransform( InputArray M, OutputArray iM );
913
914 CV_EXPORTS_W Mat getPerspectiveTransform( InputArray src, InputArray dst );
915
916 CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
917
918 //! extracts rectangle from the image at sub-pixel location
919 CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize,
920                                  Point2f center, OutputArray patch, int patchType = -1 );
921
922 //! computes the log polar transform
923 CV_EXPORTS_W void logPolar( InputArray src, OutputArray dst,
924                             Point2f center, double M, int flags );
925
926 //! computes the linear polar transform
927 CV_EXPORTS_W void linearPolar( InputArray src, OutputArray dst,
928                                Point2f center, double maxRadius, int flags );
929
930 //! computes the integral image
931 CV_EXPORTS_W void integral( InputArray src, OutputArray sum, int sdepth = -1 );
932
933 //! computes the integral image and integral for the squared image
934 CV_EXPORTS_AS(integral2) void integral( InputArray src, OutputArray sum,
935                                         OutputArray sqsum, int sdepth = -1, int sqdepth = -1 );
936
937 //! computes the integral image, integral for the squared image and the tilted integral image
938 CV_EXPORTS_AS(integral3) void integral( InputArray src, OutputArray sum,
939                                         OutputArray sqsum, OutputArray tilted,
940                                         int sdepth = -1, int sqdepth = -1 );
941
942 //! adds image to the accumulator (dst += src). Unlike cv::add, dst and src can have different types.
943 CV_EXPORTS_W void accumulate( InputArray src, InputOutputArray dst,
944                               InputArray mask = noArray() );
945
946 //! adds squared src image to the accumulator (dst += src*src).
947 CV_EXPORTS_W void accumulateSquare( InputArray src, InputOutputArray dst,
948                                     InputArray mask = noArray() );
949 //! adds product of the 2 images to the accumulator (dst += src1*src2).
950 CV_EXPORTS_W void accumulateProduct( InputArray src1, InputArray src2,
951                                      InputOutputArray dst, InputArray mask=noArray() );
952
953 //! updates the running average (dst = dst*(1-alpha) + src*alpha)
954 CV_EXPORTS_W void accumulateWeighted( InputArray src, InputOutputArray dst,
955                                       double alpha, InputArray mask = noArray() );
956
957 CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2,
958                                     InputArray window = noArray(), CV_OUT double* response = 0);
959
960 CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type);
961
962 //! applies fixed threshold to the image
963 CV_EXPORTS_W double threshold( InputArray src, OutputArray dst,
964                                double thresh, double maxval, int type );
965
966
967 //! applies variable (adaptive) threshold to the image
968 CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst,
969                                      double maxValue, int adaptiveMethod,
970                                      int thresholdType, int blockSize, double C );
971
972 //! smooths and downsamples the image
973 CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst,
974                            const Size& dstsize = Size(), int borderType = BORDER_DEFAULT );
975
976 //! upsamples and smoothes the image
977 CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst,
978                          const Size& dstsize = Size(), int borderType = BORDER_DEFAULT );
979
980 //! builds the gaussian pyramid using pyrDown() as a basic operation
981 CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst,
982                               int maxlevel, int borderType = BORDER_DEFAULT );
983
984 //! corrects lens distortion for the given camera matrix and distortion coefficients
985 CV_EXPORTS_W void undistort( InputArray src, OutputArray dst,
986                              InputArray cameraMatrix,
987                              InputArray distCoeffs,
988                              InputArray newCameraMatrix = noArray() );
989
990 //! initializes maps for cv::remap() to correct lens distortion and optionally rectify the image
991 CV_EXPORTS_W void initUndistortRectifyMap( InputArray cameraMatrix, InputArray distCoeffs,
992                            InputArray R, InputArray newCameraMatrix,
993                            Size size, int m1type, OutputArray map1, OutputArray map2 );
994
995 //! initializes maps for cv::remap() for wide-angle
996 CV_EXPORTS_W float initWideAngleProjMap( InputArray cameraMatrix, InputArray distCoeffs,
997                                          Size imageSize, int destImageWidth,
998                                          int m1type, OutputArray map1, OutputArray map2,
999                                          int projType = PROJ_SPHERICAL_EQRECT, double alpha = 0);
1000
1001 //! returns the default new camera matrix (by default it is the same as cameraMatrix unless centerPricipalPoint=true)
1002 CV_EXPORTS_W Mat getDefaultNewCameraMatrix( InputArray cameraMatrix, Size imgsize = Size(),
1003                                             bool centerPrincipalPoint = false );
1004
1005 //! returns points' coordinates after lens distortion correction
1006 CV_EXPORTS_W void undistortPoints( InputArray src, OutputArray dst,
1007                                    InputArray cameraMatrix, InputArray distCoeffs,
1008                                    InputArray R = noArray(), InputArray P = noArray());
1009
1010 //! computes the joint dense histogram for a set of images.
1011 CV_EXPORTS void calcHist( const Mat* images, int nimages,
1012                           const int* channels, InputArray mask,
1013                           OutputArray hist, int dims, const int* histSize,
1014                           const float** ranges, bool uniform = true, bool accumulate = false );
1015
1016 //! computes the joint sparse histogram for a set of images.
1017 CV_EXPORTS void calcHist( const Mat* images, int nimages,
1018                           const int* channels, InputArray mask,
1019                           SparseMat& hist, int dims,
1020                           const int* histSize, const float** ranges,
1021                           bool uniform = true, bool accumulate = false );
1022
1023 CV_EXPORTS_W void calcHist( InputArrayOfArrays images,
1024                             const std::vector<int>& channels,
1025                             InputArray mask, OutputArray hist,
1026                             const std::vector<int>& histSize,
1027                             const std::vector<float>& ranges,
1028                             bool accumulate = false );
1029
1030 //! computes back projection for the set of images
1031 CV_EXPORTS void calcBackProject( const Mat* images, int nimages,
1032                                  const int* channels, InputArray hist,
1033                                  OutputArray backProject, const float** ranges,
1034                                  double scale = 1, bool uniform = true );
1035
1036 //! computes back projection for the set of images
1037 CV_EXPORTS void calcBackProject( const Mat* images, int nimages,
1038                                  const int* channels, const SparseMat& hist,
1039                                  OutputArray backProject, const float** ranges,
1040                                  double scale = 1, bool uniform = true );
1041
1042 CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const std::vector<int>& channels,
1043                                    InputArray hist, OutputArray dst,
1044                                    const std::vector<float>& ranges,
1045                                    double scale );
1046
1047 //! compares two histograms stored in dense arrays
1048 CV_EXPORTS_W double compareHist( InputArray H1, InputArray H2, int method );
1049
1050 //! compares two histograms stored in sparse arrays
1051 CV_EXPORTS double compareHist( const SparseMat& H1, const SparseMat& H2, int method );
1052
1053 //! normalizes the grayscale image brightness and contrast by normalizing its histogram
1054 CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst );
1055
1056 CV_EXPORTS float EMD( InputArray signature1, InputArray signature2,
1057                       int distType, InputArray cost=noArray(),
1058                       float* lowerBound = 0, OutputArray flow = noArray() );
1059
1060 //! segments the image using watershed algorithm
1061 CV_EXPORTS_W void watershed( InputArray image, InputOutputArray markers );
1062
1063 //! filters image using meanshift algorithm
1064 CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst,
1065                                          double sp, double sr, int maxLevel = 1,
1066                                          TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5,1) );
1067
1068 //! segments the image using GrabCut algorithm
1069 CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect,
1070                            InputOutputArray bgdModel, InputOutputArray fgdModel,
1071                            int iterCount, int mode = GC_EVAL );
1072
1073
1074 //! builds the discrete Voronoi diagram
1075 CV_EXPORTS_AS(distanceTransformWithLabels) void distanceTransform( InputArray src, OutputArray dst,
1076                                      OutputArray labels, int distanceType, int maskSize,
1077                                      int labelType = DIST_LABEL_CCOMP );
1078
1079 //! computes the distance transform map
1080 CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst,
1081                                      int distanceType, int maskSize, int dstType=CV_32F);
1082
1083
1084 //! fills the semi-uniform image region starting from the specified seed point
1085 CV_EXPORTS int floodFill( InputOutputArray image,
1086                           Point seedPoint, Scalar newVal, CV_OUT Rect* rect = 0,
1087                           Scalar loDiff = Scalar(), Scalar upDiff = Scalar(),
1088                           int flags = 4 );
1089
1090 //! fills the semi-uniform image region and/or the mask starting from the specified seed point
1091 CV_EXPORTS_W int floodFill( InputOutputArray image, InputOutputArray mask,
1092                             Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0,
1093                             Scalar loDiff = Scalar(), Scalar upDiff = Scalar(),
1094                             int flags = 4 );
1095
1096 //! converts image from one color space to another
1097 CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn = 0 );
1098
1099 // main function for all demosaicing procceses
1100 CV_EXPORTS_W void demosaicing(InputArray _src, OutputArray _dst, int code, int dcn = 0);
1101
1102 //! computes moments of the rasterized shape or a vector of points
1103 CV_EXPORTS_W Moments moments( InputArray array, bool binaryImage = false );
1104
1105 //! computes 7 Hu invariants from the moments
1106 CV_EXPORTS void HuMoments( const Moments& moments, double hu[7] );
1107
1108 CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu );
1109
1110 //! computes the proximity map for the raster template and the image where the template is searched for
1111 CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
1112                                  OutputArray result, int method );
1113
1114
1115 // computes the connected components labeled image of boolean image ``image``
1116 // with 4 or 8 way connectivity - returns N, the total
1117 // number of labels [0, N-1] where 0 represents the background label.
1118 // ltype specifies the output label image type, an important
1119 // consideration based on the total number of labels or
1120 // alternatively the total number of pixels in the source image.
1121 CV_EXPORTS_W int connectedComponents(InputArray image, OutputArray labels,
1122                                      int connectivity = 8, int ltype = CV_32S);
1123
1124 CV_EXPORTS_W int connectedComponentsWithStats(InputArray image, OutputArray labels,
1125                                               OutputArray stats, OutputArray centroids,
1126                                               int connectivity = 8, int ltype = CV_32S);
1127
1128
1129 //! retrieves contours and the hierarchical information from black-n-white image.
1130 CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays contours,
1131                               OutputArray hierarchy, int mode,
1132                               int method, Point offset = Point());
1133
1134 //! retrieves contours from black-n-white image.
1135 CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours,
1136                               int mode, int method, Point offset = Point());
1137
1138 //! approximates contour or a curve using Douglas-Peucker algorithm
1139 CV_EXPORTS_W void approxPolyDP( InputArray curve,
1140                                 OutputArray approxCurve,
1141                                 double epsilon, bool closed );
1142
1143 //! computes the contour perimeter (closed=true) or a curve length
1144 CV_EXPORTS_W double arcLength( InputArray curve, bool closed );
1145
1146 //! computes the bounding rectangle for a contour
1147 CV_EXPORTS_W Rect boundingRect( InputArray points );
1148
1149 //! computes the contour area
1150 CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false );
1151
1152 //! computes the minimal rotated rectangle for a set of points
1153 CV_EXPORTS_W RotatedRect minAreaRect( InputArray points );
1154
1155 //! computes boxpoints
1156 CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points);
1157
1158 //! computes the minimal enclosing circle for a set of points
1159 CV_EXPORTS_W void minEnclosingCircle( InputArray points,
1160                                       CV_OUT Point2f& center, CV_OUT float& radius );
1161
1162 //! computes the minimal enclosing triangle for a set of points and returns its area
1163 CV_EXPORTS_W double minEnclosingTriangle( InputArray points, CV_OUT OutputArray triangle );
1164
1165 //! matches two contours using one of the available algorithms
1166 CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2,
1167                                  int method, double parameter );
1168
1169 //! computes convex hull for a set of 2D points.
1170 CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull,
1171                               bool clockwise = false, bool returnPoints = true );
1172
1173 //! computes the contour convexity defects
1174 CV_EXPORTS_W void convexityDefects( InputArray contour, InputArray convexhull, OutputArray convexityDefects );
1175
1176 //! returns true if the contour is convex. Does not support contours with self-intersection
1177 CV_EXPORTS_W bool isContourConvex( InputArray contour );
1178
1179 //! finds intersection of two convex polygons
1180 CV_EXPORTS_W float intersectConvexConvex( InputArray _p1, InputArray _p2,
1181                                           OutputArray _p12, bool handleNested = true );
1182
1183 //! fits ellipse to the set of 2D points
1184 CV_EXPORTS_W RotatedRect fitEllipse( InputArray points );
1185
1186 //! fits line to the set of 2D points using M-estimator algorithm
1187 CV_EXPORTS_W void fitLine( InputArray points, OutputArray line, int distType,
1188                            double param, double reps, double aeps );
1189
1190 //! checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary
1191 CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist );
1192
1193 //! computes whether two rotated rectangles intersect and returns the vertices of the intersecting region
1194 CV_EXPORTS_W int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion  );
1195
1196 CV_EXPORTS_W Ptr<CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
1197
1198 //! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
1199 //! Detects position only without traslation and rotation
1200 CV_EXPORTS Ptr<GeneralizedHoughBallard> createGeneralizedHoughBallard();
1201
1202 //! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
1203 //! Detects position, traslation and rotation
1204 CV_EXPORTS Ptr<GeneralizedHoughGuil> createGeneralizedHoughGuil();
1205
1206 //! Performs linear blending of two images
1207 CV_EXPORTS void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst);
1208
1209 enum
1210 {
1211     COLORMAP_AUTUMN = 0,
1212     COLORMAP_BONE = 1,
1213     COLORMAP_JET = 2,
1214     COLORMAP_WINTER = 3,
1215     COLORMAP_RAINBOW = 4,
1216     COLORMAP_OCEAN = 5,
1217     COLORMAP_SUMMER = 6,
1218     COLORMAP_SPRING = 7,
1219     COLORMAP_COOL = 8,
1220     COLORMAP_HSV = 9,
1221     COLORMAP_PINK = 10,
1222     COLORMAP_HOT = 11
1223 };
1224
1225 CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
1226
1227
1228 //! draws the line segment (pt1, pt2) in the image
1229 CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
1230                      int thickness = 1, int lineType = LINE_8, int shift = 0);
1231
1232 //! draws an arrow from pt1 to pt2 in the image
1233 CV_EXPORTS_W void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
1234                      int thickness=1, int line_type=8, int shift=0, double tipLength=0.1);
1235
1236 //! draws the rectangle outline or a solid rectangle with the opposite corners pt1 and pt2 in the image
1237 CV_EXPORTS_W void rectangle(InputOutputArray img, Point pt1, Point pt2,
1238                           const Scalar& color, int thickness = 1,
1239                           int lineType = LINE_8, int shift = 0);
1240
1241 //! draws the rectangle outline or a solid rectangle covering rec in the image
1242 CV_EXPORTS void rectangle(CV_IN_OUT Mat& img, Rect rec,
1243                           const Scalar& color, int thickness = 1,
1244                           int lineType = LINE_8, int shift = 0);
1245
1246 //! draws the circle outline or a solid circle in the image
1247 CV_EXPORTS_W void circle(InputOutputArray img, Point center, int radius,
1248                        const Scalar& color, int thickness = 1,
1249                        int lineType = LINE_8, int shift = 0);
1250
1251 //! draws an elliptic arc, ellipse sector or a rotated ellipse in the image
1252 CV_EXPORTS_W void ellipse(InputOutputArray img, Point center, Size axes,
1253                         double angle, double startAngle, double endAngle,
1254                         const Scalar& color, int thickness = 1,
1255                         int lineType = LINE_8, int shift = 0);
1256
1257 //! draws a rotated ellipse in the image
1258 CV_EXPORTS_W void ellipse(InputOutputArray img, const RotatedRect& box, const Scalar& color,
1259                         int thickness = 1, int lineType = LINE_8);
1260
1261 //! draws a filled convex polygon in the image
1262 CV_EXPORTS void fillConvexPoly(Mat& img, const Point* pts, int npts,
1263                                const Scalar& color, int lineType = LINE_8,
1264                                int shift = 0);
1265
1266 CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray points,
1267                                  const Scalar& color, int lineType = LINE_8,
1268                                  int shift = 0);
1269
1270 //! fills an area bounded by one or more polygons
1271 CV_EXPORTS void fillPoly(Mat& img, const Point** pts,
1272                          const int* npts, int ncontours,
1273                          const Scalar& color, int lineType = LINE_8, int shift = 0,
1274                          Point offset = Point() );
1275
1276 CV_EXPORTS_W void fillPoly(InputOutputArray img, InputArrayOfArrays pts,
1277                            const Scalar& color, int lineType = LINE_8, int shift = 0,
1278                            Point offset = Point() );
1279
1280 //! draws one or more polygonal curves
1281 CV_EXPORTS void polylines(Mat& img, const Point* const* pts, const int* npts,
1282                           int ncontours, bool isClosed, const Scalar& color,
1283                           int thickness = 1, int lineType = LINE_8, int shift = 0 );
1284
1285 CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts,
1286                             bool isClosed, const Scalar& color,
1287                             int thickness = 1, int lineType = LINE_8, int shift = 0 );
1288
1289 //! draws contours in the image
1290 CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours,
1291                               int contourIdx, const Scalar& color,
1292                               int thickness = 1, int lineType = LINE_8,
1293                               InputArray hierarchy = noArray(),
1294                               int maxLevel = INT_MAX, Point offset = Point() );
1295
1296 //! clips the line segment by the rectangle Rect(0, 0, imgSize.width, imgSize.height)
1297 CV_EXPORTS bool clipLine(Size imgSize, CV_IN_OUT Point& pt1, CV_IN_OUT Point& pt2);
1298
1299 //! clips the line segment by the rectangle imgRect
1300 CV_EXPORTS_W bool clipLine(Rect imgRect, CV_OUT CV_IN_OUT Point& pt1, CV_OUT CV_IN_OUT Point& pt2);
1301
1302 //! converts elliptic arc to a polygonal curve
1303 CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle,
1304                                 int arcStart, int arcEnd, int delta,
1305                                 CV_OUT std::vector<Point>& pts );
1306
1307 //! renders text string in the image
1308 CV_EXPORTS_W void putText( InputOutputArray img, const String& text, Point org,
1309                          int fontFace, double fontScale, Scalar color,
1310                          int thickness = 1, int lineType = LINE_8,
1311                          bool bottomLeftOrigin = false );
1312
1313 //! returns bounding box of the text string
1314 CV_EXPORTS_W Size getTextSize(const String& text, int fontFace,
1315                             double fontScale, int thickness,
1316                             CV_OUT int* baseLine);
1317
1318 } // cv
1319
1320 #endif