00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __OPENCV_LEGACY_HPP__
00043 #define __OPENCV_LEGACY_HPP__
00044
00045 #include "opencv2/imgproc/imgproc.hpp"
00046 #include "opencv2/imgproc/imgproc_c.h"
00047 #include "opencv2/features2d/features2d.hpp"
00048 #include "opencv2/calib3d/calib3d.hpp"
00049
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053
00054 CVAPI(CvSeq*) cvSegmentImage( const CvArr* srcarr, CvArr* dstarr,
00055 double canny_threshold,
00056 double ffill_threshold,
00057 CvMemStorage* storage );
00058
00059
00060
00061
00062
00063 typedef int (CV_CDECL * CvCallback)(int index, void* buffer, void* user_data);
00064 typedef union
00065 {
00066 CvCallback callback;
00067 void* data;
00068 }
00069 CvInput;
00070
00071 #define CV_EIGOBJ_NO_CALLBACK 0
00072 #define CV_EIGOBJ_INPUT_CALLBACK 1
00073 #define CV_EIGOBJ_OUTPUT_CALLBACK 2
00074 #define CV_EIGOBJ_BOTH_CALLBACK 3
00075
00076
00077 CVAPI(void) cvCalcCovarMatrixEx( int nObjects, void* input, int ioFlags,
00078 int ioBufSize, uchar* buffer, void* userData,
00079 IplImage* avg, float* covarMatrix );
00080
00081
00082
00083 CVAPI(void) cvCalcEigenObjects( int nObjects, void* input, void* output,
00084 int ioFlags, int ioBufSize, void* userData,
00085 CvTermCriteria* calcLimit, IplImage* avg,
00086 float* eigVals );
00087
00088
00089 CVAPI(double) cvCalcDecompCoeff( IplImage* obj, IplImage* eigObj, IplImage* avg );
00090
00091
00092 CVAPI(void) cvEigenDecomposite( IplImage* obj, int nEigObjs, void* eigInput,
00093 int ioFlags, void* userData, IplImage* avg,
00094 float* coeffs );
00095
00096
00097 CVAPI(void) cvEigenProjection( void* eigInput, int nEigObjs, int ioFlags,
00098 void* userData, float* coeffs, IplImage* avg,
00099 IplImage* proj );
00100
00101
00102
00103
00104
00105 typedef struct CvImgObsInfo
00106 {
00107 int obs_x;
00108 int obs_y;
00109 int obs_size;
00110 float* obs;
00111
00112 int* state;
00113 int* mix;
00114
00115 } CvImgObsInfo;
00116
00117 typedef CvImgObsInfo Cv1DObsInfo;
00118
00119 typedef struct CvEHMMState
00120 {
00121 int num_mix;
00122 float* mu;
00123 float* inv_var;
00124 float* log_var_val;
00125 float* weight;
00126
00127 } CvEHMMState;
00128
00129 typedef struct CvEHMM
00130 {
00131 int level;
00132 int num_states;
00133 float* transP;
00134 float** obsProb;
00135
00136 union
00137 {
00138 CvEHMMState* state;
00139
00140 struct CvEHMM* ehmm;
00141 } u;
00142
00143 } CvEHMM;
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 CVAPI(CvEHMM*) cvCreate2DHMM( int* stateNumber, int* numMix, int obsSize );
00170
00171
00172 CVAPI(void) cvRelease2DHMM( CvEHMM** hmm );
00173
00174 #define CV_COUNT_OBS(roi, win, delta, numObs ) \
00175 { \
00176 (numObs)->width =((roi)->width -(win)->width +(delta)->width)/(delta)->width; \
00177 (numObs)->height =((roi)->height -(win)->height +(delta)->height)/(delta)->height;\
00178 }
00179
00180
00181 CVAPI(CvImgObsInfo*) cvCreateObsInfo( CvSize numObs, int obsSize );
00182
00183
00184 CVAPI(void) cvReleaseObsInfo( CvImgObsInfo** obs_info );
00185
00186
00187
00188
00189
00190 CVAPI(void) cvImgToObs_DCT( const CvArr* arr, float* obs, CvSize dctSize,
00191 CvSize obsSize, CvSize delta );
00192
00193
00194
00195 CVAPI(void) cvUniformImgSegm( CvImgObsInfo* obs_info, CvEHMM* ehmm );
00196
00197
00198 CVAPI(void) cvInitMixSegm( CvImgObsInfo** obs_info_array,
00199 int num_img, CvEHMM* hmm );
00200
00201
00202
00203 CVAPI(void) cvEstimateHMMStateParams( CvImgObsInfo** obs_info_array,
00204 int num_img, CvEHMM* hmm );
00205
00206
00207
00208 CVAPI(void) cvEstimateTransProb( CvImgObsInfo** obs_info_array,
00209 int num_img, CvEHMM* hmm );
00210
00211
00212
00213 CVAPI(void) cvEstimateObsProb( CvImgObsInfo* obs_info,
00214 CvEHMM* hmm );
00215
00216
00217 CVAPI(float) cvEViterbi( CvImgObsInfo* obs_info, CvEHMM* hmm );
00218
00219
00220
00221
00222
00223
00224 CVAPI(void) cvMixSegmL2( CvImgObsInfo** obs_info_array,
00225 int num_img, CvEHMM* hmm );
00226
00227
00228
00229
00230
00231
00232 CVAPI(void) cvCreateHandMask( CvSeq* hand_points,
00233 IplImage *img_mask, CvRect *roi);
00234
00235
00236 CVAPI(void) cvFindHandRegion (CvPoint3D32f* points, int count,
00237 CvSeq* indexs,
00238 float* line, CvSize2D32f size, int flag,
00239 CvPoint3D32f* center,
00240 CvMemStorage* storage, CvSeq **numbers);
00241
00242
00243 CVAPI(void) cvFindHandRegionA( CvPoint3D32f* points, int count,
00244 CvSeq* indexs,
00245 float* line, CvSize2D32f size, int jc,
00246 CvPoint3D32f* center,
00247 CvMemStorage* storage, CvSeq **numbers);
00248
00249
00250 CVAPI(void) cvCalcImageHomography( float* line, CvPoint3D32f* center,
00251 float* intrinsic, float* homography );
00252
00253
00254
00255
00256
00257
00258 CVAPI(void) icvDrawMosaic( CvSubdiv2D* subdiv, IplImage* src, IplImage* dst );
00259
00260
00261
00262 CVAPI(int) icvSubdiv2DCheck( CvSubdiv2D* subdiv );
00263
00264
00265 CV_INLINE double icvSqDist2D32f( CvPoint2D32f pt1, CvPoint2D32f pt2 )
00266 {
00267 double dx = pt1.x - pt2.x;
00268 double dy = pt1.y - pt2.y;
00269
00270 return dx*dx + dy*dy;
00271 }
00272
00273
00274
00275
00276
00277
00278
00279
00280 #define CV_CURRENT_INT( reader ) (*((int *)(reader).ptr))
00281 #define CV_PREV_INT( reader ) (*((int *)(reader).prev_elem))
00282
00283 #define CV_GRAPH_WEIGHTED_VERTEX_FIELDS() CV_GRAPH_VERTEX_FIELDS()\
00284 float weight;
00285
00286 #define CV_GRAPH_WEIGHTED_EDGE_FIELDS() CV_GRAPH_EDGE_FIELDS()
00287
00288 typedef struct CvGraphWeightedVtx
00289 {
00290 CV_GRAPH_WEIGHTED_VERTEX_FIELDS()
00291 } CvGraphWeightedVtx;
00292
00293 typedef struct CvGraphWeightedEdge
00294 {
00295 CV_GRAPH_WEIGHTED_EDGE_FIELDS()
00296 } CvGraphWeightedEdge;
00297
00298 typedef enum CvGraphWeightType
00299 {
00300 CV_NOT_WEIGHTED,
00301 CV_WEIGHTED_VTX,
00302 CV_WEIGHTED_EDGE,
00303 CV_WEIGHTED_ALL
00304 } CvGraphWeightType;
00305
00306
00307
00308 CVAPI(void) cvCalcPGH( const CvSeq* contour, CvHistogram* hist );
00309
00310 #define CV_DOMINANT_IPAN 1
00311
00312
00313 CVAPI(CvSeq*) cvFindDominantPoints( CvSeq* contour, CvMemStorage* storage,
00314 int method CV_DEFAULT(CV_DOMINANT_IPAN),
00315 double parameter1 CV_DEFAULT(0),
00316 double parameter2 CV_DEFAULT(0),
00317 double parameter3 CV_DEFAULT(0),
00318 double parameter4 CV_DEFAULT(0));
00319
00320
00321
00322
00323
00324
00325 typedef struct CvCliqueFinder
00326 {
00327 CvGraph* graph;
00328 int** adj_matr;
00329 int N;
00330
00331
00332 int k;
00333 int* current_comp;
00334 int** All;
00335
00336 int* ne;
00337 int* ce;
00338 int* fixp;
00339 int* nod;
00340 int* s;
00341 int status;
00342 int best_score;
00343 int weighted;
00344 int weighted_edges;
00345 float best_weight;
00346 float* edge_weights;
00347 float* vertex_weights;
00348 float* cur_weight;
00349 float* cand_weight;
00350
00351 } CvCliqueFinder;
00352
00353 #define CLIQUE_TIME_OFF 2
00354 #define CLIQUE_FOUND 1
00355 #define CLIQUE_END 0
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 #define CV_UNDEF_SC_PARAM 12345 //default value of parameters
00460
00461 #define CV_IDP_BIRCHFIELD_PARAM1 25
00462 #define CV_IDP_BIRCHFIELD_PARAM2 5
00463 #define CV_IDP_BIRCHFIELD_PARAM3 12
00464 #define CV_IDP_BIRCHFIELD_PARAM4 15
00465 #define CV_IDP_BIRCHFIELD_PARAM5 25
00466
00467
00468 #define CV_DISPARITY_BIRCHFIELD 0
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488 CVAPI(void)
00489 cvFindStereoCorrespondence(
00490 const CvArr* leftImage, const CvArr* rightImage,
00491 int mode,
00492 CvArr* dispImage,
00493 int maxDisparity,
00494 double param1 CV_DEFAULT(CV_UNDEF_SC_PARAM),
00495 double param2 CV_DEFAULT(CV_UNDEF_SC_PARAM),
00496 double param3 CV_DEFAULT(CV_UNDEF_SC_PARAM),
00497 double param4 CV_DEFAULT(CV_UNDEF_SC_PARAM),
00498 double param5 CV_DEFAULT(CV_UNDEF_SC_PARAM) );
00499
00500
00501
00502
00503
00504
00505 typedef struct CvStereoLineCoeff
00506 {
00507 double Xcoef;
00508 double XcoefA;
00509 double XcoefB;
00510 double XcoefAB;
00511
00512 double Ycoef;
00513 double YcoefA;
00514 double YcoefB;
00515 double YcoefAB;
00516
00517 double Zcoef;
00518 double ZcoefA;
00519 double ZcoefB;
00520 double ZcoefAB;
00521 }CvStereoLineCoeff;
00522
00523
00524 typedef struct CvCamera
00525 {
00526 float imgSize[2];
00527 float matrix[9];
00528 float distortion[4];
00529
00530 float rotMatr[9];
00531 float transVect[3];
00532
00533 } CvCamera;
00534
00535 typedef struct CvStereoCamera
00536 {
00537 CvCamera* camera[2];
00538 float fundMatr[9];
00539
00540
00541 CvPoint3D32f epipole[2];
00542 CvPoint2D32f quad[2][4];
00543
00544 double coeffs[2][3][3];
00545 CvPoint2D32f border[2][4];
00546 CvSize warpSize;
00547 CvStereoLineCoeff* lineCoeffs;
00548 int needSwapCameras;
00549 float rotMatrix[9];
00550 float transVector[3];
00551 } CvStereoCamera;
00552
00553
00554 typedef struct CvContourOrientation
00555 {
00556 float egvals[2];
00557 float egvects[4];
00558
00559 float max, min;
00560 int imax, imin;
00561 } CvContourOrientation;
00562
00563 #define CV_CAMERA_TO_WARP 1
00564 #define CV_WARP_TO_CAMERA 2
00565
00566 CVAPI(int) icvConvertWarpCoordinates(double coeffs[3][3],
00567 CvPoint2D32f* cameraPoint,
00568 CvPoint2D32f* warpPoint,
00569 int direction);
00570
00571 CVAPI(int) icvGetSymPoint3D( CvPoint3D64f pointCorner,
00572 CvPoint3D64f point1,
00573 CvPoint3D64f point2,
00574 CvPoint3D64f *pointSym2);
00575
00576 CVAPI(void) icvGetPieceLength3D(CvPoint3D64f point1,CvPoint3D64f point2,double* dist);
00577
00578 CVAPI(int) icvCompute3DPoint( double alpha,double betta,
00579 CvStereoLineCoeff* coeffs,
00580 CvPoint3D64f* point);
00581
00582 CVAPI(int) icvCreateConvertMatrVect( double* rotMatr1,
00583 double* transVect1,
00584 double* rotMatr2,
00585 double* transVect2,
00586 double* convRotMatr,
00587 double* convTransVect);
00588
00589 CVAPI(int) icvConvertPointSystem(CvPoint3D64f M2,
00590 CvPoint3D64f* M1,
00591 double* rotMatr,
00592 double* transVect
00593 );
00594
00595 CVAPI(int) icvComputeCoeffForStereo( CvStereoCamera* stereoCamera);
00596
00597 CVAPI(int) icvGetCrossPieceVector(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f v2_start,CvPoint2D32f v2_end,CvPoint2D32f *cross);
00598 CVAPI(int) icvGetCrossLineDirect(CvPoint2D32f p1,CvPoint2D32f p2,float a,float b,float c,CvPoint2D32f* cross);
00599 CVAPI(float) icvDefinePointPosition(CvPoint2D32f point1,CvPoint2D32f point2,CvPoint2D32f point);
00600 CVAPI(int) icvStereoCalibration( int numImages,
00601 int* nums,
00602 CvSize imageSize,
00603 CvPoint2D32f* imagePoints1,
00604 CvPoint2D32f* imagePoints2,
00605 CvPoint3D32f* objectPoints,
00606 CvStereoCamera* stereoparams
00607 );
00608
00609
00610 CVAPI(int) icvComputeRestStereoParams(CvStereoCamera *stereoparams);
00611
00612 CVAPI(void) cvComputePerspectiveMap( const double coeffs[3][3], CvArr* rectMapX, CvArr* rectMapY );
00613
00614 CVAPI(int) icvComCoeffForLine( CvPoint2D64f point1,
00615 CvPoint2D64f point2,
00616 CvPoint2D64f point3,
00617 CvPoint2D64f point4,
00618 double* camMatr1,
00619 double* rotMatr1,
00620 double* transVect1,
00621 double* camMatr2,
00622 double* rotMatr2,
00623 double* transVect2,
00624 CvStereoLineCoeff* coeffs,
00625 int* needSwapCameras);
00626
00627 CVAPI(int) icvGetDirectionForPoint( CvPoint2D64f point,
00628 double* camMatr,
00629 CvPoint3D64f* direct);
00630
00631 CVAPI(int) icvGetCrossLines(CvPoint3D64f point11,CvPoint3D64f point12,
00632 CvPoint3D64f point21,CvPoint3D64f point22,
00633 CvPoint3D64f* midPoint);
00634
00635 CVAPI(int) icvComputeStereoLineCoeffs( CvPoint3D64f pointA,
00636 CvPoint3D64f pointB,
00637 CvPoint3D64f pointCam1,
00638 double gamma,
00639 CvStereoLineCoeff* coeffs);
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651 CVAPI(int) icvGetAngleLine( CvPoint2D64f startPoint, CvSize imageSize,CvPoint2D64f *point1,CvPoint2D64f *point2);
00652
00653 CVAPI(void) icvGetCoefForPiece( CvPoint2D64f p_start,CvPoint2D64f p_end,
00654 double *a,double *b,double *c,
00655 int* result);
00656
00657
00658
00659
00660
00661
00662
00663
00664 CVAPI(void) icvComputeeInfiniteProject1(double* rotMatr,
00665 double* camMatr1,
00666 double* camMatr2,
00667 CvPoint2D32f point1,
00668 CvPoint2D32f *point2);
00669
00670 CVAPI(void) icvComputeeInfiniteProject2(double* rotMatr,
00671 double* camMatr1,
00672 double* camMatr2,
00673 CvPoint2D32f* point1,
00674 CvPoint2D32f point2);
00675
00676 CVAPI(void) icvGetCrossDirectDirect( double* direct1,double* direct2,
00677 CvPoint2D64f *cross,int* result);
00678
00679 CVAPI(void) icvGetCrossPieceDirect( CvPoint2D64f p_start,CvPoint2D64f p_end,
00680 double a,double b,double c,
00681 CvPoint2D64f *cross,int* result);
00682
00683 CVAPI(void) icvGetCrossPiecePiece( CvPoint2D64f p1_start,CvPoint2D64f p1_end,
00684 CvPoint2D64f p2_start,CvPoint2D64f p2_end,
00685 CvPoint2D64f* cross,
00686 int* result);
00687
00688 CVAPI(void) icvGetPieceLength(CvPoint2D64f point1,CvPoint2D64f point2,double* dist);
00689
00690 CVAPI(void) icvGetCrossRectDirect( CvSize imageSize,
00691 double a,double b,double c,
00692 CvPoint2D64f *start,CvPoint2D64f *end,
00693 int* result);
00694
00695 CVAPI(void) icvProjectPointToImage( CvPoint3D64f point,
00696 double* camMatr,double* rotMatr,double* transVect,
00697 CvPoint2D64f* projPoint);
00698
00699 CVAPI(void) icvGetQuadsTransform( CvSize imageSize,
00700 double* camMatr1,
00701 double* rotMatr1,
00702 double* transVect1,
00703 double* camMatr2,
00704 double* rotMatr2,
00705 double* transVect2,
00706 CvSize* warpSize,
00707 double quad1[4][2],
00708 double quad2[4][2],
00709 double* fundMatr,
00710 CvPoint3D64f* epipole1,
00711 CvPoint3D64f* epipole2
00712 );
00713
00714 CVAPI(void) icvGetQuadsTransformStruct( CvStereoCamera* stereoCamera);
00715
00716 CVAPI(void) icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera);
00717
00718 CVAPI(void) icvGetCutPiece( double* areaLineCoef1,double* areaLineCoef2,
00719 CvPoint2D64f epipole,
00720 CvSize imageSize,
00721 CvPoint2D64f* point11,CvPoint2D64f* point12,
00722 CvPoint2D64f* point21,CvPoint2D64f* point22,
00723 int* result);
00724
00725 CVAPI(void) icvGetMiddleAnglePoint( CvPoint2D64f basePoint,
00726 CvPoint2D64f point1,CvPoint2D64f point2,
00727 CvPoint2D64f* midPoint);
00728
00729 CVAPI(void) icvGetNormalDirect(double* direct,CvPoint2D64f point,double* normDirect);
00730
00731 CVAPI(double) icvGetVect(CvPoint2D64f basePoint,CvPoint2D64f point1,CvPoint2D64f point2);
00732
00733 CVAPI(void) icvProjectPointToDirect( CvPoint2D64f point,double* lineCoeff,
00734 CvPoint2D64f* projectPoint);
00735
00736 CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64f point,double* lineCoef,double*dist);
00737
00738 CVAPI(IplImage*) icvCreateIsometricImage( IplImage* src, IplImage* dst,
00739 int desired_depth, int desired_num_channels );
00740
00741 CVAPI(void) cvDeInterlace( const CvArr* frame, CvArr* fieldEven, CvArr* fieldOdd );
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770 typedef struct CvContourTree
00771 {
00772 CV_SEQUENCE_FIELDS()
00773 CvPoint p1;
00774 CvPoint p2;
00775 } CvContourTree;
00776
00777
00778 CVAPI(CvContourTree*) cvCreateContourTree( const CvSeq* contour,
00779 CvMemStorage* storage,
00780 double threshold );
00781
00782
00783 CVAPI(CvSeq*) cvContourFromContourTree( const CvContourTree* tree,
00784 CvMemStorage* storage,
00785 CvTermCriteria criteria );
00786
00787
00788 enum { CV_CONTOUR_TREES_MATCH_I1 = 1 };
00789
00790 CVAPI(double) cvMatchContourTrees( const CvContourTree* tree1,
00791 const CvContourTree* tree2,
00792 int method, double threshold );
00793
00794
00795
00796
00797
00798
00799 CvSeq* cvCalcContoursCorrespondence( const CvSeq* contour1,
00800 const CvSeq* contour2,
00801 CvMemStorage* storage);
00802
00803
00804
00805 CvSeq* cvMorphContours( const CvSeq* contour1, const CvSeq* contour2,
00806 CvSeq* corr, double alpha,
00807 CvMemStorage* storage );
00808
00809
00810
00811
00812
00813
00814 #define CV_VALUE 1
00815 #define CV_ARRAY 2
00816
00817
00818 CVAPI(void) cvSnakeImage( const IplImage* image, CvPoint* points,
00819 int length, float* alpha,
00820 float* beta, float* gamma,
00821 int coeff_usage, CvSize win,
00822 CvTermCriteria criteria, int calc_gradient CV_DEFAULT(1));
00823
00824
00825
00826
00827
00828 #define CV_GLCM_OPTIMIZATION_NONE -2
00829 #define CV_GLCM_OPTIMIZATION_LUT -1
00830 #define CV_GLCM_OPTIMIZATION_HISTOGRAM 0
00831
00832 #define CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST 10
00833 #define CV_GLCMDESC_OPTIMIZATION_ALLOWTRIPLENEST 11
00834 #define CV_GLCMDESC_OPTIMIZATION_HISTOGRAM 4
00835
00836 #define CV_GLCMDESC_ENTROPY 0
00837 #define CV_GLCMDESC_ENERGY 1
00838 #define CV_GLCMDESC_HOMOGENITY 2
00839 #define CV_GLCMDESC_CONTRAST 3
00840 #define CV_GLCMDESC_CLUSTERTENDENCY 4
00841 #define CV_GLCMDESC_CLUSTERSHADE 5
00842 #define CV_GLCMDESC_CORRELATION 6
00843 #define CV_GLCMDESC_CORRELATIONINFO1 7
00844 #define CV_GLCMDESC_CORRELATIONINFO2 8
00845 #define CV_GLCMDESC_MAXIMUMPROBABILITY 9
00846
00847 #define CV_GLCM_ALL 0
00848 #define CV_GLCM_GLCM 1
00849 #define CV_GLCM_DESC 2
00850
00851 typedef struct CvGLCM CvGLCM;
00852
00853 CVAPI(CvGLCM*) cvCreateGLCM( const IplImage* srcImage,
00854 int stepMagnitude,
00855 const int* stepDirections CV_DEFAULT(0),
00856 int numStepDirections CV_DEFAULT(0),
00857 int optimizationType CV_DEFAULT(CV_GLCM_OPTIMIZATION_NONE));
00858
00859 CVAPI(void) cvReleaseGLCM( CvGLCM** GLCM, int flag CV_DEFAULT(CV_GLCM_ALL));
00860
00861 CVAPI(void) cvCreateGLCMDescriptors( CvGLCM* destGLCM,
00862 int descriptorOptimizationType
00863 CV_DEFAULT(CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST));
00864
00865 CVAPI(double) cvGetGLCMDescriptor( CvGLCM* GLCM, int step, int descriptor );
00866
00867 CVAPI(void) cvGetGLCMDescriptorStatistics( CvGLCM* GLCM, int descriptor,
00868 double* average, double* standardDeviation );
00869
00870 CVAPI(IplImage*) cvCreateGLCMImage( CvGLCM* GLCM, int step );
00871
00872
00873
00874
00875
00876
00877 typedef struct CvFaceTracker CvFaceTracker;
00878
00879 #define CV_NUM_FACE_ELEMENTS 3
00880 enum CV_FACE_ELEMENTS
00881 {
00882 CV_FACE_MOUTH = 0,
00883 CV_FACE_LEFT_EYE = 1,
00884 CV_FACE_RIGHT_EYE = 2
00885 };
00886
00887 CVAPI(CvFaceTracker*) cvInitFaceTracker(CvFaceTracker* pFaceTracking, const IplImage* imgGray,
00888 CvRect* pRects, int nRects);
00889 CVAPI(int) cvTrackFace( CvFaceTracker* pFaceTracker, IplImage* imgGray,
00890 CvRect* pRects, int nRects,
00891 CvPoint* ptRotate, double* dbAngleRotate);
00892 CVAPI(void) cvReleaseFaceTracker(CvFaceTracker** ppFaceTracker);
00893
00894
00895 typedef struct CvFace
00896 {
00897 CvRect MouthRect;
00898 CvRect LeftEyeRect;
00899 CvRect RightEyeRect;
00900 } CvFaceData;
00901
00902 CvSeq * cvFindFace(IplImage * Image,CvMemStorage* storage);
00903 CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* storage);
00904
00905
00906
00907
00908
00909
00910 typedef unsigned char CvBool;
00911
00912 typedef struct
00913 {
00914 int id;
00915 CvPoint2D32f p;
00916 } Cv3dTracker2dTrackedObject;
00917
00918 CV_INLINE Cv3dTracker2dTrackedObject cv3dTracker2dTrackedObject(int id, CvPoint2D32f p)
00919 {
00920 Cv3dTracker2dTrackedObject r;
00921 r.id = id;
00922 r.p = p;
00923 return r;
00924 }
00925
00926 typedef struct
00927 {
00928 int id;
00929 CvPoint3D32f p;
00930 } Cv3dTrackerTrackedObject;
00931
00932 CV_INLINE Cv3dTrackerTrackedObject cv3dTrackerTrackedObject(int id, CvPoint3D32f p)
00933 {
00934 Cv3dTrackerTrackedObject r;
00935 r.id = id;
00936 r.p = p;
00937 return r;
00938 }
00939
00940 typedef struct
00941 {
00942 CvBool valid;
00943 float mat[4][4];
00944 CvPoint2D32f principal_point;
00945
00946 } Cv3dTrackerCameraInfo;
00947
00948 typedef struct
00949 {
00950 CvPoint2D32f principal_point;
00951 float focal_length[2];
00952 float distortion[4];
00953 } Cv3dTrackerCameraIntrinsics;
00954
00955 CVAPI(CvBool) cv3dTrackerCalibrateCameras(int num_cameras,
00956 const Cv3dTrackerCameraIntrinsics camera_intrinsics[],
00957 CvSize etalon_size,
00958 float square_size,
00959 IplImage *samples[],
00960 Cv3dTrackerCameraInfo camera_info[]);
00961
00962 CVAPI(int) cv3dTrackerLocateObjects(int num_cameras, int num_objects,
00963 const Cv3dTrackerCameraInfo camera_info[],
00964 const Cv3dTracker2dTrackedObject tracking_info[],
00965 Cv3dTrackerTrackedObject tracked_objects[]);
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979 typedef enum CvLeeParameters
00980 {
00981 CV_LEE_INT = 0,
00982 CV_LEE_FLOAT = 1,
00983 CV_LEE_DOUBLE = 2,
00984 CV_LEE_AUTO = -1,
00985 CV_LEE_ERODE = 0,
00986 CV_LEE_ZOOM = 1,
00987 CV_LEE_NON = 2
00988 } CvLeeParameters;
00989
00990 #define CV_NEXT_VORONOISITE2D( SITE ) ((SITE)->edge[0]->site[((SITE)->edge[0]->site[0] == (SITE))])
00991 #define CV_PREV_VORONOISITE2D( SITE ) ((SITE)->edge[1]->site[((SITE)->edge[1]->site[0] == (SITE))])
00992 #define CV_FIRST_VORONOIEDGE2D( SITE ) ((SITE)->edge[0])
00993 #define CV_LAST_VORONOIEDGE2D( SITE ) ((SITE)->edge[1])
00994 #define CV_NEXT_VORONOIEDGE2D( EDGE, SITE ) ((EDGE)->next[(EDGE)->site[0] != (SITE)])
00995 #define CV_PREV_VORONOIEDGE2D( EDGE, SITE ) ((EDGE)->next[2 + ((EDGE)->site[0] != (SITE))])
00996 #define CV_VORONOIEDGE2D_BEGINNODE( EDGE, SITE ) ((EDGE)->node[((EDGE)->site[0] != (SITE))])
00997 #define CV_VORONOIEDGE2D_ENDNODE( EDGE, SITE ) ((EDGE)->node[((EDGE)->site[0] == (SITE))])
00998 #define CV_TWIN_VORONOISITE2D( SITE, EDGE ) ( (EDGE)->site[((EDGE)->site[0] == (SITE))])
00999
01000 #define CV_VORONOISITE2D_FIELDS() \
01001 struct CvVoronoiNode2D *node[2]; \
01002 struct CvVoronoiEdge2D *edge[2];
01003
01004 typedef struct CvVoronoiSite2D
01005 {
01006 CV_VORONOISITE2D_FIELDS()
01007 struct CvVoronoiSite2D *next[2];
01008 } CvVoronoiSite2D;
01009
01010 #define CV_VORONOIEDGE2D_FIELDS() \
01011 struct CvVoronoiNode2D *node[2]; \
01012 struct CvVoronoiSite2D *site[2]; \
01013 struct CvVoronoiEdge2D *next[4];
01014
01015 typedef struct CvVoronoiEdge2D
01016 {
01017 CV_VORONOIEDGE2D_FIELDS()
01018 } CvVoronoiEdge2D;
01019
01020 #define CV_VORONOINODE2D_FIELDS() \
01021 CV_SET_ELEM_FIELDS(CvVoronoiNode2D) \
01022 CvPoint2D32f pt; \
01023 float radius;
01024
01025 typedef struct CvVoronoiNode2D
01026 {
01027 CV_VORONOINODE2D_FIELDS()
01028 } CvVoronoiNode2D;
01029
01030 #define CV_VORONOIDIAGRAM2D_FIELDS() \
01031 CV_GRAPH_FIELDS() \
01032 CvSet *sites;
01033
01034 typedef struct CvVoronoiDiagram2D
01035 {
01036 CV_VORONOIDIAGRAM2D_FIELDS()
01037 } CvVoronoiDiagram2D;
01038
01039
01040 CVAPI(int) cvVoronoiDiagramFromContour(CvSeq* ContourSeq,
01041 CvVoronoiDiagram2D** VoronoiDiagram,
01042 CvMemStorage* VoronoiStorage,
01043 CvLeeParameters contour_type CV_DEFAULT(CV_LEE_INT),
01044 int contour_orientation CV_DEFAULT(-1),
01045 int attempt_number CV_DEFAULT(10));
01046
01047
01048 CVAPI(int) cvVoronoiDiagramFromImage(IplImage* pImage,
01049 CvSeq** ContourSeq,
01050 CvVoronoiDiagram2D** VoronoiDiagram,
01051 CvMemStorage* VoronoiStorage,
01052 CvLeeParameters regularization_method CV_DEFAULT(CV_LEE_NON),
01053 float approx_precision CV_DEFAULT(CV_LEE_AUTO));
01054
01055
01056 CVAPI(void) cvReleaseVoronoiStorage(CvVoronoiDiagram2D* VoronoiDiagram,
01057 CvMemStorage** pVoronoiStorage);
01058
01059
01060
01061 struct CvLCMEdge;
01062 struct CvLCMNode;
01063
01064 typedef struct CvLCMEdge
01065 {
01066 CV_GRAPH_EDGE_FIELDS()
01067 CvSeq* chain;
01068 float width;
01069 int index1;
01070 int index2;
01071 } CvLCMEdge;
01072
01073 typedef struct CvLCMNode
01074 {
01075 CV_GRAPH_VERTEX_FIELDS()
01076 CvContour* contour;
01077 } CvLCMNode;
01078
01079
01080
01081 CVAPI(CvGraph*) cvLinearContorModelFromVoronoiDiagram(CvVoronoiDiagram2D* VoronoiDiagram,
01082 float maxWidth);
01083
01084
01085 CVAPI(int) cvReleaseLinearContorModelStorage(CvGraph** Graph);
01086
01087
01088
01089
01090 CVAPI(void) cvInitPerspectiveTransform( CvSize size, const CvPoint2D32f vertex[4], double matrix[3][3],
01091 CvArr* rectMap );
01092
01093
01094
01095
01096
01097
01098
01099 typedef struct CvMatrix3
01100 {
01101 float m[3][3];
01102 } CvMatrix3;
01103
01104
01105
01106
01107
01108 CVAPI(void) cvMakeScanlines( const CvMatrix3* matrix, CvSize img_size,
01109 int* scanlines1, int* scanlines2,
01110 int* lengths1, int* lengths2,
01111 int* line_count );
01112
01113
01114
01115 CVAPI(void) cvPreWarpImage( int line_count,
01116 IplImage* img,
01117 uchar* dst,
01118 int* dst_nums,
01119 int* scanlines);
01120
01121
01122
01123 CVAPI(void) cvFindRuns( int line_count,
01124 uchar* prewarp1,
01125 uchar* prewarp2,
01126 int* line_lengths1,
01127 int* line_lengths2,
01128 int* runs1,
01129 int* runs2,
01130 int* num_runs1,
01131 int* num_runs2);
01132
01133
01134 CVAPI(void) cvDynamicCorrespondMulti( int line_count,
01135 int* first,
01136 int* first_runs,
01137 int* second,
01138 int* second_runs,
01139 int* first_corr,
01140 int* second_corr);
01141
01142
01143 CVAPI(void) cvMakeAlphaScanlines( int* scanlines1,
01144 int* scanlines2,
01145 int* scanlinesA,
01146 int* lengths,
01147 int line_count,
01148 float alpha);
01149
01150
01151
01152 CVAPI(void) cvMorphEpilinesMulti( int line_count,
01153 uchar* first_pix,
01154 int* first_num,
01155 uchar* second_pix,
01156 int* second_num,
01157 uchar* dst_pix,
01158 int* dst_num,
01159 float alpha,
01160 int* first,
01161 int* first_runs,
01162 int* second,
01163 int* second_runs,
01164 int* first_corr,
01165 int* second_corr);
01166
01167
01168
01169 CVAPI(void) cvPostWarpImage( int line_count,
01170 uchar* src,
01171 int* src_nums,
01172 IplImage* img,
01173 int* scanlines);
01174
01175
01176 CVAPI(void) cvDeleteMoire( IplImage* img );
01177
01178
01179 typedef struct CvConDensation
01180 {
01181 int MP;
01182 int DP;
01183 float* DynamMatr;
01184 float* State;
01185 int SamplesNum;
01186 float** flSamples;
01187 float** flNewSamples;
01188 float* flConfidence;
01189 float* flCumulative;
01190 float* Temp;
01191 float* RandomSample;
01192 struct CvRandState* RandS;
01193 } CvConDensation;
01194
01195
01196 CVAPI(CvConDensation*) cvCreateConDensation( int dynam_params,
01197 int measure_params,
01198 int sample_count );
01199
01200
01201 CVAPI(void) cvReleaseConDensation( CvConDensation** condens );
01202
01203
01204 CVAPI(void) cvConDensUpdateByTime( CvConDensation* condens);
01205
01206
01207 CVAPI(void) cvConDensInitSampleSet( CvConDensation* condens, CvMat* lower_bound, CvMat* upper_bound );
01208
01209 CV_INLINE int iplWidth( const IplImage* img )
01210 {
01211 return !img ? 0 : !img->roi ? img->width : img->roi->width;
01212 }
01213
01214 CV_INLINE int iplHeight( const IplImage* img )
01215 {
01216 return !img ? 0 : !img->roi ? img->height : img->roi->height;
01217 }
01218
01219 #ifdef __cplusplus
01220 }
01221 #endif
01222
01223 #ifdef __cplusplus
01224
01225
01226
01227
01228
01229 typedef enum CvCalibEtalonType
01230 {
01231 CV_CALIB_ETALON_USER = -1,
01232 CV_CALIB_ETALON_CHESSBOARD = 0,
01233 CV_CALIB_ETALON_CHECKERBOARD = CV_CALIB_ETALON_CHESSBOARD
01234 }
01235 CvCalibEtalonType;
01236
01237 class CV_EXPORTS CvCalibFilter
01238 {
01239 public:
01240
01241 CvCalibFilter();
01242 virtual ~CvCalibFilter();
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253 virtual bool
01254 SetEtalon( CvCalibEtalonType etalonType, double* etalonParams,
01255 int pointCount = 0, CvPoint2D32f* points = 0 );
01256
01257
01258 virtual CvCalibEtalonType
01259 GetEtalon( int* paramCount = 0, const double** etalonParams = 0,
01260 int* pointCount = 0, const CvPoint2D32f** etalonPoints = 0 ) const;
01261
01262
01263 virtual void SetCameraCount( int cameraCount );
01264
01265
01266 int GetCameraCount() const { return cameraCount; }
01267
01268
01269 virtual bool SetFrames( int totalFrames );
01270
01271
01272 virtual void Stop( bool calibrate = false );
01273
01274
01275 bool IsCalibrated() const { return isCalibrated; }
01276
01277
01278
01279
01280 virtual bool FindEtalon( IplImage** imgs );
01281
01282
01283 virtual bool FindEtalon( CvMat** imgs );
01284
01285
01286
01287 virtual bool Push( const CvPoint2D32f** points = 0 );
01288
01289
01290
01291 virtual int GetFrameCount( int* framesTotal = 0 ) const;
01292
01293
01294
01295 virtual const CvCamera* GetCameraParams( int idx = 0 ) const;
01296
01297 virtual const CvStereoCamera* GetStereoParams() const;
01298
01299
01300 virtual bool SetCameraParams( CvCamera* params );
01301
01302
01303 virtual bool SaveCameraParams( const char* filename );
01304
01305
01306 virtual bool LoadCameraParams( const char* filename );
01307
01308
01309 virtual bool Undistort( IplImage** src, IplImage** dst );
01310
01311
01312 virtual bool Undistort( CvMat** src, CvMat** dst );
01313
01314
01315
01316 virtual bool GetLatestPoints( int idx, CvPoint2D32f** pts,
01317 int* count, bool* found );
01318
01319
01320 virtual void DrawPoints( IplImage** dst );
01321
01322
01323 virtual void DrawPoints( CvMat** dst );
01324
01325 virtual bool Rectify( IplImage** srcarr, IplImage** dstarr );
01326 virtual bool Rectify( CvMat** srcarr, CvMat** dstarr );
01327
01328 protected:
01329
01330 enum { MAX_CAMERAS = 3 };
01331
01332
01333 CvCalibEtalonType etalonType;
01334 int etalonParamCount;
01335 double* etalonParams;
01336 int etalonPointCount;
01337 CvPoint2D32f* etalonPoints;
01338 CvSize imgSize;
01339 CvMat* grayImg;
01340 CvMat* tempImg;
01341 CvMemStorage* storage;
01342
01343
01344 int cameraCount;
01345 CvCamera cameraParams[MAX_CAMERAS];
01346 CvStereoCamera stereo;
01347 CvPoint2D32f* points[MAX_CAMERAS];
01348 CvMat* undistMap[MAX_CAMERAS][2];
01349 CvMat* undistImg;
01350 int latestCounts[MAX_CAMERAS];
01351 CvPoint2D32f* latestPoints[MAX_CAMERAS];
01352 CvMat* rectMap[MAX_CAMERAS][2];
01353
01354
01355
01356
01357 int maxPoints;
01358 int framesTotal;
01359 int framesAccepted;
01360 bool isCalibrated;
01361 };
01362
01363 #include <iosfwd>
01364 #include <limits>
01365
01366 class CV_EXPORTS CvImage
01367 {
01368 public:
01369 CvImage() : image(0), refcount(0) {}
01370 CvImage( CvSize size, int depth, int channels )
01371 {
01372 image = cvCreateImage( size, depth, channels );
01373 refcount = image ? new int(1) : 0;
01374 }
01375
01376 CvImage( IplImage* img ) : image(img)
01377 {
01378 refcount = image ? new int(1) : 0;
01379 }
01380
01381 CvImage( const CvImage& img ) : image(img.image), refcount(img.refcount)
01382 {
01383 if( refcount ) ++(*refcount);
01384 }
01385
01386 CvImage( const char* filename, const char* imgname=0, int color=-1 ) : image(0), refcount(0)
01387 { load( filename, imgname, color ); }
01388
01389 CvImage( CvFileStorage* fs, const char* mapname, const char* imgname ) : image(0), refcount(0)
01390 { read( fs, mapname, imgname ); }
01391
01392 CvImage( CvFileStorage* fs, const char* seqname, int idx ) : image(0), refcount(0)
01393 { read( fs, seqname, idx ); }
01394
01395 ~CvImage()
01396 {
01397 if( refcount && !(--*refcount) )
01398 {
01399 cvReleaseImage( &image );
01400 delete refcount;
01401 }
01402 }
01403
01404 CvImage clone() { return CvImage(image ? cvCloneImage(image) : 0); }
01405
01406 void create( CvSize size, int depth, int channels )
01407 {
01408 if( !image || !refcount ||
01409 image->width != size.width || image->height != size.height ||
01410 image->depth != depth || image->nChannels != channels )
01411 attach( cvCreateImage( size, depth, channels ));
01412 }
01413
01414 void release() { detach(); }
01415 void clear() { detach(); }
01416
01417 void attach( IplImage* img, bool use_refcount=true )
01418 {
01419 if( refcount && --*refcount == 0 )
01420 {
01421 cvReleaseImage( &image );
01422 delete refcount;
01423 }
01424 image = img;
01425 refcount = use_refcount && image ? new int(1) : 0;
01426 }
01427
01428 void detach()
01429 {
01430 if( refcount && --*refcount == 0 )
01431 {
01432 cvReleaseImage( &image );
01433 delete refcount;
01434 }
01435 image = 0;
01436 refcount = 0;
01437 }
01438
01439 bool load( const char* filename, const char* imgname=0, int color=-1 );
01440 bool read( CvFileStorage* fs, const char* mapname, const char* imgname );
01441 bool read( CvFileStorage* fs, const char* seqname, int idx );
01442 void save( const char* filename, const char* imgname, const int* params=0 );
01443 void write( CvFileStorage* fs, const char* imgname );
01444
01445 void show( const char* window_name );
01446 bool is_valid() { return image != 0; }
01447
01448 int width() const { return image ? image->width : 0; }
01449 int height() const { return image ? image->height : 0; }
01450
01451 CvSize size() const { return image ? cvSize(image->width, image->height) : cvSize(0,0); }
01452
01453 CvSize roi_size() const
01454 {
01455 return !image ? cvSize(0,0) :
01456 !image->roi ? cvSize(image->width,image->height) :
01457 cvSize(image->roi->width, image->roi->height);
01458 }
01459
01460 CvRect roi() const
01461 {
01462 return !image ? cvRect(0,0,0,0) :
01463 !image->roi ? cvRect(0,0,image->width,image->height) :
01464 cvRect(image->roi->xOffset,image->roi->yOffset,
01465 image->roi->width,image->roi->height);
01466 }
01467
01468 int coi() const { return !image || !image->roi ? 0 : image->roi->coi; }
01469
01470 void set_roi(CvRect roi) { cvSetImageROI(image,roi); }
01471 void reset_roi() { cvResetImageROI(image); }
01472 void set_coi(int coi) { cvSetImageCOI(image,coi); }
01473 int depth() const { return image ? image->depth : 0; }
01474 int channels() const { return image ? image->nChannels : 0; }
01475 int pix_size() const { return image ? ((image->depth & 255)>>3)*image->nChannels : 0; }
01476
01477 uchar* data() { return image ? (uchar*)image->imageData : 0; }
01478 const uchar* data() const { return image ? (const uchar*)image->imageData : 0; }
01479 int step() const { return image ? image->widthStep : 0; }
01480 int origin() const { return image ? image->origin : 0; }
01481
01482 uchar* roi_row(int y)
01483 {
01484 assert(0<=y);
01485 assert(!image ?
01486 1 : image->roi ?
01487 y<image->roi->height : y<image->height);
01488
01489 return !image ? 0 :
01490 !image->roi ?
01491 (uchar*)(image->imageData + y*image->widthStep) :
01492 (uchar*)(image->imageData + (y+image->roi->yOffset)*image->widthStep +
01493 image->roi->xOffset*((image->depth & 255)>>3)*image->nChannels);
01494 }
01495
01496 const uchar* roi_row(int y) const
01497 {
01498 assert(0<=y);
01499 assert(!image ?
01500 1 : image->roi ?
01501 y<image->roi->height : y<image->height);
01502
01503 return !image ? 0 :
01504 !image->roi ?
01505 (const uchar*)(image->imageData + y*image->widthStep) :
01506 (const uchar*)(image->imageData + (y+image->roi->yOffset)*image->widthStep +
01507 image->roi->xOffset*((image->depth & 255)>>3)*image->nChannels);
01508 }
01509
01510 operator const IplImage* () const { return image; }
01511 operator IplImage* () { return image; }
01512
01513 CvImage& operator = (const CvImage& img)
01514 {
01515 if( img.refcount )
01516 ++*img.refcount;
01517 if( refcount && !(--*refcount) )
01518 cvReleaseImage( &image );
01519 image=img.image;
01520 refcount=img.refcount;
01521 return *this;
01522 }
01523
01524 protected:
01525 IplImage* image;
01526 int* refcount;
01527 };
01528
01529
01530 class CV_EXPORTS CvMatrix
01531 {
01532 public:
01533 CvMatrix() : matrix(0) {}
01534 CvMatrix( int rows, int cols, int type )
01535 { matrix = cvCreateMat( rows, cols, type ); }
01536
01537 CvMatrix( int rows, int cols, int type, CvMat* hdr,
01538 void* data=0, int step=CV_AUTOSTEP )
01539 { matrix = cvInitMatHeader( hdr, rows, cols, type, data, step ); }
01540
01541 CvMatrix( int rows, int cols, int type, CvMemStorage* storage, bool alloc_data=true );
01542
01543 CvMatrix( int rows, int cols, int type, void* data, int step=CV_AUTOSTEP )
01544 { matrix = cvCreateMatHeader( rows, cols, type );
01545 cvSetData( matrix, data, step ); }
01546
01547 CvMatrix( CvMat* m )
01548 { matrix = m; }
01549
01550 CvMatrix( const CvMatrix& m )
01551 {
01552 matrix = m.matrix;
01553 addref();
01554 }
01555
01556 CvMatrix( const char* filename, const char* matname=0, int color=-1 ) : matrix(0)
01557 { load( filename, matname, color ); }
01558
01559 CvMatrix( CvFileStorage* fs, const char* mapname, const char* matname ) : matrix(0)
01560 { read( fs, mapname, matname ); }
01561
01562 CvMatrix( CvFileStorage* fs, const char* seqname, int idx ) : matrix(0)
01563 { read( fs, seqname, idx ); }
01564
01565 ~CvMatrix()
01566 {
01567 release();
01568 }
01569
01570 CvMatrix clone() { return CvMatrix(matrix ? cvCloneMat(matrix) : 0); }
01571
01572 void set( CvMat* m, bool add_ref )
01573 {
01574 release();
01575 matrix = m;
01576 if( add_ref )
01577 addref();
01578 }
01579
01580 void create( int rows, int cols, int type )
01581 {
01582 if( !matrix || !matrix->refcount ||
01583 matrix->rows != rows || matrix->cols != cols ||
01584 CV_MAT_TYPE(matrix->type) != type )
01585 set( cvCreateMat( rows, cols, type ), false );
01586 }
01587
01588 void addref() const
01589 {
01590 if( matrix )
01591 {
01592 if( matrix->hdr_refcount )
01593 ++matrix->hdr_refcount;
01594 else if( matrix->refcount )
01595 ++*matrix->refcount;
01596 }
01597 }
01598
01599 void release()
01600 {
01601 if( matrix )
01602 {
01603 if( matrix->hdr_refcount )
01604 {
01605 if( --matrix->hdr_refcount == 0 )
01606 cvReleaseMat( &matrix );
01607 }
01608 else if( matrix->refcount )
01609 {
01610 if( --*matrix->refcount == 0 )
01611 cvFree( &matrix->refcount );
01612 }
01613 matrix = 0;
01614 }
01615 }
01616
01617 void clear()
01618 {
01619 release();
01620 }
01621
01622 bool load( const char* filename, const char* matname=0, int color=-1 );
01623 bool read( CvFileStorage* fs, const char* mapname, const char* matname );
01624 bool read( CvFileStorage* fs, const char* seqname, int idx );
01625 void save( const char* filename, const char* matname, const int* params=0 );
01626 void write( CvFileStorage* fs, const char* matname );
01627
01628 void show( const char* window_name );
01629
01630 bool is_valid() { return matrix != 0; }
01631
01632 int rows() const { return matrix ? matrix->rows : 0; }
01633 int cols() const { return matrix ? matrix->cols : 0; }
01634
01635 CvSize size() const
01636 {
01637 return !matrix ? cvSize(0,0) : cvSize(matrix->rows,matrix->cols);
01638 }
01639
01640 int type() const { return matrix ? CV_MAT_TYPE(matrix->type) : 0; }
01641 int depth() const { return matrix ? CV_MAT_DEPTH(matrix->type) : 0; }
01642 int channels() const { return matrix ? CV_MAT_CN(matrix->type) : 0; }
01643 int pix_size() const { return matrix ? CV_ELEM_SIZE(matrix->type) : 0; }
01644
01645 uchar* data() { return matrix ? matrix->data.ptr : 0; }
01646 const uchar* data() const { return matrix ? matrix->data.ptr : 0; }
01647 int step() const { return matrix ? matrix->step : 0; }
01648
01649 void set_data( void* data, int step=CV_AUTOSTEP )
01650 { cvSetData( matrix, data, step ); }
01651
01652 uchar* row(int i) { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; }
01653 const uchar* row(int i) const
01654 { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; }
01655
01656 operator const CvMat* () const { return matrix; }
01657 operator CvMat* () { return matrix; }
01658
01659 CvMatrix& operator = (const CvMatrix& _m)
01660 {
01661 _m.addref();
01662 release();
01663 matrix = _m.matrix;
01664 return *this;
01665 }
01666
01667 protected:
01668 CvMat* matrix;
01669 };
01670
01671
01672
01673
01674
01675 class CV_EXPORTS CvCamShiftTracker
01676 {
01677 public:
01678
01679 CvCamShiftTracker();
01680 virtual ~CvCamShiftTracker();
01681
01682
01683 float get_orientation() const
01684 { return m_box.angle; }
01685 float get_length() const
01686 { return m_box.size.height; }
01687 float get_width() const
01688 { return m_box.size.width; }
01689 CvPoint2D32f get_center() const
01690 { return m_box.center; }
01691 CvRect get_window() const
01692 { return m_comp.rect; }
01693
01694
01695 int get_threshold() const
01696 { return m_threshold; }
01697
01698 int get_hist_dims( int* dims = 0 ) const
01699 { return m_hist ? cvGetDims( m_hist->bins, dims ) : 0; }
01700
01701 int get_min_ch_val( int channel ) const
01702 { return m_min_ch_val[channel]; }
01703
01704 int get_max_ch_val( int channel ) const
01705 { return m_max_ch_val[channel]; }
01706
01707
01708 bool set_window( CvRect window)
01709 { m_comp.rect = window; return true; }
01710
01711 bool set_threshold( int threshold )
01712 { m_threshold = threshold; return true; }
01713
01714 bool set_hist_bin_range( int dim, int min_val, int max_val );
01715
01716 bool set_hist_dims( int c_dims, int* dims );
01717
01718 bool set_min_ch_val( int channel, int val )
01719 { m_min_ch_val[channel] = val; return true; }
01720 bool set_max_ch_val( int channel, int val )
01721 { m_max_ch_val[channel] = val; return true; }
01722
01723
01724
01725 virtual bool track_object( const IplImage* cur_frame );
01726
01727
01728 virtual bool update_histogram( const IplImage* cur_frame );
01729
01730
01731 virtual void reset_histogram();
01732
01733
01734
01735 virtual IplImage* get_back_project()
01736 { return m_back_project; }
01737
01738 float query( int* bin ) const
01739 { return m_hist ? (float)cvGetRealND(m_hist->bins, bin) : 0.f; }
01740
01741 protected:
01742
01743
01744 virtual void color_transform( const IplImage* img );
01745
01746 CvHistogram* m_hist;
01747
01748 CvBox2D m_box;
01749 CvConnectedComp m_comp;
01750
01751 float m_hist_ranges_data[CV_MAX_DIM][2];
01752 float* m_hist_ranges[CV_MAX_DIM];
01753
01754 int m_min_ch_val[CV_MAX_DIM];
01755 int m_max_ch_val[CV_MAX_DIM];
01756 int m_threshold;
01757
01758 IplImage* m_color_planes[CV_MAX_DIM];
01759 IplImage* m_back_project;
01760 IplImage* m_temp;
01761 IplImage* m_mask;
01762 };
01763
01764
01765 #endif
01766
01767 #endif
01768
01769