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,783 @@
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_IMGPROC_C_H__
44
+ #define __OPENCV_IMGPROC_IMGPROC_C_H__
45
+
46
+ #include "opencv2/core/core_c.h"
47
+ #include "opencv2/imgproc/types_c.h"
48
+
49
+ #ifdef __cplusplus
50
+ extern "C" {
51
+ #endif
52
+
53
+ /*********************** Background statistics accumulation *****************************/
54
+
55
+ /* Adds image to accumulator */
56
+ CVAPI(void) cvAcc( const CvArr* image, CvArr* sum,
57
+ const CvArr* mask CV_DEFAULT(NULL) );
58
+
59
+ /* Adds squared image to accumulator */
60
+ CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum,
61
+ const CvArr* mask CV_DEFAULT(NULL) );
62
+
63
+ /* Adds a product of two images to accumulator */
64
+ CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
65
+ const CvArr* mask CV_DEFAULT(NULL) );
66
+
67
+ /* Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha */
68
+ CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
69
+ const CvArr* mask CV_DEFAULT(NULL) );
70
+
71
+ /****************************************************************************************\
72
+ * Image Processing *
73
+ \****************************************************************************************/
74
+
75
+ /* Copies source 2D array inside of the larger destination array and
76
+ makes a border of the specified type (IPL_BORDER_*) around the copied area. */
77
+ CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
78
+ int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0)));
79
+
80
+ /* Smoothes array (removes noise) */
81
+ CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
82
+ int smoothtype CV_DEFAULT(CV_GAUSSIAN),
83
+ int size1 CV_DEFAULT(3),
84
+ int size2 CV_DEFAULT(0),
85
+ double sigma1 CV_DEFAULT(0),
86
+ double sigma2 CV_DEFAULT(0));
87
+
88
+ /* Convolves the image with the kernel */
89
+ CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
90
+ CvPoint anchor CV_DEFAULT(cvPoint(-1,-1)));
91
+
92
+ /* Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y) */
93
+ CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum,
94
+ CvArr* sqsum CV_DEFAULT(NULL),
95
+ CvArr* tilted_sum CV_DEFAULT(NULL));
96
+
97
+ /*
98
+ Smoothes the input image with gaussian kernel and then down-samples it.
99
+ dst_width = floor(src_width/2)[+1],
100
+ dst_height = floor(src_height/2)[+1]
101
+ */
102
+ CVAPI(void) cvPyrDown( const CvArr* src, CvArr* dst,
103
+ int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
104
+
105
+ /*
106
+ Up-samples image and smoothes the result with gaussian kernel.
107
+ dst_width = src_width*2,
108
+ dst_height = src_height*2
109
+ */
110
+ CVAPI(void) cvPyrUp( const CvArr* src, CvArr* dst,
111
+ int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
112
+
113
+ /* Builds pyramid for an image */
114
+ CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
115
+ const CvSize* layer_sizes CV_DEFAULT(0),
116
+ CvArr* bufarr CV_DEFAULT(0),
117
+ int calc CV_DEFAULT(1),
118
+ int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
119
+
120
+ /* Releases pyramid */
121
+ CVAPI(void) cvReleasePyramid( CvMat*** pyramid, int extra_layers );
122
+
123
+
124
+ /* Splits color or grayscale image into multiple connected components
125
+ of nearly the same color/brightness using modification of Burt algorithm.
126
+ comp with contain a pointer to sequence (CvSeq)
127
+ of connected components (CvConnectedComp) */
128
+ CVAPI(void) cvPyrSegmentation( IplImage* src, IplImage* dst,
129
+ CvMemStorage* storage, CvSeq** comp,
130
+ int level, double threshold1,
131
+ double threshold2 );
132
+
133
+ /* Filters image using meanshift algorithm */
134
+ CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
135
+ double sp, double sr, int max_level CV_DEFAULT(1),
136
+ CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1)));
137
+
138
+ /* Segments image using seed "markers" */
139
+ CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
140
+
141
+ /* Inpaints the selected region in the image */
142
+ CVAPI(void) cvInpaint( const CvArr* src, const CvArr* inpaint_mask,
143
+ CvArr* dst, double inpaintRange, int flags );
144
+
145
+ /* Calculates an image derivative using generalized Sobel
146
+ (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
147
+ Scharr can be used only for the first dx or dy derivative */
148
+ CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
149
+ int xorder, int yorder,
150
+ int aperture_size CV_DEFAULT(3));
151
+
152
+ /* Calculates the image Laplacian: (d2/dx + d2/dy)I */
153
+ CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
154
+ int aperture_size CV_DEFAULT(3) );
155
+
156
+ /* Converts input array pixels from one color space to another */
157
+ CVAPI(void) cvCvtColor( const CvArr* src, CvArr* dst, int code );
158
+
159
+
160
+ /* Resizes image (input array is resized to fit the destination array) */
161
+ CVAPI(void) cvResize( const CvArr* src, CvArr* dst,
162
+ int interpolation CV_DEFAULT( CV_INTER_LINEAR ));
163
+
164
+ /* Warps image with affine transform */
165
+ CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
166
+ int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
167
+ CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
168
+
169
+ /* Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2) */
170
+ CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src,
171
+ const CvPoint2D32f * dst,
172
+ CvMat * map_matrix );
173
+
174
+ /* Computes rotation_matrix matrix */
175
+ CVAPI(CvMat*) cv2DRotationMatrix( CvPoint2D32f center, double angle,
176
+ double scale, CvMat* map_matrix );
177
+
178
+ /* Warps image with perspective (projective) transform */
179
+ CVAPI(void) cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
180
+ int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
181
+ CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
182
+
183
+ /* Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3) */
184
+ CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src,
185
+ const CvPoint2D32f* dst,
186
+ CvMat* map_matrix );
187
+
188
+ /* Performs generic geometric transformation using the specified coordinate maps */
189
+ CVAPI(void) cvRemap( const CvArr* src, CvArr* dst,
190
+ const CvArr* mapx, const CvArr* mapy,
191
+ int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
192
+ CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
193
+
194
+ /* Converts mapx & mapy from floating-point to integer formats for cvRemap */
195
+ CVAPI(void) cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
196
+ CvArr* mapxy, CvArr* mapalpha );
197
+
198
+ /* Performs forward or inverse log-polar image transform */
199
+ CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst,
200
+ CvPoint2D32f center, double M,
201
+ int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
202
+
203
+ /* Performs forward or inverse linear-polar image transform */
204
+ CVAPI(void) cvLinearPolar( const CvArr* src, CvArr* dst,
205
+ CvPoint2D32f center, double maxRadius,
206
+ int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
207
+
208
+ /* Transforms the input image to compensate lens distortion */
209
+ CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst,
210
+ const CvMat* camera_matrix,
211
+ const CvMat* distortion_coeffs,
212
+ const CvMat* new_camera_matrix CV_DEFAULT(0) );
213
+
214
+ /* Computes transformation map from intrinsic camera parameters
215
+ that can used by cvRemap */
216
+ CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix,
217
+ const CvMat* distortion_coeffs,
218
+ CvArr* mapx, CvArr* mapy );
219
+
220
+ /* Computes undistortion+rectification map for a head of stereo camera */
221
+ CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix,
222
+ const CvMat* dist_coeffs,
223
+ const CvMat *R, const CvMat* new_camera_matrix,
224
+ CvArr* mapx, CvArr* mapy );
225
+
226
+ /* Computes the original (undistorted) feature coordinates
227
+ from the observed (distorted) coordinates */
228
+ CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst,
229
+ const CvMat* camera_matrix,
230
+ const CvMat* dist_coeffs,
231
+ const CvMat* R CV_DEFAULT(0),
232
+ const CvMat* P CV_DEFAULT(0));
233
+
234
+ /* creates structuring element used for morphological operations */
235
+ CVAPI(IplConvKernel*) cvCreateStructuringElementEx(
236
+ int cols, int rows, int anchor_x, int anchor_y,
237
+ int shape, int* values CV_DEFAULT(NULL) );
238
+
239
+ /* releases structuring element */
240
+ CVAPI(void) cvReleaseStructuringElement( IplConvKernel** element );
241
+
242
+ /* erodes input image (applies minimum filter) one or more times.
243
+ If element pointer is NULL, 3x3 rectangular element is used */
244
+ CVAPI(void) cvErode( const CvArr* src, CvArr* dst,
245
+ IplConvKernel* element CV_DEFAULT(NULL),
246
+ int iterations CV_DEFAULT(1) );
247
+
248
+ /* dilates input image (applies maximum filter) one or more times.
249
+ If element pointer is NULL, 3x3 rectangular element is used */
250
+ CVAPI(void) cvDilate( const CvArr* src, CvArr* dst,
251
+ IplConvKernel* element CV_DEFAULT(NULL),
252
+ int iterations CV_DEFAULT(1) );
253
+
254
+ /* Performs complex morphological transformation */
255
+ CVAPI(void) cvMorphologyEx( const CvArr* src, CvArr* dst,
256
+ CvArr* temp, IplConvKernel* element,
257
+ int operation, int iterations CV_DEFAULT(1) );
258
+
259
+ /* Calculates all spatial and central moments up to the 3rd order */
260
+ CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
261
+
262
+ /* Retrieve particular spatial, central or normalized central moments */
263
+ CVAPI(double) cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
264
+ CVAPI(double) cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
265
+ CVAPI(double) cvGetNormalizedCentralMoment( CvMoments* moments,
266
+ int x_order, int y_order );
267
+
268
+ /* Calculates 7 Hu's invariants from precalculated spatial and central moments */
269
+ CVAPI(void) cvGetHuMoments( CvMoments* moments, CvHuMoments* hu_moments );
270
+
271
+ /*********************************** data sampling **************************************/
272
+
273
+ /* Fetches pixels that belong to the specified line segment and stores them to the buffer.
274
+ Returns the number of retrieved points. */
275
+ CVAPI(int) cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
276
+ int connectivity CV_DEFAULT(8));
277
+
278
+ /* Retrieves the rectangular image region with specified center from the input array.
279
+ dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
280
+ Values of pixels with fractional coordinates are retrieved using bilinear interpolation*/
281
+ CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
282
+
283
+
284
+ /* Retrieves quadrangle from the input array.
285
+ matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b)
286
+ ( a21 a22 | b2 ) (bilinear interpolation is used to retrieve pixels
287
+ with fractional coordinates)
288
+ */
289
+ CVAPI(void) cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
290
+ const CvMat* map_matrix );
291
+
292
+ /* Measures similarity between template and overlapped windows in the source image
293
+ and fills the resultant image with the measurements */
294
+ CVAPI(void) cvMatchTemplate( const CvArr* image, const CvArr* templ,
295
+ CvArr* result, int method );
296
+
297
+ /* Computes earth mover distance between
298
+ two weighted point sets (called signatures) */
299
+ CVAPI(float) cvCalcEMD2( const CvArr* signature1,
300
+ const CvArr* signature2,
301
+ int distance_type,
302
+ CvDistanceFunction distance_func CV_DEFAULT(NULL),
303
+ const CvArr* cost_matrix CV_DEFAULT(NULL),
304
+ CvArr* flow CV_DEFAULT(NULL),
305
+ float* lower_bound CV_DEFAULT(NULL),
306
+ void* userdata CV_DEFAULT(NULL));
307
+
308
+ /****************************************************************************************\
309
+ * Contours retrieving *
310
+ \****************************************************************************************/
311
+
312
+ /* Retrieves outer and optionally inner boundaries of white (non-zero) connected
313
+ components in the black (zero) background */
314
+ CVAPI(int) cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
315
+ int header_size CV_DEFAULT(sizeof(CvContour)),
316
+ int mode CV_DEFAULT(CV_RETR_LIST),
317
+ int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
318
+ CvPoint offset CV_DEFAULT(cvPoint(0,0)));
319
+
320
+ /* Initalizes contour retrieving process.
321
+ Calls cvStartFindContours.
322
+ Calls cvFindNextContour until null pointer is returned
323
+ or some other condition becomes true.
324
+ Calls cvEndFindContours at the end. */
325
+ CVAPI(CvContourScanner) cvStartFindContours( CvArr* image, CvMemStorage* storage,
326
+ int header_size CV_DEFAULT(sizeof(CvContour)),
327
+ int mode CV_DEFAULT(CV_RETR_LIST),
328
+ int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
329
+ CvPoint offset CV_DEFAULT(cvPoint(0,0)));
330
+
331
+ /* Retrieves next contour */
332
+ CVAPI(CvSeq*) cvFindNextContour( CvContourScanner scanner );
333
+
334
+
335
+ /* Substitutes the last retrieved contour with the new one
336
+ (if the substitutor is null, the last retrieved contour is removed from the tree) */
337
+ CVAPI(void) cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
338
+
339
+
340
+ /* Releases contour scanner and returns pointer to the first outer contour */
341
+ CVAPI(CvSeq*) cvEndFindContours( CvContourScanner* scanner );
342
+
343
+ /* Approximates a single Freeman chain or a tree of chains to polygonal curves */
344
+ CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
345
+ int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
346
+ double parameter CV_DEFAULT(0),
347
+ int minimal_perimeter CV_DEFAULT(0),
348
+ int recursive CV_DEFAULT(0));
349
+
350
+ /* Initalizes Freeman chain reader.
351
+ The reader is used to iteratively get coordinates of all the chain points.
352
+ If the Freeman codes should be read as is, a simple sequence reader should be used */
353
+ CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
354
+
355
+ /* Retrieves the next chain point */
356
+ CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
357
+
358
+ /****************************************************************************************\
359
+ * Planar subdivisions *
360
+ \****************************************************************************************/
361
+
362
+ /* Initializes Delaunay triangulation */
363
+ CVAPI(void) cvInitSubdivDelaunay2D( CvSubdiv2D* subdiv, CvRect rect );
364
+
365
+ /* Creates new subdivision */
366
+ CVAPI(CvSubdiv2D*) cvCreateSubdiv2D( int subdiv_type, int header_size,
367
+ int vtx_size, int quadedge_size,
368
+ CvMemStorage* storage );
369
+
370
+ /************************* high-level subdivision functions ***************************/
371
+
372
+ /* Simplified Delaunay diagram creation */
373
+ CV_INLINE CvSubdiv2D* cvCreateSubdivDelaunay2D( CvRect rect, CvMemStorage* storage )
374
+ {
375
+ CvSubdiv2D* subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D, sizeof(*subdiv),
376
+ sizeof(CvSubdiv2DPoint), sizeof(CvQuadEdge2D), storage );
377
+
378
+ cvInitSubdivDelaunay2D( subdiv, rect );
379
+ return subdiv;
380
+ }
381
+
382
+
383
+ /* Inserts new point to the Delaunay triangulation */
384
+ CVAPI(CvSubdiv2DPoint*) cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt);
385
+
386
+ /* Locates a point within the Delaunay triangulation (finds the edge
387
+ the point is left to or belongs to, or the triangulation point the given
388
+ point coinsides with */
389
+ CVAPI(CvSubdiv2DPointLocation) cvSubdiv2DLocate(
390
+ CvSubdiv2D* subdiv, CvPoint2D32f pt,
391
+ CvSubdiv2DEdge* edge,
392
+ CvSubdiv2DPoint** vertex CV_DEFAULT(NULL) );
393
+
394
+ /* Calculates Voronoi tesselation (i.e. coordinates of Voronoi points) */
395
+ CVAPI(void) cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv );
396
+
397
+
398
+ /* Removes all Voronoi points from the tesselation */
399
+ CVAPI(void) cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv );
400
+
401
+
402
+ /* Finds the nearest to the given point vertex in subdivision. */
403
+ CVAPI(CvSubdiv2DPoint*) cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt );
404
+
405
+
406
+ /************ Basic quad-edge navigation and operations ************/
407
+
408
+ CV_INLINE CvSubdiv2DEdge cvSubdiv2DNextEdge( CvSubdiv2DEdge edge )
409
+ {
410
+ return CV_SUBDIV2D_NEXT_EDGE(edge);
411
+ }
412
+
413
+
414
+ CV_INLINE CvSubdiv2DEdge cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate )
415
+ {
416
+ return (edge & ~3) + ((edge + rotate) & 3);
417
+ }
418
+
419
+ CV_INLINE CvSubdiv2DEdge cvSubdiv2DSymEdge( CvSubdiv2DEdge edge )
420
+ {
421
+ return edge ^ 2;
422
+ }
423
+
424
+ CV_INLINE CvSubdiv2DEdge cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, CvNextEdgeType type )
425
+ {
426
+ CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
427
+ edge = e->next[(edge + (int)type) & 3];
428
+ return (edge & ~3) + ((edge + ((int)type >> 4)) & 3);
429
+ }
430
+
431
+
432
+ CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge )
433
+ {
434
+ CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
435
+ return (CvSubdiv2DPoint*)e->pt[edge & 3];
436
+ }
437
+
438
+
439
+ CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge )
440
+ {
441
+ CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
442
+ return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3];
443
+ }
444
+
445
+
446
+ CV_INLINE double cvTriangleArea( CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
447
+ {
448
+ return ((double)b.x - a.x) * ((double)c.y - a.y) - ((double)b.y - a.y) * ((double)c.x - a.x);
449
+ }
450
+
451
+
452
+ /****************************************************************************************\
453
+ * Contour Processing and Shape Analysis *
454
+ \****************************************************************************************/
455
+
456
+ /* Approximates a single polygonal curve (contour) or
457
+ a tree of polygonal curves (contours) */
458
+ CVAPI(CvSeq*) cvApproxPoly( const void* src_seq,
459
+ int header_size, CvMemStorage* storage,
460
+ int method, double parameter,
461
+ int parameter2 CV_DEFAULT(0));
462
+
463
+ /* Calculates perimeter of a contour or length of a part of contour */
464
+ CVAPI(double) cvArcLength( const void* curve,
465
+ CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
466
+ int is_closed CV_DEFAULT(-1));
467
+
468
+ CV_INLINE double cvContourPerimeter( const void* contour )
469
+ {
470
+ return cvArcLength( contour, CV_WHOLE_SEQ, 1 );
471
+ }
472
+
473
+
474
+ /* Calculates contour boundning rectangle (update=1) or
475
+ just retrieves pre-calculated rectangle (update=0) */
476
+ CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
477
+
478
+ /* Calculates area of a contour or contour segment */
479
+ CVAPI(double) cvContourArea( const CvArr* contour,
480
+ CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
481
+ int oriented CV_DEFAULT(0));
482
+
483
+ /* Finds minimum area rotated rectangle bounding a set of points */
484
+ CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points,
485
+ CvMemStorage* storage CV_DEFAULT(NULL));
486
+
487
+ /* Finds minimum enclosing circle for a set of points */
488
+ CVAPI(int) cvMinEnclosingCircle( const CvArr* points,
489
+ CvPoint2D32f* center, float* radius );
490
+
491
+ /* Compares two contours by matching their moments */
492
+ CVAPI(double) cvMatchShapes( const void* object1, const void* object2,
493
+ int method, double parameter CV_DEFAULT(0));
494
+
495
+ /* Calculates exact convex hull of 2d point set */
496
+ CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
497
+ void* hull_storage CV_DEFAULT(NULL),
498
+ int orientation CV_DEFAULT(CV_CLOCKWISE),
499
+ int return_points CV_DEFAULT(0));
500
+
501
+ /* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */
502
+ CVAPI(int) cvCheckContourConvexity( const CvArr* contour );
503
+
504
+
505
+ /* Finds convexity defects for the contour */
506
+ CVAPI(CvSeq*) cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
507
+ CvMemStorage* storage CV_DEFAULT(NULL));
508
+
509
+ /* Fits ellipse into a set of 2d points */
510
+ CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points );
511
+
512
+ /* Finds minimum rectangle containing two given rectangles */
513
+ CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
514
+
515
+ /* Finds coordinates of the box vertices */
516
+ CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
517
+
518
+ /* Initializes sequence header for a matrix (column or row vector) of points -
519
+ a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */
520
+ CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat,
521
+ CvContour* contour_header,
522
+ CvSeqBlock* block );
523
+
524
+ /* Checks whether the point is inside polygon, outside, on an edge (at a vertex).
525
+ Returns positive, negative or zero value, correspondingly.
526
+ Optionally, measures a signed distance between
527
+ the point and the nearest polygon edge (measure_dist=1) */
528
+ CVAPI(double) cvPointPolygonTest( const CvArr* contour,
529
+ CvPoint2D32f pt, int measure_dist );
530
+
531
+ /****************************************************************************************\
532
+ * Histogram functions *
533
+ \****************************************************************************************/
534
+
535
+ /* Creates new histogram */
536
+ CVAPI(CvHistogram*) cvCreateHist( int dims, int* sizes, int type,
537
+ float** ranges CV_DEFAULT(NULL),
538
+ int uniform CV_DEFAULT(1));
539
+
540
+ /* Assignes histogram bin ranges */
541
+ CVAPI(void) cvSetHistBinRanges( CvHistogram* hist, float** ranges,
542
+ int uniform CV_DEFAULT(1));
543
+
544
+ /* Creates histogram header for array */
545
+ CVAPI(CvHistogram*) cvMakeHistHeaderForArray(
546
+ int dims, int* sizes, CvHistogram* hist,
547
+ float* data, float** ranges CV_DEFAULT(NULL),
548
+ int uniform CV_DEFAULT(1));
549
+
550
+ /* Releases histogram */
551
+ CVAPI(void) cvReleaseHist( CvHistogram** hist );
552
+
553
+ /* Clears all the histogram bins */
554
+ CVAPI(void) cvClearHist( CvHistogram* hist );
555
+
556
+ /* Finds indices and values of minimum and maximum histogram bins */
557
+ CVAPI(void) cvGetMinMaxHistValue( const CvHistogram* hist,
558
+ float* min_value, float* max_value,
559
+ int* min_idx CV_DEFAULT(NULL),
560
+ int* max_idx CV_DEFAULT(NULL));
561
+
562
+
563
+ /* Normalizes histogram by dividing all bins by sum of the bins, multiplied by <factor>.
564
+ After that sum of histogram bins is equal to <factor> */
565
+ CVAPI(void) cvNormalizeHist( CvHistogram* hist, double factor );
566
+
567
+
568
+ /* Clear all histogram bins that are below the threshold */
569
+ CVAPI(void) cvThreshHist( CvHistogram* hist, double threshold );
570
+
571
+
572
+ /* Compares two histogram */
573
+ CVAPI(double) cvCompareHist( const CvHistogram* hist1,
574
+ const CvHistogram* hist2,
575
+ int method);
576
+
577
+ /* Copies one histogram to another. Destination histogram is created if
578
+ the destination pointer is NULL */
579
+ CVAPI(void) cvCopyHist( const CvHistogram* src, CvHistogram** dst );
580
+
581
+
582
+ /* Calculates bayesian probabilistic histograms
583
+ (each or src and dst is an array of <number> histograms */
584
+ CVAPI(void) cvCalcBayesianProb( CvHistogram** src, int number,
585
+ CvHistogram** dst);
586
+
587
+ /* Calculates array histogram */
588
+ CVAPI(void) cvCalcArrHist( CvArr** arr, CvHistogram* hist,
589
+ int accumulate CV_DEFAULT(0),
590
+ const CvArr* mask CV_DEFAULT(NULL) );
591
+
592
+ CV_INLINE void cvCalcHist( IplImage** image, CvHistogram* hist,
593
+ int accumulate CV_DEFAULT(0),
594
+ const CvArr* mask CV_DEFAULT(NULL) )
595
+ {
596
+ cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
597
+ }
598
+
599
+ /* Calculates back project */
600
+ CVAPI(void) cvCalcArrBackProject( CvArr** image, CvArr* dst,
601
+ const CvHistogram* hist );
602
+ #define cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist)
603
+
604
+
605
+ /* Does some sort of template matching but compares histograms of
606
+ template and each window location */
607
+ CVAPI(void) cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
608
+ CvHistogram* hist, int method,
609
+ double factor );
610
+ #define cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \
611
+ cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
612
+
613
+
614
+ /* calculates probabilistic density (divides one histogram by another) */
615
+ CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
616
+ CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
617
+
618
+ /* equalizes histogram of 8-bit single-channel image */
619
+ CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst );
620
+
621
+
622
+ /* Applies distance transform to binary image */
623
+ CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst,
624
+ int distance_type CV_DEFAULT(CV_DIST_L2),
625
+ int mask_size CV_DEFAULT(3),
626
+ const float* mask CV_DEFAULT(NULL),
627
+ CvArr* labels CV_DEFAULT(NULL));
628
+
629
+
630
+ /* Applies fixed-level threshold to grayscale image.
631
+ This is a basic operation applied before retrieving contours */
632
+ CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst,
633
+ double threshold, double max_value,
634
+ int threshold_type );
635
+
636
+ /* Applies adaptive threshold to grayscale image.
637
+ The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
638
+ CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
639
+ neighborhood size (3, 5, 7 etc.),
640
+ and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */
641
+ CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
642
+ int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
643
+ int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
644
+ int block_size CV_DEFAULT(3),
645
+ double param1 CV_DEFAULT(5));
646
+
647
+ /* Fills the connected component until the color difference gets large enough */
648
+ CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point,
649
+ CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)),
650
+ CvScalar up_diff CV_DEFAULT(cvScalarAll(0)),
651
+ CvConnectedComp* comp CV_DEFAULT(NULL),
652
+ int flags CV_DEFAULT(4),
653
+ CvArr* mask CV_DEFAULT(NULL));
654
+
655
+ /****************************************************************************************\
656
+ * Feature detection *
657
+ \****************************************************************************************/
658
+
659
+ /* Runs canny edge detector */
660
+ CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1,
661
+ double threshold2, int aperture_size CV_DEFAULT(3) );
662
+
663
+ /* Calculates constraint image for corner detection
664
+ Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy.
665
+ Applying threshold to the result gives coordinates of corners */
666
+ CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners,
667
+ int aperture_size CV_DEFAULT(3) );
668
+
669
+ /* Calculates eigen values and vectors of 2x2
670
+ gradient covariation matrix at every image pixel */
671
+ CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
672
+ int block_size, int aperture_size CV_DEFAULT(3) );
673
+
674
+ /* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at
675
+ every image pixel */
676
+ CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
677
+ int block_size, int aperture_size CV_DEFAULT(3) );
678
+
679
+ /* Harris corner detector:
680
+ Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */
681
+ CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_responce,
682
+ int block_size, int aperture_size CV_DEFAULT(3),
683
+ double k CV_DEFAULT(0.04) );
684
+
685
+ /* Adjust corner position using some sort of gradient search */
686
+ CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
687
+ int count, CvSize win, CvSize zero_zone,
688
+ CvTermCriteria criteria );
689
+
690
+ /* Finds a sparse set of points within the selected region
691
+ that seem to be easy to track */
692
+ CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
693
+ CvArr* temp_image, CvPoint2D32f* corners,
694
+ int* corner_count, double quality_level,
695
+ double min_distance,
696
+ const CvArr* mask CV_DEFAULT(NULL),
697
+ int block_size CV_DEFAULT(3),
698
+ int use_harris CV_DEFAULT(0),
699
+ double k CV_DEFAULT(0.04) );
700
+
701
+ /* Finds lines on binary image using one of several methods.
702
+ line_storage is either memory storage or 1 x <max number of lines> CvMat, its
703
+ number of columns is changed by the function.
704
+ method is one of CV_HOUGH_*;
705
+ rho, theta and threshold are used for each of those methods;
706
+ param1 ~ line length, param2 ~ line gap - for probabilistic,
707
+ param1 ~ srn, param2 ~ stn - for multi-scale */
708
+ CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method,
709
+ double rho, double theta, int threshold,
710
+ double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0));
711
+
712
+ /* Finds circles in the image */
713
+ CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
714
+ int method, double dp, double min_dist,
715
+ double param1 CV_DEFAULT(100),
716
+ double param2 CV_DEFAULT(100),
717
+ int min_radius CV_DEFAULT(0),
718
+ int max_radius CV_DEFAULT(0));
719
+
720
+ /* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */
721
+ CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param,
722
+ double reps, double aeps, float* line );
723
+
724
+
725
+ /* Constructs kd-tree from set of feature descriptors */
726
+ CVAPI(struct CvFeatureTree*) cvCreateKDTree(CvMat* desc);
727
+
728
+ /* Constructs spill-tree from set of feature descriptors */
729
+ CVAPI(struct CvFeatureTree*) cvCreateSpillTree( const CvMat* raw_data,
730
+ const int naive CV_DEFAULT(50),
731
+ const double rho CV_DEFAULT(.7),
732
+ const double tau CV_DEFAULT(.1) );
733
+
734
+ /* Release feature tree */
735
+ CVAPI(void) cvReleaseFeatureTree(struct CvFeatureTree* tr);
736
+
737
+ /* Searches feature tree for k nearest neighbors of given reference points,
738
+ searching (in case of kd-tree/bbf) at most emax leaves. */
739
+ CVAPI(void) cvFindFeatures(struct CvFeatureTree* tr, const CvMat* query_points,
740
+ CvMat* indices, CvMat* dist, int k, int emax CV_DEFAULT(20));
741
+
742
+ /* Search feature tree for all points that are inlier to given rect region.
743
+ Only implemented for kd trees */
744
+ CVAPI(int) cvFindFeaturesBoxed(struct CvFeatureTree* tr,
745
+ CvMat* bounds_min, CvMat* bounds_max,
746
+ CvMat* out_indices);
747
+
748
+
749
+ /* Construct a Locality Sensitive Hash (LSH) table, for indexing d-dimensional vectors of
750
+ given type. Vectors will be hashed L times with k-dimensional p-stable (p=2) functions. */
751
+ CVAPI(struct CvLSH*) cvCreateLSH(struct CvLSHOperations* ops, int d,
752
+ int L CV_DEFAULT(10), int k CV_DEFAULT(10),
753
+ int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4),
754
+ int64 seed CV_DEFAULT(-1));
755
+
756
+ /* Construct in-memory LSH table, with n bins. */
757
+ CVAPI(struct CvLSH*) cvCreateMemoryLSH(int d, int n, int L CV_DEFAULT(10), int k CV_DEFAULT(10),
758
+ int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4),
759
+ int64 seed CV_DEFAULT(-1));
760
+
761
+ /* Free the given LSH structure. */
762
+ CVAPI(void) cvReleaseLSH(struct CvLSH** lsh);
763
+
764
+ /* Return the number of vectors in the LSH. */
765
+ CVAPI(unsigned int) LSHSize(struct CvLSH* lsh);
766
+
767
+ /* Add vectors to the LSH structure, optionally returning indices. */
768
+ CVAPI(void) cvLSHAdd(struct CvLSH* lsh, const CvMat* data, CvMat* indices CV_DEFAULT(0));
769
+
770
+ /* Remove vectors from LSH, as addressed by given indices. */
771
+ CVAPI(void) cvLSHRemove(struct CvLSH* lsh, const CvMat* indices);
772
+
773
+ /* Query the LSH n times for at most k nearest points; data is n x d,
774
+ indices and dist are n x k. At most emax stored points will be accessed. */
775
+ CVAPI(void) cvLSHQuery(struct CvLSH* lsh, const CvMat* query_points,
776
+ CvMat* indices, CvMat* dist, int k, int emax);
777
+
778
+
779
+ #ifdef __cplusplus
780
+ }
781
+ #endif
782
+
783
+ #endif