opencv 2.2.0
/usr/src/RPM/BUILD/libopencv2.2-2.2.0/modules/core/include/opencv2/core/core_c.h
Go to the documentation of this file.
00001 /*M///////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
00004 //
00005 //  By downloading, copying, installing or using the software you agree to this license.
00006 //  If you do not agree to this license, do not download, install,
00007 //  copy or use the software.
00008 //
00009 //
00010 //                           License Agreement
00011 //                For Open Source Computer Vision Library
00012 //
00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
00015 // Third party copyrights are property of their respective owners.
00016 //
00017 // Redistribution and use in source and binary forms, with or without modification,
00018 // are permitted provided that the following conditions are met:
00019 //
00020 //   * Redistribution's of source code must retain the above copyright notice,
00021 //     this list of conditions and the following disclaimer.
00022 //
00023 //   * Redistribution's in binary form must reproduce the above copyright notice,
00024 //     this list of conditions and the following disclaimer in the documentation
00025 //     and/or other materials provided with the distribution.
00026 //
00027 //   * The name of the copyright holders may not be used to endorse or promote products
00028 //     derived from this software without specific prior written permission.
00029 //
00030 // This software is provided by the copyright holders and contributors "as is" and
00031 // any express or implied warranties, including, but not limited to, the implied
00032 // warranties of merchantability and fitness for a particular purpose are disclaimed.
00033 // In no event shall the Intel Corporation or contributors be liable for any direct,
00034 // indirect, incidental, special, exemplary, or consequential damages
00035 // (including, but not limited to, procurement of substitute goods or services;
00036 // loss of use, data, or profits; or business interruption) however caused
00037 // and on any theory of liability, whether in contract, strict liability,
00038 // or tort (including negligence or otherwise) arising in any way out of
00039 // the use of this software, even if advised of the possibility of such damage.
00040 //
00041 //M*/
00042 
00043 
00044 #ifndef __OPENCV_CORE_C_H__
00045 #define __OPENCV_CORE_C_H__
00046 
00047 #include "opencv2/core/types_c.h"
00048 
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052 
00053 /****************************************************************************************\
00054 *          Array allocation, deallocation, initialization and access to elements         *
00055 \****************************************************************************************/
00056 
00057 /* <malloc> wrapper.
00058    If there is no enough memory, the function
00059    (as well as other OpenCV functions that call cvAlloc)
00060    raises an error. */
00061 CVAPI(void*)  cvAlloc( size_t size );
00062 
00063 /* <free> wrapper.
00064    Here and further all the memory releasing functions
00065    (that all call cvFree) take double pointer in order to
00066    to clear pointer to the data after releasing it.
00067    Passing pointer to NULL pointer is Ok: nothing happens in this case
00068 */
00069 CVAPI(void)   cvFree_( void* ptr );
00070 #define cvFree(ptr) (cvFree_(*(ptr)), *(ptr)=0)
00071 
00072 /* Allocates and initializes IplImage header */
00073 CVAPI(IplImage*)  cvCreateImageHeader( CvSize size, int depth, int channels );
00074 
00075 /* Inializes IplImage header */
00076 CVAPI(IplImage*) cvInitImageHeader( IplImage* image, CvSize size, int depth,
00077                                    int channels, int origin CV_DEFAULT(0),
00078                                    int align CV_DEFAULT(4));
00079 
00080 /* Creates IPL image (header and data) */
00081 CVAPI(IplImage*)  cvCreateImage( CvSize size, int depth, int channels );
00082 
00083 /* Releases (i.e. deallocates) IPL image header */
00084 CVAPI(void)  cvReleaseImageHeader( IplImage** image );
00085 
00086 /* Releases IPL image header and data */
00087 CVAPI(void)  cvReleaseImage( IplImage** image );
00088 
00089 /* Creates a copy of IPL image (widthStep may differ) */
00090 CVAPI(IplImage*) cvCloneImage( const IplImage* image );
00091 
00092 /* Sets a Channel Of Interest (only a few functions support COI) -
00093    use cvCopy to extract the selected channel and/or put it back */
00094 CVAPI(void)  cvSetImageCOI( IplImage* image, int coi );
00095 
00096 /* Retrieves image Channel Of Interest */
00097 CVAPI(int)  cvGetImageCOI( const IplImage* image );
00098 
00099 /* Sets image ROI (region of interest) (COI is not changed) */
00100 CVAPI(void)  cvSetImageROI( IplImage* image, CvRect rect );
00101 
00102 /* Resets image ROI and COI */
00103 CVAPI(void)  cvResetImageROI( IplImage* image );
00104 
00105 /* Retrieves image ROI */
00106 CVAPI(CvRect) cvGetImageROI( const IplImage* image );
00107 
00108 /* Allocates and initalizes CvMat header */
00109 CVAPI(CvMat*)  cvCreateMatHeader( int rows, int cols, int type );
00110 
00111 #define CV_AUTOSTEP  0x7fffffff
00112 
00113 /* Initializes CvMat header */
00114 CVAPI(CvMat*) cvInitMatHeader( CvMat* mat, int rows, int cols,
00115                               int type, void* data CV_DEFAULT(NULL),
00116                               int step CV_DEFAULT(CV_AUTOSTEP) );
00117 
00118 /* Allocates and initializes CvMat header and allocates data */
00119 CVAPI(CvMat*)  cvCreateMat( int rows, int cols, int type );
00120 
00121 /* Releases CvMat header and deallocates matrix data
00122    (reference counting is used for data) */
00123 CVAPI(void)  cvReleaseMat( CvMat** mat );
00124 
00125 /* Decrements CvMat data reference counter and deallocates the data if
00126    it reaches 0 */
00127 CV_INLINE  void  cvDecRefData( CvArr* arr )
00128 {
00129     if( CV_IS_MAT( arr ))
00130     {
00131         CvMat* mat = (CvMat*)arr;
00132         mat->data.ptr = NULL;
00133         if( mat->refcount != NULL && --*mat->refcount == 0 )
00134             cvFree( &mat->refcount );
00135         mat->refcount = NULL;
00136     }
00137     else if( CV_IS_MATND( arr ))
00138     {
00139         CvMatND* mat = (CvMatND*)arr;
00140         mat->data.ptr = NULL;
00141         if( mat->refcount != NULL && --*mat->refcount == 0 )
00142             cvFree( &mat->refcount );
00143         mat->refcount = NULL;
00144     }
00145 }
00146 
00147 /* Increments CvMat data reference counter */
00148 CV_INLINE  int  cvIncRefData( CvArr* arr )
00149 {
00150     int refcount = 0;
00151     if( CV_IS_MAT( arr ))
00152     {
00153         CvMat* mat = (CvMat*)arr;
00154         if( mat->refcount != NULL )
00155             refcount = ++*mat->refcount;
00156     }
00157     else if( CV_IS_MATND( arr ))
00158     {
00159         CvMatND* mat = (CvMatND*)arr;
00160         if( mat->refcount != NULL )
00161             refcount = ++*mat->refcount;
00162     }
00163     return refcount;
00164 }
00165 
00166 
00167 /* Creates an exact copy of the input matrix (except, may be, step value) */
00168 CVAPI(CvMat*) cvCloneMat( const CvMat* mat );
00169 
00170 
00171 /* Makes a new matrix from <rect> subrectangle of input array.
00172    No data is copied */
00173 CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect );
00174 #define cvGetSubArr cvGetSubRect
00175 
00176 /* Selects row span of the input array: arr(start_row:delta_row:end_row,:)
00177     (end_row is not included into the span). */
00178 CVAPI(CvMat*) cvGetRows( const CvArr* arr, CvMat* submat,
00179                         int start_row, int end_row,
00180                         int delta_row CV_DEFAULT(1));
00181 
00182 CV_INLINE  CvMat*  cvGetRow( const CvArr* arr, CvMat* submat, int row )
00183 {
00184     return cvGetRows( arr, submat, row, row + 1, 1 );
00185 }
00186 
00187 
00188 /* Selects column span of the input array: arr(:,start_col:end_col)
00189    (end_col is not included into the span) */
00190 CVAPI(CvMat*) cvGetCols( const CvArr* arr, CvMat* submat,
00191                         int start_col, int end_col );
00192 
00193 CV_INLINE  CvMat*  cvGetCol( const CvArr* arr, CvMat* submat, int col )
00194 {
00195     return cvGetCols( arr, submat, col, col + 1 );
00196 }
00197 
00198 /* Select a diagonal of the input array.
00199    (diag = 0 means the main diagonal, >0 means a diagonal above the main one,
00200    <0 - below the main one).
00201    The diagonal will be represented as a column (nx1 matrix). */
00202 CVAPI(CvMat*) cvGetDiag( const CvArr* arr, CvMat* submat,
00203                             int diag CV_DEFAULT(0));
00204 
00205 /* low-level scalar <-> raw data conversion functions */
00206 CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type,
00207                               int extend_to_12 CV_DEFAULT(0) );
00208 
00209 CVAPI(void) cvRawDataToScalar( const void* data, int type, CvScalar* scalar );
00210 
00211 /* Allocates and initializes CvMatND header */
00212 CVAPI(CvMatND*)  cvCreateMatNDHeader( int dims, const int* sizes, int type );
00213 
00214 /* Allocates and initializes CvMatND header and allocates data */
00215 CVAPI(CvMatND*)  cvCreateMatND( int dims, const int* sizes, int type );
00216 
00217 /* Initializes preallocated CvMatND header */
00218 CVAPI(CvMatND*)  cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes,
00219                                     int type, void* data CV_DEFAULT(NULL) );
00220 
00221 /* Releases CvMatND */
00222 CV_INLINE  void  cvReleaseMatND( CvMatND** mat )
00223 {
00224     cvReleaseMat( (CvMat**)mat );
00225 }
00226 
00227 /* Creates a copy of CvMatND (except, may be, steps) */
00228 CVAPI(CvMatND*) cvCloneMatND( const CvMatND* mat );
00229 
00230 /* Allocates and initializes CvSparseMat header and allocates data */
00231 CVAPI(CvSparseMat*)  cvCreateSparseMat( int dims, const int* sizes, int type );
00232 
00233 /* Releases CvSparseMat */
00234 CVAPI(void)  cvReleaseSparseMat( CvSparseMat** mat );
00235 
00236 /* Creates a copy of CvSparseMat (except, may be, zero items) */
00237 CVAPI(CvSparseMat*) cvCloneSparseMat( const CvSparseMat* mat );
00238 
00239 /* Initializes sparse array iterator
00240    (returns the first node or NULL if the array is empty) */
00241 CVAPI(CvSparseNode*) cvInitSparseMatIterator( const CvSparseMat* mat,
00242                                               CvSparseMatIterator* mat_iterator );
00243 
00244 // returns next sparse array node (or NULL if there is no more nodes)
00245 CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator )
00246 {
00247     if( mat_iterator->node->next )
00248         return mat_iterator->node = mat_iterator->node->next;
00249     else
00250     {
00251         int idx;
00252         for( idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize; idx++ )
00253         {
00254             CvSparseNode* node = (CvSparseNode*)mat_iterator->mat->hashtable[idx];
00255             if( node )
00256             {
00257                 mat_iterator->curidx = idx;
00258                 return mat_iterator->node = node;
00259             }
00260         }
00261         return NULL;
00262     }
00263 }
00264 
00265 /**************** matrix iterator: used for n-ary operations on dense arrays *********/
00266 
00267 #define CV_MAX_ARR 10
00268 
00269 typedef struct CvNArrayIterator
00270 {
00271     int count; /* number of arrays */
00272     int dims; /* number of dimensions to iterate */
00273     CvSize size; /* maximal common linear size: { width = size, height = 1 } */
00274     uchar* ptr[CV_MAX_ARR]; /* pointers to the array slices */
00275     int stack[CV_MAX_DIM]; /* for internal use */
00276     CvMatND* hdr[CV_MAX_ARR]; /* pointers to the headers of the
00277                                  matrices that are processed */
00278 }
00279 CvNArrayIterator;
00280 
00281 #define CV_NO_DEPTH_CHECK     1
00282 #define CV_NO_CN_CHECK        2
00283 #define CV_NO_SIZE_CHECK      4
00284 
00285 /* initializes iterator that traverses through several arrays simulteneously
00286    (the function together with cvNextArraySlice is used for
00287     N-ari element-wise operations) */
00288 CVAPI(int) cvInitNArrayIterator( int count, CvArr** arrs,
00289                                  const CvArr* mask, CvMatND* stubs,
00290                                  CvNArrayIterator* array_iterator,
00291                                  int flags CV_DEFAULT(0) );
00292 
00293 /* returns zero value if iteration is finished, non-zero (slice length) otherwise */
00294 CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator );
00295 
00296 
00297 /* Returns type of array elements:
00298    CV_8UC1 ... CV_64FC4 ... */
00299 CVAPI(int) cvGetElemType( const CvArr* arr );
00300 
00301 /* Retrieves number of an array dimensions and
00302    optionally sizes of the dimensions */
00303 CVAPI(int) cvGetDims( const CvArr* arr, int* sizes CV_DEFAULT(NULL) );
00304 
00305 
00306 /* Retrieves size of a particular array dimension.
00307    For 2d arrays cvGetDimSize(arr,0) returns number of rows (image height)
00308    and cvGetDimSize(arr,1) returns number of columns (image width) */
00309 CVAPI(int) cvGetDimSize( const CvArr* arr, int index );
00310 
00311 
00312 /* ptr = &arr(idx0,idx1,...). All indexes are zero-based,
00313    the major dimensions go first (e.g. (y,x) for 2D, (z,y,x) for 3D */
00314 CVAPI(uchar*) cvPtr1D( const CvArr* arr, int idx0, int* type CV_DEFAULT(NULL));
00315 CVAPI(uchar*) cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type CV_DEFAULT(NULL) );
00316 CVAPI(uchar*) cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2,
00317                       int* type CV_DEFAULT(NULL));
00318 
00319 /* For CvMat or IplImage number of indices should be 2
00320    (row index (y) goes first, column index (x) goes next).
00321    For CvMatND or CvSparseMat number of infices should match number of <dims> and
00322    indices order should match the array dimension order. */
00323 CVAPI(uchar*) cvPtrND( const CvArr* arr, const int* idx, int* type CV_DEFAULT(NULL),
00324                       int create_node CV_DEFAULT(1),
00325                       unsigned* precalc_hashval CV_DEFAULT(NULL));
00326 
00327 /* value = arr(idx0,idx1,...) */
00328 CVAPI(CvScalar) cvGet1D( const CvArr* arr, int idx0 );
00329 CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 );
00330 CVAPI(CvScalar) cvGet3D( const CvArr* arr, int idx0, int idx1, int idx2 );
00331 CVAPI(CvScalar) cvGetND( const CvArr* arr, const int* idx );
00332 
00333 /* for 1-channel arrays */
00334 CVAPI(double) cvGetReal1D( const CvArr* arr, int idx0 );
00335 CVAPI(double) cvGetReal2D( const CvArr* arr, int idx0, int idx1 );
00336 CVAPI(double) cvGetReal3D( const CvArr* arr, int idx0, int idx1, int idx2 );
00337 CVAPI(double) cvGetRealND( const CvArr* arr, const int* idx );
00338 
00339 /* arr(idx0,idx1,...) = value */
00340 CVAPI(void) cvSet1D( CvArr* arr, int idx0, CvScalar value );
00341 CVAPI(void) cvSet2D( CvArr* arr, int idx0, int idx1, CvScalar value );
00342 CVAPI(void) cvSet3D( CvArr* arr, int idx0, int idx1, int idx2, CvScalar value );
00343 CVAPI(void) cvSetND( CvArr* arr, const int* idx, CvScalar value );
00344 
00345 /* for 1-channel arrays */
00346 CVAPI(void) cvSetReal1D( CvArr* arr, int idx0, double value );
00347 CVAPI(void) cvSetReal2D( CvArr* arr, int idx0, int idx1, double value );
00348 CVAPI(void) cvSetReal3D( CvArr* arr, int idx0,
00349                         int idx1, int idx2, double value );
00350 CVAPI(void) cvSetRealND( CvArr* arr, const int* idx, double value );
00351 
00352 /* clears element of ND dense array,
00353    in case of sparse arrays it deletes the specified node */
00354 CVAPI(void) cvClearND( CvArr* arr, const int* idx );
00355 
00356 /* Converts CvArr (IplImage or CvMat,...) to CvMat.
00357    If the last parameter is non-zero, function can
00358    convert multi(>2)-dimensional array to CvMat as long as
00359    the last array's dimension is continous. The resultant
00360    matrix will be have appropriate (a huge) number of rows */
00361 CVAPI(CvMat*) cvGetMat( const CvArr* arr, CvMat* header,
00362                        int* coi CV_DEFAULT(NULL),
00363                        int allowND CV_DEFAULT(0));
00364 
00365 /* Converts CvArr (IplImage or CvMat) to IplImage */
00366 CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header );
00367 
00368 
00369 /* Changes a shape of multi-dimensional array.
00370    new_cn == 0 means that number of channels remains unchanged.
00371    new_dims == 0 means that number and sizes of dimensions remain the same
00372    (unless they need to be changed to set the new number of channels)
00373    if new_dims == 1, there is no need to specify new dimension sizes
00374    The resultant configuration should be achievable w/o data copying.
00375    If the resultant array is sparse, CvSparseMat header should be passed
00376    to the function else if the result is 1 or 2 dimensional,
00377    CvMat header should be passed to the function
00378    else CvMatND header should be passed */
00379 CVAPI(CvArr*) cvReshapeMatND( const CvArr* arr,
00380                              int sizeof_header, CvArr* header,
00381                              int new_cn, int new_dims, int* new_sizes );
00382 
00383 #define cvReshapeND( arr, header, new_cn, new_dims, new_sizes )   \
00384       cvReshapeMatND( (arr), sizeof(*(header)), (header),         \
00385                       (new_cn), (new_dims), (new_sizes))
00386 
00387 CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header,
00388                         int new_cn, int new_rows CV_DEFAULT(0) );
00389 
00390 /* Repeats source 2d array several times in both horizontal and
00391    vertical direction to fill destination array */
00392 CVAPI(void) cvRepeat( const CvArr* src, CvArr* dst );
00393 
00394 /* Allocates array data */
00395 CVAPI(void)  cvCreateData( CvArr* arr );
00396 
00397 /* Releases array data */
00398 CVAPI(void)  cvReleaseData( CvArr* arr );
00399 
00400 /* Attaches user data to the array header. The step is reffered to
00401    the pre-last dimension. That is, all the planes of the array
00402    must be joint (w/o gaps) */
00403 CVAPI(void)  cvSetData( CvArr* arr, void* data, int step );
00404 
00405 /* Retrieves raw data of CvMat, IplImage or CvMatND.
00406    In the latter case the function raises an error if
00407    the array can not be represented as a matrix */
00408 CVAPI(void) cvGetRawData( const CvArr* arr, uchar** data,
00409                          int* step CV_DEFAULT(NULL),
00410                          CvSize* roi_size CV_DEFAULT(NULL));
00411 
00412 /* Returns width and height of array in elements */
00413 CVAPI(CvSize) cvGetSize( const CvArr* arr );
00414 
00415 /* Copies source array to destination array */
00416 CVAPI(void)  cvCopy( const CvArr* src, CvArr* dst,
00417                      const CvArr* mask CV_DEFAULT(NULL) );
00418 
00419 /* Sets all or "masked" elements of input array
00420    to the same value*/
00421 CVAPI(void)  cvSet( CvArr* arr, CvScalar value,
00422                     const CvArr* mask CV_DEFAULT(NULL) );
00423 
00424 /* Clears all the array elements (sets them to 0) */
00425 CVAPI(void)  cvSetZero( CvArr* arr );
00426 #define cvZero  cvSetZero
00427 
00428 
00429 /* Splits a multi-channel array into the set of single-channel arrays or
00430    extracts particular [color] plane */
00431 CVAPI(void)  cvSplit( const CvArr* src, CvArr* dst0, CvArr* dst1,
00432                       CvArr* dst2, CvArr* dst3 );
00433 
00434 /* Merges a set of single-channel arrays into the single multi-channel array
00435    or inserts one particular [color] plane to the array */
00436 CVAPI(void)  cvMerge( const CvArr* src0, const CvArr* src1,
00437                       const CvArr* src2, const CvArr* src3,
00438                       CvArr* dst );
00439 
00440 /* Copies several channels from input arrays to
00441    certain channels of output arrays */
00442 CVAPI(void)  cvMixChannels( const CvArr** src, int src_count,
00443                             CvArr** dst, int dst_count,
00444                             const int* from_to, int pair_count );
00445 
00446 /* Performs linear transformation on every source array element:
00447    dst(x,y,c) = scale*src(x,y,c)+shift.
00448    Arbitrary combination of input and output array depths are allowed
00449    (number of channels must be the same), thus the function can be used
00450    for type conversion */
00451 CVAPI(void)  cvConvertScale( const CvArr* src, CvArr* dst,
00452                              double scale CV_DEFAULT(1),
00453                              double shift CV_DEFAULT(0) );
00454 #define cvCvtScale cvConvertScale
00455 #define cvScale  cvConvertScale
00456 #define cvConvert( src, dst )  cvConvertScale( (src), (dst), 1, 0 )
00457 
00458 
00459 /* Performs linear transformation on every source array element,
00460    stores absolute value of the result:
00461    dst(x,y,c) = abs(scale*src(x,y,c)+shift).
00462    destination array must have 8u type.
00463    In other cases one may use cvConvertScale + cvAbsDiffS */
00464 CVAPI(void)  cvConvertScaleAbs( const CvArr* src, CvArr* dst,
00465                                 double scale CV_DEFAULT(1),
00466                                 double shift CV_DEFAULT(0) );
00467 #define cvCvtScaleAbs  cvConvertScaleAbs
00468 
00469 
00470 /* checks termination criteria validity and
00471    sets eps to default_eps (if it is not set),
00472    max_iter to default_max_iters (if it is not set)
00473 */
00474 CVAPI(CvTermCriteria) cvCheckTermCriteria( CvTermCriteria criteria,
00475                                            double default_eps,
00476                                            int default_max_iters );
00477 
00478 /****************************************************************************************\
00479 *                   Arithmetic, logic and comparison operations                          *
00480 \****************************************************************************************/
00481 
00482 /* dst(mask) = src1(mask) + src2(mask) */
00483 CVAPI(void)  cvAdd( const CvArr* src1, const CvArr* src2, CvArr* dst,
00484                     const CvArr* mask CV_DEFAULT(NULL));
00485 
00486 /* dst(mask) = src(mask) + value */
00487 CVAPI(void)  cvAddS( const CvArr* src, CvScalar value, CvArr* dst,
00488                      const CvArr* mask CV_DEFAULT(NULL));
00489 
00490 /* dst(mask) = src1(mask) - src2(mask) */
00491 CVAPI(void)  cvSub( const CvArr* src1, const CvArr* src2, CvArr* dst,
00492                     const CvArr* mask CV_DEFAULT(NULL));
00493 
00494 /* dst(mask) = src(mask) - value = src(mask) + (-value) */
00495 CV_INLINE  void  cvSubS( const CvArr* src, CvScalar value, CvArr* dst,
00496                          const CvArr* mask CV_DEFAULT(NULL))
00497 {
00498     cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]),
00499             dst, mask );
00500 }
00501 
00502 /* dst(mask) = value - src(mask) */
00503 CVAPI(void)  cvSubRS( const CvArr* src, CvScalar value, CvArr* dst,
00504                       const CvArr* mask CV_DEFAULT(NULL));
00505 
00506 /* dst(idx) = src1(idx) * src2(idx) * scale
00507    (scaled element-wise multiplication of 2 arrays) */
00508 CVAPI(void)  cvMul( const CvArr* src1, const CvArr* src2,
00509                     CvArr* dst, double scale CV_DEFAULT(1) );
00510 
00511 /* element-wise division/inversion with scaling:
00512     dst(idx) = src1(idx) * scale / src2(idx)
00513     or dst(idx) = scale / src2(idx) if src1 == 0 */
00514 CVAPI(void)  cvDiv( const CvArr* src1, const CvArr* src2,
00515                     CvArr* dst, double scale CV_DEFAULT(1));
00516 
00517 /* dst = src1 * scale + src2 */
00518 CVAPI(void)  cvScaleAdd( const CvArr* src1, CvScalar scale,
00519                          const CvArr* src2, CvArr* dst );
00520 #define cvAXPY( A, real_scalar, B, C ) cvScaleAdd(A, cvRealScalar(real_scalar), B, C)
00521 
00522 /* dst = src1 * alpha + src2 * beta + gamma */
00523 CVAPI(void)  cvAddWeighted( const CvArr* src1, double alpha,
00524                             const CvArr* src2, double beta,
00525                             double gamma, CvArr* dst );
00526 
00527 /* result = sum_i(src1(i) * src2(i)) (results for all channels are accumulated together) */
00528 CVAPI(double)  cvDotProduct( const CvArr* src1, const CvArr* src2 );
00529 
00530 /* dst(idx) = src1(idx) & src2(idx) */
00531 CVAPI(void) cvAnd( const CvArr* src1, const CvArr* src2,
00532                   CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
00533 
00534 /* dst(idx) = src(idx) & value */
00535 CVAPI(void) cvAndS( const CvArr* src, CvScalar value,
00536                    CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
00537 
00538 /* dst(idx) = src1(idx) | src2(idx) */
00539 CVAPI(void) cvOr( const CvArr* src1, const CvArr* src2,
00540                  CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
00541 
00542 /* dst(idx) = src(idx) | value */
00543 CVAPI(void) cvOrS( const CvArr* src, CvScalar value,
00544                   CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
00545 
00546 /* dst(idx) = src1(idx) ^ src2(idx) */
00547 CVAPI(void) cvXor( const CvArr* src1, const CvArr* src2,
00548                   CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
00549 
00550 /* dst(idx) = src(idx) ^ value */
00551 CVAPI(void) cvXorS( const CvArr* src, CvScalar value,
00552                    CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
00553 
00554 /* dst(idx) = ~src(idx) */
00555 CVAPI(void) cvNot( const CvArr* src, CvArr* dst );
00556 
00557 /* dst(idx) = lower(idx) <= src(idx) < upper(idx) */
00558 CVAPI(void) cvInRange( const CvArr* src, const CvArr* lower,
00559                       const CvArr* upper, CvArr* dst );
00560 
00561 /* dst(idx) = lower <= src(idx) < upper */
00562 CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower,
00563                        CvScalar upper, CvArr* dst );
00564 
00565 #define CV_CMP_EQ   0
00566 #define CV_CMP_GT   1
00567 #define CV_CMP_GE   2
00568 #define CV_CMP_LT   3
00569 #define CV_CMP_LE   4
00570 #define CV_CMP_NE   5
00571 
00572 /* The comparison operation support single-channel arrays only.
00573    Destination image should be 8uC1 or 8sC1 */
00574 
00575 /* dst(idx) = src1(idx) _cmp_op_ src2(idx) */
00576 CVAPI(void) cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op );
00577 
00578 /* dst(idx) = src1(idx) _cmp_op_ value */
00579 CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op );
00580 
00581 /* dst(idx) = min(src1(idx),src2(idx)) */
00582 CVAPI(void) cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst );
00583 
00584 /* dst(idx) = max(src1(idx),src2(idx)) */
00585 CVAPI(void) cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst );
00586 
00587 /* dst(idx) = min(src(idx),value) */
00588 CVAPI(void) cvMinS( const CvArr* src, double value, CvArr* dst );
00589 
00590 /* dst(idx) = max(src(idx),value) */
00591 CVAPI(void) cvMaxS( const CvArr* src, double value, CvArr* dst );
00592 
00593 /* dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */
00594 CVAPI(void) cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst );
00595 
00596 /* dst(x,y,c) = abs(src(x,y,c) - value(c)) */
00597 CVAPI(void) cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value );
00598 #define cvAbs( src, dst ) cvAbsDiffS( (src), (dst), cvScalarAll(0))
00599 
00600 /****************************************************************************************\
00601 *                                Math operations                                         *
00602 \****************************************************************************************/
00603 
00604 /* Does cartesian->polar coordinates conversion.
00605    Either of output components (magnitude or angle) is optional */
00606 CVAPI(void)  cvCartToPolar( const CvArr* x, const CvArr* y,
00607                             CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL),
00608                             int angle_in_degrees CV_DEFAULT(0));
00609 
00610 /* Does polar->cartesian coordinates conversion.
00611    Either of output components (magnitude or angle) is optional.
00612    If magnitude is missing it is assumed to be all 1's */
00613 CVAPI(void)  cvPolarToCart( const CvArr* magnitude, const CvArr* angle,
00614                             CvArr* x, CvArr* y,
00615                             int angle_in_degrees CV_DEFAULT(0));
00616 
00617 /* Does powering: dst(idx) = src(idx)^power */
00618 CVAPI(void)  cvPow( const CvArr* src, CvArr* dst, double power );
00619 
00620 /* Does exponention: dst(idx) = exp(src(idx)).
00621    Overflow is not handled yet. Underflow is handled.
00622    Maximal relative error is ~7e-6 for single-precision input */
00623 CVAPI(void)  cvExp( const CvArr* src, CvArr* dst );
00624 
00625 /* Calculates natural logarithms: dst(idx) = log(abs(src(idx))).
00626    Logarithm of 0 gives large negative number(~-700)
00627    Maximal relative error is ~3e-7 for single-precision output
00628 */
00629 CVAPI(void)  cvLog( const CvArr* src, CvArr* dst );
00630 
00631 /* Fast arctangent calculation */
00632 CVAPI(float) cvFastArctan( float y, float x );
00633 
00634 /* Fast cubic root calculation */
00635 CVAPI(float)  cvCbrt( float value );
00636 
00637 /* Checks array values for NaNs, Infs or simply for too large numbers
00638    (if CV_CHECK_RANGE is set). If CV_CHECK_QUIET is set,
00639    no runtime errors is raised (function returns zero value in case of "bad" values).
00640    Otherwise cvError is called */
00641 #define  CV_CHECK_RANGE    1
00642 #define  CV_CHECK_QUIET    2
00643 CVAPI(int)  cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0),
00644                         double min_val CV_DEFAULT(0), double max_val CV_DEFAULT(0));
00645 #define cvCheckArray cvCheckArr
00646 
00647 #define CV_RAND_UNI      0
00648 #define CV_RAND_NORMAL   1
00649 CVAPI(void) cvRandArr( CvRNG* rng, CvArr* arr, int dist_type,
00650                       CvScalar param1, CvScalar param2 );
00651 
00652 CVAPI(void) cvRandShuffle( CvArr* mat, CvRNG* rng,
00653                            double iter_factor CV_DEFAULT(1.));
00654 
00655 #define CV_SORT_EVERY_ROW 0
00656 #define CV_SORT_EVERY_COLUMN 1
00657 #define CV_SORT_ASCENDING 0
00658 #define CV_SORT_DESCENDING 16
00659 
00660 CVAPI(void) cvSort( const CvArr* src, CvArr* dst CV_DEFAULT(NULL),
00661                     CvArr* idxmat CV_DEFAULT(NULL),
00662                     int flags CV_DEFAULT(0));
00663 
00664 /* Finds real roots of a cubic equation */
00665 CVAPI(int) cvSolveCubic( const CvMat* coeffs, CvMat* roots );
00666 
00667 /* Finds all real and complex roots of a polynomial equation */
00668 CVAPI(void) cvSolvePoly(const CvMat* coeffs, CvMat *roots2,
00669                         int maxiter CV_DEFAULT(20), int fig CV_DEFAULT(100));
00670 
00671 /****************************************************************************************\
00672 *                                Matrix operations                                       *
00673 \****************************************************************************************/
00674 
00675 /* Calculates cross product of two 3d vectors */
00676 CVAPI(void)  cvCrossProduct( const CvArr* src1, const CvArr* src2, CvArr* dst );
00677 
00678 /* Matrix transform: dst = A*B + C, C is optional */
00679 #define cvMatMulAdd( src1, src2, src3, dst ) cvGEMM( (src1), (src2), 1., (src3), 1., (dst), 0 )
00680 #define cvMatMul( src1, src2, dst )  cvMatMulAdd( (src1), (src2), NULL, (dst))
00681 
00682 #define CV_GEMM_A_T 1
00683 #define CV_GEMM_B_T 2
00684 #define CV_GEMM_C_T 4
00685 /* Extended matrix transform:
00686    dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */
00687 CVAPI(void)  cvGEMM( const CvArr* src1, const CvArr* src2, double alpha,
00688                      const CvArr* src3, double beta, CvArr* dst,
00689                      int tABC CV_DEFAULT(0));
00690 #define cvMatMulAddEx cvGEMM
00691 
00692 /* Transforms each element of source array and stores
00693    resultant vectors in destination array */
00694 CVAPI(void)  cvTransform( const CvArr* src, CvArr* dst,
00695                           const CvMat* transmat,
00696                           const CvMat* shiftvec CV_DEFAULT(NULL));
00697 #define cvMatMulAddS cvTransform
00698 
00699 /* Does perspective transform on every element of input array */
00700 CVAPI(void)  cvPerspectiveTransform( const CvArr* src, CvArr* dst,
00701                                      const CvMat* mat );
00702 
00703 /* Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1) */
00704 CVAPI(void) cvMulTransposed( const CvArr* src, CvArr* dst, int order,
00705                              const CvArr* delta CV_DEFAULT(NULL),
00706                              double scale CV_DEFAULT(1.) );
00707 
00708 /* Tranposes matrix. Square matrices can be transposed in-place */
00709 CVAPI(void)  cvTranspose( const CvArr* src, CvArr* dst );
00710 #define cvT cvTranspose
00711 
00712 /* Completes the symmetric matrix from the lower (LtoR=0) or from the upper (LtoR!=0) part */
00713 CVAPI(void)  cvCompleteSymm( CvMat* matrix, int LtoR CV_DEFAULT(0) );
00714 
00715 /* Mirror array data around horizontal (flip=0),
00716    vertical (flip=1) or both(flip=-1) axises:
00717    cvFlip(src) flips images vertically and sequences horizontally (inplace) */
00718 CVAPI(void)  cvFlip( const CvArr* src, CvArr* dst CV_DEFAULT(NULL),
00719                      int flip_mode CV_DEFAULT(0));
00720 #define cvMirror cvFlip
00721 
00722 
00723 #define CV_SVD_MODIFY_A   1
00724 #define CV_SVD_U_T        2
00725 #define CV_SVD_V_T        4
00726 
00727 /* Performs Singular Value Decomposition of a matrix */
00728 CVAPI(void)   cvSVD( CvArr* A, CvArr* W, CvArr* U CV_DEFAULT(NULL),
00729                      CvArr* V CV_DEFAULT(NULL), int flags CV_DEFAULT(0));
00730 
00731 /* Performs Singular Value Back Substitution (solves A*X = B):
00732    flags must be the same as in cvSVD */
00733 CVAPI(void)   cvSVBkSb( const CvArr* W, const CvArr* U,
00734                         const CvArr* V, const CvArr* B,
00735                         CvArr* X, int flags );
00736 
00737 #define CV_LU  0
00738 #define CV_SVD 1
00739 #define CV_SVD_SYM 2
00740 #define CV_CHOLESKY 3
00741 #define CV_QR  4
00742 #define CV_NORMAL 16
00743 
00744 /* Inverts matrix */
00745 CVAPI(double)  cvInvert( const CvArr* src, CvArr* dst,
00746                          int method CV_DEFAULT(CV_LU));
00747 #define cvInv cvInvert
00748 
00749 /* Solves linear system (src1)*(dst) = (src2)
00750    (returns 0 if src1 is a singular and CV_LU method is used) */
00751 CVAPI(int)  cvSolve( const CvArr* src1, const CvArr* src2, CvArr* dst,
00752                      int method CV_DEFAULT(CV_LU));
00753 
00754 /* Calculates determinant of input matrix */
00755 CVAPI(double) cvDet( const CvArr* mat );
00756 
00757 /* Calculates trace of the matrix (sum of elements on the main diagonal) */
00758 CVAPI(CvScalar) cvTrace( const CvArr* mat );
00759 
00760 /* Finds eigen values and vectors of a symmetric matrix */
00761 CVAPI(void)  cvEigenVV( CvArr* mat, CvArr* evects, CvArr* evals,
00762                         double eps CV_DEFAULT(0),
00763                         int lowindex CV_DEFAULT(-1),
00764                         int highindex CV_DEFAULT(-1));
00765 
00767 //CVAPI(void)  cvSelectedEigenVV( CvArr* mat, CvArr* evects, CvArr* evals,
00768 //                                int lowindex, int highindex );
00769 
00770 /* Makes an identity matrix (mat_ij = i == j) */
00771 CVAPI(void)  cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvRealScalar(1)) );
00772 
00773 /* Fills matrix with given range of numbers */
00774 CVAPI(CvArr*)  cvRange( CvArr* mat, double start, double end );
00775 
00776 /* Calculates covariation matrix for a set of vectors */
00777 /* transpose([v1-avg, v2-avg,...]) * [v1-avg,v2-avg,...] */
00778 #define CV_COVAR_SCRAMBLED 0
00779 
00780 /* [v1-avg, v2-avg,...] * transpose([v1-avg,v2-avg,...]) */
00781 #define CV_COVAR_NORMAL    1
00782 
00783 /* do not calc average (i.e. mean vector) - use the input vector instead
00784    (useful for calculating covariance matrix by parts) */
00785 #define CV_COVAR_USE_AVG   2
00786 
00787 /* scale the covariance matrix coefficients by number of the vectors */
00788 #define CV_COVAR_SCALE     4
00789 
00790 /* all the input vectors are stored in a single matrix, as its rows */
00791 #define CV_COVAR_ROWS      8
00792 
00793 /* all the input vectors are stored in a single matrix, as its columns */
00794 #define CV_COVAR_COLS     16
00795 
00796 CVAPI(void)  cvCalcCovarMatrix( const CvArr** vects, int count,
00797                                 CvArr* cov_mat, CvArr* avg, int flags );
00798 
00799 #define CV_PCA_DATA_AS_ROW 0
00800 #define CV_PCA_DATA_AS_COL 1
00801 #define CV_PCA_USE_AVG 2
00802 CVAPI(void)  cvCalcPCA( const CvArr* data, CvArr* mean,
00803                         CvArr* eigenvals, CvArr* eigenvects, int flags );
00804 
00805 CVAPI(void)  cvProjectPCA( const CvArr* data, const CvArr* mean,
00806                            const CvArr* eigenvects, CvArr* result );
00807 
00808 CVAPI(void)  cvBackProjectPCA( const CvArr* proj, const CvArr* mean,
00809                                const CvArr* eigenvects, CvArr* result );
00810 
00811 /* Calculates Mahalanobis(weighted) distance */
00812 CVAPI(double)  cvMahalanobis( const CvArr* vec1, const CvArr* vec2, const CvArr* mat );
00813 #define cvMahalonobis  cvMahalanobis
00814 
00815 /****************************************************************************************\
00816 *                                    Array Statistics                                    *
00817 \****************************************************************************************/
00818 
00819 /* Finds sum of array elements */
00820 CVAPI(CvScalar)  cvSum( const CvArr* arr );
00821 
00822 /* Calculates number of non-zero pixels */
00823 CVAPI(int)  cvCountNonZero( const CvArr* arr );
00824 
00825 /* Calculates mean value of array elements */
00826 CVAPI(CvScalar)  cvAvg( const CvArr* arr, const CvArr* mask CV_DEFAULT(NULL) );
00827 
00828 /* Calculates mean and standard deviation of pixel values */
00829 CVAPI(void)  cvAvgSdv( const CvArr* arr, CvScalar* mean, CvScalar* std_dev,
00830                        const CvArr* mask CV_DEFAULT(NULL) );
00831 
00832 /* Finds global minimum, maximum and their positions */
00833 CVAPI(void)  cvMinMaxLoc( const CvArr* arr, double* min_val, double* max_val,
00834                           CvPoint* min_loc CV_DEFAULT(NULL),
00835                           CvPoint* max_loc CV_DEFAULT(NULL),
00836                           const CvArr* mask CV_DEFAULT(NULL) );
00837 
00838 /* types of array norm */
00839 #define CV_C            1
00840 #define CV_L1           2
00841 #define CV_L2           4
00842 #define CV_NORM_MASK    7
00843 #define CV_RELATIVE     8
00844 #define CV_DIFF         16
00845 #define CV_MINMAX       32
00846 
00847 #define CV_DIFF_C       (CV_DIFF | CV_C)
00848 #define CV_DIFF_L1      (CV_DIFF | CV_L1)
00849 #define CV_DIFF_L2      (CV_DIFF | CV_L2)
00850 #define CV_RELATIVE_C   (CV_RELATIVE | CV_C)
00851 #define CV_RELATIVE_L1  (CV_RELATIVE | CV_L1)
00852 #define CV_RELATIVE_L2  (CV_RELATIVE | CV_L2)
00853 
00854 /* Finds norm, difference norm or relative difference norm for an array (or two arrays) */
00855 CVAPI(double)  cvNorm( const CvArr* arr1, const CvArr* arr2 CV_DEFAULT(NULL),
00856                        int norm_type CV_DEFAULT(CV_L2),
00857                        const CvArr* mask CV_DEFAULT(NULL) );
00858 
00859 CVAPI(void)  cvNormalize( const CvArr* src, CvArr* dst,
00860                           double a CV_DEFAULT(1.), double b CV_DEFAULT(0.),
00861                           int norm_type CV_DEFAULT(CV_L2),
00862                           const CvArr* mask CV_DEFAULT(NULL) );
00863 
00864 
00865 #define CV_REDUCE_SUM 0
00866 #define CV_REDUCE_AVG 1
00867 #define CV_REDUCE_MAX 2
00868 #define CV_REDUCE_MIN 3
00869 
00870 CVAPI(void)  cvReduce( const CvArr* src, CvArr* dst, int dim CV_DEFAULT(-1),
00871                        int op CV_DEFAULT(CV_REDUCE_SUM) );
00872 
00873 /****************************************************************************************\
00874 *                      Discrete Linear Transforms and Related Functions                  *
00875 \****************************************************************************************/
00876 
00877 #define CV_DXT_FORWARD  0
00878 #define CV_DXT_INVERSE  1
00879 #define CV_DXT_SCALE    2 /* divide result by size of array */
00880 #define CV_DXT_INV_SCALE (CV_DXT_INVERSE + CV_DXT_SCALE)
00881 #define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE
00882 #define CV_DXT_ROWS     4 /* transform each row individually */
00883 #define CV_DXT_MUL_CONJ 8 /* conjugate the second argument of cvMulSpectrums */
00884 
00885 /* Discrete Fourier Transform:
00886     complex->complex,
00887     real->ccs (forward),
00888     ccs->real (inverse) */
00889 CVAPI(void)  cvDFT( const CvArr* src, CvArr* dst, int flags,
00890                     int nonzero_rows CV_DEFAULT(0) );
00891 #define cvFFT cvDFT
00892 
00893 /* Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y)) */
00894 CVAPI(void)  cvMulSpectrums( const CvArr* src1, const CvArr* src2,
00895                              CvArr* dst, int flags );
00896 
00897 /* Finds optimal DFT vector size >= size0 */
00898 CVAPI(int)  cvGetOptimalDFTSize( int size0 );
00899 
00900 /* Discrete Cosine Transform */
00901 CVAPI(void)  cvDCT( const CvArr* src, CvArr* dst, int flags );
00902 
00903 /****************************************************************************************\
00904 *                              Dynamic data structures                                   *
00905 \****************************************************************************************/
00906 
00907 /* Calculates length of sequence slice (with support of negative indices). */
00908 CVAPI(int) cvSliceLength( CvSlice slice, const CvSeq* seq );
00909 
00910 
00911 /* Creates new memory storage.
00912    block_size == 0 means that default,
00913    somewhat optimal size, is used (currently, it is 64K) */
00914 CVAPI(CvMemStorage*)  cvCreateMemStorage( int block_size CV_DEFAULT(0));
00915 
00916 
00917 /* Creates a memory storage that will borrow memory blocks from parent storage */
00918 CVAPI(CvMemStorage*)  cvCreateChildMemStorage( CvMemStorage* parent );
00919 
00920 
00921 /* Releases memory storage. All the children of a parent must be released before
00922    the parent. A child storage returns all the blocks to parent when it is released */
00923 CVAPI(void)  cvReleaseMemStorage( CvMemStorage** storage );
00924 
00925 
00926 /* Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos)
00927    to reuse memory allocated for the storage - cvClearSeq,cvClearSet ...
00928    do not free any memory.
00929    A child storage returns all the blocks to the parent when it is cleared */
00930 CVAPI(void)  cvClearMemStorage( CvMemStorage* storage );
00931 
00932 /* Remember a storage "free memory" position */
00933 CVAPI(void)  cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos );
00934 
00935 /* Restore a storage "free memory" position */
00936 CVAPI(void)  cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos );
00937 
00938 /* Allocates continuous buffer of the specified size in the storage */
00939 CVAPI(void*) cvMemStorageAlloc( CvMemStorage* storage, size_t size );
00940 
00941 /* Allocates string in memory storage */
00942 CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr,
00943                                         int len CV_DEFAULT(-1) );
00944 
00945 /* Creates new empty sequence that will reside in the specified storage */
00946 CVAPI(CvSeq*)  cvCreateSeq( int seq_flags, int header_size,
00947                             int elem_size, CvMemStorage* storage );
00948 
00949 /* Changes default size (granularity) of sequence blocks.
00950    The default size is ~1Kbyte */
00951 CVAPI(void)  cvSetSeqBlockSize( CvSeq* seq, int delta_elems );
00952 
00953 
00954 /* Adds new element to the end of sequence. Returns pointer to the element */
00955 CVAPI(schar*)  cvSeqPush( CvSeq* seq, const void* element CV_DEFAULT(NULL));
00956 
00957 
00958 /* Adds new element to the beginning of sequence. Returns pointer to it */
00959 CVAPI(schar*)  cvSeqPushFront( CvSeq* seq, const void* element CV_DEFAULT(NULL));
00960 
00961 
00962 /* Removes the last element from sequence and optionally saves it */
00963 CVAPI(void)  cvSeqPop( CvSeq* seq, void* element CV_DEFAULT(NULL));
00964 
00965 
00966 /* Removes the first element from sequence and optioanally saves it */
00967 CVAPI(void)  cvSeqPopFront( CvSeq* seq, void* element CV_DEFAULT(NULL));
00968 
00969 
00970 #define CV_FRONT 1
00971 #define CV_BACK 0
00972 /* Adds several new elements to the end of sequence */
00973 CVAPI(void)  cvSeqPushMulti( CvSeq* seq, const void* elements,
00974                              int count, int in_front CV_DEFAULT(0) );
00975 
00976 /* Removes several elements from the end of sequence and optionally saves them */
00977 CVAPI(void)  cvSeqPopMulti( CvSeq* seq, void* elements,
00978                             int count, int in_front CV_DEFAULT(0) );
00979 
00980 /* Inserts a new element in the middle of sequence.
00981    cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */
00982 CVAPI(schar*)  cvSeqInsert( CvSeq* seq, int before_index,
00983                             const void* element CV_DEFAULT(NULL));
00984 
00985 /* Removes specified sequence element */
00986 CVAPI(void)  cvSeqRemove( CvSeq* seq, int index );
00987 
00988 
00989 /* Removes all the elements from the sequence. The freed memory
00990    can be reused later only by the same sequence unless cvClearMemStorage
00991    or cvRestoreMemStoragePos is called */
00992 CVAPI(void)  cvClearSeq( CvSeq* seq );
00993 
00994 
00995 /* Retrieves pointer to specified sequence element.
00996    Negative indices are supported and mean counting from the end
00997    (e.g -1 means the last sequence element) */
00998 CVAPI(schar*)  cvGetSeqElem( const CvSeq* seq, int index );
00999 
01000 /* Calculates index of the specified sequence element.
01001    Returns -1 if element does not belong to the sequence */
01002 CVAPI(int)  cvSeqElemIdx( const CvSeq* seq, const void* element,
01003                          CvSeqBlock** block CV_DEFAULT(NULL) );
01004 
01005 /* Initializes sequence writer. The new elements will be added to the end of sequence */
01006 CVAPI(void)  cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer );
01007 
01008 
01009 /* Combination of cvCreateSeq and cvStartAppendToSeq */
01010 CVAPI(void)  cvStartWriteSeq( int seq_flags, int header_size,
01011                               int elem_size, CvMemStorage* storage,
01012                               CvSeqWriter* writer );
01013 
01014 /* Closes sequence writer, updates sequence header and returns pointer
01015    to the resultant sequence
01016    (which may be useful if the sequence was created using cvStartWriteSeq))
01017 */
01018 CVAPI(CvSeq*)  cvEndWriteSeq( CvSeqWriter* writer );
01019 
01020 
01021 /* Updates sequence header. May be useful to get access to some of previously
01022    written elements via cvGetSeqElem or sequence reader */
01023 CVAPI(void)   cvFlushSeqWriter( CvSeqWriter* writer );
01024 
01025 
01026 /* Initializes sequence reader.
01027    The sequence can be read in forward or backward direction */
01028 CVAPI(void) cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader,
01029                            int reverse CV_DEFAULT(0) );
01030 
01031 
01032 /* Returns current sequence reader position (currently observed sequence element) */
01033 CVAPI(int)  cvGetSeqReaderPos( CvSeqReader* reader );
01034 
01035 
01036 /* Changes sequence reader position. It may seek to an absolute or
01037    to relative to the current position */
01038 CVAPI(void)   cvSetSeqReaderPos( CvSeqReader* reader, int index,
01039                                  int is_relative CV_DEFAULT(0));
01040 
01041 /* Copies sequence content to a continuous piece of memory */
01042 CVAPI(void*)  cvCvtSeqToArray( const CvSeq* seq, void* elements,
01043                                CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) );
01044 
01045 /* Creates sequence header for array.
01046    After that all the operations on sequences that do not alter the content
01047    can be applied to the resultant sequence */
01048 CVAPI(CvSeq*) cvMakeSeqHeaderForArray( int seq_type, int header_size,
01049                                        int elem_size, void* elements, int total,
01050                                        CvSeq* seq, CvSeqBlock* block );
01051 
01052 /* Extracts sequence slice (with or without copying sequence elements) */
01053 CVAPI(CvSeq*) cvSeqSlice( const CvSeq* seq, CvSlice slice,
01054                          CvMemStorage* storage CV_DEFAULT(NULL),
01055                          int copy_data CV_DEFAULT(0));
01056 
01057 CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL))
01058 {
01059     return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 );
01060 }
01061 
01062 /* Removes sequence slice */
01063 CVAPI(void)  cvSeqRemoveSlice( CvSeq* seq, CvSlice slice );
01064 
01065 /* Inserts a sequence or array into another sequence */
01066 CVAPI(void)  cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr );
01067 
01068 /* a < b ? -1 : a > b ? 1 : 0 */
01069 typedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata );
01070 
01071 /* Sorts sequence in-place given element comparison function */
01072 CVAPI(void) cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata CV_DEFAULT(NULL) );
01073 
01074 /* Finds element in a [sorted] sequence */
01075 CVAPI(schar*) cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func,
01076                            int is_sorted, int* elem_idx,
01077                            void* userdata CV_DEFAULT(NULL) );
01078 
01079 /* Reverses order of sequence elements in-place */
01080 CVAPI(void) cvSeqInvert( CvSeq* seq );
01081 
01082 /* Splits sequence into one or more equivalence classes using the specified criteria */
01083 CVAPI(int)  cvSeqPartition( const CvSeq* seq, CvMemStorage* storage,
01084                             CvSeq** labels, CvCmpFunc is_equal, void* userdata );
01085 
01086 /************ Internal sequence functions ************/
01087 CVAPI(void)  cvChangeSeqBlock( void* reader, int direction );
01088 CVAPI(void)  cvCreateSeqBlock( CvSeqWriter* writer );
01089 
01090 
01091 /* Creates a new set */
01092 CVAPI(CvSet*)  cvCreateSet( int set_flags, int header_size,
01093                             int elem_size, CvMemStorage* storage );
01094 
01095 /* Adds new element to the set and returns pointer to it */
01096 CVAPI(int)  cvSetAdd( CvSet* set_header, CvSetElem* elem CV_DEFAULT(NULL),
01097                       CvSetElem** inserted_elem CV_DEFAULT(NULL) );
01098 
01099 /* Fast variant of cvSetAdd */
01100 CV_INLINE  CvSetElem* cvSetNew( CvSet* set_header )
01101 {
01102     CvSetElem* elem = set_header->free_elems;
01103     if( elem )
01104     {
01105         set_header->free_elems = elem->next_free;
01106         elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK;
01107         set_header->active_count++;
01108     }
01109     else
01110         cvSetAdd( set_header, NULL, (CvSetElem**)&elem );
01111     return elem;
01112 }
01113 
01114 /* Removes set element given its pointer */
01115 CV_INLINE  void cvSetRemoveByPtr( CvSet* set_header, void* elem )
01116 {
01117     CvSetElem* _elem = (CvSetElem*)elem;
01118     assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ );
01119     _elem->next_free = set_header->free_elems;
01120     _elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG;
01121     set_header->free_elems = _elem;
01122     set_header->active_count--;
01123 }
01124 
01125 /* Removes element from the set by its index  */
01126 CVAPI(void)   cvSetRemove( CvSet* set_header, int index );
01127 
01128 /* Returns a set element by index. If the element doesn't belong to the set,
01129    NULL is returned */
01130 CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int index )
01131 {
01132     CvSetElem* elem = (CvSetElem*)cvGetSeqElem( (CvSeq*)set_header, index );
01133     return elem && CV_IS_SET_ELEM( elem ) ? elem : 0;
01134 }
01135 
01136 /* Removes all the elements from the set */
01137 CVAPI(void)  cvClearSet( CvSet* set_header );
01138 
01139 /* Creates new graph */
01140 CVAPI(CvGraph*)  cvCreateGraph( int graph_flags, int header_size,
01141                                 int vtx_size, int edge_size,
01142                                 CvMemStorage* storage );
01143 
01144 /* Adds new vertex to the graph */
01145 CVAPI(int)  cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx CV_DEFAULT(NULL),
01146                            CvGraphVtx** inserted_vtx CV_DEFAULT(NULL) );
01147 
01148 
01149 /* Removes vertex from the graph together with all incident edges */
01150 CVAPI(int)  cvGraphRemoveVtx( CvGraph* graph, int index );
01151 CVAPI(int)  cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx );
01152 
01153 
01154 /* Link two vertices specifed by indices or pointers if they
01155    are not connected or return pointer to already existing edge
01156    connecting the vertices.
01157    Functions return 1 if a new edge was created, 0 otherwise */
01158 CVAPI(int)  cvGraphAddEdge( CvGraph* graph,
01159                             int start_idx, int end_idx,
01160                             const CvGraphEdge* edge CV_DEFAULT(NULL),
01161                             CvGraphEdge** inserted_edge CV_DEFAULT(NULL) );
01162 
01163 CVAPI(int)  cvGraphAddEdgeByPtr( CvGraph* graph,
01164                                CvGraphVtx* start_vtx, CvGraphVtx* end_vtx,
01165                                const CvGraphEdge* edge CV_DEFAULT(NULL),
01166                                CvGraphEdge** inserted_edge CV_DEFAULT(NULL) );
01167 
01168 /* Remove edge connecting two vertices */
01169 CVAPI(void)  cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx );
01170 CVAPI(void)  cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx,
01171                                      CvGraphVtx* end_vtx );
01172 
01173 /* Find edge connecting two vertices */
01174 CVAPI(CvGraphEdge*)  cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx );
01175 CVAPI(CvGraphEdge*)  cvFindGraphEdgeByPtr( const CvGraph* graph,
01176                                            const CvGraphVtx* start_vtx,
01177                                            const CvGraphVtx* end_vtx );
01178 #define cvGraphFindEdge cvFindGraphEdge
01179 #define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr
01180 
01181 /* Remove all vertices and edges from the graph */
01182 CVAPI(void)  cvClearGraph( CvGraph* graph );
01183 
01184 
01185 /* Count number of edges incident to the vertex */
01186 CVAPI(int)  cvGraphVtxDegree( const CvGraph* graph, int vtx_idx );
01187 CVAPI(int)  cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx );
01188 
01189 
01190 /* Retrieves graph vertex by given index */
01191 #define cvGetGraphVtx( graph, idx ) (CvGraphVtx*)cvGetSetElem((CvSet*)(graph), (idx))
01192 
01193 /* Retrieves index of a graph vertex given its pointer */
01194 #define cvGraphVtxIdx( graph, vtx ) ((vtx)->flags & CV_SET_ELEM_IDX_MASK)
01195 
01196 /* Retrieves index of a graph edge given its pointer */
01197 #define cvGraphEdgeIdx( graph, edge ) ((edge)->flags & CV_SET_ELEM_IDX_MASK)
01198 
01199 #define cvGraphGetVtxCount( graph ) ((graph)->active_count)
01200 #define cvGraphGetEdgeCount( graph ) ((graph)->edges->active_count)
01201 
01202 #define  CV_GRAPH_VERTEX        1
01203 #define  CV_GRAPH_TREE_EDGE     2
01204 #define  CV_GRAPH_BACK_EDGE     4
01205 #define  CV_GRAPH_FORWARD_EDGE  8
01206 #define  CV_GRAPH_CROSS_EDGE    16
01207 #define  CV_GRAPH_ANY_EDGE      30
01208 #define  CV_GRAPH_NEW_TREE      32
01209 #define  CV_GRAPH_BACKTRACKING  64
01210 #define  CV_GRAPH_OVER          -1
01211 
01212 #define  CV_GRAPH_ALL_ITEMS    -1
01213 
01214 /* flags for graph vertices and edges */
01215 #define  CV_GRAPH_ITEM_VISITED_FLAG  (1 << 30)
01216 #define  CV_IS_GRAPH_VERTEX_VISITED(vtx) \
01217     (((CvGraphVtx*)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG)
01218 #define  CV_IS_GRAPH_EDGE_VISITED(edge) \
01219     (((CvGraphEdge*)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG)
01220 #define  CV_GRAPH_SEARCH_TREE_NODE_FLAG   (1 << 29)
01221 #define  CV_GRAPH_FORWARD_EDGE_FLAG       (1 << 28)
01222 
01223 typedef struct CvGraphScanner
01224 {
01225     CvGraphVtx* vtx;       /* current graph vertex (or current edge origin) */
01226     CvGraphVtx* dst;       /* current graph edge destination vertex */
01227     CvGraphEdge* edge;     /* current edge */
01228 
01229     CvGraph* graph;        /* the graph */
01230     CvSeq*   stack;        /* the graph vertex stack */
01231     int      index;        /* the lower bound of certainly visited vertices */
01232     int      mask;         /* event mask */
01233 }
01234 CvGraphScanner;
01235 
01236 /* Creates new graph scanner. */
01237 CVAPI(CvGraphScanner*)  cvCreateGraphScanner( CvGraph* graph,
01238                                              CvGraphVtx* vtx CV_DEFAULT(NULL),
01239                                              int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS));
01240 
01241 /* Releases graph scanner. */
01242 CVAPI(void) cvReleaseGraphScanner( CvGraphScanner** scanner );
01243 
01244 /* Get next graph element */
01245 CVAPI(int)  cvNextGraphItem( CvGraphScanner* scanner );
01246 
01247 /* Creates a copy of graph */
01248 CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage );
01249 
01250 /****************************************************************************************\
01251 *                                     Drawing                                            *
01252 \****************************************************************************************/
01253 
01254 /****************************************************************************************\
01255 *       Drawing functions work with images/matrices of arbitrary type.                   *
01256 *       For color images the channel order is BGR[A]                                     *
01257 *       Antialiasing is supported only for 8-bit image now.                              *
01258 *       All the functions include parameter color that means rgb value (that may be      *
01259 *       constructed with CV_RGB macro) for color images and brightness                   *
01260 *       for grayscale images.                                                            *
01261 *       If a drawn figure is partially or completely outside of the image, it is clipped.*
01262 \****************************************************************************************/
01263 
01264 #define CV_RGB( r, g, b )  cvScalar( (b), (g), (r), 0 )
01265 #define CV_FILLED -1
01266 
01267 #define CV_AA 16
01268 
01269 /* Draws 4-connected, 8-connected or antialiased line segment connecting two points */
01270 CVAPI(void)  cvLine( CvArr* img, CvPoint pt1, CvPoint pt2,
01271                      CvScalar color, int thickness CV_DEFAULT(1),
01272                      int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
01273 
01274 /* Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2),
01275    if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn */
01276 CVAPI(void)  cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2,
01277                           CvScalar color, int thickness CV_DEFAULT(1),
01278                           int line_type CV_DEFAULT(8),
01279                           int shift CV_DEFAULT(0));
01280 
01281 /* Draws a rectangle specified by a CvRect structure */
01282 CVAPI(void)  cvRectangleR( CvArr* img, CvRect r,
01283                            CvScalar color, int thickness CV_DEFAULT(1),
01284                            int line_type CV_DEFAULT(8),
01285                            int shift CV_DEFAULT(0));
01286     
01287     
01288 /* Draws a circle with specified center and radius.
01289    Thickness works in the same way as with cvRectangle */
01290 CVAPI(void)  cvCircle( CvArr* img, CvPoint center, int radius,
01291                        CvScalar color, int thickness CV_DEFAULT(1),
01292                        int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
01293 
01294 /* Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector,
01295    depending on <thickness>, <start_angle> and <end_angle> parameters. The resultant figure
01296    is rotated by <angle>. All the angles are in degrees */
01297 CVAPI(void)  cvEllipse( CvArr* img, CvPoint center, CvSize axes,
01298                         double angle, double start_angle, double end_angle,
01299                         CvScalar color, int thickness CV_DEFAULT(1),
01300                         int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
01301 
01302 CV_INLINE  void  cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color,
01303                                int thickness CV_DEFAULT(1),
01304                                int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) )
01305 {
01306     CvSize axes;
01307     axes.width = cvRound(box.size.width*0.5);
01308     axes.height = cvRound(box.size.height*0.5);
01309 
01310     cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle,
01311                0, 360, color, thickness, line_type, shift );
01312 }
01313 
01314 /* Fills convex or monotonous polygon. */
01315 CVAPI(void)  cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color,
01316                                int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
01317 
01318 /* Fills an area bounded by one or more arbitrary polygons */
01319 CVAPI(void)  cvFillPoly( CvArr* img, CvPoint** pts, const int* npts,
01320                          int contours, CvScalar color,
01321                          int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
01322 
01323 /* Draws one or more polygonal curves */
01324 CVAPI(void)  cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contours,
01325                          int is_closed, CvScalar color, int thickness CV_DEFAULT(1),
01326                          int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
01327 
01328 #define cvDrawRect cvRectangle
01329 #define cvDrawLine cvLine
01330 #define cvDrawCircle cvCircle
01331 #define cvDrawEllipse cvEllipse
01332 #define cvDrawPolyLine cvPolyLine
01333 
01334 /* Clips the line segment connecting *pt1 and *pt2
01335    by the rectangular window
01336    (0<=x<img_size.width, 0<=y<img_size.height). */
01337 CVAPI(int) cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 );
01338 
01339 /* Initializes line iterator. Initially, line_iterator->ptr will point
01340    to pt1 (or pt2, see left_to_right description) location in the image.
01341    Returns the number of pixels on the line between the ending points. */
01342 CVAPI(int)  cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2,
01343                                 CvLineIterator* line_iterator,
01344                                 int connectivity CV_DEFAULT(8),
01345                                 int left_to_right CV_DEFAULT(0));
01346 
01347 /* Moves iterator to the next line point */
01348 #define CV_NEXT_LINE_POINT( line_iterator )                     \
01349 {                                                               \
01350     int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \
01351     (line_iterator).err += (line_iterator).minus_delta +        \
01352         ((line_iterator).plus_delta & _line_iterator_mask);     \
01353     (line_iterator).ptr += (line_iterator).minus_step +         \
01354         ((line_iterator).plus_step & _line_iterator_mask);      \
01355 }
01356 
01357 
01358 /* basic font types */
01359 #define CV_FONT_HERSHEY_SIMPLEX         0
01360 #define CV_FONT_HERSHEY_PLAIN           1
01361 #define CV_FONT_HERSHEY_DUPLEX          2
01362 #define CV_FONT_HERSHEY_COMPLEX         3
01363 #define CV_FONT_HERSHEY_TRIPLEX         4
01364 #define CV_FONT_HERSHEY_COMPLEX_SMALL   5
01365 #define CV_FONT_HERSHEY_SCRIPT_SIMPLEX  6
01366 #define CV_FONT_HERSHEY_SCRIPT_COMPLEX  7
01367 
01368 /* font flags */
01369 #define CV_FONT_ITALIC                 16
01370 
01371 #define CV_FONT_VECTOR0    CV_FONT_HERSHEY_SIMPLEX
01372 
01373 
01374 /* Font structure */
01375 typedef struct CvFont
01376 {
01377         const char* nameFont;           //Qt:nameFont
01378         CvScalar color;                         //Qt:ColorFont -> cvScalar(blue_component, green_component, red\_component[, alpha_component])
01379     int         font_face;              //Qt: bool italic         /* =CV_FONT_* */
01380     const int*  ascii;                  /* font data and metrics */
01381     const int*  greek;
01382     const int*  cyrillic;
01383     float       hscale, vscale;
01384     float       shear;                  /* slope coefficient: 0 - normal, >0 - italic */
01385     int         thickness;              //Qt: weight               /* letters thickness */
01386     float       dx;                     /* horizontal interval between letters */
01387     int         line_type;              //Qt: PointSize
01388 }
01389 CvFont;
01390 
01391 /* Initializes font structure used further in cvPutText */
01392 CVAPI(void)  cvInitFont( CvFont* font, int font_face,
01393                          double hscale, double vscale,
01394                          double shear CV_DEFAULT(0),
01395                          int thickness CV_DEFAULT(1),
01396                          int line_type CV_DEFAULT(8));
01397 
01398 CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) )
01399 {
01400     CvFont font;
01401     cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA );
01402     return font;
01403 }
01404 
01405 /* Renders text stroke with specified font and color at specified location.
01406    CvFont should be initialized with cvInitFont */
01407 CVAPI(void)  cvPutText( CvArr* img, const char* text, CvPoint org,
01408                         const CvFont* font, CvScalar color );
01409 
01410 /* Calculates bounding box of text stroke (useful for alignment) */
01411 CVAPI(void)  cvGetTextSize( const char* text_string, const CvFont* font,
01412                             CvSize* text_size, int* baseline );
01413 
01414 
01415 
01416 /* Unpacks color value, if arrtype is CV_8UC?, <color> is treated as
01417    packed color value, otherwise the first channels (depending on arrtype)
01418    of destination scalar are set to the same value = <color> */
01419 CVAPI(CvScalar)  cvColorToScalar( double packed_color, int arrtype );
01420 
01421 /* Returns the polygon points which make up the given ellipse.  The ellipse is define by
01422    the box of size 'axes' rotated 'angle' around the 'center'.  A partial sweep
01423    of the ellipse arc can be done by spcifying arc_start and arc_end to be something
01424    other than 0 and 360, respectively.  The input array 'pts' must be large enough to
01425    hold the result.  The total number of points stored into 'pts' is returned by this
01426    function. */
01427 CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes,
01428                  int angle, int arc_start, int arc_end, CvPoint * pts, int delta );
01429 
01430 /* Draws contour outlines or filled interiors on the image */
01431 CVAPI(void)  cvDrawContours( CvArr *img, CvSeq* contour,
01432                              CvScalar external_color, CvScalar hole_color,
01433                              int max_level, int thickness CV_DEFAULT(1),
01434                              int line_type CV_DEFAULT(8),
01435                              CvPoint offset CV_DEFAULT(cvPoint(0,0)));
01436 
01437 /* Does look-up transformation. Elements of the source array
01438    (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */
01439 CVAPI(void) cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut );
01440 
01441 
01442 /******************* Iteration through the sequence tree *****************/
01443 typedef struct CvTreeNodeIterator
01444 {
01445     const void* node;
01446     int level;
01447     int max_level;
01448 }
01449 CvTreeNodeIterator;
01450 
01451 CVAPI(void) cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator,
01452                                    const void* first, int max_level );
01453 CVAPI(void*) cvNextTreeNode( CvTreeNodeIterator* tree_iterator );
01454 CVAPI(void*) cvPrevTreeNode( CvTreeNodeIterator* tree_iterator );
01455 
01456 /* Inserts sequence into tree with specified "parent" sequence.
01457    If parent is equal to frame (e.g. the most external contour),
01458    then added contour will have null pointer to parent. */
01459 CVAPI(void) cvInsertNodeIntoTree( void* node, void* parent, void* frame );
01460 
01461 /* Removes contour from tree (together with the contour children). */
01462 CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame );
01463 
01464 /* Gathers pointers to all the sequences,
01465    accessible from the <first>, to the single sequence */
01466 CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size,
01467                               CvMemStorage* storage );
01468 
01469 /* The function implements the K-means algorithm for clustering an array of sample
01470    vectors in a specified number of classes */
01471 #define CV_KMEANS_USE_INITIAL_LABELS    1
01472 CVAPI(int) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels,
01473                       CvTermCriteria termcrit, int attempts CV_DEFAULT(1),
01474                       CvRNG* rng CV_DEFAULT(0), int flags CV_DEFAULT(0),
01475                       CvArr* _centers CV_DEFAULT(0), double* compactness CV_DEFAULT(0) );
01476 
01477 /****************************************************************************************\
01478 *                                    System functions                                    *
01479 \****************************************************************************************/
01480 
01481 /* Add the function pointers table with associated information to the IPP primitives list */
01482 CVAPI(int)  cvRegisterModule( const CvModuleInfo* module_info );
01483 
01484 /* Loads optimized functions from IPP, MKL etc. or switches back to pure C code */
01485 CVAPI(int)  cvUseOptimized( int on_off );
01486 
01487 /* Retrieves information about the registered modules and loaded optimized plugins */
01488 CVAPI(void)  cvGetModuleInfo( const char* module_name,
01489                               const char** version,
01490                               const char** loaded_addon_plugins );
01491 
01492 typedef void* (CV_CDECL *CvAllocFunc)(size_t size, void* userdata);
01493 typedef int (CV_CDECL *CvFreeFunc)(void* pptr, void* userdata);
01494 
01495 /* Set user-defined memory managment functions (substitutors for malloc and free) that
01496    will be called by cvAlloc, cvFree and higher-level functions (e.g. cvCreateImage) */
01497 CVAPI(void) cvSetMemoryManager( CvAllocFunc alloc_func CV_DEFAULT(NULL),
01498                                CvFreeFunc free_func CV_DEFAULT(NULL),
01499                                void* userdata CV_DEFAULT(NULL));
01500 
01501 
01502 typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader)
01503                             (int,int,int,char*,char*,int,int,int,int,int,
01504                             IplROI*,IplImage*,void*,IplTileInfo*);
01505 typedef void (CV_STDCALL* Cv_iplAllocateImageData)(IplImage*,int,int);
01506 typedef void (CV_STDCALL* Cv_iplDeallocate)(IplImage*,int);
01507 typedef IplROI* (CV_STDCALL* Cv_iplCreateROI)(int,int,int,int,int);
01508 typedef IplImage* (CV_STDCALL* Cv_iplCloneImage)(const IplImage*);
01509 
01510 /* Makes OpenCV use IPL functions for IplImage allocation/deallocation */
01511 CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header,
01512                                Cv_iplAllocateImageData allocate_data,
01513                                Cv_iplDeallocate deallocate,
01514                                Cv_iplCreateROI create_roi,
01515                                Cv_iplCloneImage clone_image );
01516 
01517 #define CV_TURN_ON_IPL_COMPATIBILITY()                                  \
01518     cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage,         \
01519                         iplDeallocate, iplCreateROI, iplCloneImage )
01520 
01521 /****************************************************************************************\
01522 *                                    Data Persistence                                    *
01523 \****************************************************************************************/
01524 
01525 /********************************** High-level functions ********************************/
01526 
01527 /* opens existing or creates new file storage */
01528 CVAPI(CvFileStorage*)  cvOpenFileStorage( const char* filename,
01529                                           CvMemStorage* memstorage,
01530                                           int flags );
01531 
01532 /* closes file storage and deallocates buffers */
01533 CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs );
01534 
01535 /* returns attribute value or 0 (NULL) if there is no such attribute */
01536 CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name );
01537 
01538 /* starts writing compound structure (map or sequence) */
01539 CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name,
01540                                 int struct_flags, const char* type_name CV_DEFAULT(NULL),
01541                                 CvAttrList attributes CV_DEFAULT(cvAttrList()));
01542 
01543 /* finishes writing compound structure */
01544 CVAPI(void) cvEndWriteStruct( CvFileStorage* fs );
01545 
01546 /* writes an integer */
01547 CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value );
01548 
01549 /* writes a floating-point number */
01550 CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value );
01551 
01552 /* writes a string */
01553 CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name,
01554                            const char* str, int quote CV_DEFAULT(0) );
01555 
01556 /* writes a comment */
01557 CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment,
01558                             int eol_comment );
01559 
01560 /* writes instance of a standard type (matrix, image, sequence, graph etc.)
01561    or user-defined type */
01562 CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr,
01563                          CvAttrList attributes CV_DEFAULT(cvAttrList()));
01564 
01565 /* starts the next stream */
01566 CVAPI(void) cvStartNextStream( CvFileStorage* fs );
01567 
01568 /* helper function: writes multiple integer or floating-point numbers */
01569 CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src,
01570                                 int len, const char* dt );
01571 
01572 /* returns the hash entry corresponding to the specified literal key string or 0
01573    if there is no such a key in the storage */
01574 CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name,
01575                                         int len CV_DEFAULT(-1),
01576                                         int create_missing CV_DEFAULT(0));
01577 
01578 /* returns file node with the specified key within the specified map
01579    (collection of named nodes) */
01580 CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs,
01581                                      int stream_index CV_DEFAULT(0) );
01582 
01583 /* returns file node with the specified key within the specified map
01584    (collection of named nodes) */
01585 CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map,
01586                                  const CvStringHashNode* key,
01587                                  int create_missing CV_DEFAULT(0) );
01588 
01589 /* this is a slower version of cvGetFileNode that takes the key as a literal string */
01590 CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs,
01591                                        const CvFileNode* map,
01592                                        const char* name );
01593 
01594 CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) )
01595 {
01596     return !node ? default_value :
01597         CV_NODE_IS_INT(node->tag) ? node->data.i :
01598         CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff;
01599 }
01600 
01601 
01602 CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map,
01603                          const char* name, int default_value CV_DEFAULT(0) )
01604 {
01605     return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value );
01606 }
01607 
01608 
01609 CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) )
01610 {
01611     return !node ? default_value :
01612         CV_NODE_IS_INT(node->tag) ? (double)node->data.i :
01613         CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300;
01614 }
01615 
01616 
01617 CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map,
01618                         const char* name, double default_value CV_DEFAULT(0.) )
01619 {
01620     return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value );
01621 }
01622 
01623 
01624 CV_INLINE const char* cvReadString( const CvFileNode* node,
01625                         const char* default_value CV_DEFAULT(NULL) )
01626 {
01627     return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0;
01628 }
01629 
01630 
01631 CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map,
01632                         const char* name, const char* default_value CV_DEFAULT(NULL) )
01633 {
01634     return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value );
01635 }
01636 
01637 
01638 /* decodes standard or user-defined object and returns it */
01639 CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node,
01640                         CvAttrList* attributes CV_DEFAULT(NULL));
01641 
01642 /* decodes standard or user-defined object and returns it */
01643 CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map,
01644                               const char* name, CvAttrList* attributes CV_DEFAULT(NULL) )
01645 {
01646     return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes );
01647 }
01648 
01649 
01650 /* starts reading data from sequence or scalar numeric node */
01651 CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src,
01652                                CvSeqReader* reader );
01653 
01654 /* reads multiple numbers and stores them to array */
01655 CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
01656                                int count, void* dst, const char* dt );
01657 
01658 /* combination of two previous functions for easier reading of whole sequences */
01659 CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src,
01660                           void* dst, const char* dt );
01661 
01662 /* writes a copy of file node to file storage */
01663 CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name,
01664                             const CvFileNode* node, int embed );
01665 
01666 /* returns name of file node */
01667 CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node );
01668 
01669 /*********************************** Adding own types ***********************************/
01670 
01671 CVAPI(void) cvRegisterType( const CvTypeInfo* info );
01672 CVAPI(void) cvUnregisterType( const char* type_name );
01673 CVAPI(CvTypeInfo*) cvFirstType(void);
01674 CVAPI(CvTypeInfo*) cvFindType( const char* type_name );
01675 CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr );
01676 
01677 /* universal functions */
01678 CVAPI(void) cvRelease( void** struct_ptr );
01679 CVAPI(void*) cvClone( const void* struct_ptr );
01680 
01681 /* simple API for reading/writing data */
01682 CVAPI(void) cvSave( const char* filename, const void* struct_ptr,
01683                     const char* name CV_DEFAULT(NULL),
01684                     const char* comment CV_DEFAULT(NULL),
01685                     CvAttrList attributes CV_DEFAULT(cvAttrList()));
01686 CVAPI(void*) cvLoad( const char* filename,
01687                      CvMemStorage* memstorage CV_DEFAULT(NULL),
01688                      const char* name CV_DEFAULT(NULL),
01689                      const char** real_name CV_DEFAULT(NULL) );
01690 
01691 /*********************************** Measuring Execution Time ***************************/
01692 
01693 /* helper functions for RNG initialization and accurate time measurement:
01694    uses internal clock counter on x86 */
01695 CVAPI(int64)  cvGetTickCount( void );
01696 CVAPI(double) cvGetTickFrequency( void );
01697 
01698 /*********************************** CPU capabilities ***********************************/
01699 
01700 #define CV_CPU_NONE    0    
01701 #define CV_CPU_MMX     1
01702 #define CV_CPU_SSE     2
01703 #define CV_CPU_SSE2    3
01704 #define CV_CPU_SSE3    4
01705 #define CV_CPU_SSSE3   5
01706 #define CV_CPU_SSE4_1  6
01707 #define CV_CPU_SSE4_2  7
01708 #define CV_CPU_AVX    10
01709 #define CV_HARDWARE_MAX_FEATURE 255
01710 
01711 CVAPI(int) cvCheckHardwareSupport(int feature);
01712 
01713 /*********************************** Multi-Threading ************************************/
01714 
01715 /* retrieve/set the number of threads used in OpenMP implementations */
01716 CVAPI(int)  cvGetNumThreads( void );
01717 CVAPI(void) cvSetNumThreads( int threads CV_DEFAULT(0) );
01718 /* get index of the thread being executed */
01719 CVAPI(int)  cvGetThreadNum( void );
01720 
01721     
01722 /********************************** Error Handling **************************************/
01723     
01724 /* Get current OpenCV error status */
01725 CVAPI(int) cvGetErrStatus( void );
01726 
01727 /* Sets error status silently */
01728 CVAPI(void) cvSetErrStatus( int status );
01729 
01730 #define CV_ErrModeLeaf     0   /* Print error and exit program */
01731 #define CV_ErrModeParent   1   /* Print error and continue */
01732 #define CV_ErrModeSilent   2   /* Don't print and continue */
01733 
01734 /* Retrives current error processing mode */
01735 CVAPI(int)  cvGetErrMode( void );
01736 
01737 /* Sets error processing mode, returns previously used mode */
01738 CVAPI(int) cvSetErrMode( int mode );
01739 
01740 /* Sets error status and performs some additonal actions (displaying message box,
01741  writing message to stderr, terminating application etc.)
01742  depending on the current error mode */
01743 CVAPI(void) cvError( int status, const char* func_name,
01744                     const char* err_msg, const char* file_name, int line );
01745 
01746 /* Retrieves textual description of the error given its code */
01747 CVAPI(const char*) cvErrorStr( int status );
01748 
01749 /* Retrieves detailed information about the last error occured */
01750 CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description,
01751                         const char** filename, int* line );
01752 
01753 /* Maps IPP error codes to the counterparts from OpenCV */
01754 CVAPI(int) cvErrorFromIppStatus( int ipp_status );
01755 
01756 typedef int (CV_CDECL *CvErrorCallback)( int status, const char* func_name,
01757                                         const char* err_msg, const char* file_name, int line, void* userdata );
01758 
01759 /* Assigns a new error-handling function */
01760 CVAPI(CvErrorCallback) cvRedirectError( CvErrorCallback error_handler,
01761                                        void* userdata CV_DEFAULT(NULL),
01762                                        void** prev_userdata CV_DEFAULT(NULL) );
01763 
01764 /*
01765  Output to:
01766  cvNulDevReport - nothing
01767  cvStdErrReport - console(fprintf(stderr,...))
01768  cvGuiBoxReport - MessageBox(WIN32)
01769  */
01770 CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg,
01771                           const char* file_name, int line, void* userdata );
01772 
01773 CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg,
01774                           const char* file_name, int line, void* userdata );
01775 
01776 CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg,
01777                           const char* file_name, int line, void* userdata );    
01778     
01779 #define OPENCV_ERROR(status,func,context)                           \
01780 cvError((status),(func),(context),__FILE__,__LINE__)
01781     
01782 #define OPENCV_ERRCHK(func,context)                                 \
01783 {if (cvGetErrStatus() >= 0)                         \
01784 {OPENCV_ERROR(CV_StsBackTrace,(func),(context));}}
01785     
01786 #define OPENCV_ASSERT(expr,func,context)                            \
01787 {if (! (expr))                                      \
01788 {OPENCV_ERROR(CV_StsInternal,(func),(context));}}
01789     
01790 #define OPENCV_RSTERR() (cvSetErrStatus(CV_StsOk))
01791     
01792 #define OPENCV_CALL( Func )                                         \
01793 {                                                                   \
01794 Func;                                                           \
01795 } 
01796     
01797     
01798 /* CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */
01799 #ifdef CV_NO_FUNC_NAMES
01800 #define CV_FUNCNAME( Name )
01801 #define cvFuncName ""
01802 #else    
01803 #define CV_FUNCNAME( Name )  \
01804 static char cvFuncName[] = Name
01805 #endif
01806   
01807     
01808 /*
01809  CV_ERROR macro unconditionally raises error with passed code and message.
01810  After raising error, control will be transferred to the exit label.
01811  */
01812 #define CV_ERROR( Code, Msg )                                       \
01813 {                                                                   \
01814     cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ );        \
01815     __CV_EXIT__;                                                   \
01816 }
01817     
01818 /* Simplified form of CV_ERROR */
01819 #define CV_ERROR_FROM_CODE( code )   \
01820     CV_ERROR( code, "" )
01821     
01822 /*
01823  CV_CHECK macro checks error status after CV (or IPL)
01824  function call. If error detected, control will be transferred to the exit
01825  label.
01826  */
01827 #define CV_CHECK()                                                  \
01828 {                                                                   \
01829     if( cvGetErrStatus() < 0 )                                      \
01830         CV_ERROR( CV_StsBackTrace, "Inner function failed." );      \
01831 }
01832     
01833     
01834 /*
01835  CV_CALL macro calls CV (or IPL) function, checks error status and
01836  signals a error if the function failed. Useful in "parent node"
01837  error procesing mode
01838  */
01839 #define CV_CALL( Func )                                             \
01840 {                                                                   \
01841     Func;                                                           \
01842     CV_CHECK();                                                     \
01843 }
01844     
01845     
01846 /* Runtime assertion macro */
01847 #define CV_ASSERT( Condition )                                          \
01848 {                                                                       \
01849     if( !(Condition) )                                                  \
01850         CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \
01851 }
01852     
01853 #define __CV_BEGIN__       {
01854 #define __CV_END__         goto exit; exit: ; }
01855 #define __CV_EXIT__        goto exit    
01856     
01857 #ifdef __cplusplus
01858 }
01859 
01860 // classes for automatic module/RTTI data registration/unregistration
01861 struct CV_EXPORTS CvModule
01862 {
01863     CvModule( CvModuleInfo* _info );
01864     ~CvModule();
01865     CvModuleInfo* info;
01866 
01867     static CvModuleInfo* first;
01868     static CvModuleInfo* last;
01869 };
01870 
01871 struct CV_EXPORTS CvType
01872 {
01873     CvType( const char* type_name,
01874             CvIsInstanceFunc is_instance, CvReleaseFunc release=0,
01875             CvReadFunc read=0, CvWriteFunc write=0, CvCloneFunc clone=0 );
01876     ~CvType();
01877     CvTypeInfo* info;
01878 
01879     static CvTypeInfo* first;
01880     static CvTypeInfo* last;
01881 };
01882 
01883 #endif
01884 
01885 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines