Wondercoll
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
cv.h
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
8 //
9 //
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
21 //
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
25 //
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41 
42 
43 #ifndef _CV_H_
44 #define _CV_H_
45 
46 #ifdef __IPL_H__
47 #define HAVE_IPL
48 #endif
49 
50 #ifndef SKIP_INCLUDES
51  #if defined(_CH_)
52  #pragma package <chopencv>
53  #include <chdl.h>
54  LOAD_CHDL(cv)
55  #endif
56 #endif
57 
58 #include "cxcore.h"
59 #include "cvtypes.h"
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 /****************************************************************************************\
66 * Image Processing *
67 \****************************************************************************************/
68 
69 /* Copies source 2D array inside of the larger destination array and
70  makes a border of the specified type (IPL_BORDER_*) around the copied area. */
73 
74 #define CV_BLUR_NO_SCALE 0
75 #define CV_BLUR 1
76 #define CV_GAUSSIAN 2
77 #define CV_MEDIAN 3
78 #define CV_BILATERAL 4
79 
80 /* Smoothes array (removes noise) */
81 CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
82  int smoothtype CV_DEFAULT(CV_GAUSSIAN),
83  int size1 CV_DEFAULT(3),
84  int size2 CV_DEFAULT(0),
85  double sigma1 CV_DEFAULT(0),
86  double sigma2 CV_DEFAULT(0));
87 
88 /* Convolves the image with the kernel */
89 CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
90  CvPoint anchor CV_DEFAULT(cvPoint(-1,-1)));
91 
92 /* Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y) */
93 CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum,
94  CvArr* sqsum CV_DEFAULT(NULL),
95  CvArr* tilted_sum CV_DEFAULT(NULL));
96 
97 /*
98  Smoothes the input image with gaussian kernel and then down-samples it.
99  dst_width = floor(src_width/2)[+1],
100  dst_height = floor(src_height/2)[+1]
101 */
102 CVAPI(void) cvPyrDown( const CvArr* src, CvArr* dst,
103  int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
104 
105 /*
106  Up-samples image and smoothes the result with gaussian kernel.
107  dst_width = src_width*2,
108  dst_height = src_height*2
109 */
110 CVAPI(void) cvPyrUp( const CvArr* src, CvArr* dst,
111  int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
112 
113 /* Builds pyramid for an image */
115  const CvSize* layer_sizes CV_DEFAULT(0),
116  CvArr* bufarr CV_DEFAULT(0),
117  int calc CV_DEFAULT(1),
118  int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
119 
120 /* Releases pyramid */
121 CVAPI(void) cvReleasePyramid( CvMat*** pyramid, int extra_layers );
122 
123 
124 /* Splits color or grayscale image into multiple connected components
125  of nearly the same color/brightness using modification of Burt algorithm.
126  comp with contain a pointer to sequence (CvSeq)
127  of connected components (CvConnectedComp) */
130  int level, double threshold1,
131  double threshold2 );
132 
133 /* Filters image using meanshift algorithm */
134 CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
135  double sp, double sr, int max_level CV_DEFAULT(1),
137 
138 /* Segments image using seed "markers" */
139 CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
140 
141 #define CV_INPAINT_NS 0
142 #define CV_INPAINT_TELEA 1
143 
144 /* Inpaints the selected region in the image */
145 CVAPI(void) cvInpaint( const CvArr* src, const CvArr* inpaint_mask,
146  CvArr* dst, double inpaintRange, int flags );
147 
148 #define CV_SCHARR -1
149 #define CV_MAX_SOBEL_KSIZE 7
150 
151 /* Calculates an image derivative using generalized Sobel
152  (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
153  Scharr can be used only for the first dx or dy derivative */
154 CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
155  int xorder, int yorder,
156  int aperture_size CV_DEFAULT(3));
157 
158 /* Calculates the image Laplacian: (d2/dx + d2/dy)I */
159 CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
160  int aperture_size CV_DEFAULT(3) );
161 
162 /* Constants for color conversion */
163 #define CV_BGR2BGRA 0
164 #define CV_RGB2RGBA CV_BGR2BGRA
165 
166 #define CV_BGRA2BGR 1
167 #define CV_RGBA2RGB CV_BGRA2BGR
168 
169 #define CV_BGR2RGBA 2
170 #define CV_RGB2BGRA CV_BGR2RGBA
171 
172 #define CV_RGBA2BGR 3
173 #define CV_BGRA2RGB CV_RGBA2BGR
174 
175 #define CV_BGR2RGB 4
176 #define CV_RGB2BGR CV_BGR2RGB
177 
178 #define CV_BGRA2RGBA 5
179 #define CV_RGBA2BGRA CV_BGRA2RGBA
180 
181 #define CV_BGR2GRAY 6
182 #define CV_RGB2GRAY 7
183 #define CV_GRAY2BGR 8
184 #define CV_GRAY2RGB CV_GRAY2BGR
185 #define CV_GRAY2BGRA 9
186 #define CV_GRAY2RGBA CV_GRAY2BGRA
187 #define CV_BGRA2GRAY 10
188 #define CV_RGBA2GRAY 11
189 
190 #define CV_BGR2BGR565 12
191 #define CV_RGB2BGR565 13
192 #define CV_BGR5652BGR 14
193 #define CV_BGR5652RGB 15
194 #define CV_BGRA2BGR565 16
195 #define CV_RGBA2BGR565 17
196 #define CV_BGR5652BGRA 18
197 #define CV_BGR5652RGBA 19
198 
199 #define CV_GRAY2BGR565 20
200 #define CV_BGR5652GRAY 21
201 
202 #define CV_BGR2BGR555 22
203 #define CV_RGB2BGR555 23
204 #define CV_BGR5552BGR 24
205 #define CV_BGR5552RGB 25
206 #define CV_BGRA2BGR555 26
207 #define CV_RGBA2BGR555 27
208 #define CV_BGR5552BGRA 28
209 #define CV_BGR5552RGBA 29
210 
211 #define CV_GRAY2BGR555 30
212 #define CV_BGR5552GRAY 31
213 
214 #define CV_BGR2XYZ 32
215 #define CV_RGB2XYZ 33
216 #define CV_XYZ2BGR 34
217 #define CV_XYZ2RGB 35
218 
219 #define CV_BGR2YCrCb 36
220 #define CV_RGB2YCrCb 37
221 #define CV_YCrCb2BGR 38
222 #define CV_YCrCb2RGB 39
223 
224 #define CV_BGR2HSV 40
225 #define CV_RGB2HSV 41
226 
227 #define CV_BGR2Lab 44
228 #define CV_RGB2Lab 45
229 
230 #define CV_BayerBG2BGR 46
231 #define CV_BayerGB2BGR 47
232 #define CV_BayerRG2BGR 48
233 #define CV_BayerGR2BGR 49
234 
235 #define CV_BayerBG2RGB CV_BayerRG2BGR
236 #define CV_BayerGB2RGB CV_BayerGR2BGR
237 #define CV_BayerRG2RGB CV_BayerBG2BGR
238 #define CV_BayerGR2RGB CV_BayerGB2BGR
239 
240 #define CV_BGR2Luv 50
241 #define CV_RGB2Luv 51
242 #define CV_BGR2HLS 52
243 #define CV_RGB2HLS 53
244 
245 #define CV_HSV2BGR 54
246 #define CV_HSV2RGB 55
247 
248 #define CV_Lab2BGR 56
249 #define CV_Lab2RGB 57
250 #define CV_Luv2BGR 58
251 #define CV_Luv2RGB 59
252 #define CV_HLS2BGR 60
253 #define CV_HLS2RGB 61
254 
255 #define CV_COLORCVT_MAX 100
256 
257 /* Converts input array pixels from one color space to another */
258 CVAPI(void) cvCvtColor( const CvArr* src, CvArr* dst, int code );
259 
260 #define CV_INTER_NN 0
261 #define CV_INTER_LINEAR 1
262 #define CV_INTER_CUBIC 2
263 #define CV_INTER_AREA 3
264 
265 #define CV_WARP_FILL_OUTLIERS 8
266 #define CV_WARP_INVERSE_MAP 16
267 
268 /* Resizes image (input array is resized to fit the destination array) */
269 CVAPI(void) cvResize( const CvArr* src, CvArr* dst,
270  int interpolation CV_DEFAULT( CV_INTER_LINEAR ));
271 
272 /* Warps image with affine transform */
273 CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
274  int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
275  CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
276 
277 /* Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2) */
279  const CvPoint2D32f * dst,
280  CvMat * map_matrix );
281 
282 /* Computes rotation_matrix matrix */
284  double scale, CvMat* map_matrix );
285 
286 /* Warps image with perspective (projective) transform */
287 CVAPI(void) cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
288  int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
289  CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
290 
291 /* Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3) */
293  const CvPoint2D32f* dst,
294  CvMat* map_matrix );
295 
296 /* Performs generic geometric transformation using the specified coordinate maps */
297 CVAPI(void) cvRemap( const CvArr* src, CvArr* dst,
298  const CvArr* mapx, const CvArr* mapy,
299  int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
300  CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
301 
302 /* Converts mapx & mapy from floating-point to integer formats for cvRemap */
303 CVAPI(void) cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
304  CvArr* mapxy, CvArr* mapalpha );
305 
306 /* Performs forward or inverse log-polar image transform */
307 CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst,
308  CvPoint2D32f center, double M,
309  int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
310 
311 #define CV_SHAPE_RECT 0
312 #define CV_SHAPE_CROSS 1
313 #define CV_SHAPE_ELLIPSE 2
314 #define CV_SHAPE_CUSTOM 100
315 
316 /* creates structuring element used for morphological operations */
318  int cols, int rows, int anchor_x, int anchor_y,
319  int shape, int* values CV_DEFAULT(NULL) );
320 
321 /* releases structuring element */
323 
324 /* erodes input image (applies minimum filter) one or more times.
325  If element pointer is NULL, 3x3 rectangular element is used */
326 CVAPI(void) cvErode( const CvArr* src, CvArr* dst,
327  IplConvKernel* element CV_DEFAULT(NULL),
328  int iterations CV_DEFAULT(1) );
329 
330 /* dilates input image (applies maximum filter) one or more times.
331  If element pointer is NULL, 3x3 rectangular element is used */
332 CVAPI(void) cvDilate( const CvArr* src, CvArr* dst,
333  IplConvKernel* element CV_DEFAULT(NULL),
334  int iterations CV_DEFAULT(1) );
335 
336 #define CV_MOP_OPEN 2
337 #define CV_MOP_CLOSE 3
338 #define CV_MOP_GRADIENT 4
339 #define CV_MOP_TOPHAT 5
340 #define CV_MOP_BLACKHAT 6
341 
342 /* Performs complex morphological transformation */
343 CVAPI(void) cvMorphologyEx( const CvArr* src, CvArr* dst,
344  CvArr* temp, IplConvKernel* element,
345  int operation, int iterations CV_DEFAULT(1) );
346 
347 /* Calculates all spatial and central moments up to the 3rd order */
348 CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
349 
350 /* Retrieve particular spatial, central or normalized central moments */
351 CVAPI(double) cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
352 CVAPI(double) cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
354  int x_order, int y_order );
355 
356 /* Calculates 7 Hu's invariants from precalculated spatial and central moments */
358 
359 /*********************************** data sampling **************************************/
360 
361 /* Fetches pixels that belong to the specified line segment and stores them to the buffer.
362  Returns the number of retrieved points. */
363 CVAPI(int) cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
364  int connectivity CV_DEFAULT(8));
365 
366 /* Retrieves the rectangular image region with specified center from the input array.
367  dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
368  Values of pixels with fractional coordinates are retrieved using bilinear interpolation*/
369 CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
370 
371 
372 /* Retrieves quadrangle from the input array.
373  matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b)
374  ( a21 a22 | b2 ) (bilinear interpolation is used to retrieve pixels
375  with fractional coordinates)
376 */
377 CVAPI(void) cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
378  const CvMat* map_matrix );
379 
380 /* Methods for comparing two array */
381 #define CV_TM_SQDIFF 0
382 #define CV_TM_SQDIFF_NORMED 1
383 #define CV_TM_CCORR 2
384 #define CV_TM_CCORR_NORMED 3
385 #define CV_TM_CCOEFF 4
386 #define CV_TM_CCOEFF_NORMED 5
387 
388 /* Measures similarity between template and overlapped windows in the source image
389  and fills the resultant image with the measurements */
390 CVAPI(void) cvMatchTemplate( const CvArr* image, const CvArr* templ,
391  CvArr* result, int method );
392 
393 /* Computes earth mover distance between
394  two weighted point sets (called signatures) */
395 CVAPI(float) cvCalcEMD2( const CvArr* signature1,
397  int distance_type,
398  CvDistanceFunction distance_func CV_DEFAULT(NULL),
399  const CvArr* cost_matrix CV_DEFAULT(NULL),
400  CvArr* flow CV_DEFAULT(NULL),
401  float* lower_bound CV_DEFAULT(NULL),
402  void* userdata CV_DEFAULT(NULL));
403 
404 /****************************************************************************************\
405 * Contours retrieving *
406 \****************************************************************************************/
407 
408 /* Retrieves outer and optionally inner boundaries of white (non-zero) connected
409  components in the black (zero) background */
411  int header_size CV_DEFAULT(sizeof(CvContour)),
412  int mode CV_DEFAULT(CV_RETR_LIST),
413  int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
414  CvPoint offset CV_DEFAULT(cvPoint(0,0)));
415 
416 
417 /* Initalizes contour retrieving process.
418  Calls cvStartFindContours.
419  Calls cvFindNextContour until null pointer is returned
420  or some other condition becomes true.
421  Calls cvEndFindContours at the end. */
423  int header_size CV_DEFAULT(sizeof(CvContour)),
424  int mode CV_DEFAULT(CV_RETR_LIST),
425  int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
426  CvPoint offset CV_DEFAULT(cvPoint(0,0)));
427 
428 /* Retrieves next contour */
430 
431 
432 /* Substitutes the last retrieved contour with the new one
433  (if the substitutor is null, the last retrieved contour is removed from the tree) */
435 
436 
437 /* Releases contour scanner and returns pointer to the first outer contour */
439 
440 /* Approximates a single Freeman chain or a tree of chains to polygonal curves */
441 CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
442  int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
443  double parameter CV_DEFAULT(0),
444  int minimal_perimeter CV_DEFAULT(0),
445  int recursive CV_DEFAULT(0));
446 
447 
448 /* Initalizes Freeman chain reader.
449  The reader is used to iteratively get coordinates of all the chain points.
450  If the Freeman codes should be read as is, a simple sequence reader should be used */
452 
453 /* Retrieves the next chain point */
455 
456 
457 /****************************************************************************************\
458 * Motion Analysis *
459 \****************************************************************************************/
460 
461 /************************************ optical flow ***************************************/
462 
463 /* Calculates optical flow for 2 images using classical Lucas & Kanade algorithm */
464 CVAPI(void) cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr,
466 
467 /* Calculates optical flow for 2 images using block matching algorithm */
468 CVAPI(void) cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr,
471  CvArr* velx, CvArr* vely );
472 
473 /* Calculates Optical flow for 2 images using Horn & Schunck algorithm */
474 CVAPI(void) cvCalcOpticalFlowHS( const CvArr* prev, const CvArr* curr,
475  int use_previous, CvArr* velx, CvArr* vely,
476  double lambda, CvTermCriteria criteria );
477 
478 #define CV_LKFLOW_PYR_A_READY 1
479 #define CV_LKFLOW_PYR_B_READY 2
480 #define CV_LKFLOW_INITIAL_GUESSES 4
481 #define CV_LKFLOW_GET_MIN_EIGENVALS 8
482 
483 /* It is Lucas & Kanade method, modified to use pyramids.
484  Also it does several iterations to get optical flow for
485  every point at every pyramid level.
486  Calculates optical flow between two images for certain set of points (i.e.
487  it is a "sparse" optical flow, which is opposite to the previous 3 methods) */
488 CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr,
492  int count,
493  CvSize win_size,
494  int level,
495  char* status,
496  float* track_error,
497  CvTermCriteria criteria,
498  int flags );
499 
500 
501 /* Modification of a previous sparse optical flow algorithm to calculate
502  affine flow */
503 CVAPI(void) cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr,
504  CvArr* prev_pyr, CvArr* curr_pyr,
505  const CvPoint2D32f* prev_features,
506  CvPoint2D32f* curr_features,
507  float* matrices, int count,
508  CvSize win_size, int level,
509  char* status, float* track_error,
510  CvTermCriteria criteria, int flags );
511 
512 /* Estimate rigid transformation between 2 images or 2 point sets */
513 CVAPI(int) cvEstimateRigidTransform( const CvArr* A, const CvArr* B,
514  CvMat* M, int full_affine );
515 
516 /********************************* motion templates *************************************/
517 
518 /****************************************************************************************\
519 * All the motion template functions work only with single channel images. *
520 * Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S *
521 * Motion history image must have depth IPL_DEPTH_32F, *
522 * Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S, *
523 * Motion orientation image - IPL_DEPTH_32F *
524 * Segmentation mask - IPL_DEPTH_32F *
525 * All the angles are in degrees, all the times are in milliseconds *
526 \****************************************************************************************/
527 
528 /* Updates motion history image given motion silhouette */
529 CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi,
530  double timestamp, double duration );
531 
532 /* Calculates gradient of the motion history image and fills
533  a mask indicating where the gradient is valid */
535  double delta1, double delta2,
536  int aperture_size CV_DEFAULT(3));
537 
538 /* Calculates average motion direction within a selected motion region
539  (region can be selected by setting ROIs and/or by composing a valid gradient mask
540  with the region mask) */
541 CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask,
542  const CvArr* mhi, double timestamp,
543  double duration );
544 
545 /* Splits a motion history image into a few parts corresponding to separate independent motions
546  (e.g. left hand, right hand) */
548  CvMemStorage* storage,
549  double timestamp, double seg_thresh );
550 
551 /*********************** Background statistics accumulation *****************************/
552 
553 /* Adds image to accumulator */
554 CVAPI(void) cvAcc( const CvArr* image, CvArr* sum,
555  const CvArr* mask CV_DEFAULT(NULL) );
556 
557 /* Adds squared image to accumulator */
558 CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum,
559  const CvArr* mask CV_DEFAULT(NULL) );
560 
561 /* Adds a product of two images to accumulator */
562 CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
563  const CvArr* mask CV_DEFAULT(NULL) );
564 
565 /* Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha */
566 CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
567  const CvArr* mask CV_DEFAULT(NULL) );
568 
569 
570 /****************************************************************************************\
571 * Tracking *
572 \****************************************************************************************/
573 
574 /* Implements CAMSHIFT algorithm - determines object position, size and orientation
575  from the object histogram back project (extension of meanshift) */
576 CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window,
577  CvTermCriteria criteria, CvConnectedComp* comp,
578  CvBox2D* box CV_DEFAULT(NULL) );
579 
580 /* Implements MeanShift algorithm - determines object position
581  from the object histogram back project */
582 CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window,
583  CvTermCriteria criteria, CvConnectedComp* comp );
584 
585 /* Creates ConDensation filter state */
586 CVAPI(CvConDensation*) cvCreateConDensation( int dynam_params,
588  int sample_count );
589 
590 /* Releases ConDensation filter state */
591 CVAPI(void) cvReleaseConDensation( CvConDensation** condens );
592 
593 /* Updates ConDensation filter by time (predict future state of the system) */
595 
596 /* Initializes ConDensation filter samples */
598 
599 /* Creates Kalman filter and sets A, B, Q, R and state to some initial values */
600 CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params,
601  int control_params CV_DEFAULT(0));
602 
603 /* Releases Kalman filter state */
604 CVAPI(void) cvReleaseKalman( CvKalman** kalman);
605 
606 /* Updates Kalman filter by time (predicts future state of the system) */
607 CVAPI(const CvMat*) cvKalmanPredict( CvKalman* kalman,
608  const CvMat* control CV_DEFAULT(NULL));
609 
610 /* Updates Kalman filter by measurement
611  (corrects state of the system and internal matrices) */
613 
614 /****************************************************************************************\
615 * Planar subdivisions *
616 \****************************************************************************************/
617 
618 /* Initializes Delaunay triangulation */
620 
621 /* Creates new subdivision */
623  int vtx_size, int quadedge_size,
624  CvMemStorage* storage );
625 
626 /************************* high-level subdivision functions ***************************/
627 
628 /* Simplified Delaunay diagram creation */
630 {
631  CvSubdiv2D* subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D, sizeof(*subdiv),
632  sizeof(CvSubdiv2DPoint), sizeof(CvQuadEdge2D), storage );
633 
634  cvInitSubdivDelaunay2D( subdiv, rect );
635  return subdiv;
636 }
637 
638 
639 /* Inserts new point to the Delaunay triangulation */
641 
642 /* Locates a point within the Delaunay triangulation (finds the edge
643  the point is left to or belongs to, or the triangulation point the given
644  point coinsides with */
648  CvSubdiv2DPoint** vertex CV_DEFAULT(NULL) );
649 
650 /* Calculates Voronoi tesselation (i.e. coordinates of Voronoi points) */
651 CVAPI(void) cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv );
652 
653 
654 /* Removes all Voronoi points from the tesselation */
655 CVAPI(void) cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv );
656 
657 
658 /* Finds the nearest to the given point vertex in subdivision. */
660 
661 
662 /************ Basic quad-edge navigation and operations ************/
663 
665 {
666  return CV_SUBDIV2D_NEXT_EDGE(edge);
667 }
668 
669 
671 {
672  return (edge & ~3) + ((edge + rotate) & 3);
673 }
674 
676 {
677  return edge ^ 2;
678 }
679 
681 {
682  CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
683  edge = e->next[(edge + (int)type) & 3];
684  return (edge & ~3) + ((edge + ((int)type >> 4)) & 3);
685 }
686 
687 
689 {
690  CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
691  return (CvSubdiv2DPoint*)e->pt[edge & 3];
692 }
693 
694 
696 {
697  CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
698  return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3];
699 }
700 
701 
703 {
704  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
705 }
706 
707 
708 /****************************************************************************************\
709 * Contour Processing and Shape Analysis *
710 \****************************************************************************************/
711 
712 #define CV_POLY_APPROX_DP 0
713 
714 /* Approximates a single polygonal curve (contour) or
715  a tree of polygonal curves (contours) */
716 CVAPI(CvSeq*) cvApproxPoly( const void* src_seq,
717  int header_size, CvMemStorage* storage,
718  int method, double parameter,
719  int parameter2 CV_DEFAULT(0));
720 
721 #define CV_DOMINANT_IPAN 1
722 
723 /* Finds high-curvature points of the contour */
725  int method CV_DEFAULT(CV_DOMINANT_IPAN),
726  double parameter1 CV_DEFAULT(0),
727  double parameter2 CV_DEFAULT(0),
728  double parameter3 CV_DEFAULT(0),
729  double parameter4 CV_DEFAULT(0));
730 
731 /* Calculates perimeter of a contour or length of a part of contour */
732 CVAPI(double) cvArcLength( const void* curve,
733  CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
734  int is_closed CV_DEFAULT(-1));
735 #define cvContourPerimeter( contour ) cvArcLength( contour, CV_WHOLE_SEQ, 1 )
736 
737 /* Calculates contour boundning rectangle (update=1) or
738  just retrieves pre-calculated rectangle (update=0) */
739 CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
740 
741 /* Calculates area of a contour or contour segment */
742 CVAPI(double) cvContourArea( const CvArr* contour,
743  CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ));
744 
745 /* Finds minimum area rotated rectangle bounding a set of points */
746 CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points,
747  CvMemStorage* storage CV_DEFAULT(NULL));
748 
749 /* Finds minimum enclosing circle for a set of points */
750 CVAPI(int) cvMinEnclosingCircle( const CvArr* points,
751  CvPoint2D32f* center, float* radius );
752 
753 #define CV_CONTOURS_MATCH_I1 1
754 #define CV_CONTOURS_MATCH_I2 2
755 #define CV_CONTOURS_MATCH_I3 3
756 
757 /* Compares two contours by matching their moments */
758 CVAPI(double) cvMatchShapes( const void* object1, const void* object2,
759  int method, double parameter CV_DEFAULT(0));
760 
761 /* Builds hierarhical representation of a contour */
762 CVAPI(CvContourTree*) cvCreateContourTree( const CvSeq* contour,
763  CvMemStorage* storage,
764  double threshold );
765 
766 /* Reconstruct (completelly or partially) contour a from contour tree */
768  CvMemStorage* storage,
769  CvTermCriteria criteria );
770 
771 /* Compares two contour trees */
772 #define CV_CONTOUR_TREES_MATCH_I1 1
773 
774 CVAPI(double) cvMatchContourTrees( const CvContourTree* tree1,
776  int method, double threshold );
777 
778 /* Calculates histogram of a contour */
779 CVAPI(void) cvCalcPGH( const CvSeq* contour, CvHistogram* hist );
780 
781 #define CV_CLOCKWISE 1
782 #define CV_COUNTER_CLOCKWISE 2
783 
784 /* Calculates exact convex hull of 2d point set */
785 CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
786  void* hull_storage CV_DEFAULT(NULL),
787  int orientation CV_DEFAULT(CV_CLOCKWISE),
788  int return_points CV_DEFAULT(0));
789 
790 /* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */
791 CVAPI(int) cvCheckContourConvexity( const CvArr* contour );
792 
793 /* Finds convexity defects for the contour */
795  CvMemStorage* storage CV_DEFAULT(NULL));
796 
797 /* Fits ellipse into a set of 2d points */
798 CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points );
799 
800 /* Finds minimum rectangle containing two given rectangles */
801 CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
802 
803 /* Finds coordinates of the box vertices */
804 CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
805 
806 /* Initializes sequence header for a matrix (column or row vector) of points -
807  a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */
808 CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat,
809  CvContour* contour_header,
810  CvSeqBlock* block );
811 
812 /* Checks whether the point is inside polygon, outside, on an edge (at a vertex).
813  Returns positive, negative or zero value, correspondingly.
814  Optionally, measures a signed distance between
815  the point and the nearest polygon edge (measure_dist=1) */
816 CVAPI(double) cvPointPolygonTest( const CvArr* contour,
818 
819 /****************************************************************************************\
820 * Histogram functions *
821 \****************************************************************************************/
822 
823 /* Creates new histogram */
825  float** ranges CV_DEFAULT(NULL),
826  int uniform CV_DEFAULT(1));
827 
828 /* Assignes histogram bin ranges */
830  int uniform CV_DEFAULT(1));
831 
832 /* Creates histogram header for array */
834  int dims, int* sizes, CvHistogram* hist,
835  float* data, float** ranges CV_DEFAULT(NULL),
836  int uniform CV_DEFAULT(1));
837 
838 /* Releases histogram */
839 CVAPI(void) cvReleaseHist( CvHistogram** hist );
840 
841 /* Clears all the histogram bins */
842 CVAPI(void) cvClearHist( CvHistogram* hist );
843 
844 /* Finds indices and values of minimum and maximum histogram bins */
845 CVAPI(void) cvGetMinMaxHistValue( const CvHistogram* hist,
846  float* min_value, float* max_value,
847  int* min_idx CV_DEFAULT(NULL),
848  int* max_idx CV_DEFAULT(NULL));
849 
850 
851 /* Normalizes histogram by dividing all bins by sum of the bins, multiplied by <factor>.
852  After that sum of histogram bins is equal to <factor> */
853 CVAPI(void) cvNormalizeHist( CvHistogram* hist, double factor );
854 
855 
856 /* Clear all histogram bins that are below the threshold */
857 CVAPI(void) cvThreshHist( CvHistogram* hist, double threshold );
858 
859 #define CV_COMP_CORREL 0
860 #define CV_COMP_CHISQR 1
861 #define CV_COMP_INTERSECT 2
862 #define CV_COMP_BHATTACHARYYA 3
863 
864 /* Compares two histogram */
865 CVAPI(double) cvCompareHist( const CvHistogram* hist1,
867  int method);
868 
869 /* Copies one histogram to another. Destination histogram is created if
870  the destination pointer is NULL */
871 CVAPI(void) cvCopyHist( const CvHistogram* src, CvHistogram** dst );
872 
873 
874 /* Calculates bayesian probabilistic histograms
875  (each or src and dst is an array of <number> histograms */
877  CvHistogram** dst);
878 
879 /* Calculates array histogram */
880 CVAPI(void) cvCalcArrHist( CvArr** arr, CvHistogram* hist,
881  int accumulate CV_DEFAULT(0),
882  const CvArr* mask CV_DEFAULT(NULL) );
883 
885  int accumulate CV_DEFAULT(0),
886  const CvArr* mask CV_DEFAULT(NULL) )
887 {
888  cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
889 }
890 
891 /* Calculates back project */
892 CVAPI(void) cvCalcArrBackProject( CvArr** image, CvArr* dst,
893  const CvHistogram* hist );
894 #define cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist)
895 
896 
897 /* Does some sort of template matching but compares histograms of
898  template and each window location */
900  CvHistogram* hist, int method,
901  double factor );
902 #define cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \
903  cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
904 
905 
906 /* calculates probabilistic density (divides one histogram by another) */
908  CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
909 
910 /* equalizes histogram of 8-bit single-channel image */
911 CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst );
912 
913 
914 #define CV_VALUE 1
915 #define CV_ARRAY 2
916 /* Updates active contour in order to minimize its cummulative
917  (internal and external) energy. */
918 CVAPI(void) cvSnakeImage( const IplImage* image, CvPoint* points,
919  int length, float* alpha,
920  float* beta, float* gamma,
921  int coeff_usage, CvSize win,
922  CvTermCriteria criteria, int calc_gradient CV_DEFAULT(1));
923 
924 /* Calculates the cooficients of the homography matrix */
926  float* intrinsic, float* homography );
927 
928 #define CV_DIST_MASK_3 3
929 #define CV_DIST_MASK_5 5
930 #define CV_DIST_MASK_PRECISE 0
931 
932 /* Applies distance transform to binary image */
933 CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst,
934  int distance_type CV_DEFAULT(CV_DIST_L2),
935  int mask_size CV_DEFAULT(3),
936  const float* mask CV_DEFAULT(NULL),
937  CvArr* labels CV_DEFAULT(NULL));
938 
939 
940 /* Types of thresholding */
941 #define CV_THRESH_BINARY 0 /* value = value > threshold ? max_value : 0 */
942 #define CV_THRESH_BINARY_INV 1 /* value = value > threshold ? 0 : max_value */
943 #define CV_THRESH_TRUNC 2 /* value = value > threshold ? threshold : value */
944 #define CV_THRESH_TOZERO 3 /* value = value > threshold ? value : 0 */
945 #define CV_THRESH_TOZERO_INV 4 /* value = value > threshold ? 0 : value */
946 #define CV_THRESH_MASK 7
947 
948 #define CV_THRESH_OTSU 8 /* use Otsu algorithm to choose the optimal threshold value;
949  combine the flag with one of the above CV_THRESH_* values */
950 
951 /* Applies fixed-level threshold to grayscale image.
952  This is a basic operation applied before retrieving contours */
953 CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst,
954  double threshold, double max_value,
955  int threshold_type );
956 
957 #define CV_ADAPTIVE_THRESH_MEAN_C 0
958 #define CV_ADAPTIVE_THRESH_GAUSSIAN_C 1
959 
960 /* Applies adaptive threshold to grayscale image.
961  The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
962  CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
963  neighborhood size (3, 5, 7 etc.),
964  and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */
965 CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
966  int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
967  int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
968  int block_size CV_DEFAULT(3),
969  double param1 CV_DEFAULT(5));
970 
971 #define CV_FLOODFILL_FIXED_RANGE (1 << 16)
972 #define CV_FLOODFILL_MASK_ONLY (1 << 17)
973 
974 /* Fills the connected component until the color difference gets large enough */
976  CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)),
977  CvScalar up_diff CV_DEFAULT(cvScalarAll(0)),
978  CvConnectedComp* comp CV_DEFAULT(NULL),
979  int flags CV_DEFAULT(4),
980  CvArr* mask CV_DEFAULT(NULL));
981 
982 /****************************************************************************************\
983 * Feature detection *
984 \****************************************************************************************/
985 
986 #define CV_CANNY_L2_GRADIENT (1 << 31)
987 
988 /* Runs canny edge detector */
989 CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1,
990  double threshold2, int aperture_size CV_DEFAULT(3) );
991 
992 /* Calculates constraint image for corner detection
993  Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy.
994  Applying threshold to the result gives coordinates of corners */
995 CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners,
996  int aperture_size CV_DEFAULT(3) );
997 
998 /* Calculates eigen values and vectors of 2x2
999  gradient covariation matrix at every image pixel */
1001  int block_size, int aperture_size CV_DEFAULT(3) );
1002 
1003 /* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at
1004  every image pixel */
1006  int block_size, int aperture_size CV_DEFAULT(3) );
1007 
1008 /* Harris corner detector:
1009  Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */
1011  int block_size, int aperture_size CV_DEFAULT(3),
1012  double k CV_DEFAULT(0.04) );
1013 
1014 /* Adjust corner position using some sort of gradient search */
1015 CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
1016  int count, CvSize win, CvSize zero_zone,
1017  CvTermCriteria criteria );
1018 
1019 /* Finds a sparse set of points within the selected region
1020  that seem to be easy to track */
1021 CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
1022  CvArr* temp_image, CvPoint2D32f* corners,
1023  int* corner_count, double quality_level,
1024  double min_distance,
1025  const CvArr* mask CV_DEFAULT(NULL),
1026  int block_size CV_DEFAULT(3),
1027  int use_harris CV_DEFAULT(0),
1028  double k CV_DEFAULT(0.04) );
1029 
1030 #define CV_HOUGH_STANDARD 0
1031 #define CV_HOUGH_PROBABILISTIC 1
1032 #define CV_HOUGH_MULTI_SCALE 2
1033 #define CV_HOUGH_GRADIENT 3
1034 
1035 /* Finds lines on binary image using one of several methods.
1036  line_storage is either memory storage or 1 x <max number of lines> CvMat, its
1037  number of columns is changed by the function.
1038  method is one of CV_HOUGH_*;
1039  rho, theta and threshold are used for each of those methods;
1040  param1 ~ line length, param2 ~ line gap - for probabilistic,
1041  param1 ~ srn, param2 ~ stn - for multi-scale */
1042 CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method,
1043  double rho, double theta, int threshold,
1044  double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0));
1045 
1046 /* Finds circles in the image */
1048  int method, double dp, double min_dist,
1049  double param1 CV_DEFAULT(100),
1050  double param2 CV_DEFAULT(100),
1051  int min_radius CV_DEFAULT(0),
1052  int max_radius CV_DEFAULT(0));
1053 
1054 /* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */
1055 CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param,
1056  double reps, double aeps, float* line );
1057 
1058 
1059 
1060 struct CvFeatureTree;
1061 
1062 /* Constructs kd-tree from set of feature descriptors */
1063 CVAPI(struct CvFeatureTree*) cvCreateFeatureTree(CvMat* desc);
1064 
1065 /* Release kd-tree */
1066 CVAPI(void) cvReleaseFeatureTree(struct CvFeatureTree* tr);
1067 
1068 /* Searches kd-tree for k nearest neighbors of given reference points,
1069  searching at most emax leaves. */
1070 CVAPI(void) cvFindFeatures(struct CvFeatureTree* tr, CvMat* desc,
1071  CvMat* results, CvMat* dist, int k CV_DEFAULT(2), int emax CV_DEFAULT(20));
1072 
1073 /* Search kd-tree for all points that are inlier to given rect region. */
1074 CVAPI(int) cvFindFeaturesBoxed(struct CvFeatureTree* tr,
1076  CvMat* results);
1077 
1078 typedef struct CvSURFPoint
1079 {
1082  int size;
1083  float dir;
1084  float hessian;
1085 } CvSURFPoint;
1086 
1088  int size, float dir CV_DEFAULT(0),
1089  float hessian CV_DEFAULT(0))
1090 {
1091  CvSURFPoint kp;
1092  kp.pt = pt;
1093  kp.laplacian = laplacian;
1094  kp.size = size;
1095  kp.dir = dir;
1096  kp.hessian = hessian;
1097  return kp;
1098 }
1099 
1100 typedef struct CvSURFParams
1101 {
1104 
1107 }
1108 CvSURFParams;
1109 
1110 CVAPI(CvSURFParams) cvSURFParams( double hessianThreshold, int extended CV_DEFAULT(0) );
1111 CVAPI(void) cvExtractSURF( const CvArr* img, const CvArr* mask,
1113  CvMemStorage* storage, CvSURFParams params );
1114 
1115 /****************************************************************************************\
1116 * Haar-like Object Detection functions *
1117 \****************************************************************************************/
1118 
1119 /* Loads haar classifier cascade from a directory.
1120  It is obsolete: convert your cascade to xml and use cvLoad instead */
1122  const char* directory, CvSize orig_window_size);
1123 
1125 
1126 #define CV_HAAR_DO_CANNY_PRUNING 1
1127 #define CV_HAAR_SCALE_IMAGE 2
1128 #define CV_HAAR_FIND_BIGGEST_OBJECT 4
1129 #define CV_HAAR_DO_ROUGH_SEARCH 8
1130 
1131 CVAPI(CvSeq*) cvHaarDetectObjects( const CvArr* image,
1133  CvMemStorage* storage, double scale_factor CV_DEFAULT(1.1),
1134  int min_neighbors CV_DEFAULT(3), int flags CV_DEFAULT(0),
1135  CvSize min_size CV_DEFAULT(cvSize(0,0)));
1136 
1137 /* sets images for haar classifier cascade */
1139  const CvArr* sum, const CvArr* sqsum,
1140  const CvArr* tilted_sum, double scale );
1141 
1142 /* runs the cascade on the specified window */
1144  CvPoint pt, int start_stage CV_DEFAULT(0));
1145 
1146 /****************************************************************************************\
1147 * Camera Calibration, Pose Estimation and Stereo *
1148 \****************************************************************************************/
1149 
1150 /* Transforms the input image to compensate lens distortion */
1151 CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst,
1152  const CvMat* camera_matrix,
1153  const CvMat* distortion_coeffs );
1154 
1155 /* Computes transformation map from intrinsic camera parameters
1156  that can used by cvRemap */
1157 CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix,
1158  const CvMat* distortion_coeffs,
1159  CvArr* mapx, CvArr* mapy );
1160 
1161 /* Computes undistortion+rectification map for a head of stereo camera */
1162 CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix,
1164  const CvMat *R, const CvMat* new_camera_matrix,
1165  CvArr* mapx, CvArr* mapy );
1166 
1167 /* Computes the original (undistorted) feature coordinates
1168  from the observed (distorted) coordinates */
1169 CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst,
1170  const CvMat* camera_matrix,
1171  const CvMat* dist_coeffs,
1172  const CvMat* R CV_DEFAULT(0),
1173  const CvMat* P CV_DEFAULT(0));
1174 
1175 /* Converts rotation vector to rotation matrix or vice versa */
1176 CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
1177  CvMat* jacobian CV_DEFAULT(0) );
1178 
1179 #define CV_LMEDS 4
1180 #define CV_RANSAC 8
1181 
1182 /* Finds perspective transformation between the object plane and image (view) plane */
1183 CVAPI(int) cvFindHomography( const CvMat* src_points,
1185  CvMat* homography,
1186  int method CV_DEFAULT(0),
1187  double ransacReprojThreshold CV_DEFAULT(0),
1188  CvMat* mask CV_DEFAULT(0));
1189 
1190 /* Computes RQ decomposition for 3x3 matrices */
1191 CVAPI(void) cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
1192  CvMat *matrixQx CV_DEFAULT(NULL),
1193  CvMat *matrixQy CV_DEFAULT(NULL),
1194  CvMat *matrixQz CV_DEFAULT(NULL),
1195  CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
1196 
1197 /* Computes projection matrix decomposition */
1200  CvMat *rotMatrX CV_DEFAULT(NULL),
1201  CvMat *rotMatrY CV_DEFAULT(NULL),
1202  CvMat *rotMatrZ CV_DEFAULT(NULL),
1203  CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
1204 
1205 /* Computes d(AB)/dA and d(AB)/dB */
1206 CVAPI(void) cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, CvMat* dABdB );
1207 
1208 /* Computes r3 = rodrigues(rodrigues(r2)*rodrigues(r1)),
1209  t3 = rodrigues(r2)*t1 + t2 and the respective derivatives */
1210 CVAPI(void) cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
1211  const CvMat* _rvec2, const CvMat* _tvec2,
1212  CvMat* _rvec3, CvMat* _tvec3,
1213  CvMat* dr3dr1 CV_DEFAULT(0), CvMat* dr3dt1 CV_DEFAULT(0),
1214  CvMat* dr3dr2 CV_DEFAULT(0), CvMat* dr3dt2 CV_DEFAULT(0),
1215  CvMat* dt3dr1 CV_DEFAULT(0), CvMat* dt3dt1 CV_DEFAULT(0),
1216  CvMat* dt3dr2 CV_DEFAULT(0), CvMat* dt3dt2 CV_DEFAULT(0) );
1217 
1218 /* Projects object points to the view plane using
1219  the specified extrinsic and intrinsic camera parameters */
1220 CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
1221  const CvMat* translation_vector, const CvMat* camera_matrix,
1222  const CvMat* distortion_coeffs, CvMat* image_points,
1223  CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL),
1224  CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL),
1225  CvMat* dpddist CV_DEFAULT(NULL),
1226  double aspect_ratio CV_DEFAULT(0));
1227 
1228 /* Finds extrinsic camera parameters from
1229  a few known corresponding point pairs and intrinsic parameters */
1230 CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points,
1231  const CvMat* image_points,
1232  const CvMat* camera_matrix,
1233  const CvMat* distortion_coeffs,
1234  CvMat* rotation_vector,
1235  CvMat* translation_vector );
1236 
1237 /* Computes initial estimate of the intrinsic camera parameters
1238  in case of planar calibration target (e.g. chessboard) */
1239 CVAPI(void) cvInitIntrinsicParams2D( const CvMat* object_points,
1240  const CvMat* image_points,
1241  const CvMat* npoints, CvSize image_size,
1242  CvMat* camera_matrix,
1243  double aspect_ratio CV_DEFAULT(1.) );
1244 
1245 #define CV_CALIB_CB_ADAPTIVE_THRESH 1
1246 #define CV_CALIB_CB_NORMALIZE_IMAGE 2
1247 #define CV_CALIB_CB_FILTER_QUADS 4
1248 
1249 /* Detects corners on a chessboard calibration pattern */
1251  CvPoint2D32f* corners,
1252  int* corner_count CV_DEFAULT(NULL),
1253  int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH+
1255 
1256 /* Draws individual chessboard corners or the whole chessboard detected */
1257 CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
1258  CvPoint2D32f* corners,
1259  int count, int pattern_was_found );
1260 
1261 #define CV_CALIB_USE_INTRINSIC_GUESS 1
1262 #define CV_CALIB_FIX_ASPECT_RATIO 2
1263 #define CV_CALIB_FIX_PRINCIPAL_POINT 4
1264 #define CV_CALIB_ZERO_TANGENT_DIST 8
1265 #define CV_CALIB_FIX_FOCAL_LENGTH 16
1266 #define CV_CALIB_FIX_K1 32
1267 #define CV_CALIB_FIX_K2 64
1268 #define CV_CALIB_FIX_K3 128
1269 
1270 /* Finds intrinsic and extrinsic camera parameters
1271  from a few views of known calibration pattern */
1272 CVAPI(void) cvCalibrateCamera2( const CvMat* object_points,
1273  const CvMat* image_points,
1274  const CvMat* point_counts,
1275  CvSize image_size,
1276  CvMat* camera_matrix,
1277  CvMat* distortion_coeffs,
1278  CvMat* rotation_vectors CV_DEFAULT(NULL),
1279  CvMat* translation_vectors CV_DEFAULT(NULL),
1280  int flags CV_DEFAULT(0) );
1281 
1282 /* Computes various useful characteristics of the camera from the data computed by
1283  cvCalibrateCamera2 */
1284 CVAPI(void) cvCalibrationMatrixValues( const CvMat *camera_matrix,
1285  CvSize image_size,
1286  double aperture_width CV_DEFAULT(0),
1287  double aperture_height CV_DEFAULT(0),
1288  double *fovx CV_DEFAULT(NULL),
1289  double *fovy CV_DEFAULT(NULL),
1290  double *focal_length CV_DEFAULT(NULL),
1291  CvPoint2D64f *principal_point CV_DEFAULT(NULL),
1292  double *pixel_aspect_ratio CV_DEFAULT(NULL));
1293 
1294 #define CV_CALIB_FIX_INTRINSIC 256
1295 #define CV_CALIB_SAME_FOCAL_LENGTH 512
1296 
1297 /* Computes the transformation from one camera coordinate system to another one
1298  from a few correspondent views of the same calibration target. Optionally, calibrates
1299  both cameras */
1300 CVAPI(void) cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1,
1301  const CvMat* image_points2, const CvMat* npoints,
1304  CvSize image_size, CvMat* R, CvMat* T,
1305  CvMat* E CV_DEFAULT(0), CvMat* F CV_DEFAULT(0),
1306  CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
1307  CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6)),
1308  int flags CV_DEFAULT(CV_CALIB_FIX_INTRINSIC) );
1309 
1310 #define CV_CALIB_ZERO_DISPARITY 1024
1311 
1312 /* Computes 3D rotations (+ optional shift) for each camera coordinate system to make both
1313  views parallel (=> to make all the epipolar lines horizontal or vertical) */
1314 CVAPI(void) cvStereoRectify( const CvMat* camera_matrix1, const CvMat* camera_matrix2,
1315  const CvMat* dist_coeffs1, const CvMat* dist_coeffs2,
1316  CvSize image_size, const CvMat* R, const CvMat* T,
1317  CvMat* R1, CvMat* R2, CvMat* P1, CvMat* P2,
1318  CvMat* Q CV_DEFAULT(0),
1319  int flags CV_DEFAULT(CV_CALIB_ZERO_DISPARITY) );
1320 
1321 /* Computes rectification transformations for uncalibrated pair of images using a set
1322  of point correspondences */
1323 CVAPI(int) cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2,
1324  const CvMat* F, CvSize img_size,
1325  CvMat* H1, CvMat* H2,
1326  double threshold CV_DEFAULT(5));
1327 
1329 
1330 /* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
1331 CVAPI(CvPOSITObject*) cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
1332 
1333 
1334 /* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
1335  an object given its model and projection in a weak-perspective case */
1336 CVAPI(void) cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points,
1337  double focal_length, CvTermCriteria criteria,
1338  CvMatr32f rotation_matrix, CvVect32f translation_vector);
1339 
1340 /* Releases CvPOSITObject structure */
1341 CVAPI(void) cvReleasePOSITObject( CvPOSITObject** posit_object );
1342 
1343 /* updates the number of RANSAC iterations */
1344 CVAPI(int) cvRANSACUpdateNumIters( double p, double err_prob,
1345  int model_points, int max_iters );
1346 
1347 CVAPI(void) cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst );
1348 
1349 /* Calculates fundamental matrix given a set of corresponding points */
1350 #define CV_FM_7POINT 1
1351 #define CV_FM_8POINT 2
1352 #define CV_FM_LMEDS_ONLY CV_LMEDS
1353 #define CV_FM_RANSAC_ONLY CV_RANSAC
1354 #define CV_FM_LMEDS CV_LMEDS
1355 #define CV_FM_RANSAC CV_RANSAC
1356 CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
1358  int method CV_DEFAULT(CV_FM_RANSAC),
1359  double param1 CV_DEFAULT(3.), double param2 CV_DEFAULT(0.99),
1360  CvMat* status CV_DEFAULT(NULL) );
1361 
1362 /* For each input point on one of images
1363  computes parameters of the corresponding
1364  epipolar line on the other image */
1365 CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points,
1367  const CvMat* fundamental_matrix,
1369 
1370 /* stereo correspondence parameters and functions */
1371 
1372 #define CV_STEREO_BM_NORMALIZED_RESPONSE 0
1373 
1374 /* Block matching algorithm structure */
1375 typedef struct CvStereoBMState
1376 {
1377  // pre-filtering (normalization of input images)
1378  int preFilterType; // =CV_STEREO_BM_NORMALIZED_RESPONSE now
1379  int preFilterSize; // averaging window size: ~5x5..21x21
1380  int preFilterCap; // the output of pre-filtering is clipped by [-preFilterCap,preFilterCap]
1381 
1382  // correspondence using Sum of Absolute Difference (SAD)
1383  int SADWindowSize; // ~5x5..21x21
1384  int minDisparity; // minimum disparity (can be negative)
1385  int numberOfDisparities; // maximum disparity - minimum disparity (> 0)
1386 
1387  // post-filtering
1388  int textureThreshold; // the disparity is only computed for pixels
1389  // with textured enough neighborhood
1390  int uniquenessRatio; // accept the computed disparity d* only if
1391  // SAD(d) >= SAD(d*)*(1 + uniquenessRatio/100.)
1392  // for any d != d*+/-1 within the search range.
1393  int speckleWindowSize; // disparity variation window
1394  int speckleRange; // acceptable range of variation in window
1395 
1396  // temporary buffers
1400 }
1402 
1403 #define CV_STEREO_BM_BASIC 0
1404 #define CV_STEREO_BM_FISH_EYE 1
1405 #define CV_STEREO_BM_NARROW 2
1406 
1408  int numberOfDisparities CV_DEFAULT(0));
1409 
1411 
1413  CvArr* disparity, CvStereoBMState* state );
1414 
1415 /* Kolmogorov-Zabin stereo-correspondence algorithm (a.k.a. KZ1) */
1416 #define CV_STEREO_GC_OCCLUDED SHRT_MAX
1417 
1418 typedef struct CvStereoGCState
1419 {
1427 
1436 }
1438 
1439 CVAPI(CvStereoGCState*) cvCreateStereoGCState( int numberOfDisparities, int maxIters );
1441 
1442 CVAPI(void) cvFindStereoCorrespondenceGC( const CvArr* left, const CvArr* right,
1444  CvStereoGCState* state,
1445  int useDisparityGuess CV_DEFAULT(0) );
1446 
1447 /* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
1448 CVAPI(void) cvReprojectImageTo3D( const CvArr* disparityImage,
1449  CvArr* _3dImage, const CvMat* Q );
1450 
1451 #ifdef __cplusplus
1452 }
1453 #endif
1454 
1455 #ifdef __cplusplus
1456 #include "cv.hpp"
1457 #endif
1458 
1459 /****************************************************************************************\
1460 * Backward compatibility *
1461 \****************************************************************************************/
1462 
1463 #ifndef CV_NO_BACKWARD_COMPATIBILITY
1464 #include "cvcompat.h"
1465 #endif
1466 
1467 #endif /*_CV_H_*/