Cinder

  • Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

include/OpenCV/cv.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 #ifndef __OPENCV_CV_H__
00044 #define __OPENCV_CV_H__
00045 
00046 #ifdef __IPL_H__
00047 #define HAVE_IPL
00048 #endif
00049 
00050 #ifndef SKIP_INCLUDES
00051   #if defined(_CH_)
00052     #pragma package <chopencv>
00053     #include <chdl.h>
00054     LOAD_CHDL(cv)
00055   #endif
00056 #endif
00057 
00058 #include "cxcore.h"
00059 #include "cvtypes.h"
00060 
00061 #ifdef __cplusplus
00062 extern "C" {
00063 #endif
00064 
00065 /****************************************************************************************\
00066 *                                    Image Processing                                    *
00067 \****************************************************************************************/
00068 
00069 /* Copies source 2D array inside of the larger destination array and
00070    makes a border of the specified type (IPL_BORDER_*) around the copied area. */
00071 CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
00072                               int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0)));
00073 
00074 #define CV_BLUR_NO_SCALE 0
00075 #define CV_BLUR  1
00076 #define CV_GAUSSIAN  2
00077 #define CV_MEDIAN 3
00078 #define CV_BILATERAL 4
00079 
00080 /* Smoothes array (removes noise) */
00081 CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
00082                       int smoothtype CV_DEFAULT(CV_GAUSSIAN),
00083                       int size1 CV_DEFAULT(3),
00084                       int size2 CV_DEFAULT(0),
00085                       double sigma1 CV_DEFAULT(0),
00086                       double sigma2 CV_DEFAULT(0));
00087 
00088 /* Convolves the image with the kernel */
00089 CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
00090                         CvPoint anchor CV_DEFAULT(cvPoint(-1,-1)));
00091 
00092 /* Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y) */
00093 CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum,
00094                        CvArr* sqsum CV_DEFAULT(NULL),
00095                        CvArr* tilted_sum CV_DEFAULT(NULL));
00096 
00097 /*
00098    Smoothes the input image with gaussian kernel and then down-samples it.
00099    dst_width = floor(src_width/2)[+1],
00100    dst_height = floor(src_height/2)[+1]
00101 */
00102 CVAPI(void)  cvPyrDown( const CvArr* src, CvArr* dst,
00103                         int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
00104 
00105 /*
00106    Up-samples image and smoothes the result with gaussian kernel.
00107    dst_width = src_width*2,
00108    dst_height = src_height*2
00109 */
00110 CVAPI(void)  cvPyrUp( const CvArr* src, CvArr* dst,
00111                       int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
00112 
00113 /* Builds pyramid for an image */
00114 CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
00115                                 const CvSize* layer_sizes CV_DEFAULT(0),
00116                                 CvArr* bufarr CV_DEFAULT(0),
00117                                 int calc CV_DEFAULT(1),
00118                                 int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
00119 
00120 /* Releases pyramid */
00121 CVAPI(void)  cvReleasePyramid( CvMat*** pyramid, int extra_layers );
00122 
00123 
00124 /* Splits color or grayscale image into multiple connected components
00125    of nearly the same color/brightness using modification of Burt algorithm.
00126    comp with contain a pointer to sequence (CvSeq)
00127    of connected components (CvConnectedComp) */
00128 CVAPI(void) cvPyrSegmentation( IplImage* src, IplImage* dst,
00129                               CvMemStorage* storage, CvSeq** comp,
00130                               int level, double threshold1,
00131                               double threshold2 );
00132 
00133 /* Filters image using meanshift algorithm */
00134 CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
00135     double sp, double sr, int max_level CV_DEFAULT(1),
00136     CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1)));
00137 
00138 /* Segments image using seed "markers" */
00139 CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
00140 
00141 #define CV_INPAINT_NS      0
00142 #define CV_INPAINT_TELEA   1
00143 
00144 /* Inpaints the selected region in the image */
00145 CVAPI(void) cvInpaint( const CvArr* src, const CvArr* inpaint_mask,
00146                        CvArr* dst, double inpaintRange, int flags );
00147 
00148 #define CV_SCHARR -1
00149 #define CV_MAX_SOBEL_KSIZE 7
00150 
00151 /* Calculates an image derivative using generalized Sobel
00152    (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
00153    Scharr can be used only for the first dx or dy derivative */
00154 CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
00155                     int xorder, int yorder,
00156                     int aperture_size CV_DEFAULT(3));
00157 
00158 /* Calculates the image Laplacian: (d2/dx + d2/dy)I */
00159 CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
00160                       int aperture_size CV_DEFAULT(3) );
00161 
00162 /* Constants for color conversion */
00163 #define  CV_BGR2BGRA    0
00164 #define  CV_RGB2RGBA    CV_BGR2BGRA
00165 
00166 #define  CV_BGRA2BGR    1
00167 #define  CV_RGBA2RGB    CV_BGRA2BGR
00168 
00169 #define  CV_BGR2RGBA    2
00170 #define  CV_RGB2BGRA    CV_BGR2RGBA
00171 
00172 #define  CV_RGBA2BGR    3
00173 #define  CV_BGRA2RGB    CV_RGBA2BGR
00174 
00175 #define  CV_BGR2RGB     4
00176 #define  CV_RGB2BGR     CV_BGR2RGB
00177 
00178 #define  CV_BGRA2RGBA   5
00179 #define  CV_RGBA2BGRA   CV_BGRA2RGBA
00180 
00181 #define  CV_BGR2GRAY    6
00182 #define  CV_RGB2GRAY    7
00183 #define  CV_GRAY2BGR    8
00184 #define  CV_GRAY2RGB    CV_GRAY2BGR
00185 #define  CV_GRAY2BGRA   9
00186 #define  CV_GRAY2RGBA   CV_GRAY2BGRA
00187 #define  CV_BGRA2GRAY   10
00188 #define  CV_RGBA2GRAY   11
00189 
00190 #define  CV_BGR2BGR565  12
00191 #define  CV_RGB2BGR565  13
00192 #define  CV_BGR5652BGR  14
00193 #define  CV_BGR5652RGB  15
00194 #define  CV_BGRA2BGR565 16
00195 #define  CV_RGBA2BGR565 17
00196 #define  CV_BGR5652BGRA 18
00197 #define  CV_BGR5652RGBA 19
00198 
00199 #define  CV_GRAY2BGR565 20
00200 #define  CV_BGR5652GRAY 21
00201 
00202 #define  CV_BGR2BGR555  22
00203 #define  CV_RGB2BGR555  23
00204 #define  CV_BGR5552BGR  24
00205 #define  CV_BGR5552RGB  25
00206 #define  CV_BGRA2BGR555 26
00207 #define  CV_RGBA2BGR555 27
00208 #define  CV_BGR5552BGRA 28
00209 #define  CV_BGR5552RGBA 29
00210 
00211 #define  CV_GRAY2BGR555 30
00212 #define  CV_BGR5552GRAY 31
00213 
00214 #define  CV_BGR2XYZ     32
00215 #define  CV_RGB2XYZ     33
00216 #define  CV_XYZ2BGR     34
00217 #define  CV_XYZ2RGB     35
00218 
00219 #define  CV_BGR2YCrCb   36
00220 #define  CV_RGB2YCrCb   37
00221 #define  CV_YCrCb2BGR   38
00222 #define  CV_YCrCb2RGB   39
00223 
00224 #define  CV_BGR2HSV     40
00225 #define  CV_RGB2HSV     41
00226 
00227 #define  CV_BGR2Lab     44
00228 #define  CV_RGB2Lab     45
00229 
00230 #define  CV_BayerBG2BGR 46
00231 #define  CV_BayerGB2BGR 47
00232 #define  CV_BayerRG2BGR 48
00233 #define  CV_BayerGR2BGR 49
00234 
00235 #define  CV_BayerBG2RGB CV_BayerRG2BGR
00236 #define  CV_BayerGB2RGB CV_BayerGR2BGR
00237 #define  CV_BayerRG2RGB CV_BayerBG2BGR
00238 #define  CV_BayerGR2RGB CV_BayerGB2BGR
00239 
00240 #define  CV_BGR2Luv     50
00241 #define  CV_RGB2Luv     51
00242 #define  CV_BGR2HLS     52
00243 #define  CV_RGB2HLS     53
00244 
00245 #define  CV_HSV2BGR     54
00246 #define  CV_HSV2RGB     55
00247 
00248 #define  CV_Lab2BGR     56
00249 #define  CV_Lab2RGB     57
00250 #define  CV_Luv2BGR     58
00251 #define  CV_Luv2RGB     59
00252 #define  CV_HLS2BGR     60
00253 #define  CV_HLS2RGB     61
00254 
00255 #define  CV_COLORCVT_MAX  100
00256 
00257 /* Converts input array pixels from one color space to another */
00258 CVAPI(void)  cvCvtColor( const CvArr* src, CvArr* dst, int code );
00259 
00260 #define  CV_INTER_NN        0
00261 #define  CV_INTER_LINEAR    1
00262 #define  CV_INTER_CUBIC     2
00263 #define  CV_INTER_AREA      3
00264 
00265 #define  CV_WARP_FILL_OUTLIERS 8
00266 #define  CV_WARP_INVERSE_MAP  16
00267 
00268 /* Resizes image (input array is resized to fit the destination array) */
00269 CVAPI(void)  cvResize( const CvArr* src, CvArr* dst,
00270                        int interpolation CV_DEFAULT( CV_INTER_LINEAR ));
00271 
00272 /* Warps image with affine transform */
00273 CVAPI(void)  cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
00274                            int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
00275                            CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
00276 
00277 /* Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2) */
00278 CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src,
00279                                     const CvPoint2D32f * dst,
00280                                     CvMat * map_matrix );
00281 
00282 /* Computes rotation_matrix matrix */
00283 CVAPI(CvMat*)  cv2DRotationMatrix( CvPoint2D32f center, double angle,
00284                                    double scale, CvMat* map_matrix );
00285 
00286 /* Warps image with perspective (projective) transform */
00287 CVAPI(void)  cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
00288                                 int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
00289                                 CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
00290 
00291 /* Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3) */
00292 CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src,
00293                                          const CvPoint2D32f* dst,
00294                                          CvMat* map_matrix );
00295 
00296 /* Performs generic geometric transformation using the specified coordinate maps */
00297 CVAPI(void)  cvRemap( const CvArr* src, CvArr* dst,
00298                       const CvArr* mapx, const CvArr* mapy,
00299                       int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
00300                       CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
00301 
00302 /* Converts mapx & mapy from floating-point to integer formats for cvRemap */
00303 CVAPI(void)  cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
00304                             CvArr* mapxy, CvArr* mapalpha );
00305 
00306 /* Performs forward or inverse log-polar image transform */
00307 CVAPI(void)  cvLogPolar( const CvArr* src, CvArr* dst,
00308                          CvPoint2D32f center, double M,
00309                          int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
00310 
00311 /* Performs forward or inverse linear-polar image transform */
00312 CVAPI(void)  cvLinearPolar( const CvArr* src, CvArr* dst,
00313                          CvPoint2D32f center, double maxRadius,
00314                          int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
00315 
00316 #define  CV_SHAPE_RECT      0
00317 #define  CV_SHAPE_CROSS     1
00318 #define  CV_SHAPE_ELLIPSE   2
00319 #define  CV_SHAPE_CUSTOM    100
00320 
00321 /* creates structuring element used for morphological operations */
00322 CVAPI(IplConvKernel*)  cvCreateStructuringElementEx(
00323             int cols, int  rows, int  anchor_x, int  anchor_y,
00324             int shape, int* values CV_DEFAULT(NULL) );
00325 
00326 /* releases structuring element */
00327 CVAPI(void)  cvReleaseStructuringElement( IplConvKernel** element );
00328 
00329 /* erodes input image (applies minimum filter) one or more times.
00330    If element pointer is NULL, 3x3 rectangular element is used */
00331 CVAPI(void)  cvErode( const CvArr* src, CvArr* dst,
00332                       IplConvKernel* element CV_DEFAULT(NULL),
00333                       int iterations CV_DEFAULT(1) );
00334 
00335 /* dilates input image (applies maximum filter) one or more times.
00336    If element pointer is NULL, 3x3 rectangular element is used */
00337 CVAPI(void)  cvDilate( const CvArr* src, CvArr* dst,
00338                        IplConvKernel* element CV_DEFAULT(NULL),
00339                        int iterations CV_DEFAULT(1) );
00340 
00341 #define CV_MOP_ERODE        0
00342 #define CV_MOP_DILATE       1
00343 #define CV_MOP_OPEN         2
00344 #define CV_MOP_CLOSE        3
00345 #define CV_MOP_GRADIENT     4
00346 #define CV_MOP_TOPHAT       5
00347 #define CV_MOP_BLACKHAT     6
00348 
00349 /* Performs complex morphological transformation */
00350 CVAPI(void)  cvMorphologyEx( const CvArr* src, CvArr* dst,
00351                              CvArr* temp, IplConvKernel* element,
00352                              int operation, int iterations CV_DEFAULT(1) );
00353 
00354 /* Calculates all spatial and central moments up to the 3rd order */
00355 CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
00356 
00357 /* Retrieve particular spatial, central or normalized central moments */
00358 CVAPI(double)  cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
00359 CVAPI(double)  cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
00360 CVAPI(double)  cvGetNormalizedCentralMoment( CvMoments* moments,
00361                                              int x_order, int y_order );
00362 
00363 /* Calculates 7 Hu's invariants from precalculated spatial and central moments */
00364 CVAPI(void) cvGetHuMoments( CvMoments*  moments, CvHuMoments*  hu_moments );
00365 
00366 /*********************************** data sampling **************************************/
00367 
00368 /* Fetches pixels that belong to the specified line segment and stores them to the buffer.
00369    Returns the number of retrieved points. */
00370 CVAPI(int)  cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
00371                           int connectivity CV_DEFAULT(8));
00372 
00373 /* Retrieves the rectangular image region with specified center from the input array.
00374  dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
00375  Values of pixels with fractional coordinates are retrieved using bilinear interpolation*/
00376 CVAPI(void)  cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
00377 
00378 
00379 /* Retrieves quadrangle from the input array.
00380     matrixarr = ( a11  a12 | b1 )   dst(x,y) <- src(A[x y]' + b)
00381                 ( a21  a22 | b2 )   (bilinear interpolation is used to retrieve pixels
00382                                      with fractional coordinates)
00383 */
00384 CVAPI(void)  cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
00385                                     const CvMat* map_matrix );
00386 
00387 /* Methods for comparing two array */
00388 #define  CV_TM_SQDIFF        0
00389 #define  CV_TM_SQDIFF_NORMED 1
00390 #define  CV_TM_CCORR         2
00391 #define  CV_TM_CCORR_NORMED  3
00392 #define  CV_TM_CCOEFF        4
00393 #define  CV_TM_CCOEFF_NORMED 5
00394 
00395 /* Measures similarity between template and overlapped windows in the source image
00396    and fills the resultant image with the measurements */
00397 CVAPI(void)  cvMatchTemplate( const CvArr* image, const CvArr* templ,
00398                               CvArr* result, int method );
00399 
00400 /* Computes earth mover distance between
00401    two weighted point sets (called signatures) */
00402 CVAPI(float)  cvCalcEMD2( const CvArr* signature1,
00403                           const CvArr* signature2,
00404                           int distance_type,
00405                           CvDistanceFunction distance_func CV_DEFAULT(NULL),
00406                           const CvArr* cost_matrix CV_DEFAULT(NULL),
00407                           CvArr* flow CV_DEFAULT(NULL),
00408                           float* lower_bound CV_DEFAULT(NULL),
00409                           void* userdata CV_DEFAULT(NULL));
00410 
00411 /****************************************************************************************\
00412 *                              Contours retrieving                                       *
00413 \****************************************************************************************/
00414 
00415 /* Retrieves outer and optionally inner boundaries of white (non-zero) connected
00416    components in the black (zero) background */
00417 CVAPI(int)  cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
00418                             int header_size CV_DEFAULT(sizeof(CvContour)),
00419                             int mode CV_DEFAULT(CV_RETR_LIST),
00420                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
00421                             CvPoint offset CV_DEFAULT(cvPoint(0,0)));
00422 
00423 
00424 /* Initalizes contour retrieving process.
00425    Calls cvStartFindContours.
00426    Calls cvFindNextContour until null pointer is returned
00427    or some other condition becomes true.
00428    Calls cvEndFindContours at the end. */
00429 CVAPI(CvContourScanner)  cvStartFindContours( CvArr* image, CvMemStorage* storage,
00430                             int header_size CV_DEFAULT(sizeof(CvContour)),
00431                             int mode CV_DEFAULT(CV_RETR_LIST),
00432                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
00433                             CvPoint offset CV_DEFAULT(cvPoint(0,0)));
00434 
00435 /* Retrieves next contour */
00436 CVAPI(CvSeq*)  cvFindNextContour( CvContourScanner scanner );
00437 
00438 
00439 /* Substitutes the last retrieved contour with the new one
00440    (if the substitutor is null, the last retrieved contour is removed from the tree) */
00441 CVAPI(void)   cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
00442 
00443 
00444 /* Releases contour scanner and returns pointer to the first outer contour */
00445 CVAPI(CvSeq*)  cvEndFindContours( CvContourScanner* scanner );
00446 
00447 /* Approximates a single Freeman chain or a tree of chains to polygonal curves */
00448 CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
00449                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
00450                             double parameter CV_DEFAULT(0),
00451                             int  minimal_perimeter CV_DEFAULT(0),
00452                             int  recursive CV_DEFAULT(0));
00453 
00454 
00455 /* Initalizes Freeman chain reader.
00456    The reader is used to iteratively get coordinates of all the chain points.
00457    If the Freeman codes should be read as is, a simple sequence reader should be used */
00458 CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
00459 
00460 /* Retrieves the next chain point */
00461 CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
00462 
00463 
00464 /****************************************************************************************\
00465 *                                  Motion Analysis                                       *
00466 \****************************************************************************************/
00467 
00468 /************************************ optical flow ***************************************/
00469 
00470 /* Calculates optical flow for 2 images using classical Lucas & Kanade algorithm */
00471 CVAPI(void)  cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr,
00472                                   CvSize win_size, CvArr* velx, CvArr* vely );
00473 
00474 /* Calculates optical flow for 2 images using block matching algorithm */
00475 CVAPI(void)  cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr,
00476                                   CvSize block_size, CvSize shift_size,
00477                                   CvSize max_range, int use_previous,
00478                                   CvArr* velx, CvArr* vely );
00479 
00480 /* Calculates Optical flow for 2 images using Horn & Schunck algorithm */
00481 CVAPI(void)  cvCalcOpticalFlowHS( const CvArr* prev, const CvArr* curr,
00482                                   int use_previous, CvArr* velx, CvArr* vely,
00483                                   double lambda, CvTermCriteria criteria );
00484 
00485 #define  CV_LKFLOW_PYR_A_READY       1
00486 #define  CV_LKFLOW_PYR_B_READY       2
00487 #define  CV_LKFLOW_INITIAL_GUESSES   4
00488 #define  CV_LKFLOW_GET_MIN_EIGENVALS 8
00489 
00490 /* It is Lucas & Kanade method, modified to use pyramids.
00491    Also it does several iterations to get optical flow for
00492    every point at every pyramid level.
00493    Calculates optical flow between two images for certain set of points (i.e.
00494    it is a "sparse" optical flow, which is opposite to the previous 3 methods) */
00495 CVAPI(void)  cvCalcOpticalFlowPyrLK( const CvArr*  prev, const CvArr*  curr,
00496                                      CvArr*  prev_pyr, CvArr*  curr_pyr,
00497                                      const CvPoint2D32f* prev_features,
00498                                      CvPoint2D32f* curr_features,
00499                                      int       count,
00500                                      CvSize    win_size,
00501                                      int       level,
00502                                      char*     status,
00503                                      float*    track_error,
00504                                      CvTermCriteria criteria,
00505                                      int       flags );
00506 
00507 
00508 /* Modification of a previous sparse optical flow algorithm to calculate
00509    affine flow */
00510 CVAPI(void)  cvCalcAffineFlowPyrLK( const CvArr*  prev, const CvArr*  curr,
00511                                     CvArr*  prev_pyr, CvArr*  curr_pyr,
00512                                     const CvPoint2D32f* prev_features,
00513                                     CvPoint2D32f* curr_features,
00514                                     float* matrices, int  count,
00515                                     CvSize win_size, int  level,
00516                                     char* status, float* track_error,
00517                                     CvTermCriteria criteria, int flags );
00518 
00519 /* Estimate rigid transformation between 2 images or 2 point sets */
00520 CVAPI(int)  cvEstimateRigidTransform( const CvArr* A, const CvArr* B,
00521                                       CvMat* M, int full_affine );
00522 
00523 /* Estimate optical flow for each pixel using the two-frame G. Farneback algorithm */
00524 CVAPI(void) cvCalcOpticalFlowFarneback( const CvArr* prev, const CvArr* next,
00525                                         CvArr* flow, double pyr_scale, int levels,
00526                                         int winsize, int iterations, int poly_n,
00527                                         double poly_sigma, int flags );
00528 
00529 /********************************* motion templates *************************************/
00530 
00531 /****************************************************************************************\
00532 *        All the motion template functions work only with single channel images.         *
00533 *        Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S                   *
00534 *        Motion history image must have depth IPL_DEPTH_32F,                             *
00535 *        Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S,                                   *
00536 *        Motion orientation image - IPL_DEPTH_32F                                        *
00537 *        Segmentation mask - IPL_DEPTH_32F                                               *
00538 *        All the angles are in degrees, all the times are in milliseconds                *
00539 \****************************************************************************************/
00540 
00541 /* Updates motion history image given motion silhouette */
00542 CVAPI(void)    cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi,
00543                                       double timestamp, double duration );
00544 
00545 /* Calculates gradient of the motion history image and fills
00546    a mask indicating where the gradient is valid */
00547 CVAPI(void)    cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation,
00548                                      double delta1, double delta2,
00549                                      int aperture_size CV_DEFAULT(3));
00550 
00551 /* Calculates average motion direction within a selected motion region
00552    (region can be selected by setting ROIs and/or by composing a valid gradient mask
00553    with the region mask) */
00554 CVAPI(double)  cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask,
00555                                         const CvArr* mhi, double timestamp,
00556                                         double duration );
00557 
00558 /* Splits a motion history image into a few parts corresponding to separate independent motions
00559    (e.g. left hand, right hand) */
00560 CVAPI(CvSeq*)  cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask,
00561                                 CvMemStorage* storage,
00562                                 double timestamp, double seg_thresh );
00563 
00564 /*********************** Background statistics accumulation *****************************/
00565 
00566 /* Adds image to accumulator */
00567 CVAPI(void)  cvAcc( const CvArr* image, CvArr* sum,
00568                     const CvArr* mask CV_DEFAULT(NULL) );
00569 
00570 /* Adds squared image to accumulator */
00571 CVAPI(void)  cvSquareAcc( const CvArr* image, CvArr* sqsum,
00572                           const CvArr* mask CV_DEFAULT(NULL) );
00573 
00574 /* Adds a product of two images to accumulator */
00575 CVAPI(void)  cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
00576                             const CvArr* mask CV_DEFAULT(NULL) );
00577 
00578 /* Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha */
00579 CVAPI(void)  cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
00580                            const CvArr* mask CV_DEFAULT(NULL) );
00581 
00582 
00583 /****************************************************************************************\
00584 *                                       Tracking                                         *
00585 \****************************************************************************************/
00586 
00587 /* Implements CAMSHIFT algorithm - determines object position, size and orientation
00588    from the object histogram back project (extension of meanshift) */
00589 CVAPI(int)  cvCamShift( const CvArr* prob_image, CvRect  window,
00590                        CvTermCriteria criteria, CvConnectedComp* comp,
00591                        CvBox2D* box CV_DEFAULT(NULL) );
00592 
00593 /* Implements MeanShift algorithm - determines object position
00594    from the object histogram back project */
00595 CVAPI(int)  cvMeanShift( const CvArr* prob_image, CvRect  window,
00596                         CvTermCriteria criteria, CvConnectedComp* comp );
00597 
00598 /* Creates Kalman filter and sets A, B, Q, R and state to some initial values */
00599 CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params,
00600                                 int control_params CV_DEFAULT(0));
00601 
00602 /* Releases Kalman filter state */
00603 CVAPI(void)  cvReleaseKalman( CvKalman** kalman);
00604 
00605 /* Updates Kalman filter by time (predicts future state of the system) */
00606 CVAPI(const CvMat*)  cvKalmanPredict( CvKalman* kalman,
00607                                      const CvMat* control CV_DEFAULT(NULL));
00608 
00609 /* Updates Kalman filter by measurement
00610    (corrects state of the system and internal matrices) */
00611 CVAPI(const CvMat*)  cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement );
00612 
00613 /****************************************************************************************\
00614 *                              Planar subdivisions                                       *
00615 \****************************************************************************************/
00616 
00617 /* Initializes Delaunay triangulation */
00618 CVAPI(void)  cvInitSubdivDelaunay2D( CvSubdiv2D* subdiv, CvRect rect );
00619 
00620 /* Creates new subdivision */
00621 CVAPI(CvSubdiv2D*)  cvCreateSubdiv2D( int subdiv_type, int header_size,
00622                                       int vtx_size, int quadedge_size,
00623                                       CvMemStorage* storage );
00624 
00625 /************************* high-level subdivision functions ***************************/
00626 
00627 /* Simplified Delaunay diagram creation */
00628 CV_INLINE  CvSubdiv2D* cvCreateSubdivDelaunay2D( CvRect rect, CvMemStorage* storage )
00629 {
00630     CvSubdiv2D* subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D, sizeof(*subdiv),
00631                          sizeof(CvSubdiv2DPoint), sizeof(CvQuadEdge2D), storage );
00632 
00633     cvInitSubdivDelaunay2D( subdiv, rect );
00634     return subdiv;
00635 }
00636 
00637 
00638 /* Inserts new point to the Delaunay triangulation */
00639 CVAPI(CvSubdiv2DPoint*)  cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt);
00640 
00641 /* Locates a point within the Delaunay triangulation (finds the edge
00642    the point is left to or belongs to, or the triangulation point the given
00643    point coinsides with */
00644 CVAPI(CvSubdiv2DPointLocation)  cvSubdiv2DLocate(
00645                                CvSubdiv2D* subdiv, CvPoint2D32f pt,
00646                                CvSubdiv2DEdge* edge,
00647                                CvSubdiv2DPoint** vertex CV_DEFAULT(NULL) );
00648 
00649 /* Calculates Voronoi tesselation (i.e. coordinates of Voronoi points) */
00650 CVAPI(void)  cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv );
00651 
00652 
00653 /* Removes all Voronoi points from the tesselation */
00654 CVAPI(void)  cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv );
00655 
00656 
00657 /* Finds the nearest to the given point vertex in subdivision. */
00658 CVAPI(CvSubdiv2DPoint*) cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt );
00659 
00660 
00661 /************ Basic quad-edge navigation and operations ************/
00662 
00663 CV_INLINE  CvSubdiv2DEdge  cvSubdiv2DNextEdge( CvSubdiv2DEdge edge )
00664 {
00665     return  CV_SUBDIV2D_NEXT_EDGE(edge);
00666 }
00667 
00668 
00669 CV_INLINE  CvSubdiv2DEdge  cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate )
00670 {
00671     return  (edge & ~3) + ((edge + rotate) & 3);
00672 }
00673 
00674 CV_INLINE  CvSubdiv2DEdge  cvSubdiv2DSymEdge( CvSubdiv2DEdge edge )
00675 {
00676     return edge ^ 2;
00677 }
00678 
00679 CV_INLINE  CvSubdiv2DEdge  cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, CvNextEdgeType type )
00680 {
00681     CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
00682     edge = e->next[(edge + (int)type) & 3];
00683     return  (edge & ~3) + ((edge + ((int)type >> 4)) & 3);
00684 }
00685 
00686 
00687 CV_INLINE  CvSubdiv2DPoint*  cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge )
00688 {
00689     CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
00690     return (CvSubdiv2DPoint*)e->pt[edge & 3];
00691 }
00692 
00693 
00694 CV_INLINE  CvSubdiv2DPoint*  cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge )
00695 {
00696     CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
00697     return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3];
00698 }
00699 
00700 
00701 CV_INLINE  double  cvTriangleArea( CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
00702 {
00703     return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
00704 }
00705 
00706 
00707 /****************************************************************************************\
00708 *                            Contour Processing and Shape Analysis                       *
00709 \****************************************************************************************/
00710 
00711 #define CV_POLY_APPROX_DP 0
00712 
00713 /* Approximates a single polygonal curve (contour) or
00714    a tree of polygonal curves (contours) */
00715 CVAPI(CvSeq*)  cvApproxPoly( const void* src_seq,
00716                              int header_size, CvMemStorage* storage,
00717                              int method, double parameter,
00718                              int parameter2 CV_DEFAULT(0));
00719 
00720 /* Calculates perimeter of a contour or length of a part of contour */
00721 CVAPI(double)  cvArcLength( const void* curve,
00722                             CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
00723                             int is_closed CV_DEFAULT(-1));
00724 #define cvContourPerimeter( contour ) cvArcLength( contour, CV_WHOLE_SEQ, 1 )
00725 
00726 /* Calculates contour boundning rectangle (update=1) or
00727    just retrieves pre-calculated rectangle (update=0) */
00728 CVAPI(CvRect)  cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
00729 
00730 /* Calculates area of a contour or contour segment */
00731 CVAPI(double)  cvContourArea( const CvArr* contour,
00732                               CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
00733                               int oriented CV_DEFAULT(0));
00734 
00735 /* Finds minimum area rotated rectangle bounding a set of points */
00736 CVAPI(CvBox2D)  cvMinAreaRect2( const CvArr* points,
00737                                 CvMemStorage* storage CV_DEFAULT(NULL));
00738 
00739 /* Finds minimum enclosing circle for a set of points */
00740 CVAPI(int)  cvMinEnclosingCircle( const CvArr* points,
00741                                   CvPoint2D32f* center, float* radius );
00742 
00743 #define CV_CONTOURS_MATCH_I1  1
00744 #define CV_CONTOURS_MATCH_I2  2
00745 #define CV_CONTOURS_MATCH_I3  3
00746 
00747 /* Compares two contours by matching their moments */
00748 CVAPI(double)  cvMatchShapes( const void* object1, const void* object2,
00749                               int method, double parameter CV_DEFAULT(0));
00750 
00751 /* Builds hierarhical representation of a contour */
00752 CVAPI(CvContourTree*)  cvCreateContourTree( const CvSeq* contour,
00753                                             CvMemStorage* storage,
00754                                             double threshold );
00755 
00756 /* Reconstruct (completelly or partially) contour a from contour tree */
00757 CVAPI(CvSeq*)  cvContourFromContourTree( const CvContourTree* tree,
00758                                          CvMemStorage* storage,
00759                                          CvTermCriteria criteria );
00760 
00761 /* Compares two contour trees */
00762 #define  CV_CONTOUR_TREES_MATCH_I1  1
00763 
00764 CVAPI(double)  cvMatchContourTrees( const CvContourTree* tree1,
00765                                     const CvContourTree* tree2,
00766                                     int method, double threshold );
00767 
00768 #define CV_CLOCKWISE         1
00769 #define CV_COUNTER_CLOCKWISE 2
00770 
00771 /* Calculates exact convex hull of 2d point set */
00772 CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
00773                              void* hull_storage CV_DEFAULT(NULL),
00774                              int orientation CV_DEFAULT(CV_CLOCKWISE),
00775                              int return_points CV_DEFAULT(0));
00776 
00777 /* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */
00778 CVAPI(int)  cvCheckContourConvexity( const CvArr* contour );
00779 
00780 /* Finds convexity defects for the contour */
00781 CVAPI(CvSeq*)  cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
00782                                    CvMemStorage* storage CV_DEFAULT(NULL));
00783 
00784 /* Fits ellipse into a set of 2d points */
00785 CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points );
00786 
00787 /* Finds minimum rectangle containing two given rectangles */
00788 CVAPI(CvRect)  cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
00789 
00790 /* Finds coordinates of the box vertices */
00791 CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
00792 
00793 /* Initializes sequence header for a matrix (column or row vector) of points -
00794    a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */
00795 CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat,
00796                                  CvContour* contour_header,
00797                                  CvSeqBlock* block );
00798 
00799 /* Checks whether the point is inside polygon, outside, on an edge (at a vertex).
00800    Returns positive, negative or zero value, correspondingly.
00801    Optionally, measures a signed distance between
00802    the point and the nearest polygon edge (measure_dist=1) */
00803 CVAPI(double) cvPointPolygonTest( const CvArr* contour,
00804                                   CvPoint2D32f pt, int measure_dist );
00805 
00806 /****************************************************************************************\
00807 *                                  Histogram functions                                   *
00808 \****************************************************************************************/
00809 
00810 /* Creates new histogram */
00811 CVAPI(CvHistogram*)  cvCreateHist( int dims, int* sizes, int type,
00812                                    float** ranges CV_DEFAULT(NULL),
00813                                    int uniform CV_DEFAULT(1));
00814 
00815 /* Assignes histogram bin ranges */
00816 CVAPI(void)  cvSetHistBinRanges( CvHistogram* hist, float** ranges,
00817                                 int uniform CV_DEFAULT(1));
00818 
00819 /* Creates histogram header for array */
00820 CVAPI(CvHistogram*)  cvMakeHistHeaderForArray(
00821                             int  dims, int* sizes, CvHistogram* hist,
00822                             float* data, float** ranges CV_DEFAULT(NULL),
00823                             int uniform CV_DEFAULT(1));
00824 
00825 /* Releases histogram */
00826 CVAPI(void)  cvReleaseHist( CvHistogram** hist );
00827 
00828 /* Clears all the histogram bins */
00829 CVAPI(void)  cvClearHist( CvHistogram* hist );
00830 
00831 /* Finds indices and values of minimum and maximum histogram bins */
00832 CVAPI(void)  cvGetMinMaxHistValue( const CvHistogram* hist,
00833                                    float* min_value, float* max_value,
00834                                    int* min_idx CV_DEFAULT(NULL),
00835                                    int* max_idx CV_DEFAULT(NULL));
00836 
00837 
00838 /* Normalizes histogram by dividing all bins by sum of the bins, multiplied by <factor>.
00839    After that sum of histogram bins is equal to <factor> */
00840 CVAPI(void)  cvNormalizeHist( CvHistogram* hist, double factor );
00841 
00842 
00843 /* Clear all histogram bins that are below the threshold */
00844 CVAPI(void)  cvThreshHist( CvHistogram* hist, double threshold );
00845 
00846 #define CV_COMP_CORREL        0
00847 #define CV_COMP_CHISQR        1
00848 #define CV_COMP_INTERSECT     2
00849 #define CV_COMP_BHATTACHARYYA 3
00850 
00851 /* Compares two histogram */
00852 CVAPI(double)  cvCompareHist( const CvHistogram* hist1,
00853                               const CvHistogram* hist2,
00854                               int method);
00855 
00856 /* Copies one histogram to another. Destination histogram is created if
00857    the destination pointer is NULL */
00858 CVAPI(void)  cvCopyHist( const CvHistogram* src, CvHistogram** dst );
00859 
00860 
00861 /* Calculates bayesian probabilistic histograms
00862    (each or src and dst is an array of <number> histograms */
00863 CVAPI(void)  cvCalcBayesianProb( CvHistogram** src, int number,
00864                                 CvHistogram** dst);
00865 
00866 /* Calculates array histogram */
00867 CVAPI(void)  cvCalcArrHist( CvArr** arr, CvHistogram* hist,
00868                             int accumulate CV_DEFAULT(0),
00869                             const CvArr* mask CV_DEFAULT(NULL) );
00870 
00871 CV_INLINE  void  cvCalcHist( IplImage** image, CvHistogram* hist,
00872                              int accumulate CV_DEFAULT(0),
00873                              const CvArr* mask CV_DEFAULT(NULL) )
00874 {
00875     cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
00876 }
00877 
00878 /* Calculates back project */
00879 CVAPI(void)  cvCalcArrBackProject( CvArr** image, CvArr* dst,
00880                                    const CvHistogram* hist );
00881 #define  cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist)
00882 
00883 
00884 /* Does some sort of template matching but compares histograms of
00885    template and each window location */
00886 CVAPI(void)  cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
00887                                         CvHistogram* hist, int method,
00888                                         double factor );
00889 #define  cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \
00890      cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
00891 
00892 
00893 /* calculates probabilistic density (divides one histogram by another) */
00894 CVAPI(void)  cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
00895                                 CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
00896 
00897 /* equalizes histogram of 8-bit single-channel image */
00898 CVAPI(void)  cvEqualizeHist( const CvArr* src, CvArr* dst );
00899 
00900 
00901 #define  CV_VALUE  1
00902 #define  CV_ARRAY  2
00903 /* Updates active contour in order to minimize its cummulative
00904    (internal and external) energy. */
00905 CVAPI(void)  cvSnakeImage( const IplImage* image, CvPoint* points,
00906                            int  length, float* alpha,
00907                            float* beta, float* gamma,
00908                            int coeff_usage, CvSize  win,
00909                            CvTermCriteria criteria, int calc_gradient CV_DEFAULT(1));
00910 
00911 #define CV_DIST_MASK_3   3
00912 #define CV_DIST_MASK_5   5
00913 #define CV_DIST_MASK_PRECISE 0
00914 
00915 /* Applies distance transform to binary image */
00916 CVAPI(void)  cvDistTransform( const CvArr* src, CvArr* dst,
00917                               int distance_type CV_DEFAULT(CV_DIST_L2),
00918                               int mask_size CV_DEFAULT(3),
00919                               const float* mask CV_DEFAULT(NULL),
00920                               CvArr* labels CV_DEFAULT(NULL));
00921 
00922 
00923 /* Types of thresholding */
00924 #define CV_THRESH_BINARY      0  /* value = value > threshold ? max_value : 0       */
00925 #define CV_THRESH_BINARY_INV  1  /* value = value > threshold ? 0 : max_value       */
00926 #define CV_THRESH_TRUNC       2  /* value = value > threshold ? threshold : value   */
00927 #define CV_THRESH_TOZERO      3  /* value = value > threshold ? value : 0           */
00928 #define CV_THRESH_TOZERO_INV  4  /* value = value > threshold ? 0 : value           */
00929 #define CV_THRESH_MASK        7
00930 
00931 #define CV_THRESH_OTSU        8  /* use Otsu algorithm to choose the optimal threshold value;
00932                                     combine the flag with one of the above CV_THRESH_* values */
00933 
00934 /* Applies fixed-level threshold to grayscale image.
00935    This is a basic operation applied before retrieving contours */
00936 CVAPI(double)  cvThreshold( const CvArr*  src, CvArr*  dst,
00937                             double  threshold, double  max_value,
00938                             int threshold_type );
00939 
00940 #define CV_ADAPTIVE_THRESH_MEAN_C  0
00941 #define CV_ADAPTIVE_THRESH_GAUSSIAN_C  1
00942 
00943 /* Applies adaptive threshold to grayscale image.
00944    The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
00945    CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
00946    neighborhood size (3, 5, 7 etc.),
00947    and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */
00948 CVAPI(void)  cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
00949                                   int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
00950                                   int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
00951                                   int block_size CV_DEFAULT(3),
00952                                   double param1 CV_DEFAULT(5));
00953 
00954 #define CV_FLOODFILL_FIXED_RANGE (1 << 16)
00955 #define CV_FLOODFILL_MASK_ONLY   (1 << 17)
00956 
00957 /* Fills the connected component until the color difference gets large enough */
00958 CVAPI(void)  cvFloodFill( CvArr* image, CvPoint seed_point,
00959                           CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)),
00960                           CvScalar up_diff CV_DEFAULT(cvScalarAll(0)),
00961                           CvConnectedComp* comp CV_DEFAULT(NULL),
00962                           int flags CV_DEFAULT(4),
00963                           CvArr* mask CV_DEFAULT(NULL));
00964 
00965 /****************************************************************************************\
00966 *                                  Feature detection                                     *
00967 \****************************************************************************************/
00968 
00969 #define CV_CANNY_L2_GRADIENT  (1 << 31)
00970 
00971 /* Runs canny edge detector */
00972 CVAPI(void)  cvCanny( const CvArr* image, CvArr* edges, double threshold1,
00973                       double threshold2, int  aperture_size CV_DEFAULT(3) );
00974 
00975 /* Calculates constraint image for corner detection
00976    Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy.
00977    Applying threshold to the result gives coordinates of corners */
00978 CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners,
00979                               int aperture_size CV_DEFAULT(3) );
00980 
00981 /* Calculates eigen values and vectors of 2x2
00982    gradient covariation matrix at every image pixel */
00983 CVAPI(void)  cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
00984                                       int block_size, int aperture_size CV_DEFAULT(3) );
00985 
00986 /* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at
00987    every image pixel */
00988 CVAPI(void)  cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
00989                                  int block_size, int aperture_size CV_DEFAULT(3) );
00990 
00991 /* Harris corner detector:
00992    Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */
00993 CVAPI(void)  cvCornerHarris( const CvArr* image, CvArr* harris_responce,
00994                              int block_size, int aperture_size CV_DEFAULT(3),
00995                              double k CV_DEFAULT(0.04) );
00996 
00997 /* Adjust corner position using some sort of gradient search */
00998 CVAPI(void)  cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
00999                                  int count, CvSize win, CvSize zero_zone,
01000                                  CvTermCriteria  criteria );
01001 
01002 /* Finds a sparse set of points within the selected region
01003    that seem to be easy to track */
01004 CVAPI(void)  cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
01005                                    CvArr* temp_image, CvPoint2D32f* corners,
01006                                    int* corner_count, double  quality_level,
01007                                    double  min_distance,
01008                                    const CvArr* mask CV_DEFAULT(NULL),
01009                                    int block_size CV_DEFAULT(3),
01010                                    int use_harris CV_DEFAULT(0),
01011                                    double k CV_DEFAULT(0.04) );
01012 
01013 #define CV_HOUGH_STANDARD 0
01014 #define CV_HOUGH_PROBABILISTIC 1
01015 #define CV_HOUGH_MULTI_SCALE 2
01016 #define CV_HOUGH_GRADIENT 3
01017 
01018 /* Finds lines on binary image using one of several methods.
01019    line_storage is either memory storage or 1 x <max number of lines> CvMat, its
01020    number of columns is changed by the function.
01021    method is one of CV_HOUGH_*;
01022    rho, theta and threshold are used for each of those methods;
01023    param1 ~ line length, param2 ~ line gap - for probabilistic,
01024    param1 ~ srn, param2 ~ stn - for multi-scale */
01025 CVAPI(CvSeq*)  cvHoughLines2( CvArr* image, void* line_storage, int method,
01026                               double rho, double theta, int threshold,
01027                               double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0));
01028 
01029 /* Finds circles in the image */
01030 CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
01031                               int method, double dp, double min_dist,
01032                               double param1 CV_DEFAULT(100),
01033                               double param2 CV_DEFAULT(100),
01034                               int min_radius CV_DEFAULT(0),
01035                               int max_radius CV_DEFAULT(0));
01036 
01037 /* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */
01038 CVAPI(void)  cvFitLine( const CvArr* points, int dist_type, double param,
01039                         double reps, double aeps, float* line );
01040 
01041 
01042 
01043 struct CvFeatureTree;
01044 
01045 /* Constructs kd-tree from set of feature descriptors */
01046 CVAPI(struct CvFeatureTree*) cvCreateKDTree(CvMat* desc);
01047 
01048 /* Constructs spill-tree from set of feature descriptors */
01049 CVAPI(struct CvFeatureTree*) cvCreateSpillTree( const CvMat* raw_data,
01050                                     const int naive CV_DEFAULT(50),
01051                                     const double rho CV_DEFAULT(.7),
01052                                     const double tau CV_DEFAULT(.1) );
01053 
01054 /* Release feature tree */
01055 CVAPI(void) cvReleaseFeatureTree(struct CvFeatureTree* tr);
01056 
01057 /* Searches feature tree for k nearest neighbors of given reference points,
01058    searching (in case of kd-tree/bbf) at most emax leaves. */
01059 CVAPI(void) cvFindFeatures(struct CvFeatureTree* tr, const CvMat* query_points,
01060                            CvMat* indices, CvMat* dist, int k, int emax CV_DEFAULT(20));
01061 
01062 /* Search feature tree for all points that are inlier to given rect region.
01063    Only implemented for kd trees */
01064 CVAPI(int) cvFindFeaturesBoxed(struct CvFeatureTree* tr,
01065                                CvMat* bounds_min, CvMat* bounds_max,
01066                                CvMat* out_indices);
01067 
01068 
01069 struct CvLSH;
01070 struct CvLSHOperations;
01071 
01072 /* Construct a Locality Sensitive Hash (LSH) table, for indexing d-dimensional vectors of
01073    given type. Vectors will be hashed L times with k-dimensional p-stable (p=2) functions. */
01074 CVAPI(struct CvLSH*) cvCreateLSH(struct CvLSHOperations* ops, int d,
01075                                  int L CV_DEFAULT(10), int k CV_DEFAULT(10),
01076                                  int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4),
01077                                  int64 seed CV_DEFAULT(-1));
01078 
01079 /* Construct in-memory LSH table, with n bins. */
01080 CVAPI(struct CvLSH*) cvCreateMemoryLSH(int d, int n, int L CV_DEFAULT(10), int k CV_DEFAULT(10),
01081                                        int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4),
01082                                        int64 seed CV_DEFAULT(-1));
01083 
01084 /* Free the given LSH structure. */
01085 CVAPI(void) cvReleaseLSH(struct CvLSH** lsh);
01086 
01087 /* Return the number of vectors in the LSH. */
01088 CVAPI(unsigned int) LSHSize(struct CvLSH* lsh);
01089 
01090 /* Add vectors to the LSH structure, optionally returning indices. */
01091 CVAPI(void) cvLSHAdd(struct CvLSH* lsh, const CvMat* data, CvMat* indices CV_DEFAULT(0));
01092 
01093 /* Remove vectors from LSH, as addressed by given indices. */
01094 CVAPI(void) cvLSHRemove(struct CvLSH* lsh, const CvMat* indices);
01095 
01096 /* Query the LSH n times for at most k nearest points; data is n x d,
01097    indices and dist are n x k. At most emax stored points will be accessed. */
01098 CVAPI(void) cvLSHQuery(struct CvLSH* lsh, const CvMat* query_points,
01099                        CvMat* indices, CvMat* dist, int k, int emax);
01100 
01101 
01102 typedef struct CvSURFPoint
01103 {
01104     CvPoint2D32f pt;
01105     int laplacian;
01106     int size;
01107     float dir;
01108     float hessian;
01109 } CvSURFPoint;
01110 
01111 CV_INLINE CvSURFPoint cvSURFPoint( CvPoint2D32f pt, int laplacian,
01112                                    int size, float dir CV_DEFAULT(0),
01113                                    float hessian CV_DEFAULT(0))
01114 {
01115     CvSURFPoint kp;
01116     kp.pt = pt;
01117     kp.laplacian = laplacian;
01118     kp.size = size;
01119     kp.dir = dir;
01120     kp.hessian = hessian;
01121     return kp;
01122 }
01123 
01124 typedef struct CvSURFParams
01125 {
01126     int extended;
01127     double hessianThreshold;
01128 
01129     int nOctaves;
01130     int nOctaveLayers;
01131 }
01132 CvSURFParams;
01133 
01134 CVAPI(CvSURFParams) cvSURFParams( double hessianThreshold, int extended CV_DEFAULT(0) );
01135 
01136 // If useProvidedKeyPts!=0, keypoints are not detected, but descriptors are computed
01137 //  at the locations provided in keypoints (a CvSeq of CvSURFPoint).
01138 CVAPI(void) cvExtractSURF( const CvArr* img, const CvArr* mask,
01139                            CvSeq** keypoints, CvSeq** descriptors,
01140                            CvMemStorage* storage, CvSURFParams params, int useProvidedKeyPts CV_DEFAULT(0)  );
01141 
01142 typedef struct CvMSERParams
01143 {
01144     // delta, in the code, it compares (size_{i}-size_{i-delta})/size_{i-delta}
01145     int delta;
01146     // prune the area which bigger/smaller than max_area/min_area
01147     int maxArea;
01148     int minArea;
01149     // prune the area have simliar size to its children
01150     float maxVariation;
01151     // trace back to cut off mser with diversity < min_diversity
01152     float minDiversity;
01153     /* the next few params for MSER of color image */
01154     // for color image, the evolution steps
01155     int maxEvolution;
01156     // the area threshold to cause re-initialize
01157     double areaThreshold;
01158     // ignore too small margin
01159     double minMargin;
01160     // the aperture size for edge blur
01161     int edgeBlurSize;
01162 }
01163 CvMSERParams;
01164 
01165 CVAPI(CvMSERParams) cvMSERParams( int delta CV_DEFAULT(5), int min_area CV_DEFAULT(60),
01166                            int max_area CV_DEFAULT(14400), float max_variation CV_DEFAULT(.25f),
01167                            float min_diversity CV_DEFAULT(.2f), int max_evolution CV_DEFAULT(200),
01168                            double area_threshold CV_DEFAULT(1.01),
01169                            double min_margin CV_DEFAULT(.003),
01170                            int edge_blur_size CV_DEFAULT(5) );
01171 
01172 // Extracts the contours of Maximally Stable Extremal Regions
01173 CVAPI(void) cvExtractMSER( CvArr* _img, CvArr* _mask, CvSeq** contours, CvMemStorage* storage, CvMSERParams params );
01174 
01175 
01176 typedef struct CvStarKeypoint
01177 {
01178     CvPoint pt;
01179     int size;
01180     float response;
01181 }
01182 CvStarKeypoint;
01183 
01184 CV_INLINE CvStarKeypoint cvStarKeypoint(CvPoint pt, int size, float response)
01185 {
01186     CvStarKeypoint kpt;
01187     kpt.pt = pt;
01188     kpt.size = size;
01189     kpt.response = response;
01190     return kpt;
01191 }
01192 
01193 typedef struct CvStarDetectorParams
01194 {
01195     int maxSize;
01196     int responseThreshold;
01197     int lineThresholdProjected;
01198     int lineThresholdBinarized;
01199     int suppressNonmaxSize;
01200 }
01201 CvStarDetectorParams;
01202 
01203 CV_INLINE CvStarDetectorParams cvStarDetectorParams(
01204     int maxSize CV_DEFAULT(45),
01205     int responseThreshold CV_DEFAULT(30),
01206     int lineThresholdProjected CV_DEFAULT(10),
01207     int lineThresholdBinarized CV_DEFAULT(8),
01208     int suppressNonmaxSize CV_DEFAULT(5))
01209 {
01210     CvStarDetectorParams params;
01211     params.maxSize = maxSize;
01212     params.responseThreshold = responseThreshold;
01213     params.lineThresholdProjected = lineThresholdProjected;
01214     params.lineThresholdBinarized = lineThresholdBinarized;
01215     params.suppressNonmaxSize = suppressNonmaxSize;
01216 
01217     return params;
01218 }
01219 
01220 CVAPI(CvSeq*) cvGetStarKeypoints( const CvArr* img, CvMemStorage* storage,
01221         CvStarDetectorParams params CV_DEFAULT(cvStarDetectorParams()));
01222 
01223 /****************************************************************************************\
01224 *                         Haar-like Object Detection functions                           *
01225 \****************************************************************************************/
01226 
01227 /* Loads haar classifier cascade from a directory.
01228    It is obsolete: convert your cascade to xml and use cvLoad instead */
01229 CVAPI(CvHaarClassifierCascade*) cvLoadHaarClassifierCascade(
01230                     const char* directory, CvSize orig_window_size);
01231 
01232 CVAPI(void) cvReleaseHaarClassifierCascade( CvHaarClassifierCascade** cascade );
01233 
01234 #define CV_HAAR_DO_CANNY_PRUNING    1
01235 #define CV_HAAR_SCALE_IMAGE         2
01236 #define CV_HAAR_FIND_BIGGEST_OBJECT 4
01237 #define CV_HAAR_DO_ROUGH_SEARCH     8
01238 
01239 CVAPI(CvSeq*) cvHaarDetectObjects( const CvArr* image,
01240                      CvHaarClassifierCascade* cascade,
01241                      CvMemStorage* storage, double scale_factor CV_DEFAULT(1.1),
01242                      int min_neighbors CV_DEFAULT(3), int flags CV_DEFAULT(0),
01243                      CvSize min_size CV_DEFAULT(cvSize(0,0)));
01244 
01245 /* sets images for haar classifier cascade */
01246 CVAPI(void) cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* cascade,
01247                                                 const CvArr* sum, const CvArr* sqsum,
01248                                                 const CvArr* tilted_sum, double scale );
01249 
01250 /* runs the cascade on the specified window */
01251 CVAPI(int) cvRunHaarClassifierCascade( const CvHaarClassifierCascade* cascade,
01252                                        CvPoint pt, int start_stage CV_DEFAULT(0));
01253 
01254 /****************************************************************************************\
01255 *                      Camera Calibration, Pose Estimation and Stereo                    *
01256 \****************************************************************************************/
01257 
01258 /* Transforms the input image to compensate lens distortion */
01259 CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst,
01260                           const CvMat* camera_matrix,
01261                           const CvMat* distortion_coeffs,
01262                           const CvMat* new_camera_matrix CV_DEFAULT(0) );
01263 
01264 /* Computes transformation map from intrinsic camera parameters
01265    that can used by cvRemap */
01266 CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix,
01267                                 const CvMat* distortion_coeffs,
01268                                 CvArr* mapx, CvArr* mapy );
01269 
01270 /* Computes undistortion+rectification map for a head of stereo camera */
01271 CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix,
01272                                        const CvMat* dist_coeffs,
01273                                        const CvMat *R, const CvMat* new_camera_matrix,
01274                                        CvArr* mapx, CvArr* mapy );
01275 
01276 /* Computes the original (undistorted) feature coordinates
01277    from the observed (distorted) coordinates */
01278 CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst,
01279                                const CvMat* camera_matrix,
01280                                const CvMat* dist_coeffs,
01281                                const CvMat* R CV_DEFAULT(0),
01282                                const CvMat* P CV_DEFAULT(0));
01283     
01284 /* Computes the optimal new camera matrix according to the free scaling parameter alpha:
01285    alpha=0 - only valid pixels will be retained in the undistorted image
01286    alpha=1 - all the source image pixels will be retained in the undistorted image
01287 */
01288 CVAPI(void) cvGetOptimalNewCameraMatrix( const CvMat* camera_matrix,
01289                                          const CvMat* dist_coeffs,
01290                                          CvSize image_size, double alpha,
01291                                          CvMat* new_camera_matrix,
01292                                          CvSize new_imag_size CV_DEFAULT(cvSize(0,0)),
01293                                          CvRect* valid_pixel_ROI CV_DEFAULT(0) );
01294 
01295 /* Converts rotation vector to rotation matrix or vice versa */
01296 CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
01297                          CvMat* jacobian CV_DEFAULT(0) );
01298 
01299 #define CV_LMEDS 4
01300 #define CV_RANSAC 8
01301 
01302 /* Finds perspective transformation between the object plane and image (view) plane */
01303 CVAPI(int) cvFindHomography( const CvMat* src_points,
01304                              const CvMat* dst_points,
01305                              CvMat* homography,
01306                              int method CV_DEFAULT(0),
01307                              double ransacReprojThreshold CV_DEFAULT(0),
01308                              CvMat* mask CV_DEFAULT(0));
01309 
01310 /* Computes RQ decomposition for 3x3 matrices */
01311 CVAPI(void) cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
01312                            CvMat *matrixQx CV_DEFAULT(NULL),
01313                            CvMat *matrixQy CV_DEFAULT(NULL),
01314                            CvMat *matrixQz CV_DEFAULT(NULL),
01315                            CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
01316 
01317 /* Computes projection matrix decomposition */
01318 CVAPI(void) cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr,
01319                                          CvMat *rotMatr, CvMat *posVect,
01320                                          CvMat *rotMatrX CV_DEFAULT(NULL),
01321                                          CvMat *rotMatrY CV_DEFAULT(NULL),
01322                                          CvMat *rotMatrZ CV_DEFAULT(NULL),
01323                                          CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
01324 
01325 /* Computes d(AB)/dA and d(AB)/dB */
01326 CVAPI(void) cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, CvMat* dABdB );
01327 
01328 /* Computes r3 = rodrigues(rodrigues(r2)*rodrigues(r1)),
01329    t3 = rodrigues(r2)*t1 + t2 and the respective derivatives */
01330 CVAPI(void) cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
01331                          const CvMat* _rvec2, const CvMat* _tvec2,
01332                          CvMat* _rvec3, CvMat* _tvec3,
01333                          CvMat* dr3dr1 CV_DEFAULT(0), CvMat* dr3dt1 CV_DEFAULT(0),
01334                          CvMat* dr3dr2 CV_DEFAULT(0), CvMat* dr3dt2 CV_DEFAULT(0),
01335                          CvMat* dt3dr1 CV_DEFAULT(0), CvMat* dt3dt1 CV_DEFAULT(0),
01336                          CvMat* dt3dr2 CV_DEFAULT(0), CvMat* dt3dt2 CV_DEFAULT(0) );
01337 
01338 /* Projects object points to the view plane using
01339    the specified extrinsic and intrinsic camera parameters */
01340 CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
01341                               const CvMat* translation_vector, const CvMat* camera_matrix,
01342                               const CvMat* distortion_coeffs, CvMat* image_points,
01343                               CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL),
01344                               CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL),
01345                               CvMat* dpddist CV_DEFAULT(NULL),
01346                               double aspect_ratio CV_DEFAULT(0));
01347 
01348 /* Finds extrinsic camera parameters from
01349    a few known corresponding point pairs and intrinsic parameters */
01350 CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points,
01351                                           const CvMat* image_points,
01352                                           const CvMat* camera_matrix,
01353                                           const CvMat* distortion_coeffs,
01354                                           CvMat* rotation_vector,
01355                                           CvMat* translation_vector,
01356                                           int use_extrinsic_guess CV_DEFAULT(0) );
01357 
01358 /* Computes initial estimate of the intrinsic camera parameters
01359    in case of planar calibration target (e.g. chessboard) */
01360 CVAPI(void) cvInitIntrinsicParams2D( const CvMat* object_points,
01361                                      const CvMat* image_points,
01362                                      const CvMat* npoints, CvSize image_size,
01363                                      CvMat* camera_matrix,
01364                                      double aspect_ratio CV_DEFAULT(1.) );
01365 
01366 #define CV_CALIB_CB_ADAPTIVE_THRESH  1
01367 #define CV_CALIB_CB_NORMALIZE_IMAGE  2
01368 #define CV_CALIB_CB_FILTER_QUADS     4
01369 #define CV_CALIB_CB_FAST_CHECK       8
01370 
01371 // Performs a fast check if a chessboard is in the input image. This is a workaround to 
01372 // a problem of cvFindChessboardCorners being slow on images with no chessboard
01373 // - src: input image
01374 // - size: chessboard size
01375 // Returns 1 if a chessboard can be in this image and findChessboardCorners should be called, 
01376 // 0 if there is no chessboard, -1 in case of error
01377 CVAPI(int) cvCheckChessboard(IplImage* src, CvSize size);
01378     
01379     /* Detects corners on a chessboard calibration pattern */
01380 CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size,
01381                                     CvPoint2D32f* corners,
01382                                     int* corner_count CV_DEFAULT(NULL),
01383                                     int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH+
01384                                         CV_CALIB_CB_NORMALIZE_IMAGE) );
01385 
01386 /* Draws individual chessboard corners or the whole chessboard detected */
01387 CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
01388                                      CvPoint2D32f* corners,
01389                                      int count, int pattern_was_found );
01390 
01391 #define CV_CALIB_USE_INTRINSIC_GUESS  1
01392 #define CV_CALIB_FIX_ASPECT_RATIO     2
01393 #define CV_CALIB_FIX_PRINCIPAL_POINT  4
01394 #define CV_CALIB_ZERO_TANGENT_DIST    8
01395 #define CV_CALIB_FIX_FOCAL_LENGTH 16
01396 #define CV_CALIB_FIX_K1  32
01397 #define CV_CALIB_FIX_K2  64
01398 #define CV_CALIB_FIX_K3  128
01399 
01400 /* Finds intrinsic and extrinsic camera parameters
01401    from a few views of known calibration pattern */
01402 CVAPI(double) cvCalibrateCamera2( const CvMat* object_points,
01403                                 const CvMat* image_points,
01404                                 const CvMat* point_counts,
01405                                 CvSize image_size,
01406                                 CvMat* camera_matrix,
01407                                 CvMat* distortion_coeffs,
01408                                 CvMat* rotation_vectors CV_DEFAULT(NULL),
01409                                 CvMat* translation_vectors CV_DEFAULT(NULL),
01410                                 int flags CV_DEFAULT(0) );
01411 
01412 /* Computes various useful characteristics of the camera from the data computed by
01413    cvCalibrateCamera2 */
01414 CVAPI(void) cvCalibrationMatrixValues( const CvMat *camera_matrix,
01415                                 CvSize image_size,
01416                                 double aperture_width CV_DEFAULT(0),
01417                                 double aperture_height CV_DEFAULT(0),
01418                                 double *fovx CV_DEFAULT(NULL),
01419                                 double *fovy CV_DEFAULT(NULL),
01420                                 double *focal_length CV_DEFAULT(NULL),
01421                                 CvPoint2D64f *principal_point CV_DEFAULT(NULL),
01422                                 double *pixel_aspect_ratio CV_DEFAULT(NULL));
01423 
01424 #define CV_CALIB_FIX_INTRINSIC  256
01425 #define CV_CALIB_SAME_FOCAL_LENGTH 512
01426 
01427 /* Computes the transformation from one camera coordinate system to another one
01428    from a few correspondent views of the same calibration target. Optionally, calibrates
01429    both cameras */
01430 CVAPI(double) cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1,
01431                                const CvMat* image_points2, const CvMat* npoints,
01432                                CvMat* camera_matrix1, CvMat* dist_coeffs1,
01433                                CvMat* camera_matrix2, CvMat* dist_coeffs2,
01434                                CvSize image_size, CvMat* R, CvMat* T,
01435                                CvMat* E CV_DEFAULT(0), CvMat* F CV_DEFAULT(0),
01436                                CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
01437                                    CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6)),
01438                                int flags CV_DEFAULT(CV_CALIB_FIX_INTRINSIC));
01439 
01440 #define CV_CALIB_ZERO_DISPARITY 1024
01441 
01442 /* Computes 3D rotations (+ optional shift) for each camera coordinate system to make both
01443    views parallel (=> to make all the epipolar lines horizontal or vertical) */
01444 CVAPI(void) cvStereoRectify( const CvMat* camera_matrix1, const CvMat* camera_matrix2,
01445                              const CvMat* dist_coeffs1, const CvMat* dist_coeffs2,
01446                              CvSize image_size, const CvMat* R, const CvMat* T,
01447                              CvMat* R1, CvMat* R2, CvMat* P1, CvMat* P2,
01448                              CvMat* Q CV_DEFAULT(0),
01449                              int flags CV_DEFAULT(CV_CALIB_ZERO_DISPARITY),
01450                              double alpha CV_DEFAULT(-1),
01451                              CvSize new_image_size CV_DEFAULT(cvSize(0,0)),
01452                              CvRect* valid_pix_ROI1 CV_DEFAULT(0),
01453                              CvRect* valid_pix_ROI2 CV_DEFAULT(0));
01454 
01455 /* Computes rectification transformations for uncalibrated pair of images using a set
01456    of point correspondences */
01457 CVAPI(int) cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2,
01458                                         const CvMat* F, CvSize img_size,
01459                                         CvMat* H1, CvMat* H2,
01460                                         double threshold CV_DEFAULT(5));
01461 
01462 typedef struct CvPOSITObject CvPOSITObject;
01463 
01464 /* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
01465 CVAPI(CvPOSITObject*)  cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
01466 
01467 
01468 /* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
01469    an object given its model and projection in a weak-perspective case */
01470 CVAPI(void)  cvPOSIT(  CvPOSITObject* posit_object, CvPoint2D32f* image_points,
01471                        double focal_length, CvTermCriteria criteria,
01472                        CvMatr32f rotation_matrix, CvVect32f translation_vector);
01473 
01474 /* Releases CvPOSITObject structure */
01475 CVAPI(void)  cvReleasePOSITObject( CvPOSITObject**  posit_object );
01476 
01477 /* updates the number of RANSAC iterations */
01478 CVAPI(int) cvRANSACUpdateNumIters( double p, double err_prob,
01479                                    int model_points, int max_iters );
01480 
01481 CVAPI(void) cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst );
01482 
01483 /* Calculates fundamental matrix given a set of corresponding points */
01484 #define CV_FM_7POINT 1
01485 #define CV_FM_8POINT 2
01486 #define CV_FM_LMEDS_ONLY  CV_LMEDS
01487 #define CV_FM_RANSAC_ONLY CV_RANSAC
01488 #define CV_FM_LMEDS CV_LMEDS
01489 #define CV_FM_RANSAC CV_RANSAC
01490 CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
01491                                  CvMat* fundamental_matrix,
01492                                  int method CV_DEFAULT(CV_FM_RANSAC),
01493                                  double param1 CV_DEFAULT(3.), double param2 CV_DEFAULT(0.99),
01494                                  CvMat* status CV_DEFAULT(NULL) );
01495 
01496 /* For each input point on one of images
01497    computes parameters of the corresponding
01498    epipolar line on the other image */
01499 CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points,
01500                                          int which_image,
01501                                          const CvMat* fundamental_matrix,
01502                                          CvMat* correspondent_lines );
01503 
01504 /* Triangulation functions */
01505 
01506 CVAPI(void) cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2,
01507                                 CvMat* projPoints1, CvMat* projPoints2,
01508                                 CvMat* points4D);
01509 
01510 CVAPI(void) cvCorrectMatches(CvMat* F, CvMat* points1, CvMat* points2,
01511                              CvMat* new_points1, CvMat* new_points2);
01512 
01513 /* stereo correspondence parameters and functions */
01514 
01515 #define CV_STEREO_BM_NORMALIZED_RESPONSE  0
01516 #define CV_STEREO_BM_XSOBEL               1
01517 
01518 /* Block matching algorithm structure */
01519 typedef struct CvStereoBMState
01520 {
01521     // pre-filtering (normalization of input images)
01522     int preFilterType; // =CV_STEREO_BM_NORMALIZED_RESPONSE now
01523     int preFilterSize; // averaging window size: ~5x5..21x21
01524     int preFilterCap; // the output of pre-filtering is clipped by [-preFilterCap,preFilterCap]
01525 
01526     // correspondence using Sum of Absolute Difference (SAD)
01527     int SADWindowSize; // ~5x5..21x21
01528     int minDisparity;  // minimum disparity (can be negative)
01529     int numberOfDisparities; // maximum disparity - minimum disparity (> 0)
01530 
01531     // post-filtering
01532     int textureThreshold;  // the disparity is only computed for pixels
01533                            // with textured enough neighborhood
01534     int uniquenessRatio;   // accept the computed disparity d* only if
01535                            // SAD(d) >= SAD(d*)*(1 + uniquenessRatio/100.)
01536                            // for any d != d*+/-1 within the search range.
01537     int speckleWindowSize; // disparity variation window
01538     int speckleRange; // acceptable range of variation in window
01539 
01540     int trySmallerWindows; // if 1, the results may be more accurate,
01541                            // at the expense of slower processing 
01542     CvRect roi1, roi2;
01543     int disp12MaxDiff;
01544 
01545     // temporary buffers
01546     CvMat* preFilteredImg0;
01547     CvMat* preFilteredImg1;
01548     CvMat* slidingSumBuf;
01549     CvMat* cost;
01550     CvMat* disp;
01551 }
01552 CvStereoBMState;
01553 
01554 #define CV_STEREO_BM_BASIC 0
01555 #define CV_STEREO_BM_FISH_EYE 1
01556 #define CV_STEREO_BM_NARROW 2
01557 
01558 CVAPI(CvStereoBMState*) cvCreateStereoBMState(int preset CV_DEFAULT(CV_STEREO_BM_BASIC),
01559                                               int numberOfDisparities CV_DEFAULT(0));
01560 
01561 CVAPI(void) cvReleaseStereoBMState( CvStereoBMState** state );
01562 
01563 CVAPI(void) cvFindStereoCorrespondenceBM( const CvArr* left, const CvArr* right,
01564                                           CvArr* disparity, CvStereoBMState* state );
01565     
01566 CVAPI(CvRect) cvGetValidDisparityROI( CvRect roi1, CvRect roi2, int minDisparity,
01567                                       int numberOfDisparities, int SADWindowSize );
01568     
01569 CVAPI(void) cvValidateDisparity( CvArr* disparity, const CvArr* cost,
01570                                  int minDisparity, int numberOfDisparities,
01571                                  int disp12MaxDiff CV_DEFAULT(1) );  
01572 
01573 /* Kolmogorov-Zabin stereo-correspondence algorithm (a.k.a. KZ1) */
01574 #define CV_STEREO_GC_OCCLUDED  SHRT_MAX
01575 
01576 typedef struct CvStereoGCState
01577 {
01578     int Ithreshold;
01579     int interactionRadius;
01580     float K, lambda, lambda1, lambda2;
01581     int occlusionCost;
01582     int minDisparity;
01583     int numberOfDisparities;
01584     int maxIters;
01585 
01586     CvMat* left;
01587     CvMat* right;
01588     CvMat* dispLeft;
01589     CvMat* dispRight;
01590     CvMat* ptrLeft;
01591     CvMat* ptrRight;
01592     CvMat* vtxBuf;
01593     CvMat* edgeBuf;
01594 }
01595 CvStereoGCState;
01596 
01597 CVAPI(CvStereoGCState*) cvCreateStereoGCState( int numberOfDisparities, int maxIters );
01598 CVAPI(void) cvReleaseStereoGCState( CvStereoGCState** state );
01599 
01600 CVAPI(void) cvFindStereoCorrespondenceGC( const CvArr* left, const CvArr* right,
01601                                           CvArr* disparityLeft, CvArr* disparityRight,
01602                                           CvStereoGCState* state,
01603                                           int useDisparityGuess CV_DEFAULT(0) );
01604 
01605 /* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
01606 CVAPI(void)  cvReprojectImageTo3D( const CvArr* disparityImage,
01607                                    CvArr* _3dImage, const CvMat* Q,
01608                                    int handleMissingValues CV_DEFAULT(0) );
01609 
01610 #ifdef __cplusplus
01611 }
01612 #endif
01613 
01614 #ifdef __cplusplus
01615 #ifndef SKIP_INCLUDES // for now only expose old interface to swig
01616 #include "cv.hpp"
01617 #endif // SKIP_INCLUDES
01618 #endif
01619 
01620 /****************************************************************************************\
01621 *                                 Backward compatibility                                 *
01622 \****************************************************************************************/
01623 
01624 #ifndef CV_NO_BACKWARD_COMPATIBILITY
01625 #include "cvcompat.h"
01626 #endif
01627 
01628 #endif