imagecore 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/.gitignore +24 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +2 -0
  4. data/ext/imagecore/analyze_image.cxx +58 -0
  5. data/ext/imagecore/analyze_image.h +6 -0
  6. data/ext/imagecore/extconf.rb +9 -0
  7. data/ext/imagecore/imagecore.cxx +34 -0
  8. data/ext/opencv/core/___.c +3 -0
  9. data/ext/opencv/core/alloc.cpp +697 -0
  10. data/ext/opencv/core/array.cpp +3206 -0
  11. data/ext/opencv/core/datastructs.cpp +4064 -0
  12. data/ext/opencv/core/extconf.rb +22 -0
  13. data/ext/opencv/core/matrix.cpp +3777 -0
  14. data/ext/opencv/core/precomp.hpp +216 -0
  15. data/ext/opencv/core/system.cpp +832 -0
  16. data/ext/opencv/core/tables.cpp +3512 -0
  17. data/ext/opencv/highgui/___.c +3 -0
  18. data/ext/opencv/highgui/bitstrm.cpp +582 -0
  19. data/ext/opencv/highgui/bitstrm.hpp +182 -0
  20. data/ext/opencv/highgui/extconf.rb +28 -0
  21. data/ext/opencv/highgui/grfmt_base.cpp +128 -0
  22. data/ext/opencv/highgui/grfmt_base.hpp +113 -0
  23. data/ext/opencv/highgui/grfmt_bmp.cpp +564 -0
  24. data/ext/opencv/highgui/grfmt_bmp.hpp +99 -0
  25. data/ext/opencv/highgui/grfmt_exr.hpp +113 -0
  26. data/ext/opencv/highgui/grfmt_imageio.hpp +56 -0
  27. data/ext/opencv/highgui/grfmt_jpeg.cpp +622 -0
  28. data/ext/opencv/highgui/grfmt_jpeg.hpp +90 -0
  29. data/ext/opencv/highgui/grfmt_jpeg2000.cpp +529 -0
  30. data/ext/opencv/highgui/grfmt_jpeg2000.hpp +95 -0
  31. data/ext/opencv/highgui/grfmt_png.cpp +406 -0
  32. data/ext/opencv/highgui/grfmt_png.hpp +101 -0
  33. data/ext/opencv/highgui/grfmt_pxm.cpp +513 -0
  34. data/ext/opencv/highgui/grfmt_pxm.hpp +92 -0
  35. data/ext/opencv/highgui/grfmt_sunras.cpp +425 -0
  36. data/ext/opencv/highgui/grfmt_sunras.hpp +105 -0
  37. data/ext/opencv/highgui/grfmt_tiff.cpp +718 -0
  38. data/ext/opencv/highgui/grfmt_tiff.hpp +136 -0
  39. data/ext/opencv/highgui/grfmts.hpp +56 -0
  40. data/ext/opencv/highgui/loadsave.cpp +535 -0
  41. data/ext/opencv/highgui/precomp.hpp +223 -0
  42. data/ext/opencv/highgui/utils.cpp +689 -0
  43. data/ext/opencv/highgui/utils.hpp +128 -0
  44. data/ext/opencv/imgproc/___.c +3 -0
  45. data/ext/opencv/imgproc/_geom.h +72 -0
  46. data/ext/opencv/imgproc/color.cpp +3179 -0
  47. data/ext/opencv/imgproc/contours.cpp +1780 -0
  48. data/ext/opencv/imgproc/extconf.rb +11 -0
  49. data/ext/opencv/imgproc/filter.cpp +3063 -0
  50. data/ext/opencv/imgproc/precomp.hpp +159 -0
  51. data/ext/opencv/imgproc/shapedescr.cpp +1306 -0
  52. data/ext/opencv/imgproc/smooth.cpp +1566 -0
  53. data/ext/opencv/imgproc/tables.cpp +214 -0
  54. data/ext/opencv/imgproc/thresh.cpp +636 -0
  55. data/ext/opencv/imgproc/utils.cpp +242 -0
  56. data/ext/opencv/include/opencv2/core/core.hpp +4344 -0
  57. data/ext/opencv/include/opencv2/core/core_c.h +1885 -0
  58. data/ext/opencv/include/opencv2/core/internal.hpp +710 -0
  59. data/ext/opencv/include/opencv2/core/mat.hpp +2557 -0
  60. data/ext/opencv/include/opencv2/core/operations.hpp +3623 -0
  61. data/ext/opencv/include/opencv2/core/types_c.h +1875 -0
  62. data/ext/opencv/include/opencv2/core/version.hpp +58 -0
  63. data/ext/opencv/include/opencv2/highgui/highgui.hpp +198 -0
  64. data/ext/opencv/include/opencv2/highgui/highgui_c.h +506 -0
  65. data/ext/opencv/include/opencv2/imgproc/imgproc.hpp +1139 -0
  66. data/ext/opencv/include/opencv2/imgproc/imgproc_c.h +783 -0
  67. data/ext/opencv/include/opencv2/imgproc/types_c.h +538 -0
  68. data/imagecore.gemspec +20 -0
  69. data/lib/imagecore.rb +16 -0
  70. data/lib/imagecore/version.rb +3 -0
  71. metadata +119 -0
@@ -0,0 +1,1139 @@
1
+ /*! \file imgproc.hpp
2
+ \brief The Image Processing
3
+ */
4
+
5
+ /*M///////////////////////////////////////////////////////////////////////////////////////
6
+ //
7
+ // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
8
+ //
9
+ // By downloading, copying, installing or using the software you agree to this license.
10
+ // If you do not agree to this license, do not download, install,
11
+ // copy or use the software.
12
+ //
13
+ //
14
+ // License Agreement
15
+ // For Open Source Computer Vision Library
16
+ //
17
+ // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
18
+ // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
19
+ // Third party copyrights are property of their respective owners.
20
+ //
21
+ // Redistribution and use in source and binary forms, with or without modification,
22
+ // are permitted provided that the following conditions are met:
23
+ //
24
+ // * Redistribution's of source code must retain the above copyright notice,
25
+ // this list of conditions and the following disclaimer.
26
+ //
27
+ // * Redistribution's in binary form must reproduce the above copyright notice,
28
+ // this list of conditions and the following disclaimer in the documentation
29
+ // and/or other materials provided with the distribution.
30
+ //
31
+ // * The name of the copyright holders may not be used to endorse or promote products
32
+ // derived from this software without specific prior written permission.
33
+ //
34
+ // This software is provided by the copyright holders and contributors "as is" and
35
+ // any express or implied warranties, including, but not limited to, the implied
36
+ // warranties of merchantability and fitness for a particular purpose are disclaimed.
37
+ // In no event shall the Intel Corporation or contributors be liable for any direct,
38
+ // indirect, incidental, special, exemplary, or consequential damages
39
+ // (including, but not limited to, procurement of substitute goods or services;
40
+ // loss of use, data, or profits; or business interruption) however caused
41
+ // and on any theory of liability, whether in contract, strict liability,
42
+ // or tort (including negligence or otherwise) arising in any way out of
43
+ // the use of this software, even if advised of the possibility of such damage.
44
+ //
45
+ //M*/
46
+
47
+ #ifndef __OPENCV_IMGPROC_HPP__
48
+ #define __OPENCV_IMGPROC_HPP__
49
+
50
+ #include "opencv2/core/core.hpp"
51
+ #include "opencv2/imgproc/types_c.h"
52
+
53
+ #ifdef __cplusplus
54
+
55
+ /*! \namespace cv
56
+ Namespace where all the C++ OpenCV functionality resides
57
+ */
58
+ namespace cv
59
+ {
60
+
61
+ //! various border interpolation methods
62
+ enum { BORDER_REPLICATE=IPL_BORDER_REPLICATE, BORDER_CONSTANT=IPL_BORDER_CONSTANT,
63
+ BORDER_REFLECT=IPL_BORDER_REFLECT, BORDER_WRAP=IPL_BORDER_WRAP,
64
+ BORDER_REFLECT_101=IPL_BORDER_REFLECT_101, BORDER_REFLECT101=BORDER_REFLECT_101,
65
+ BORDER_TRANSPARENT=IPL_BORDER_TRANSPARENT,
66
+ BORDER_DEFAULT=BORDER_REFLECT_101, BORDER_ISOLATED=16 };
67
+
68
+ //! 1D interpolation function: returns coordinate of the "donor" pixel for the specified location p.
69
+ CV_EXPORTS_W int borderInterpolate( int p, int len, int borderType );
70
+
71
+ /*!
72
+ The Base Class for 1D or Row-wise Filters
73
+
74
+ This is the base class for linear or non-linear filters that process 1D data.
75
+ In particular, such filters are used for the "horizontal" filtering parts in separable filters.
76
+
77
+ Several functions in OpenCV return Ptr<BaseRowFilter> for the specific types of filters,
78
+ and those pointers can be used directly or within cv::FilterEngine.
79
+ */
80
+ class CV_EXPORTS BaseRowFilter
81
+ {
82
+ public:
83
+ //! the default constructor
84
+ BaseRowFilter();
85
+ //! the destructor
86
+ virtual ~BaseRowFilter();
87
+ //! the filtering operator. Must be overrided in the derived classes. The horizontal border interpolation is done outside of the class.
88
+ virtual void operator()(const uchar* src, uchar* dst,
89
+ int width, int cn) = 0;
90
+ int ksize, anchor;
91
+ };
92
+
93
+
94
+ /*!
95
+ The Base Class for Column-wise Filters
96
+
97
+ This is the base class for linear or non-linear filters that process columns of 2D arrays.
98
+ Such filters are used for the "vertical" filtering parts in separable filters.
99
+
100
+ Several functions in OpenCV return Ptr<BaseColumnFilter> for the specific types of filters,
101
+ and those pointers can be used directly or within cv::FilterEngine.
102
+
103
+ Unlike cv::BaseRowFilter, cv::BaseColumnFilter may have some context information,
104
+ i.e. box filter keeps the sliding sum of elements. To reset the state BaseColumnFilter::reset()
105
+ must be called (e.g. the method is called by cv::FilterEngine)
106
+ */
107
+ class CV_EXPORTS BaseColumnFilter
108
+ {
109
+ public:
110
+ //! the default constructor
111
+ BaseColumnFilter();
112
+ //! the destructor
113
+ virtual ~BaseColumnFilter();
114
+ //! the filtering operator. Must be overrided in the derived classes. The vertical border interpolation is done outside of the class.
115
+ virtual void operator()(const uchar** src, uchar* dst, int dststep,
116
+ int dstcount, int width) = 0;
117
+ //! resets the internal buffers, if any
118
+ virtual void reset();
119
+ int ksize, anchor;
120
+ };
121
+
122
+ /*!
123
+ The Base Class for Non-Separable 2D Filters.
124
+
125
+ This is the base class for linear or non-linear 2D filters.
126
+
127
+ Several functions in OpenCV return Ptr<BaseFilter> for the specific types of filters,
128
+ and those pointers can be used directly or within cv::FilterEngine.
129
+
130
+ Similar to cv::BaseColumnFilter, the class may have some context information,
131
+ that should be reset using BaseFilter::reset() method before processing the new array.
132
+ */
133
+ class CV_EXPORTS BaseFilter
134
+ {
135
+ public:
136
+ //! the default constructor
137
+ BaseFilter();
138
+ //! the destructor
139
+ virtual ~BaseFilter();
140
+ //! the filtering operator. The horizontal and the vertical border interpolation is done outside of the class.
141
+ virtual void operator()(const uchar** src, uchar* dst, int dststep,
142
+ int dstcount, int width, int cn) = 0;
143
+ //! resets the internal buffers, if any
144
+ virtual void reset();
145
+ Size ksize;
146
+ Point anchor;
147
+ };
148
+
149
+ /*!
150
+ The Main Class for Image Filtering.
151
+
152
+ The class can be used to apply an arbitrary filtering operation to an image.
153
+ It contains all the necessary intermediate buffers, it computes extrapolated values
154
+ of the "virtual" pixels outside of the image etc.
155
+ Pointers to the initialized cv::FilterEngine instances
156
+ are returned by various OpenCV functions, such as cv::createSeparableLinearFilter(),
157
+ cv::createLinearFilter(), cv::createGaussianFilter(), cv::createDerivFilter(),
158
+ cv::createBoxFilter() and cv::createMorphologyFilter().
159
+
160
+ Using the class you can process large images by parts and build complex pipelines
161
+ that include filtering as some of the stages. If all you need is to apply some pre-defined
162
+ filtering operation, you may use cv::filter2D(), cv::erode(), cv::dilate() etc.
163
+ functions that create FilterEngine internally.
164
+
165
+ Here is the example on how to use the class to implement Laplacian operator, which is the sum of
166
+ second-order derivatives. More complex variant for different types is implemented in cv::Laplacian().
167
+
168
+ \code
169
+ void laplace_f(const Mat& src, Mat& dst)
170
+ {
171
+ CV_Assert( src.type() == CV_32F );
172
+ // make sure the destination array has the proper size and type
173
+ dst.create(src.size(), src.type());
174
+
175
+ // get the derivative and smooth kernels for d2I/dx2.
176
+ // for d2I/dy2 we could use the same kernels, just swapped
177
+ Mat kd, ks;
178
+ getSobelKernels( kd, ks, 2, 0, ksize, false, ktype );
179
+
180
+ // let's process 10 source rows at once
181
+ int DELTA = std::min(10, src.rows);
182
+ Ptr<FilterEngine> Fxx = createSeparableLinearFilter(src.type(),
183
+ dst.type(), kd, ks, Point(-1,-1), 0, borderType, borderType, Scalar() );
184
+ Ptr<FilterEngine> Fyy = createSeparableLinearFilter(src.type(),
185
+ dst.type(), ks, kd, Point(-1,-1), 0, borderType, borderType, Scalar() );
186
+
187
+ int y = Fxx->start(src), dsty = 0, dy = 0;
188
+ Fyy->start(src);
189
+ const uchar* sptr = src.data + y*src.step;
190
+
191
+ // allocate the buffers for the spatial image derivatives;
192
+ // the buffers need to have more than DELTA rows, because at the
193
+ // last iteration the output may take max(kd.rows-1,ks.rows-1)
194
+ // rows more than the input.
195
+ Mat Ixx( DELTA + kd.rows - 1, src.cols, dst.type() );
196
+ Mat Iyy( DELTA + kd.rows - 1, src.cols, dst.type() );
197
+
198
+ // inside the loop we always pass DELTA rows to the filter
199
+ // (note that the "proceed" method takes care of possibe overflow, since
200
+ // it was given the actual image height in the "start" method)
201
+ // on output we can get:
202
+ // * < DELTA rows (the initial buffer accumulation stage)
203
+ // * = DELTA rows (settled state in the middle)
204
+ // * > DELTA rows (then the input image is over, but we generate
205
+ // "virtual" rows using the border mode and filter them)
206
+ // this variable number of output rows is dy.
207
+ // dsty is the current output row.
208
+ // sptr is the pointer to the first input row in the portion to process
209
+ for( ; dsty < dst.rows; sptr += DELTA*src.step, dsty += dy )
210
+ {
211
+ Fxx->proceed( sptr, (int)src.step, DELTA, Ixx.data, (int)Ixx.step );
212
+ dy = Fyy->proceed( sptr, (int)src.step, DELTA, d2y.data, (int)Iyy.step );
213
+ if( dy > 0 )
214
+ {
215
+ Mat dstripe = dst.rowRange(dsty, dsty + dy);
216
+ add(Ixx.rowRange(0, dy), Iyy.rowRange(0, dy), dstripe);
217
+ }
218
+ }
219
+ }
220
+ \endcode
221
+ */
222
+ class CV_EXPORTS FilterEngine
223
+ {
224
+ public:
225
+ //! the default constructor
226
+ FilterEngine();
227
+ //! the full constructor. Either _filter2D or both _rowFilter and _columnFilter must be non-empty.
228
+ FilterEngine(const Ptr<BaseFilter>& _filter2D,
229
+ const Ptr<BaseRowFilter>& _rowFilter,
230
+ const Ptr<BaseColumnFilter>& _columnFilter,
231
+ int srcType, int dstType, int bufType,
232
+ int _rowBorderType=BORDER_REPLICATE,
233
+ int _columnBorderType=-1,
234
+ const Scalar& _borderValue=Scalar());
235
+ //! the destructor
236
+ virtual ~FilterEngine();
237
+ //! reinitializes the engine. The previously assigned filters are released.
238
+ void init(const Ptr<BaseFilter>& _filter2D,
239
+ const Ptr<BaseRowFilter>& _rowFilter,
240
+ const Ptr<BaseColumnFilter>& _columnFilter,
241
+ int srcType, int dstType, int bufType,
242
+ int _rowBorderType=BORDER_REPLICATE, int _columnBorderType=-1,
243
+ const Scalar& _borderValue=Scalar());
244
+ //! starts filtering of the specified ROI of an image of size wholeSize.
245
+ virtual int start(Size wholeSize, Rect roi, int maxBufRows=-1);
246
+ //! starts filtering of the specified ROI of the specified image.
247
+ virtual int start(const Mat& src, const Rect& srcRoi=Rect(0,0,-1,-1),
248
+ bool isolated=false, int maxBufRows=-1);
249
+ //! processes the next srcCount rows of the image.
250
+ virtual int proceed(const uchar* src, int srcStep, int srcCount,
251
+ uchar* dst, int dstStep);
252
+ //! applies filter to the specified ROI of the image. if srcRoi=(0,0,-1,-1), the whole image is filtered.
253
+ virtual void apply( const Mat& src, Mat& dst,
254
+ const Rect& srcRoi=Rect(0,0,-1,-1),
255
+ Point dstOfs=Point(0,0),
256
+ bool isolated=false);
257
+ //! returns true if the filter is separable
258
+ bool isSeparable() const { return (const BaseFilter*)filter2D == 0; }
259
+ //! returns the number
260
+ int remainingInputRows() const;
261
+ int remainingOutputRows() const;
262
+
263
+ int srcType, dstType, bufType;
264
+ Size ksize;
265
+ Point anchor;
266
+ int maxWidth;
267
+ Size wholeSize;
268
+ Rect roi;
269
+ int dx1, dx2;
270
+ int rowBorderType, columnBorderType;
271
+ vector<int> borderTab;
272
+ int borderElemSize;
273
+ vector<uchar> ringBuf;
274
+ vector<uchar> srcRow;
275
+ vector<uchar> constBorderValue;
276
+ vector<uchar> constBorderRow;
277
+ int bufStep, startY, startY0, endY, rowCount, dstY;
278
+ vector<uchar*> rows;
279
+
280
+ Ptr<BaseFilter> filter2D;
281
+ Ptr<BaseRowFilter> rowFilter;
282
+ Ptr<BaseColumnFilter> columnFilter;
283
+ };
284
+
285
+ //! type of the kernel
286
+ enum { KERNEL_GENERAL=0, KERNEL_SYMMETRICAL=1, KERNEL_ASYMMETRICAL=2,
287
+ KERNEL_SMOOTH=4, KERNEL_INTEGER=8 };
288
+
289
+ //! returns type (one of KERNEL_*) of 1D or 2D kernel specified by its coefficients.
290
+ CV_EXPORTS int getKernelType(InputArray kernel, Point anchor);
291
+
292
+ //! returns the primitive row filter with the specified kernel
293
+ CV_EXPORTS Ptr<BaseRowFilter> getLinearRowFilter(int srcType, int bufType,
294
+ InputArray kernel, int anchor,
295
+ int symmetryType);
296
+
297
+ //! returns the primitive column filter with the specified kernel
298
+ CV_EXPORTS Ptr<BaseColumnFilter> getLinearColumnFilter(int bufType, int dstType,
299
+ InputArray kernel, int anchor,
300
+ int symmetryType, double delta=0,
301
+ int bits=0);
302
+
303
+ //! returns 2D filter with the specified kernel
304
+ CV_EXPORTS Ptr<BaseFilter> getLinearFilter(int srcType, int dstType,
305
+ InputArray kernel,
306
+ Point anchor=Point(-1,-1),
307
+ double delta=0, int bits=0);
308
+
309
+ //! returns the separable linear filter engine
310
+ CV_EXPORTS Ptr<FilterEngine> createSeparableLinearFilter(int srcType, int dstType,
311
+ InputArray rowKernel, InputArray columnKernel,
312
+ Point _anchor=Point(-1,-1), double delta=0,
313
+ int _rowBorderType=BORDER_DEFAULT,
314
+ int _columnBorderType=-1,
315
+ const Scalar& _borderValue=Scalar());
316
+
317
+ //! returns the non-separable linear filter engine
318
+ CV_EXPORTS Ptr<FilterEngine> createLinearFilter(int srcType, int dstType,
319
+ InputArray kernel, Point _anchor=Point(-1,-1),
320
+ double delta=0, int _rowBorderType=BORDER_DEFAULT,
321
+ int _columnBorderType=-1, const Scalar& _borderValue=Scalar());
322
+
323
+ //! returns the Gaussian kernel with the specified parameters
324
+ CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype=CV_64F );
325
+
326
+ //! returns the Gaussian filter engine
327
+ CV_EXPORTS Ptr<FilterEngine> createGaussianFilter( int type, Size ksize,
328
+ double sigma1, double sigma2=0,
329
+ int borderType=BORDER_DEFAULT);
330
+ //! initializes kernels of the generalized Sobel operator
331
+ CV_EXPORTS_W void getDerivKernels( OutputArray kx, OutputArray ky,
332
+ int dx, int dy, int ksize,
333
+ bool normalize=false, int ktype=CV_32F );
334
+ //! returns filter engine for the generalized Sobel operator
335
+ CV_EXPORTS Ptr<FilterEngine> createDerivFilter( int srcType, int dstType,
336
+ int dx, int dy, int ksize,
337
+ int borderType=BORDER_DEFAULT );
338
+ //! returns horizontal 1D box filter
339
+ CV_EXPORTS Ptr<BaseRowFilter> getRowSumFilter(int srcType, int sumType,
340
+ int ksize, int anchor=-1);
341
+ //! returns vertical 1D box filter
342
+ CV_EXPORTS Ptr<BaseColumnFilter> getColumnSumFilter( int sumType, int dstType,
343
+ int ksize, int anchor=-1,
344
+ double scale=1);
345
+ //! returns box filter engine
346
+ CV_EXPORTS Ptr<FilterEngine> createBoxFilter( int srcType, int dstType, Size ksize,
347
+ Point anchor=Point(-1,-1),
348
+ bool normalize=true,
349
+ int borderType=BORDER_DEFAULT);
350
+ //! type of morphological operation
351
+ enum { MORPH_ERODE=CV_MOP_ERODE, MORPH_DILATE=CV_MOP_DILATE,
352
+ MORPH_OPEN=CV_MOP_OPEN, MORPH_CLOSE=CV_MOP_CLOSE,
353
+ MORPH_GRADIENT=CV_MOP_GRADIENT, MORPH_TOPHAT=CV_MOP_TOPHAT,
354
+ MORPH_BLACKHAT=CV_MOP_BLACKHAT };
355
+
356
+ //! returns horizontal 1D morphological filter
357
+ CV_EXPORTS Ptr<BaseRowFilter> getMorphologyRowFilter(int op, int type, int ksize, int anchor=-1);
358
+ //! returns vertical 1D morphological filter
359
+ CV_EXPORTS Ptr<BaseColumnFilter> getMorphologyColumnFilter(int op, int type, int ksize, int anchor=-1);
360
+ //! returns 2D morphological filter
361
+ CV_EXPORTS Ptr<BaseFilter> getMorphologyFilter(int op, int type, InputArray kernel,
362
+ Point anchor=Point(-1,-1));
363
+
364
+ //! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation.
365
+ static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); }
366
+
367
+ //! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported.
368
+ CV_EXPORTS Ptr<FilterEngine> createMorphologyFilter(int op, int type, InputArray kernel,
369
+ Point anchor=Point(-1,-1), int _rowBorderType=BORDER_CONSTANT,
370
+ int _columnBorderType=-1,
371
+ const Scalar& _borderValue=morphologyDefaultBorderValue());
372
+
373
+ //! shape of the structuring element
374
+ enum { MORPH_RECT=0, MORPH_CROSS=1, MORPH_ELLIPSE=2 };
375
+ //! returns structuring element of the specified shape and size
376
+ CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor=Point(-1,-1));
377
+
378
+ template<> CV_EXPORTS void Ptr<IplConvKernel>::delete_obj();
379
+
380
+ //! copies 2D array to a larger destination array with extrapolation of the outer part of src using the specified border mode
381
+ CV_EXPORTS_W void copyMakeBorder( InputArray src, OutputArray dst,
382
+ int top, int bottom, int left, int right,
383
+ int borderType, const Scalar& value=Scalar() );
384
+
385
+ //! smooths the image using median filter.
386
+ CV_EXPORTS_W void medianBlur( InputArray src, OutputArray dst, int ksize );
387
+ //! smooths the image using Gaussian filter.
388
+ CV_EXPORTS_W void GaussianBlur( InputArray src,
389
+ OutputArray dst, Size ksize,
390
+ double sigma1, double sigma2=0,
391
+ int borderType=BORDER_DEFAULT );
392
+ //! smooths the image using bilateral filter
393
+ CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d,
394
+ double sigmaColor, double sigmaSpace,
395
+ int borderType=BORDER_DEFAULT );
396
+ //! smooths the image using the box filter. Each pixel is processed in O(1) time
397
+ CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth,
398
+ Size ksize, Point anchor=Point(-1,-1),
399
+ bool normalize=true,
400
+ int borderType=BORDER_DEFAULT );
401
+ //! a synonym for normalized box filter
402
+ CV_EXPORTS_W void blur( InputArray src, OutputArray dst,
403
+ Size ksize, Point anchor=Point(-1,-1),
404
+ int borderType=BORDER_DEFAULT );
405
+
406
+ //! applies non-separable 2D linear filter to the image
407
+ CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth,
408
+ InputArray kernel, Point anchor=Point(-1,-1),
409
+ double delta=0, int borderType=BORDER_DEFAULT );
410
+
411
+ //! applies separable 2D linear filter to the image
412
+ CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth,
413
+ InputArray kernelX, InputArray kernelY,
414
+ Point anchor=Point(-1,-1),
415
+ double delta=0, int borderType=BORDER_DEFAULT );
416
+
417
+ //! applies generalized Sobel operator to the image
418
+ CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth,
419
+ int dx, int dy, int ksize=3,
420
+ double scale=1, double delta=0,
421
+ int borderType=BORDER_DEFAULT );
422
+
423
+ //! applies the vertical or horizontal Scharr operator to the image
424
+ CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth,
425
+ int dx, int dy, double scale=1, double delta=0,
426
+ int borderType=BORDER_DEFAULT );
427
+
428
+ //! applies Laplacian operator to the image
429
+ CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
430
+ int ksize=1, double scale=1, double delta=0,
431
+ int borderType=BORDER_DEFAULT );
432
+
433
+ //! applies Canny edge detector and produces the edge map.
434
+ CV_EXPORTS_W void Canny( InputArray image, OutputArray edges,
435
+ double threshold1, double threshold2,
436
+ int apertureSize=3, bool L2gradient=false );
437
+
438
+ //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
439
+ CV_EXPORTS_W void cornerMinEigenVal( InputArray src, OutputArray dst,
440
+ int blockSize, int ksize=3,
441
+ int borderType=BORDER_DEFAULT );
442
+
443
+ //! computes Harris cornerness criteria at each image pixel
444
+ CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize,
445
+ int ksize, double k,
446
+ int borderType=BORDER_DEFAULT );
447
+
448
+ //! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix at each pixel. The output is stored as 6-channel matrix.
449
+ CV_EXPORTS_W void cornerEigenValsAndVecs( InputArray src, OutputArray dst,
450
+ int blockSize, int ksize,
451
+ int borderType=BORDER_DEFAULT );
452
+
453
+ //! computes another complex cornerness criteria at each pixel
454
+ CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize,
455
+ int borderType=BORDER_DEFAULT );
456
+
457
+ //! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria
458
+ CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners,
459
+ Size winSize, Size zeroZone,
460
+ TermCriteria criteria );
461
+
462
+ //! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima
463
+ CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
464
+ int maxCorners, double qualityLevel, double minDistance,
465
+ InputArray mask=noArray(), int blockSize=3,
466
+ bool useHarrisDetector=false, double k=0.04 );
467
+
468
+ //! finds lines in the black-n-white image using the standard or pyramid Hough transform
469
+ CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines,
470
+ double rho, double theta, int threshold,
471
+ double srn=0, double stn=0 );
472
+
473
+ //! finds line segments in the black-n-white image using probabalistic Hough transform
474
+ CV_EXPORTS_W void HoughLinesP( InputArray image, OutputArray lines,
475
+ double rho, double theta, int threshold,
476
+ double minLineLength=0, double maxLineGap=0 );
477
+
478
+ //! finds circles in the grayscale image using 2+1 gradient Hough transform
479
+ CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles,
480
+ int method, double dp, double minDist,
481
+ double param1=100, double param2=100,
482
+ int minRadius=0, int maxRadius=0 );
483
+
484
+ //! erodes the image (applies the local minimum operator)
485
+ CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel,
486
+ Point anchor=Point(-1,-1), int iterations=1,
487
+ int borderType=BORDER_CONSTANT,
488
+ const Scalar& borderValue=morphologyDefaultBorderValue() );
489
+
490
+ //! dilates the image (applies the local maximum operator)
491
+ CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel,
492
+ Point anchor=Point(-1,-1), int iterations=1,
493
+ int borderType=BORDER_CONSTANT,
494
+ const Scalar& borderValue=morphologyDefaultBorderValue() );
495
+
496
+ //! applies an advanced morphological operation to the image
497
+ CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst,
498
+ int op, InputArray kernel,
499
+ Point anchor=Point(-1,-1), int iterations=1,
500
+ int borderType=BORDER_CONSTANT,
501
+ const Scalar& borderValue=morphologyDefaultBorderValue() );
502
+
503
+ //! interpolation algorithm
504
+ enum
505
+ {
506
+ INTER_NEAREST=CV_INTER_NN, //!< nearest neighbor interpolation
507
+ INTER_LINEAR=CV_INTER_LINEAR, //!< bilinear interpolation
508
+ INTER_CUBIC=CV_INTER_CUBIC, //!< bicubic interpolation
509
+ INTER_AREA=CV_INTER_AREA, //!< area-based (or super) interpolation
510
+ INTER_LANCZOS4=CV_INTER_LANCZOS4, //!< Lanczos interpolation over 8x8 neighborhood
511
+ INTER_MAX=7,
512
+ WARP_INVERSE_MAP=CV_WARP_INVERSE_MAP
513
+ };
514
+
515
+ //! resizes the image
516
+ CV_EXPORTS_W void resize( InputArray src, OutputArray dst,
517
+ Size dsize, double fx=0, double fy=0,
518
+ int interpolation=INTER_LINEAR );
519
+
520
+ //! warps the image using affine transformation
521
+ CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst,
522
+ InputArray M, Size dsize,
523
+ int flags=INTER_LINEAR,
524
+ int borderMode=BORDER_CONSTANT,
525
+ const Scalar& borderValue=Scalar());
526
+
527
+ //! warps the image using perspective transformation
528
+ CV_EXPORTS_W void warpPerspective( InputArray src, OutputArray dst,
529
+ InputArray M, Size dsize,
530
+ int flags=INTER_LINEAR,
531
+ int borderMode=BORDER_CONSTANT,
532
+ const Scalar& borderValue=Scalar());
533
+
534
+ enum
535
+ {
536
+ INTER_BITS=5, INTER_BITS2=INTER_BITS*2,
537
+ INTER_TAB_SIZE=(1<<INTER_BITS),
538
+ INTER_TAB_SIZE2=INTER_TAB_SIZE*INTER_TAB_SIZE
539
+ };
540
+
541
+ //! warps the image using the precomputed maps. The maps are stored in either floating-point or integer fixed-point format
542
+ CV_EXPORTS_W void remap( InputArray src, OutputArray dst,
543
+ InputArray map1, InputArray map2,
544
+ int interpolation, int borderMode=BORDER_CONSTANT,
545
+ const Scalar& borderValue=Scalar());
546
+
547
+ //! converts maps for remap from floating-point to fixed-point format or backwards
548
+ CV_EXPORTS_W void convertMaps( InputArray map1, InputArray map2,
549
+ OutputArray dstmap1, OutputArray dstmap2,
550
+ int dstmap1type, bool nninterpolation=false );
551
+
552
+ //! returns 2x3 affine transformation matrix for the planar rotation.
553
+ CV_EXPORTS_W Mat getRotationMatrix2D( Point2f center, double angle, double scale );
554
+ //! returns 3x3 perspective transformation for the corresponding 4 point pairs.
555
+ CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] );
556
+ //! returns 2x3 affine transformation for the corresponding 3 point pairs.
557
+ CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] );
558
+ //! computes 2x3 affine transformation matrix that is inverse to the specified 2x3 affine transformation.
559
+ CV_EXPORTS_W void invertAffineTransform( InputArray M, OutputArray iM );
560
+
561
+ CV_EXPORTS_W Mat getPerspectiveTransform( InputArray src, InputArray dst );
562
+ CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
563
+
564
+ //! extracts rectangle from the image at sub-pixel location
565
+ CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize,
566
+ Point2f center, OutputArray patch, int patchType=-1 );
567
+
568
+ //! computes the integral image
569
+ CV_EXPORTS_W void integral( InputArray src, OutputArray sum, int sdepth=-1 );
570
+
571
+ //! computes the integral image and integral for the squared image
572
+ CV_EXPORTS_AS(integral2) void integral( InputArray src, OutputArray sum,
573
+ OutputArray sqsum, int sdepth=-1 );
574
+ //! computes the integral image, integral for the squared image and the tilted integral image
575
+ CV_EXPORTS_AS(integral3) void integral( InputArray src, OutputArray sum,
576
+ OutputArray sqsum, OutputArray tilted,
577
+ int sdepth=-1 );
578
+
579
+ //! adds image to the accumulator (dst += src). Unlike cv::add, dst and src can have different types.
580
+ CV_EXPORTS_W void accumulate( InputArray src, InputOutputArray dst,
581
+ InputArray mask=noArray() );
582
+ //! adds squared src image to the accumulator (dst += src*src).
583
+ CV_EXPORTS_W void accumulateSquare( InputArray src, InputOutputArray dst,
584
+ InputArray mask=noArray() );
585
+ //! adds product of the 2 images to the accumulator (dst += src1*src2).
586
+ CV_EXPORTS_W void accumulateProduct( InputArray src1, InputArray src2,
587
+ InputOutputArray dst, InputArray mask=noArray() );
588
+ //! updates the running average (dst = dst*(1-alpha) + src*alpha)
589
+ CV_EXPORTS_W void accumulateWeighted( InputArray src, InputOutputArray dst,
590
+ double alpha, InputArray mask=noArray() );
591
+
592
+ //! type of the threshold operation
593
+ enum { THRESH_BINARY=CV_THRESH_BINARY, THRESH_BINARY_INV=CV_THRESH_BINARY_INV,
594
+ THRESH_TRUNC=CV_THRESH_TRUNC, THRESH_TOZERO=CV_THRESH_TOZERO,
595
+ THRESH_TOZERO_INV=CV_THRESH_TOZERO_INV, THRESH_MASK=CV_THRESH_MASK,
596
+ THRESH_OTSU=CV_THRESH_OTSU };
597
+
598
+ //! applies fixed threshold to the image
599
+ CV_EXPORTS_W double threshold( InputArray src, OutputArray dst,
600
+ double thresh, double maxval, int type );
601
+
602
+ //! adaptive threshold algorithm
603
+ enum { ADAPTIVE_THRESH_MEAN_C=0, ADAPTIVE_THRESH_GAUSSIAN_C=1 };
604
+
605
+ //! applies variable (adaptive) threshold to the image
606
+ CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst,
607
+ double maxValue, int adaptiveMethod,
608
+ int thresholdType, int blockSize, double C );
609
+
610
+ //! smooths and downsamples the image
611
+ CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst,
612
+ const Size& dstsize=Size());
613
+ //! upsamples and smoothes the image
614
+ CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst,
615
+ const Size& dstsize=Size());
616
+
617
+ //! builds the gaussian pyramid using pyrDown() as a basic operation
618
+ CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst, int maxlevel );
619
+
620
+ //! corrects lens distortion for the given camera matrix and distortion coefficients
621
+ CV_EXPORTS_W void undistort( InputArray src, OutputArray dst,
622
+ InputArray cameraMatrix,
623
+ InputArray distCoeffs,
624
+ InputArray newCameraMatrix=noArray() );
625
+
626
+ //! initializes maps for cv::remap() to correct lens distortion and optionally rectify the image
627
+ CV_EXPORTS_W void initUndistortRectifyMap( InputArray cameraMatrix, InputArray distCoeffs,
628
+ InputArray R, InputArray newCameraMatrix,
629
+ Size size, int m1type, OutputArray map1, OutputArray map2 );
630
+
631
+ enum
632
+ {
633
+ PROJ_SPHERICAL_ORTHO = 0,
634
+ PROJ_SPHERICAL_EQRECT = 1
635
+ };
636
+
637
+ //! initializes maps for cv::remap() for wide-angle
638
+ CV_EXPORTS_W float initWideAngleProjMap( InputArray cameraMatrix, InputArray distCoeffs,
639
+ Size imageSize, int destImageWidth,
640
+ int m1type, OutputArray map1, OutputArray map2,
641
+ int projType=PROJ_SPHERICAL_EQRECT, double alpha=0);
642
+
643
+ //! returns the default new camera matrix (by default it is the same as cameraMatrix unless centerPricipalPoint=true)
644
+ CV_EXPORTS_W Mat getDefaultNewCameraMatrix( InputArray cameraMatrix, Size imgsize=Size(),
645
+ bool centerPrincipalPoint=false );
646
+
647
+ //! returns points' coordinates after lens distortion correction
648
+ CV_EXPORTS void undistortPoints( InputArray src, OutputArray dst,
649
+ InputArray cameraMatrix, InputArray distCoeffs,
650
+ InputArray R=noArray(), InputArray P=noArray());
651
+
652
+ template<> CV_EXPORTS void Ptr<CvHistogram>::delete_obj();
653
+
654
+ //! computes the joint dense histogram for a set of images.
655
+ CV_EXPORTS void calcHist( const Mat* images, int nimages,
656
+ const int* channels, InputArray mask,
657
+ OutputArray hist, int dims, const int* histSize,
658
+ const float** ranges, bool uniform=true, bool accumulate=false );
659
+
660
+ //! computes the joint sparse histogram for a set of images.
661
+ CV_EXPORTS void calcHist( const Mat* images, int nimages,
662
+ const int* channels, InputArray mask,
663
+ SparseMat& hist, int dims,
664
+ const int* histSize, const float** ranges,
665
+ bool uniform=true, bool accumulate=false );
666
+
667
+ CV_EXPORTS_W void calcHist( InputArrayOfArrays images,
668
+ const vector<int>& channels,
669
+ InputArray mask, OutputArray hist,
670
+ const vector<int>& histSize,
671
+ const vector<float>& ranges,
672
+ bool accumulate=false );
673
+
674
+ //! computes back projection for the set of images
675
+ CV_EXPORTS void calcBackProject( const Mat* images, int nimages,
676
+ const int* channels, InputArray hist,
677
+ OutputArray backProject, const float** ranges,
678
+ double scale=1, bool uniform=true );
679
+
680
+ //! computes back projection for the set of images
681
+ CV_EXPORTS void calcBackProject( const Mat* images, int nimages,
682
+ const int* channels, const SparseMat& hist,
683
+ OutputArray backProject, const float** ranges,
684
+ double scale=1, bool uniform=true );
685
+
686
+ CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const vector<int>& channels,
687
+ InputArray hist, OutputArray dst,
688
+ const vector<float>& ranges,
689
+ double scale );
690
+
691
+ //! compares two histograms stored in dense arrays
692
+ CV_EXPORTS_W double compareHist( InputArray H1, InputArray H2, int method );
693
+
694
+ //! compares two histograms stored in sparse arrays
695
+ CV_EXPORTS double compareHist( const SparseMat& H1, const SparseMat& H2, int method );
696
+
697
+ //! normalizes the grayscale image brightness and contrast by normalizing its histogram
698
+ CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst );
699
+
700
+ CV_EXPORTS float EMD( InputArray signature1, InputArray signature2,
701
+ int distType, InputArray cost=noArray(),
702
+ float* lowerBound=0, OutputArray flow=noArray() );
703
+
704
+ //! segments the image using watershed algorithm
705
+ CV_EXPORTS_W void watershed( InputArray image, InputOutputArray markers );
706
+
707
+ //! filters image using meanshift algorithm
708
+ CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst,
709
+ double sp, double sr, int maxLevel=1,
710
+ TermCriteria termcrit=TermCriteria(
711
+ TermCriteria::MAX_ITER+TermCriteria::EPS,5,1) );
712
+
713
+ //! class of the pixel in GrabCut algorithm
714
+ enum
715
+ {
716
+ GC_BGD = 0, //!< background
717
+ GC_FGD = 1, //!< foreground
718
+ GC_PR_BGD = 2, //!< most probably background
719
+ GC_PR_FGD = 3 //!< most probably foreground
720
+ };
721
+
722
+ //! GrabCut algorithm flags
723
+ enum
724
+ {
725
+ GC_INIT_WITH_RECT = 0,
726
+ GC_INIT_WITH_MASK = 1,
727
+ GC_EVAL = 2
728
+ };
729
+
730
+ //! segments the image using GrabCut algorithm
731
+ CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect,
732
+ InputOutputArray bgdModel, InputOutputArray fgdModel,
733
+ int iterCount, int mode = GC_EVAL );
734
+
735
+ //! the inpainting algorithm
736
+ enum
737
+ {
738
+ INPAINT_NS=CV_INPAINT_NS, // Navier-Stokes algorithm
739
+ INPAINT_TELEA=CV_INPAINT_TELEA // A. Telea algorithm
740
+ };
741
+
742
+ //! restores the damaged image areas using one of the available intpainting algorithms
743
+ CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask,
744
+ OutputArray dst, double inpaintRange, int flags );
745
+
746
+ //! builds the discrete Voronoi diagram
747
+ CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst,
748
+ OutputArray labels, int distanceType, int maskSize );
749
+
750
+ //! computes the distance transform map
751
+ CV_EXPORTS void distanceTransform( InputArray src, OutputArray dst,
752
+ int distanceType, int maskSize );
753
+
754
+ enum { FLOODFILL_FIXED_RANGE = 1 << 16, FLOODFILL_MASK_ONLY = 1 << 17 };
755
+
756
+ //! fills the semi-uniform image region starting from the specified seed point
757
+ CV_EXPORTS int floodFill( InputOutputArray image,
758
+ Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0,
759
+ Scalar loDiff=Scalar(), Scalar upDiff=Scalar(),
760
+ int flags=4 );
761
+
762
+ //! fills the semi-uniform image region and/or the mask starting from the specified seed point
763
+ CV_EXPORTS_W int floodFill( InputOutputArray image, InputOutputArray mask,
764
+ Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0,
765
+ Scalar loDiff=Scalar(), Scalar upDiff=Scalar(),
766
+ int flags=4 );
767
+
768
+
769
+ enum
770
+ {
771
+ COLOR_BGR2BGRA =0,
772
+ COLOR_RGB2RGBA =COLOR_BGR2BGRA,
773
+
774
+ COLOR_BGRA2BGR =1,
775
+ COLOR_RGBA2RGB =COLOR_BGRA2BGR,
776
+
777
+ COLOR_BGR2RGBA =2,
778
+ COLOR_RGB2BGRA =COLOR_BGR2RGBA,
779
+
780
+ COLOR_RGBA2BGR =3,
781
+ COLOR_BGRA2RGB =COLOR_RGBA2BGR,
782
+
783
+ COLOR_BGR2RGB =4,
784
+ COLOR_RGB2BGR =COLOR_BGR2RGB,
785
+
786
+ COLOR_BGRA2RGBA =5,
787
+ COLOR_RGBA2BGRA =COLOR_BGRA2RGBA,
788
+
789
+ COLOR_BGR2GRAY =6,
790
+ COLOR_RGB2GRAY =7,
791
+ COLOR_GRAY2BGR =8,
792
+ COLOR_GRAY2RGB =COLOR_GRAY2BGR,
793
+ COLOR_GRAY2BGRA =9,
794
+ COLOR_GRAY2RGBA =COLOR_GRAY2BGRA,
795
+ COLOR_BGRA2GRAY =10,
796
+ COLOR_RGBA2GRAY =11,
797
+
798
+ COLOR_BGR2BGR565 =12,
799
+ COLOR_RGB2BGR565 =13,
800
+ COLOR_BGR5652BGR =14,
801
+ COLOR_BGR5652RGB =15,
802
+ COLOR_BGRA2BGR565 =16,
803
+ COLOR_RGBA2BGR565 =17,
804
+ COLOR_BGR5652BGRA =18,
805
+ COLOR_BGR5652RGBA =19,
806
+
807
+ COLOR_GRAY2BGR565 =20,
808
+ COLOR_BGR5652GRAY =21,
809
+
810
+ COLOR_BGR2BGR555 =22,
811
+ COLOR_RGB2BGR555 =23,
812
+ COLOR_BGR5552BGR =24,
813
+ COLOR_BGR5552RGB =25,
814
+ COLOR_BGRA2BGR555 =26,
815
+ COLOR_RGBA2BGR555 =27,
816
+ COLOR_BGR5552BGRA =28,
817
+ COLOR_BGR5552RGBA =29,
818
+
819
+ COLOR_GRAY2BGR555 =30,
820
+ COLOR_BGR5552GRAY =31,
821
+
822
+ COLOR_BGR2XYZ =32,
823
+ COLOR_RGB2XYZ =33,
824
+ COLOR_XYZ2BGR =34,
825
+ COLOR_XYZ2RGB =35,
826
+
827
+ COLOR_BGR2YCrCb =36,
828
+ COLOR_RGB2YCrCb =37,
829
+ COLOR_YCrCb2BGR =38,
830
+ COLOR_YCrCb2RGB =39,
831
+
832
+ COLOR_BGR2HSV =40,
833
+ COLOR_RGB2HSV =41,
834
+
835
+ COLOR_BGR2Lab =44,
836
+ COLOR_RGB2Lab =45,
837
+
838
+ COLOR_BayerBG2BGR =46,
839
+ COLOR_BayerGB2BGR =47,
840
+ COLOR_BayerRG2BGR =48,
841
+ COLOR_BayerGR2BGR =49,
842
+
843
+ COLOR_BayerBG2RGB =COLOR_BayerRG2BGR,
844
+ COLOR_BayerGB2RGB =COLOR_BayerGR2BGR,
845
+ COLOR_BayerRG2RGB =COLOR_BayerBG2BGR,
846
+ COLOR_BayerGR2RGB =COLOR_BayerGB2BGR,
847
+
848
+ COLOR_BGR2Luv =50,
849
+ COLOR_RGB2Luv =51,
850
+ COLOR_BGR2HLS =52,
851
+ COLOR_RGB2HLS =53,
852
+
853
+ COLOR_HSV2BGR =54,
854
+ COLOR_HSV2RGB =55,
855
+
856
+ COLOR_Lab2BGR =56,
857
+ COLOR_Lab2RGB =57,
858
+ COLOR_Luv2BGR =58,
859
+ COLOR_Luv2RGB =59,
860
+ COLOR_HLS2BGR =60,
861
+ COLOR_HLS2RGB =61,
862
+
863
+ COLOR_BayerBG2BGR_VNG =62,
864
+ COLOR_BayerGB2BGR_VNG =63,
865
+ COLOR_BayerRG2BGR_VNG =64,
866
+ COLOR_BayerGR2BGR_VNG =65,
867
+
868
+ COLOR_BayerBG2RGB_VNG =COLOR_BayerRG2BGR_VNG,
869
+ COLOR_BayerGB2RGB_VNG =COLOR_BayerGR2BGR_VNG,
870
+ COLOR_BayerRG2RGB_VNG =COLOR_BayerBG2BGR_VNG,
871
+ COLOR_BayerGR2RGB_VNG =COLOR_BayerGB2BGR_VNG,
872
+
873
+ COLOR_BGR2HSV_FULL = 66,
874
+ COLOR_RGB2HSV_FULL = 67,
875
+ COLOR_BGR2HLS_FULL = 68,
876
+ COLOR_RGB2HLS_FULL = 69,
877
+
878
+ COLOR_HSV2BGR_FULL = 70,
879
+ COLOR_HSV2RGB_FULL = 71,
880
+ COLOR_HLS2BGR_FULL = 72,
881
+ COLOR_HLS2RGB_FULL = 73,
882
+
883
+ COLOR_LBGR2Lab = 74,
884
+ COLOR_LRGB2Lab = 75,
885
+ COLOR_LBGR2Luv = 76,
886
+ COLOR_LRGB2Luv = 77,
887
+
888
+ COLOR_Lab2LBGR = 78,
889
+ COLOR_Lab2LRGB = 79,
890
+ COLOR_Luv2LBGR = 80,
891
+ COLOR_Luv2LRGB = 81,
892
+
893
+ COLOR_BGR2YUV = 82,
894
+ COLOR_RGB2YUV = 83,
895
+ COLOR_YUV2BGR = 84,
896
+ COLOR_YUV2RGB = 85,
897
+
898
+ COLOR_BayerBG2GRAY = 86,
899
+ COLOR_BayerGB2GRAY = 87,
900
+ COLOR_BayerRG2GRAY = 88,
901
+ COLOR_BayerGR2GRAY = 89,
902
+
903
+ COLOR_YUV420i2RGB = 90,
904
+ COLOR_YUV420i2BGR = 91,
905
+ COLOR_YUV420sp2RGB = 92,
906
+ COLOR_YUV420sp2BGR = 93,
907
+
908
+ COLOR_COLORCVT_MAX =100
909
+ };
910
+
911
+
912
+ //! converts image from one color space to another
913
+ CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn=0 );
914
+
915
+ //! raster image moments
916
+ class CV_EXPORTS_W_MAP Moments
917
+ {
918
+ public:
919
+ //! the default constructor
920
+ Moments();
921
+ //! the full constructor
922
+ Moments(double m00, double m10, double m01, double m20, double m11,
923
+ double m02, double m30, double m21, double m12, double m03 );
924
+ //! the conversion from CvMoments
925
+ Moments( const CvMoments& moments );
926
+ //! the conversion to CvMoments
927
+ operator CvMoments() const;
928
+
929
+ //! spatial moments
930
+ CV_PROP_RW double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;
931
+ //! central moments
932
+ CV_PROP_RW double mu20, mu11, mu02, mu30, mu21, mu12, mu03;
933
+ //! central normalized moments
934
+ CV_PROP_RW double nu20, nu11, nu02, nu30, nu21, nu12, nu03;
935
+ };
936
+
937
+ //! computes moments of the rasterized shape or a vector of points
938
+ CV_EXPORTS_W Moments moments( InputArray array, bool binaryImage=false );
939
+
940
+ //! computes 7 Hu invariants from the moments
941
+ CV_EXPORTS void HuMoments( const Moments& moments, double hu[7] );
942
+ CV_EXPORTS_W void HuMoments( const Moments& m, CV_OUT OutputArray hu );
943
+
944
+ //! type of the template matching operation
945
+ enum { TM_SQDIFF=0, TM_SQDIFF_NORMED=1, TM_CCORR=2, TM_CCORR_NORMED=3, TM_CCOEFF=4, TM_CCOEFF_NORMED=5 };
946
+
947
+ //! computes the proximity map for the raster template and the image where the template is searched for
948
+ CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
949
+ OutputArray result, int method );
950
+
951
+ //! mode of the contour retrieval algorithm
952
+ enum
953
+ {
954
+ RETR_EXTERNAL=CV_RETR_EXTERNAL, //!< retrieve only the most external (top-level) contours
955
+ RETR_LIST=CV_RETR_LIST, //!< retrieve all the contours without any hierarchical information
956
+ RETR_CCOMP=CV_RETR_CCOMP, //!< retrieve the connected components (that can possibly be nested)
957
+ RETR_TREE=CV_RETR_TREE //!< retrieve all the contours and the whole hierarchy
958
+ };
959
+
960
+ //! the contour approximation algorithm
961
+ enum
962
+ {
963
+ CHAIN_APPROX_NONE=CV_CHAIN_APPROX_NONE,
964
+ CHAIN_APPROX_SIMPLE=CV_CHAIN_APPROX_SIMPLE,
965
+ CHAIN_APPROX_TC89_L1=CV_CHAIN_APPROX_TC89_L1,
966
+ CHAIN_APPROX_TC89_KCOS=CV_CHAIN_APPROX_TC89_KCOS
967
+ };
968
+
969
+ //! retrieves contours and the hierarchical information from black-n-white image.
970
+ CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays contours,
971
+ OutputArray hierarchy, int mode,
972
+ int method, Point offset=Point());
973
+
974
+ //! retrieves contours from black-n-white image.
975
+ CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours,
976
+ int mode, int method, Point offset=Point());
977
+
978
+ //! draws contours in the image
979
+ CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours,
980
+ int contourIdx, const Scalar& color,
981
+ int thickness=1, int lineType=8,
982
+ InputArray hierarchy=noArray(),
983
+ int maxLevel=INT_MAX, Point offset=Point() );
984
+
985
+ //! approximates contour or a curve using Douglas-Peucker algorithm
986
+ CV_EXPORTS_W void approxPolyDP( InputArray curve,
987
+ OutputArray approxCurve,
988
+ double epsilon, bool closed );
989
+
990
+ //! computes the contour perimeter (closed=true) or a curve length
991
+ CV_EXPORTS_W double arcLength( InputArray curve, bool closed );
992
+ //! computes the bounding rectangle for a contour
993
+ CV_EXPORTS_W Rect boundingRect( InputArray points );
994
+ //! computes the contour area
995
+ CV_EXPORTS_W double contourArea( InputArray contour, bool oriented=false );
996
+ //! computes the minimal rotated rectangle for a set of points
997
+ CV_EXPORTS_W RotatedRect minAreaRect( InputArray points );
998
+ //! computes the minimal enclosing circle for a set of points
999
+ CV_EXPORTS_W void minEnclosingCircle( InputArray points,
1000
+ CV_OUT Point2f& center, CV_OUT float& radius );
1001
+ //! matches two contours using one of the available algorithms
1002
+ CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2,
1003
+ int method, double parameter );
1004
+ //! computes convex hull for a set of 2D points.
1005
+ CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull,
1006
+ bool clockwise=false, bool returnPoints=true );
1007
+
1008
+ //! returns true iff the contour is convex. Does not support contours with self-intersection
1009
+ CV_EXPORTS_W bool isContourConvex( InputArray contour );
1010
+
1011
+ //! fits ellipse to the set of 2D points
1012
+ CV_EXPORTS_W RotatedRect fitEllipse( InputArray points );
1013
+
1014
+ //! fits line to the set of 2D points using M-estimator algorithm
1015
+ CV_EXPORTS_W void fitLine( InputArray points, OutputArray line, int distType,
1016
+ double param, double reps, double aeps );
1017
+ //! checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary
1018
+ CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist );
1019
+
1020
+
1021
+ class CV_EXPORTS_W Subdiv2D
1022
+ {
1023
+ public:
1024
+ enum
1025
+ {
1026
+ PTLOC_ERROR = -2,
1027
+ PTLOC_OUTSIDE_RECT = -1,
1028
+ PTLOC_INSIDE = 0,
1029
+ PTLOC_VERTEX = 1,
1030
+ PTLOC_ON_EDGE = 2
1031
+ };
1032
+
1033
+ enum
1034
+ {
1035
+ NEXT_AROUND_ORG = 0x00,
1036
+ NEXT_AROUND_DST = 0x22,
1037
+ PREV_AROUND_ORG = 0x11,
1038
+ PREV_AROUND_DST = 0x33,
1039
+ NEXT_AROUND_LEFT = 0x13,
1040
+ NEXT_AROUND_RIGHT = 0x31,
1041
+ PREV_AROUND_LEFT = 0x20,
1042
+ PREV_AROUND_RIGHT = 0x02
1043
+ };
1044
+
1045
+ CV_WRAP Subdiv2D();
1046
+ CV_WRAP Subdiv2D(Rect rect);
1047
+ CV_WRAP void initDelaunay(Rect rect);
1048
+
1049
+ CV_WRAP int insert(Point2f pt);
1050
+ CV_WRAP void insert(const vector<Point2f>& ptvec);
1051
+ CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex);
1052
+
1053
+ CV_WRAP int findNearest(Point2f pt, CV_OUT Point2f* nearestPt=0);
1054
+ CV_WRAP void getEdgeList(CV_OUT vector<Vec4f>& edgeList) const;
1055
+ CV_WRAP void getTriangleList(CV_OUT vector<Vec6f>& triangleList) const;
1056
+ CV_WRAP void getVoronoiFacetList(const vector<int>& idx, CV_OUT vector<vector<Point2f> >& facetList,
1057
+ CV_OUT vector<Point2f>& facetCenters);
1058
+
1059
+ CV_WRAP Point2f getVertex(int vertex, CV_OUT int* firstEdge=0) const;
1060
+
1061
+ CV_WRAP int getEdge( int edge, int nextEdgeType ) const;
1062
+ CV_WRAP int nextEdge(int edge) const;
1063
+ CV_WRAP int rotateEdge(int edge, int rotate) const;
1064
+ CV_WRAP int symEdge(int edge) const;
1065
+ CV_WRAP int edgeOrg(int edge, CV_OUT Point2f* orgpt=0) const;
1066
+ CV_WRAP int edgeDst(int edge, CV_OUT Point2f* dstpt=0) const;
1067
+
1068
+ protected:
1069
+ int newEdge();
1070
+ void deleteEdge(int edge);
1071
+ int newPoint(Point2f pt, bool isvirtual, int firstEdge=0);
1072
+ void deletePoint(int vtx);
1073
+ void setEdgePoints( int edge, int orgPt, int dstPt );
1074
+ void splice( int edgeA, int edgeB );
1075
+ int connectEdges( int edgeA, int edgeB );
1076
+ void swapEdges( int edge );
1077
+ int isRightOf(Point2f pt, int edge) const;
1078
+ void calcVoronoi();
1079
+ void clearVoronoi();
1080
+ void check() const;
1081
+
1082
+ struct CV_EXPORTS Vertex
1083
+ {
1084
+ Vertex();
1085
+ Vertex(Point2f pt, bool _isvirtual, int _firstEdge=0);
1086
+ bool isvirtual() const;
1087
+ bool isfree() const;
1088
+ int firstEdge;
1089
+ int type;
1090
+ Point2f pt;
1091
+ };
1092
+ struct CV_EXPORTS QuadEdge
1093
+ {
1094
+ QuadEdge();
1095
+ QuadEdge(int edgeidx);
1096
+ bool isfree() const;
1097
+ int next[4];
1098
+ int pt[4];
1099
+ };
1100
+
1101
+ vector<Vertex> vtx;
1102
+ vector<QuadEdge> qedges;
1103
+ int freeQEdge;
1104
+ int freePoint;
1105
+ bool validGeometry;
1106
+
1107
+ int recentEdge;
1108
+ Point2f topLeft;
1109
+ Point2f bottomRight;
1110
+ };
1111
+
1112
+ }
1113
+
1114
+ // 2009-01-12, Xavier Delacour <xavier.delacour@gmail.com>
1115
+
1116
+ struct lsh_hash {
1117
+ int h1, h2;
1118
+ };
1119
+
1120
+ struct CvLSHOperations
1121
+ {
1122
+ virtual ~CvLSHOperations() {}
1123
+
1124
+ virtual int vector_add(const void* data) = 0;
1125
+ virtual void vector_remove(int i) = 0;
1126
+ virtual const void* vector_lookup(int i) = 0;
1127
+ virtual void vector_reserve(int n) = 0;
1128
+ virtual unsigned int vector_count() = 0;
1129
+
1130
+ virtual void hash_insert(lsh_hash h, int l, int i) = 0;
1131
+ virtual void hash_remove(lsh_hash h, int l, int i) = 0;
1132
+ virtual int hash_lookup(lsh_hash h, int l, int* ret_i, int ret_i_max) = 0;
1133
+ };
1134
+
1135
+ #endif /* __cplusplus */
1136
+
1137
+ #endif
1138
+
1139
+ /* End of file. */