• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/imgproc/types_c.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /** @addtogroup imgproc_c
53 @{
54 */
55 
56 /*********************** Background statistics accumulation *****************************/
57 
58 /** @brief Adds image to accumulator
59 @see cv::accumulate
60 */
61 CVAPI(void)  cvAcc( const CvArr* image, CvArr* sum,
62                    const CvArr* mask CV_DEFAULT(NULL) );
63 
64 /** @brief Adds squared image to accumulator
65 @see cv::accumulateSquare
66 */
67 CVAPI(void)  cvSquareAcc( const CvArr* image, CvArr* sqsum,
68                          const CvArr* mask CV_DEFAULT(NULL) );
69 
70 /** @brief Adds a product of two images to accumulator
71 @see cv::accumulateProduct
72 */
73 CVAPI(void)  cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
74                            const CvArr* mask CV_DEFAULT(NULL) );
75 
76 /** @brief Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha
77 @see cv::accumulateWeighted
78 */
79 CVAPI(void)  cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
80                           const CvArr* mask CV_DEFAULT(NULL) );
81 
82 /****************************************************************************************\
83 *                                    Image Processing                                    *
84 \****************************************************************************************/
85 
86 /** Copies source 2D array inside of the larger destination array and
87    makes a border of the specified type (IPL_BORDER_*) around the copied area. */
88 CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
89                               int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0)));
90 
91 /** @brief Smooths the image in one of several ways.
92 
93 @param src The source image
94 @param dst The destination image
95 @param smoothtype Type of the smoothing, see SmoothMethod_c
96 @param size1 The first parameter of the smoothing operation, the aperture width. Must be a
97 positive odd number (1, 3, 5, ...)
98 @param size2 The second parameter of the smoothing operation, the aperture height. Ignored by
99 CV_MEDIAN and CV_BILATERAL methods. In the case of simple scaled/non-scaled and Gaussian blur if
100 size2 is zero, it is set to size1. Otherwise it must be a positive odd number.
101 @param sigma1 In the case of a Gaussian parameter this parameter may specify Gaussian \f$\sigma\f$
102 (standard deviation). If it is zero, it is calculated from the kernel size:
103 \f[\sigma  = 0.3 (n/2 - 1) + 0.8  \quad   \text{where}   \quad  n= \begin{array}{l l} \mbox{\texttt{size1} for horizontal kernel} \\ \mbox{\texttt{size2} for vertical kernel} \end{array}\f]
104 Using standard sigma for small kernels ( \f$3\times 3\f$ to \f$7\times 7\f$ ) gives better speed. If
105 sigma1 is not zero, while size1 and size2 are zeros, the kernel size is calculated from the
106 sigma (to provide accurate enough operation).
107 @param sigma2 additional parameter for bilateral filtering
108 
109 @see cv::GaussianBlur, cv::blur, cv::medianBlur, cv::bilateralFilter.
110  */
111 CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
112                       int smoothtype CV_DEFAULT(CV_GAUSSIAN),
113                       int size1 CV_DEFAULT(3),
114                       int size2 CV_DEFAULT(0),
115                       double sigma1 CV_DEFAULT(0),
116                       double sigma2 CV_DEFAULT(0));
117 
118 /** @brief Convolves an image with the kernel.
119 
120 @param src input image.
121 @param dst output image of the same size and the same number of channels as src.
122 @param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point
123 matrix; if you want to apply different kernels to different channels, split the image into
124 separate color planes using split and process them individually.
125 @param anchor anchor of the kernel that indicates the relative position of a filtered point within
126 the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor
127 is at the kernel center.
128 
129 @see cv::filter2D
130  */
131 CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
132                         CvPoint anchor CV_DEFAULT(cvPoint(-1,-1)));
133 
134 /** @brief Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y)
135 @see cv::integral
136 */
137 CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum,
138                        CvArr* sqsum CV_DEFAULT(NULL),
139                        CvArr* tilted_sum CV_DEFAULT(NULL));
140 
141 /** @brief Smoothes the input image with gaussian kernel and then down-samples it.
142 
143    dst_width = floor(src_width/2)[+1],
144    dst_height = floor(src_height/2)[+1]
145    @see cv::pyrDown
146 */
147 CVAPI(void)  cvPyrDown( const CvArr* src, CvArr* dst,
148                         int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
149 
150 /** @brief Up-samples image and smoothes the result with gaussian kernel.
151 
152    dst_width = src_width*2,
153    dst_height = src_height*2
154    @see cv::pyrUp
155 */
156 CVAPI(void)  cvPyrUp( const CvArr* src, CvArr* dst,
157                       int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
158 
159 /** @brief Builds pyramid for an image
160 @see buildPyramid
161 */
162 CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
163                                 const CvSize* layer_sizes CV_DEFAULT(0),
164                                 CvArr* bufarr CV_DEFAULT(0),
165                                 int calc CV_DEFAULT(1),
166                                 int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
167 
168 /** @brief Releases pyramid */
169 CVAPI(void)  cvReleasePyramid( CvMat*** pyramid, int extra_layers );
170 
171 
172 /** @brief Filters image using meanshift algorithm
173 @see cv::pyrMeanShiftFiltering
174 */
175 CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
176     double sp, double sr, int max_level CV_DEFAULT(1),
177     CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1)));
178 
179 /** @brief Segments image using seed "markers"
180 @see cv::watershed
181 */
182 CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
183 
184 /** @brief Calculates an image derivative using generalized Sobel
185 
186    (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
187    Scharr can be used only for the first dx or dy derivative
188 @see cv::Sobel
189 */
190 CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
191                     int xorder, int yorder,
192                     int aperture_size CV_DEFAULT(3));
193 
194 /** @brief Calculates the image Laplacian: (d2/dx + d2/dy)I
195 @see cv::Laplacian
196 */
197 CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
198                       int aperture_size CV_DEFAULT(3) );
199 
200 /** @brief Converts input array pixels from one color space to another
201 @see cv::cvtColor
202 */
203 CVAPI(void)  cvCvtColor( const CvArr* src, CvArr* dst, int code );
204 
205 
206 /** @brief Resizes image (input array is resized to fit the destination array)
207 @see cv::resize
208 */
209 CVAPI(void)  cvResize( const CvArr* src, CvArr* dst,
210                        int interpolation CV_DEFAULT( CV_INTER_LINEAR ));
211 
212 /** @brief Warps image with affine transform
213 @note ::cvGetQuadrangleSubPix is similar to ::cvWarpAffine, but the outliers are extrapolated using
214 replication border mode.
215 @see cv::warpAffine
216 */
217 CVAPI(void)  cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
218                            int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
219                            CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
220 
221 /** @brief Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2)
222 @see cv::getAffineTransform
223 */
224 CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src,
225                                     const CvPoint2D32f * dst,
226                                     CvMat * map_matrix );
227 
228 /** @brief Computes rotation_matrix matrix
229 @see cv::getRotationMatrix2D
230 */
231 CVAPI(CvMat*)  cv2DRotationMatrix( CvPoint2D32f center, double angle,
232                                    double scale, CvMat* map_matrix );
233 
234 /** @brief Warps image with perspective (projective) transform
235 @see cv::warpPerspective
236 */
237 CVAPI(void)  cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
238                                 int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
239                                 CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
240 
241 /** @brief Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3)
242 @see cv::getPerspectiveTransform
243 */
244 CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src,
245                                          const CvPoint2D32f* dst,
246                                          CvMat* map_matrix );
247 
248 /** @brief Performs generic geometric transformation using the specified coordinate maps
249 @see cv::remap
250 */
251 CVAPI(void)  cvRemap( const CvArr* src, CvArr* dst,
252                       const CvArr* mapx, const CvArr* mapy,
253                       int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
254                       CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
255 
256 /** @brief Converts mapx & mapy from floating-point to integer formats for cvRemap
257 @see cv::convertMaps
258 */
259 CVAPI(void)  cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
260                             CvArr* mapxy, CvArr* mapalpha );
261 
262 /** @brief Performs forward or inverse log-polar image transform
263 @see cv::logPolar
264 */
265 CVAPI(void)  cvLogPolar( const CvArr* src, CvArr* dst,
266                          CvPoint2D32f center, double M,
267                          int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
268 
269 /** Performs forward or inverse linear-polar image transform
270 @see cv::linearPolar
271 */
272 CVAPI(void)  cvLinearPolar( const CvArr* src, CvArr* dst,
273                          CvPoint2D32f center, double maxRadius,
274                          int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
275 
276 /** @brief Transforms the input image to compensate lens distortion
277 @see cv::undistort
278 */
279 CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst,
280                           const CvMat* camera_matrix,
281                           const CvMat* distortion_coeffs,
282                           const CvMat* new_camera_matrix CV_DEFAULT(0) );
283 
284 /** @brief Computes transformation map from intrinsic camera parameters
285    that can used by cvRemap
286 */
287 CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix,
288                                 const CvMat* distortion_coeffs,
289                                 CvArr* mapx, CvArr* mapy );
290 
291 /** @brief Computes undistortion+rectification map for a head of stereo camera
292 @see cv::initUndistortRectifyMap
293 */
294 CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix,
295                                        const CvMat* dist_coeffs,
296                                        const CvMat *R, const CvMat* new_camera_matrix,
297                                        CvArr* mapx, CvArr* mapy );
298 
299 /** @brief Computes the original (undistorted) feature coordinates
300    from the observed (distorted) coordinates
301 @see cv::undistortPoints
302 */
303 CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst,
304                                const CvMat* camera_matrix,
305                                const CvMat* dist_coeffs,
306                                const CvMat* R CV_DEFAULT(0),
307                                const CvMat* P CV_DEFAULT(0));
308 
309 /** @brief Returns a structuring element of the specified size and shape for morphological operations.
310 
311 @note the created structuring element IplConvKernel\* element must be released in the end using
312 `cvReleaseStructuringElement(&element)`.
313 
314 @param cols Width of the structuring element
315 @param rows Height of the structuring element
316 @param anchor_x x-coordinate of the anchor
317 @param anchor_y y-coordinate of the anchor
318 @param shape element shape that could be one of the cv::MorphShapes_c
319 @param values integer array of cols*rows elements that specifies the custom shape of the
320 structuring element, when shape=CV_SHAPE_CUSTOM.
321 
322 @see cv::getStructuringElement
323  */
324  CVAPI(IplConvKernel*)  cvCreateStructuringElementEx(
325             int cols, int  rows, int  anchor_x, int  anchor_y,
326             int shape, int* values CV_DEFAULT(NULL) );
327 
328 /** @brief releases structuring element
329 @see cvCreateStructuringElementEx
330 */
331 CVAPI(void)  cvReleaseStructuringElement( IplConvKernel** element );
332 
333 /** @brief erodes input image (applies minimum filter) one or more times.
334    If element pointer is NULL, 3x3 rectangular element is used
335 @see cv::erode
336 */
337 CVAPI(void)  cvErode( const CvArr* src, CvArr* dst,
338                       IplConvKernel* element CV_DEFAULT(NULL),
339                       int iterations CV_DEFAULT(1) );
340 
341 /** @brief dilates input image (applies maximum filter) one or more times.
342 
343    If element pointer is NULL, 3x3 rectangular element is used
344 @see cv::dilate
345 */
346 CVAPI(void)  cvDilate( const CvArr* src, CvArr* dst,
347                        IplConvKernel* element CV_DEFAULT(NULL),
348                        int iterations CV_DEFAULT(1) );
349 
350 /** @brief Performs complex morphological transformation
351 @see cv::morphologyEx
352 */
353 CVAPI(void)  cvMorphologyEx( const CvArr* src, CvArr* dst,
354                              CvArr* temp, IplConvKernel* element,
355                              int operation, int iterations CV_DEFAULT(1) );
356 
357 /** @brief Calculates all spatial and central moments up to the 3rd order
358 @see cv::moments
359 */
360 CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
361 
362 /** @brief Retrieve spatial moments */
363 CVAPI(double)  cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
364 /** @brief Retrieve central moments */
365 CVAPI(double)  cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
366 /** @brief Retrieve normalized central moments */
367 CVAPI(double)  cvGetNormalizedCentralMoment( CvMoments* moments,
368                                              int x_order, int y_order );
369 
370 /** @brief Calculates 7 Hu's invariants from precalculated spatial and central moments
371 @see cv::HuMoments
372 */
373 CVAPI(void) cvGetHuMoments( CvMoments*  moments, CvHuMoments*  hu_moments );
374 
375 /*********************************** data sampling **************************************/
376 
377 /** @brief Fetches pixels that belong to the specified line segment and stores them to the buffer.
378 
379    Returns the number of retrieved points.
380 @see cv::LineSegmentDetector
381 */
382 CVAPI(int)  cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
383                           int connectivity CV_DEFAULT(8));
384 
385 /** @brief Retrieves the rectangular image region with specified center from the input array.
386 
387  dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
388  Values of pixels with fractional coordinates are retrieved using bilinear interpolation
389 @see cv::getRectSubPix
390 */
391 CVAPI(void)  cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
392 
393 
394 /** @brief Retrieves quadrangle from the input array.
395 
396     matrixarr = ( a11  a12 | b1 )   dst(x,y) <- src(A[x y]' + b)
397                 ( a21  a22 | b2 )   (bilinear interpolation is used to retrieve pixels
398                                      with fractional coordinates)
399 @see cvWarpAffine
400 */
401 CVAPI(void)  cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
402                                     const CvMat* map_matrix );
403 
404 /** @brief Measures similarity between template and overlapped windows in the source image
405    and fills the resultant image with the measurements
406 @see cv::matchTemplate
407 */
408 CVAPI(void)  cvMatchTemplate( const CvArr* image, const CvArr* templ,
409                               CvArr* result, int method );
410 
411 /** @brief Computes earth mover distance between
412    two weighted point sets (called signatures)
413 @see cv::EMD
414 */
415 CVAPI(float)  cvCalcEMD2( const CvArr* signature1,
416                           const CvArr* signature2,
417                           int distance_type,
418                           CvDistanceFunction distance_func CV_DEFAULT(NULL),
419                           const CvArr* cost_matrix CV_DEFAULT(NULL),
420                           CvArr* flow CV_DEFAULT(NULL),
421                           float* lower_bound CV_DEFAULT(NULL),
422                           void* userdata CV_DEFAULT(NULL));
423 
424 /****************************************************************************************\
425 *                              Contours retrieving                                       *
426 \****************************************************************************************/
427 
428 /** @brief Retrieves outer and optionally inner boundaries of white (non-zero) connected
429    components in the black (zero) background
430 @see cv::findContours, cvStartFindContours, cvFindNextContour, cvSubstituteContour, cvEndFindContours
431 */
432 CVAPI(int)  cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
433                             int header_size CV_DEFAULT(sizeof(CvContour)),
434                             int mode CV_DEFAULT(CV_RETR_LIST),
435                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
436                             CvPoint offset CV_DEFAULT(cvPoint(0,0)));
437 
438 /** @brief Initializes contour retrieving process.
439 
440    Calls cvStartFindContours.
441    Calls cvFindNextContour until null pointer is returned
442    or some other condition becomes true.
443    Calls cvEndFindContours at the end.
444 @see cvFindContours
445 */
446 CVAPI(CvContourScanner)  cvStartFindContours( CvArr* image, CvMemStorage* storage,
447                             int header_size CV_DEFAULT(sizeof(CvContour)),
448                             int mode CV_DEFAULT(CV_RETR_LIST),
449                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
450                             CvPoint offset CV_DEFAULT(cvPoint(0,0)));
451 
452 /** @brief Retrieves next contour
453 @see cvFindContours
454 */
455 CVAPI(CvSeq*)  cvFindNextContour( CvContourScanner scanner );
456 
457 
458 /** @brief Substitutes the last retrieved contour with the new one
459 
460    (if the substitutor is null, the last retrieved contour is removed from the tree)
461 @see cvFindContours
462 */
463 CVAPI(void)   cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
464 
465 
466 /** @brief Releases contour scanner and returns pointer to the first outer contour
467 @see cvFindContours
468 */
469 CVAPI(CvSeq*)  cvEndFindContours( CvContourScanner* scanner );
470 
471 /** @brief Approximates Freeman chain(s) with a polygonal curve.
472 
473 This is a standalone contour approximation routine, not represented in the new interface. When
474 cvFindContours retrieves contours as Freeman chains, it calls the function to get approximated
475 contours, represented as polygons.
476 
477 @param src_seq Pointer to the approximated Freeman chain that can refer to other chains.
478 @param storage Storage location for the resulting polylines.
479 @param method Approximation method (see the description of the function :ocvFindContours ).
480 @param parameter Method parameter (not used now).
481 @param minimal_perimeter Approximates only those contours whose perimeters are not less than
482 minimal_perimeter . Other chains are removed from the resulting structure.
483 @param recursive Recursion flag. If it is non-zero, the function approximates all chains that can
484 be obtained from chain by using the h_next or v_next links. Otherwise, the single input chain is
485 approximated.
486 @see cvStartReadChainPoints, cvReadChainPoint
487  */
488 CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
489                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
490                             double parameter CV_DEFAULT(0),
491                             int  minimal_perimeter CV_DEFAULT(0),
492                             int  recursive CV_DEFAULT(0));
493 
494 /** @brief Initializes Freeman chain reader.
495 
496    The reader is used to iteratively get coordinates of all the chain points.
497    If the Freeman codes should be read as is, a simple sequence reader should be used
498 @see cvApproxChains
499 */
500 CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
501 
502 /** @brief Retrieves the next chain point
503 @see cvApproxChains
504 */
505 CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
506 
507 
508 /****************************************************************************************\
509 *                            Contour Processing and Shape Analysis                       *
510 \****************************************************************************************/
511 
512 /** @brief Approximates a single polygonal curve (contour) or
513    a tree of polygonal curves (contours)
514 @see cv::approxPolyDP
515 */
516 CVAPI(CvSeq*)  cvApproxPoly( const void* src_seq,
517                              int header_size, CvMemStorage* storage,
518                              int method, double eps,
519                              int recursive CV_DEFAULT(0));
520 
521 /** @brief Calculates perimeter of a contour or length of a part of contour
522 @see cv::arcLength
523 */
524 CVAPI(double)  cvArcLength( const void* curve,
525                             CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
526                             int is_closed CV_DEFAULT(-1));
527 
528 /** same as cvArcLength for closed contour
529 */
cvContourPerimeter(const void * contour)530 CV_INLINE double cvContourPerimeter( const void* contour )
531 {
532     return cvArcLength( contour, CV_WHOLE_SEQ, 1 );
533 }
534 
535 
536 /** @brief Calculates contour bounding rectangle (update=1) or
537    just retrieves pre-calculated rectangle (update=0)
538 @see cv::boundingRect
539 */
540 CVAPI(CvRect)  cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
541 
542 /** @brief Calculates area of a contour or contour segment
543 @see cv::contourArea
544 */
545 CVAPI(double)  cvContourArea( const CvArr* contour,
546                               CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
547                               int oriented CV_DEFAULT(0));
548 
549 /** @brief Finds minimum area rotated rectangle bounding a set of points
550 @see cv::minAreaRect
551 */
552 CVAPI(CvBox2D)  cvMinAreaRect2( const CvArr* points,
553                                 CvMemStorage* storage CV_DEFAULT(NULL));
554 
555 /** @brief Finds minimum enclosing circle for a set of points
556 @see cv::minEnclosingCircle
557 */
558 CVAPI(int)  cvMinEnclosingCircle( const CvArr* points,
559                                   CvPoint2D32f* center, float* radius );
560 
561 /** @brief Compares two contours by matching their moments
562 @see cv::matchShapes
563 */
564 CVAPI(double)  cvMatchShapes( const void* object1, const void* object2,
565                               int method, double parameter CV_DEFAULT(0));
566 
567 /** @brief Calculates exact convex hull of 2d point set
568 @see cv::convexHull
569 */
570 CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
571                              void* hull_storage CV_DEFAULT(NULL),
572                              int orientation CV_DEFAULT(CV_CLOCKWISE),
573                              int return_points CV_DEFAULT(0));
574 
575 /** @brief Checks whether the contour is convex or not (returns 1 if convex, 0 if not)
576 @see cv::isContourConvex
577 */
578 CVAPI(int)  cvCheckContourConvexity( const CvArr* contour );
579 
580 
581 /** @brief Finds convexity defects for the contour
582 @see cv::convexityDefects
583 */
584 CVAPI(CvSeq*)  cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
585                                    CvMemStorage* storage CV_DEFAULT(NULL));
586 
587 /** @brief Fits ellipse into a set of 2d points
588 @see cv::fitEllipse
589 */
590 CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points );
591 
592 /** @brief Finds minimum rectangle containing two given rectangles */
593 CVAPI(CvRect)  cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
594 
595 /** @brief Finds coordinates of the box vertices */
596 CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
597 
598 /** @brief Initializes sequence header for a matrix (column or row vector) of points
599 
600    a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */
601 CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat,
602                                  CvContour* contour_header,
603                                  CvSeqBlock* block );
604 
605 /** @brief Checks whether the point is inside polygon, outside, on an edge (at a vertex).
606 
607    Returns positive, negative or zero value, correspondingly.
608    Optionally, measures a signed distance between
609    the point and the nearest polygon edge (measure_dist=1)
610 @see cv::pointPolygonTest
611 */
612 CVAPI(double) cvPointPolygonTest( const CvArr* contour,
613                                   CvPoint2D32f pt, int measure_dist );
614 
615 /****************************************************************************************\
616 *                                  Histogram functions                                   *
617 \****************************************************************************************/
618 
619 /** @brief Creates a histogram.
620 
621 The function creates a histogram of the specified size and returns a pointer to the created
622 histogram. If the array ranges is 0, the histogram bin ranges must be specified later via the
623 function cvSetHistBinRanges. Though cvCalcHist and cvCalcBackProject may process 8-bit images
624 without setting bin ranges, they assume they are equally spaced in 0 to 255 bins.
625 
626 @param dims Number of histogram dimensions.
627 @param sizes Array of the histogram dimension sizes.
628 @param type Histogram representation format. CV_HIST_ARRAY means that the histogram data is
629 represented as a multi-dimensional dense array CvMatND. CV_HIST_SPARSE means that histogram data
630 is represented as a multi-dimensional sparse array CvSparseMat.
631 @param ranges Array of ranges for the histogram bins. Its meaning depends on the uniform parameter
632 value. The ranges are used when the histogram is calculated or backprojected to determine which
633 histogram bin corresponds to which value/tuple of values from the input image(s).
634 @param uniform Uniformity flag. If not zero, the histogram has evenly spaced bins and for every
635 \f$0<=i<cDims\f$ ranges[i] is an array of two numbers: lower and upper boundaries for the i-th
636 histogram dimension. The whole range [lower,upper] is then split into dims[i] equal parts to
637 determine the i-th input tuple value ranges for every histogram bin. And if uniform=0 , then the
638 i-th element of the ranges array contains dims[i]+1 elements: \f$\texttt{lower}_0,
639 \texttt{upper}_0, \texttt{lower}_1, \texttt{upper}_1 = \texttt{lower}_2,
640 ...
641 \texttt{upper}_{dims[i]-1}\f$ where \f$\texttt{lower}_j\f$ and \f$\texttt{upper}_j\f$ are lower
642 and upper boundaries of the i-th input tuple value for the j-th bin, respectively. In either
643 case, the input values that are beyond the specified range for a histogram bin are not counted
644 by cvCalcHist and filled with 0 by cvCalcBackProject.
645  */
646 CVAPI(CvHistogram*)  cvCreateHist( int dims, int* sizes, int type,
647                                    float** ranges CV_DEFAULT(NULL),
648                                    int uniform CV_DEFAULT(1));
649 
650 /** @brief Sets the bounds of the histogram bins.
651 
652 This is a standalone function for setting bin ranges in the histogram. For a more detailed
653 description of the parameters ranges and uniform, see the :ocvCalcHist function that can initialize
654 the ranges as well. Ranges for the histogram bins must be set before the histogram is calculated or
655 the backproject of the histogram is calculated.
656 
657 @param hist Histogram.
658 @param ranges Array of bin ranges arrays. See :ocvCreateHist for details.
659 @param uniform Uniformity flag. See :ocvCreateHist for details.
660  */
661 CVAPI(void)  cvSetHistBinRanges( CvHistogram* hist, float** ranges,
662                                 int uniform CV_DEFAULT(1));
663 
664 /** @brief Makes a histogram out of an array.
665 
666 The function initializes the histogram, whose header and bins are allocated by the user.
667 cvReleaseHist does not need to be called afterwards. Only dense histograms can be initialized this
668 way. The function returns hist.
669 
670 @param dims Number of the histogram dimensions.
671 @param sizes Array of the histogram dimension sizes.
672 @param hist Histogram header initialized by the function.
673 @param data Array used to store histogram bins.
674 @param ranges Histogram bin ranges. See cvCreateHist for details.
675 @param uniform Uniformity flag. See cvCreateHist for details.
676  */
677 CVAPI(CvHistogram*)  cvMakeHistHeaderForArray(
678                             int  dims, int* sizes, CvHistogram* hist,
679                             float* data, float** ranges CV_DEFAULT(NULL),
680                             int uniform CV_DEFAULT(1));
681 
682 /** @brief Releases the histogram.
683 
684 The function releases the histogram (header and the data). The pointer to the histogram is cleared
685 by the function. If \*hist pointer is already NULL, the function does nothing.
686 
687 @param hist Double pointer to the released histogram.
688  */
689 CVAPI(void)  cvReleaseHist( CvHistogram** hist );
690 
691 /** @brief Clears the histogram.
692 
693 The function sets all of the histogram bins to 0 in case of a dense histogram and removes all
694 histogram bins in case of a sparse array.
695 
696 @param hist Histogram.
697  */
698 CVAPI(void)  cvClearHist( CvHistogram* hist );
699 
700 /** @brief Finds the minimum and maximum histogram bins.
701 
702 The function finds the minimum and maximum histogram bins and their positions. All of output
703 arguments are optional. Among several extremas with the same value the ones with the minimum index
704 (in the lexicographical order) are returned. In case of several maximums or minimums, the earliest
705 in the lexicographical order (extrema locations) is returned.
706 
707 @param hist Histogram.
708 @param min_value Pointer to the minimum value of the histogram.
709 @param max_value Pointer to the maximum value of the histogram.
710 @param min_idx Pointer to the array of coordinates for the minimum.
711 @param max_idx Pointer to the array of coordinates for the maximum.
712  */
713 CVAPI(void)  cvGetMinMaxHistValue( const CvHistogram* hist,
714                                    float* min_value, float* max_value,
715                                    int* min_idx CV_DEFAULT(NULL),
716                                    int* max_idx CV_DEFAULT(NULL));
717 
718 
719 /** @brief Normalizes the histogram.
720 
721 The function normalizes the histogram bins by scaling them so that the sum of the bins becomes equal
722 to factor.
723 
724 @param hist Pointer to the histogram.
725 @param factor Normalization factor.
726  */
727 CVAPI(void)  cvNormalizeHist( CvHistogram* hist, double factor );
728 
729 
730 /** @brief Thresholds the histogram.
731 
732 The function clears histogram bins that are below the specified threshold.
733 
734 @param hist Pointer to the histogram.
735 @param threshold Threshold level.
736  */
737 CVAPI(void)  cvThreshHist( CvHistogram* hist, double threshold );
738 
739 
740 /** Compares two histogram */
741 CVAPI(double)  cvCompareHist( const CvHistogram* hist1,
742                               const CvHistogram* hist2,
743                               int method);
744 
745 /** @brief Copies a histogram.
746 
747 The function makes a copy of the histogram. If the second histogram pointer \*dst is NULL, a new
748 histogram of the same size as src is created. Otherwise, both histograms must have equal types and
749 sizes. Then the function copies the bin values of the source histogram to the destination histogram
750 and sets the same bin value ranges as in src.
751 
752 @param src Source histogram.
753 @param dst Pointer to the destination histogram.
754  */
755 CVAPI(void)  cvCopyHist( const CvHistogram* src, CvHistogram** dst );
756 
757 
758 /** @brief Calculates bayesian probabilistic histograms
759    (each or src and dst is an array of _number_ histograms */
760 CVAPI(void)  cvCalcBayesianProb( CvHistogram** src, int number,
761                                 CvHistogram** dst);
762 
763 /** @brief Calculates array histogram
764 @see cv::calcHist
765 */
766 CVAPI(void)  cvCalcArrHist( CvArr** arr, CvHistogram* hist,
767                             int accumulate CV_DEFAULT(0),
768                             const CvArr* mask CV_DEFAULT(NULL) );
769 
770 /** @overload */
771 CV_INLINE  void  cvCalcHist( IplImage** image, CvHistogram* hist,
772                              int accumulate CV_DEFAULT(0),
773                              const CvArr* mask CV_DEFAULT(NULL) )
774 {
775     cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
776 }
777 
778 /** @brief Calculates back project
779 @see cvCalcBackProject, cv::calcBackProject
780 */
781 CVAPI(void)  cvCalcArrBackProject( CvArr** image, CvArr* dst,
782                                    const CvHistogram* hist );
783 
784 #define  cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist)
785 
786 
787 /** @brief Locates a template within an image by using a histogram comparison.
788 
789 The function calculates the back projection by comparing histograms of the source image patches with
790 the given histogram. The function is similar to matchTemplate, but instead of comparing the raster
791 patch with all its possible positions within the search window, the function CalcBackProjectPatch
792 compares histograms. See the algorithm diagram below:
793 
794 ![image](pics/backprojectpatch.png)
795 
796 @param image Source images (though, you may pass CvMat\*\* as well).
797 @param dst Destination image.
798 @param range
799 @param hist Histogram.
800 @param method Comparison method passed to cvCompareHist (see the function description).
801 @param factor Normalization factor for histograms that affects the normalization scale of the
802 destination image. Pass 1 if not sure.
803 
804 @see cvCalcBackProjectPatch
805  */
806 CVAPI(void)  cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
807                                         CvHistogram* hist, int method,
808                                         double factor );
809 
810 #define  cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \
811      cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
812 
813 
814 /** @brief Divides one histogram by another.
815 
816 The function calculates the object probability density from two histograms as:
817 
818 \f[\texttt{disthist} (I)= \forkthree{0}{if \(\texttt{hist1}(I)=0\)}{\texttt{scale}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) > \texttt{hist1}(I)\)}{\frac{\texttt{hist2}(I) \cdot \texttt{scale}}{\texttt{hist1}(I)}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) \le \texttt{hist1}(I)\)}\f]
819 
820 @param hist1 First histogram (the divisor).
821 @param hist2 Second histogram.
822 @param dst_hist Destination histogram.
823 @param scale Scale factor for the destination histogram.
824  */
825 CVAPI(void)  cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
826                                 CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
827 
828 /** @brief equalizes histogram of 8-bit single-channel image
829 @see cv::equalizeHist
830 */
831 CVAPI(void)  cvEqualizeHist( const CvArr* src, CvArr* dst );
832 
833 
834 /** @brief Applies distance transform to binary image
835 @see cv::distanceTransform
836 */
837 CVAPI(void)  cvDistTransform( const CvArr* src, CvArr* dst,
838                               int distance_type CV_DEFAULT(CV_DIST_L2),
839                               int mask_size CV_DEFAULT(3),
840                               const float* mask CV_DEFAULT(NULL),
841                               CvArr* labels CV_DEFAULT(NULL),
842                               int labelType CV_DEFAULT(CV_DIST_LABEL_CCOMP));
843 
844 
845 /** @brief Applies fixed-level threshold to grayscale image.
846 
847    This is a basic operation applied before retrieving contours
848 @see cv::threshold
849 */
850 CVAPI(double)  cvThreshold( const CvArr*  src, CvArr*  dst,
851                             double  threshold, double  max_value,
852                             int threshold_type );
853 
854 /** @brief Applies adaptive threshold to grayscale image.
855 
856    The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
857    CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
858    neighborhood size (3, 5, 7 etc.),
859    and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...)
860 @see cv::adaptiveThreshold
861 */
862 CVAPI(void)  cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
863                                   int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
864                                   int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
865                                   int block_size CV_DEFAULT(3),
866                                   double param1 CV_DEFAULT(5));
867 
868 /** @brief Fills the connected component until the color difference gets large enough
869 @see cv::floodFill
870 */
871 CVAPI(void)  cvFloodFill( CvArr* image, CvPoint seed_point,
872                           CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)),
873                           CvScalar up_diff CV_DEFAULT(cvScalarAll(0)),
874                           CvConnectedComp* comp CV_DEFAULT(NULL),
875                           int flags CV_DEFAULT(4),
876                           CvArr* mask CV_DEFAULT(NULL));
877 
878 /****************************************************************************************\
879 *                                  Feature detection                                     *
880 \****************************************************************************************/
881 
882 /** @brief Runs canny edge detector
883 @see cv::Canny
884 */
885 CVAPI(void)  cvCanny( const CvArr* image, CvArr* edges, double threshold1,
886                       double threshold2, int  aperture_size CV_DEFAULT(3) );
887 
888 /** @brief Calculates constraint image for corner detection
889 
890    Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy.
891    Applying threshold to the result gives coordinates of corners
892 @see cv::preCornerDetect
893 */
894 CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners,
895                                int aperture_size CV_DEFAULT(3) );
896 
897 /** @brief Calculates eigen values and vectors of 2x2
898    gradient covariation matrix at every image pixel
899 @see cv::cornerEigenValsAndVecs
900 */
901 CVAPI(void)  cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
902                                        int block_size, int aperture_size CV_DEFAULT(3) );
903 
904 /** @brief Calculates minimal eigenvalue for 2x2 gradient covariation matrix at
905    every image pixel
906 @see cv::cornerMinEigenVal
907 */
908 CVAPI(void)  cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
909                                   int block_size, int aperture_size CV_DEFAULT(3) );
910 
911 /** @brief Harris corner detector:
912 
913    Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel
914 @see cv::cornerHarris
915 */
916 CVAPI(void)  cvCornerHarris( const CvArr* image, CvArr* harris_response,
917                              int block_size, int aperture_size CV_DEFAULT(3),
918                              double k CV_DEFAULT(0.04) );
919 
920 /** @brief Adjust corner position using some sort of gradient search
921 @see cv::cornerSubPix
922 */
923 CVAPI(void)  cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
924                                  int count, CvSize win, CvSize zero_zone,
925                                  CvTermCriteria  criteria );
926 
927 /** @brief Finds a sparse set of points within the selected region
928    that seem to be easy to track
929 @see cv::goodFeaturesToTrack
930 */
931 CVAPI(void)  cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
932                                     CvArr* temp_image, CvPoint2D32f* corners,
933                                     int* corner_count, double  quality_level,
934                                     double  min_distance,
935                                     const CvArr* mask CV_DEFAULT(NULL),
936                                     int block_size CV_DEFAULT(3),
937                                     int use_harris CV_DEFAULT(0),
938                                     double k CV_DEFAULT(0.04) );
939 
940 /** @brief Finds lines on binary image using one of several methods.
941 
942    line_storage is either memory storage or 1 x _max number of lines_ CvMat, its
943    number of columns is changed by the function.
944    method is one of CV_HOUGH_*;
945    rho, theta and threshold are used for each of those methods;
946    param1 ~ line length, param2 ~ line gap - for probabilistic,
947    param1 ~ srn, param2 ~ stn - for multi-scale
948 @see cv::HoughLines
949 */
950 CVAPI(CvSeq*)  cvHoughLines2( CvArr* image, void* line_storage, int method,
951                               double rho, double theta, int threshold,
952                               double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0),
953                               double min_theta CV_DEFAULT(0), double max_theta CV_DEFAULT(CV_PI));
954 
955 /** @brief Finds circles in the image
956 @see cv::HoughCircles
957 */
958 CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
959                               int method, double dp, double min_dist,
960                               double param1 CV_DEFAULT(100),
961                               double param2 CV_DEFAULT(100),
962                               int min_radius CV_DEFAULT(0),
963                               int max_radius CV_DEFAULT(0));
964 
965 /** @brief Fits a line into set of 2d or 3d points in a robust way (M-estimator technique)
966 @see cv::fitLine
967 */
968 CVAPI(void)  cvFitLine( const CvArr* points, int dist_type, double param,
969                         double reps, double aeps, float* line );
970 
971 /****************************************************************************************\
972 *                                     Drawing                                            *
973 \****************************************************************************************/
974 
975 /****************************************************************************************\
976 *       Drawing functions work with images/matrices of arbitrary type.                   *
977 *       For color images the channel order is BGR[A]                                     *
978 *       Antialiasing is supported only for 8-bit image now.                              *
979 *       All the functions include parameter color that means rgb value (that may be      *
980 *       constructed with CV_RGB macro) for color images and brightness                   *
981 *       for grayscale images.                                                            *
982 *       If a drawn figure is partially or completely outside of the image, it is clipped.*
983 \****************************************************************************************/
984 
985 #define CV_RGB( r, g, b )  cvScalar( (b), (g), (r), 0 )
986 #define CV_FILLED -1
987 
988 #define CV_AA 16
989 
990 /** @brief Draws 4-connected, 8-connected or antialiased line segment connecting two points
991 @see cv::line
992 */
993 CVAPI(void)  cvLine( CvArr* img, CvPoint pt1, CvPoint pt2,
994                      CvScalar color, int thickness CV_DEFAULT(1),
995                      int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
996 
997 /** @brief Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2)
998 
999    if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn
1000 @see cv::rectangle
1001 */
1002 CVAPI(void)  cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2,
1003                           CvScalar color, int thickness CV_DEFAULT(1),
1004                           int line_type CV_DEFAULT(8),
1005                           int shift CV_DEFAULT(0));
1006 
1007 /** @brief Draws a rectangle specified by a CvRect structure
1008 @see cv::rectangle
1009 */
1010 CVAPI(void)  cvRectangleR( CvArr* img, CvRect r,
1011                            CvScalar color, int thickness CV_DEFAULT(1),
1012                            int line_type CV_DEFAULT(8),
1013                            int shift CV_DEFAULT(0));
1014 
1015 
1016 /** @brief Draws a circle with specified center and radius.
1017 
1018    Thickness works in the same way as with cvRectangle
1019 @see cv::circle
1020 */
1021 CVAPI(void)  cvCircle( CvArr* img, CvPoint center, int radius,
1022                        CvScalar color, int thickness CV_DEFAULT(1),
1023                        int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
1024 
1025 /** @brief Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector
1026 
1027    depending on _thickness_, _start_angle_ and _end_angle_ parameters. The resultant figure
1028    is rotated by _angle_. All the angles are in degrees
1029 @see cv::ellipse
1030 */
1031 CVAPI(void)  cvEllipse( CvArr* img, CvPoint center, CvSize axes,
1032                         double angle, double start_angle, double end_angle,
1033                         CvScalar color, int thickness CV_DEFAULT(1),
1034                         int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
1035 
1036 CV_INLINE  void  cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color,
1037                                int thickness CV_DEFAULT(1),
1038                                int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) )
1039 {
1040     CvSize axes;
1041     axes.width = cvRound(box.size.width*0.5);
1042     axes.height = cvRound(box.size.height*0.5);
1043 
1044     cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle,
1045                0, 360, color, thickness, line_type, shift );
1046 }
1047 
1048 /** @brief Fills convex or monotonous polygon.
1049 @see cv::fillConvexPoly
1050 */
1051 CVAPI(void)  cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color,
1052                                int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
1053 
1054 /** @brief Fills an area bounded by one or more arbitrary polygons
1055 @see cv::fillPoly
1056 */
1057 CVAPI(void)  cvFillPoly( CvArr* img, CvPoint** pts, const int* npts,
1058                          int contours, CvScalar color,
1059                          int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
1060 
1061 /** @brief Draws one or more polygonal curves
1062 @see cv::polylines
1063 */
1064 CVAPI(void)  cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contours,
1065                          int is_closed, CvScalar color, int thickness CV_DEFAULT(1),
1066                          int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
1067 
1068 #define cvDrawRect cvRectangle
1069 #define cvDrawLine cvLine
1070 #define cvDrawCircle cvCircle
1071 #define cvDrawEllipse cvEllipse
1072 #define cvDrawPolyLine cvPolyLine
1073 
1074 /** @brief Clips the line segment connecting *pt1 and *pt2
1075    by the rectangular window
1076 
1077    (0<=x<img_size.width, 0<=y<img_size.height).
1078 @see cv::clipLine
1079 */
1080 CVAPI(int) cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 );
1081 
1082 /** @brief Initializes line iterator.
1083 
1084 Initially, line_iterator->ptr will point to pt1 (or pt2, see left_to_right description) location in
1085 the image. Returns the number of pixels on the line between the ending points.
1086 @see cv::LineIterator
1087 */
1088 CVAPI(int)  cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2,
1089                                 CvLineIterator* line_iterator,
1090                                 int connectivity CV_DEFAULT(8),
1091                                 int left_to_right CV_DEFAULT(0));
1092 
1093 #define CV_NEXT_LINE_POINT( line_iterator )                     \
1094 {                                                               \
1095     int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \
1096     (line_iterator).err += (line_iterator).minus_delta +        \
1097         ((line_iterator).plus_delta & _line_iterator_mask);     \
1098     (line_iterator).ptr += (line_iterator).minus_step +         \
1099         ((line_iterator).plus_step & _line_iterator_mask);      \
1100 }
1101 
1102 
1103 #define CV_FONT_HERSHEY_SIMPLEX         0
1104 #define CV_FONT_HERSHEY_PLAIN           1
1105 #define CV_FONT_HERSHEY_DUPLEX          2
1106 #define CV_FONT_HERSHEY_COMPLEX         3
1107 #define CV_FONT_HERSHEY_TRIPLEX         4
1108 #define CV_FONT_HERSHEY_COMPLEX_SMALL   5
1109 #define CV_FONT_HERSHEY_SCRIPT_SIMPLEX  6
1110 #define CV_FONT_HERSHEY_SCRIPT_COMPLEX  7
1111 
1112 #define CV_FONT_ITALIC                 16
1113 
1114 #define CV_FONT_VECTOR0    CV_FONT_HERSHEY_SIMPLEX
1115 
1116 
1117 /** Font structure */
1118 typedef struct CvFont
1119 {
1120   const char* nameFont;   //Qt:nameFont
1121   CvScalar color;       //Qt:ColorFont -> cvScalar(blue_component, green_component, red_component[, alpha_component])
1122     int         font_face;    //Qt: bool italic         /** =CV_FONT_* */
1123     const int*  ascii;      //!< font data and metrics
1124     const int*  greek;
1125     const int*  cyrillic;
1126     float       hscale, vscale;
1127     float       shear;      //!< slope coefficient: 0 - normal, >0 - italic
1128     int         thickness;    //!< Qt: weight               /** letters thickness */
1129     float       dx;       //!< horizontal interval between letters
1130     int         line_type;    //!< Qt: PointSize
1131 }
1132 CvFont;
1133 
1134 /** @brief Initializes font structure (OpenCV 1.x API).
1135 
1136 The function initializes the font structure that can be passed to text rendering functions.
1137 
1138 @param font Pointer to the font structure initialized by the function
1139 @param font_face Font name identifier. See cv::HersheyFonts and corresponding old CV_* identifiers.
1140 @param hscale Horizontal scale. If equal to 1.0f , the characters have the original width
1141 depending on the font type. If equal to 0.5f , the characters are of half the original width.
1142 @param vscale Vertical scale. If equal to 1.0f , the characters have the original height depending
1143 on the font type. If equal to 0.5f , the characters are of half the original height.
1144 @param shear Approximate tangent of the character slope relative to the vertical line. A zero
1145 value means a non-italic font, 1.0f means about a 45 degree slope, etc.
1146 @param thickness Thickness of the text strokes
1147 @param line_type Type of the strokes, see line description
1148 
1149 @sa cvPutText
1150  */
1151 CVAPI(void)  cvInitFont( CvFont* font, int font_face,
1152                          double hscale, double vscale,
1153                          double shear CV_DEFAULT(0),
1154                          int thickness CV_DEFAULT(1),
1155                          int line_type CV_DEFAULT(8));
1156 
1157 CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) )
1158 {
1159     CvFont font;
1160     cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA );
1161     return font;
1162 }
1163 
1164 /** @brief Renders text stroke with specified font and color at specified location.
1165    CvFont should be initialized with cvInitFont
1166 @see cvInitFont, cvGetTextSize, cvFont, cv::putText
1167 */
1168 CVAPI(void)  cvPutText( CvArr* img, const char* text, CvPoint org,
1169                         const CvFont* font, CvScalar color );
1170 
1171 /** @brief Calculates bounding box of text stroke (useful for alignment)
1172 @see cv::getTextSize
1173 */
1174 CVAPI(void)  cvGetTextSize( const char* text_string, const CvFont* font,
1175                             CvSize* text_size, int* baseline );
1176 
1177 /** @brief Unpacks color value
1178 
1179 if arrtype is CV_8UC?, _color_ is treated as packed color value, otherwise the first channels
1180 (depending on arrtype) of destination scalar are set to the same value = _color_
1181 */
1182 CVAPI(CvScalar)  cvColorToScalar( double packed_color, int arrtype );
1183 
1184 /** @brief Returns the polygon points which make up the given ellipse.
1185 
1186 The ellipse is define by the box of size 'axes' rotated 'angle' around the 'center'. A partial
1187 sweep of the ellipse arc can be done by spcifying arc_start and arc_end to be something other than
1188 0 and 360, respectively. The input array 'pts' must be large enough to hold the result. The total
1189 number of points stored into 'pts' is returned by this function.
1190 @see cv::ellipse2Poly
1191 */
1192 CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes,
1193                  int angle, int arc_start, int arc_end, CvPoint * pts, int delta );
1194 
1195 /** @brief Draws contour outlines or filled interiors on the image
1196 @see cv::drawContours
1197 */
1198 CVAPI(void)  cvDrawContours( CvArr *img, CvSeq* contour,
1199                              CvScalar external_color, CvScalar hole_color,
1200                              int max_level, int thickness CV_DEFAULT(1),
1201                              int line_type CV_DEFAULT(8),
1202                              CvPoint offset CV_DEFAULT(cvPoint(0,0)));
1203 
1204 /** @} */
1205 
1206 #ifdef __cplusplus
1207 }
1208 #endif
1209 
1210 #endif
1211