cvtypes.h
来自「微软的基于HMM的人脸识别原代码, 非常经典的说」· C头文件 代码 · 共 1,432 行 · 第 1/3 页
H
1,432 行
return x*arg;}/* RNG state */typedef struct CvRandState{ unsigned seed; /* current 32-bit pseudo-random number */ unsigned carry; /* carry (upper half of 64-bit random number) */ float factor; /* (upper - lower) */ float delta; /* lower - (upper - lower) */} CvRandState;/* Defines for Threshold functions */typedef enum CvThreshType{ CV_THRESH_BINARY = 0, /* val = (val>thresh? MAX:0) */ CV_THRESH_BINARY_INV = 1, /* val = (val>thresh? 0:MAX) */ CV_THRESH_TRUNC = 2, /* val = (val>thresh? thresh:val) */ CV_THRESH_TOZERO = 3, /* val = (val>thresh? val:0) */ CV_THRESH_TOZERO_INV = 4 /* val = (val>thresh? 0:val) */} CvThreshType;typedef enum CvAdaptiveThreshMethod{ CV_STDDEV_ADAPTIVE_THRESH = 0 /* method for the defining local adaptive threshold */}CvAdaptiveThreshMethod;/* Defines for Distance Transform */typedef enum CvDisType{ CV_DIST_USER = -1, /* User defined distance */ CV_DIST_L1 = 1, /* distance = |x1-x2| + |y1-y2| */ CV_DIST_L2 = 2, /* the simple euclidean distance */ CV_DIST_C = 3, /* distance = max(|x1-x2|,|y1-y2|) */ CV_DIST_L12 = 4, /* L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */ CV_DIST_FAIR = 5, /* distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */ CV_DIST_WELSCH = 6 /* distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */} CvDisType;typedef enum CvDisMaskType{ CV_DIST_MASK_3 = 0, CV_DIST_MASK_5 = 1} CvDisMaskType;/* Filters used in pyramid decomposition */typedef enum CvFilter{ CV_GAUSSIAN_5x5 = 7} CvFilter;typedef enum CvMorphOp{ CV_MOP_OPEN = 2, CV_MOP_CLOSE = 3, CV_MOP_GRADIENT = 4, CV_MOP_TOPHAT = 5, CV_MOP_BLACKHAT = 6} CvMorphOp;typedef enum CvElementShape{ CV_SHAPE_RECT = 0, CV_SHAPE_CROSS = 1, CV_SHAPE_ELLIPSE = 2, CV_SHAPE_CUSTOM = 100}CvElementShape;/* POSIT structure */typedef struct CvPOSITObject{ int N; float* inv_matr; float* obj_vecs; float* img_vecs;} CvPOSITObject;typedef struct CvMoments{ double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; double mu20, mu11, mu02, mu30, mu21, mu12, mu03; double inv_sqrt_m00;} CvMoments;typedef struct CvHuMoments{ double hu1; /* First Hu moment (reflection changes its sign) */ double hu2, hu3, hu4, hu5, hu6, hu7; /* Other, "unchangeable" moments */} CvHuMoments;/* method for comparing two images */typedef enum CvTemplMatchMethod{ CV_TM_SQDIFF = 0, CV_TM_SQDIFF_NORMED = 1, CV_TM_CCORR = 2, CV_TM_CCORR_NORMED = 3, CV_TM_CCOEFF = 4, CV_TM_CCOEFF_NORMED = 5}CvTemplMatchMethod;typedef enum CvFontFace{ CV_FONT_VECTOR0 = 0} CvFontFace;typedef struct CvFont{ const int* data; /* font faces and other characteristics */ CvSize size; /* horizontal and vertical scale factors (8:8) fix-point nums */ int italic_scale; /* slope coefficient: 0 - normal, >0 - italic */ int thickness; /* letters thickness */ int dx; /* horizontal interval between letters */} CvFont;#define CV_RGB( r, g, b ) ( (((r)&255) << 16)|(((g)&255) << 8)|((b)&255))#define CV_FILLED -1typedef struct CvLineIterator{ uchar* ptr; int err; int plus_delta; int minus_delta; int plus_step; int minus_step;} CvLineIterator;#define CV_NEXT_LINE_POINT( iterator ) \{ \ int mask = ((iterator).err -= (iterator).minus_delta) >> 31; \ (iterator).err += (iterator).plus_delta & mask; \ (iterator).ptr += (iterator).minus_step + ((iterator).plus_step & mask); \}/* Rodrigues transform direction */typedef enum CvRodriguesType{ CV_RODRIGUES_M2V = 0, CV_RODRIGUES_V2M = 1}CvRodriguesType;/**************** segmented component's structure *************************************/typedef struct CvConnectedComp{ double area; /* area of the segmented component */ double value; /* gray scale value of the segmented component */ CvRect rect; /* ROI of the segmented component */} CvConnectedComp;/*********************************** HMM structures *************************************/typedef struct CvEHMMState{ int num_mix; /*number of mixtures in this state*/ float* mu; /*mean vectors corresponding to each mixture*/ float* inv_var; /* square root of inversed variances corresp. to each mixture*/ float* log_var_val; /* sum of 0.5 (LN2PI + ln(variance[i]) ) for i=1,n */ float* weight; /*array of mixture weights. Summ of all weights in state is 1. */} CvEHMMState;typedef struct CvEHMM{ int level; /* 0 - lowest(i.e its states are real states), ..... */ int num_states; /* number of HMM states */ float* transP;/*transition probab. matrices for states */ float** obsProb; /* if level == 0 - array of brob matrices corresponding to hmm if level == 1 - martix of matrices */ union { CvEHMMState* state; /* if level == 0 points to real states array, if not - points to embedded hmms */ struct CvEHMM* ehmm; /* pointer to embedded models (if NULL then no embedded models) */ } u;} CvEHMM;typedef struct CvImgObsInfo{ int obs_x; int obs_y; int obs_size; float* obs;//consequtive observations int* state;/* array of pairs superstate/state to which observation belong */ int* mix; /* number of mixture to which observation belong */} CvImgObsInfo;/*struct for 1 image*/typedef struct { int MP; int DP; float* PosterState; // Vector of State of the System in k-th step float* PriorState; // Vector of State of the System in (k-1)-th step float* DynamMatr; // Matrix of the linear Dynamics system // (Must be updated by LinearizedDynamics function on each step // for nonlinear systems) float* MeasurementMatr; // Matrix of linear measurement (Must be updated by // LinearizedMeasurement function on each step // for nonlinear measurements) float* MNCovariance; // Matrix of measurement noice covariance // Initializes to Zero matrix, or sets by SetMeasureNoiseCov // method float* PNCovariance; // Matrix of process noice covariance // Initializes to Identity matrix, or sets by SetProcessNoiseCov // method float* KalmGainMatr; // Kalman Gain Matrix float* PriorErrorCovariance; //Prior Error Covariance matrix float* PosterErrorCovariance;//Poster Error Covariance matrix float* Temp1; // Temporary Matrix float* Temp2; } CvKalman;typedef struct { int MP; int DP; float* DynamMatr; // Matrix of the linear Dynamics system float* State; // Vector of State int SamplesNum; // Number of the Samples float** flSamples; // array of the Sample Vectors float** flNewSamples; // temporary array of the Sample Vectors float* flConfidence; // Confidence for each Sample float* flCumulative; // Cumulative confidence float* Temp; // Temporary vector float* RandomSample; // RandomVector to update sample set CvRandState* RandS; // Array of structures to generate random vectors} CvConDensation;#define CV_LKFLOW_PYR_A_READY 1#define CV_LKFLOW_PYR_B_READY 2#define CV_LKFLOW_INITIAL_GUESSES 4#define CV_EIGOBJ_NO_CALLBACK 0#define CV_EIGOBJ_INPUT_CALLBACK 1#define CV_EIGOBJ_OUTPUT_CALLBACK 2#define CV_EIGOBJ_BOTH_CALLBACK 3typedef CvStatus (*CvCallback)( int index, void* buffer, void* userData );typedef union{ CvCallback callback; void* data;}CvInput;#define CV_SCHARR -1/****************************************************************************************//* Norm types defines *//****************************************************************************************/#define CV_C 1#define CV_L1 2#define CV_L2 4#define CV_RELATIVE 8#define CV_DIFF 16#define CV_DIFF_C (CV_DIFF | CV_C)#define CV_DIFF_L1 (CV_DIFF | CV_L1)#define CV_DIFF_L2 (CV_DIFF | CV_L2)#define CV_RELATIVE_C (CV_RELATIVE | CV_C)#define CV_RELATIVE_L1 (CV_RELATIVE | CV_L1)#define CV_RELATIVE_L2 (CV_RELATIVE | CV_L2)/****************************************************************************************\* Histogram structures & defines *\****************************************************************************************/#define CV_HIST_MAX_DIM 16typedef enum CvHistType { CV_HIST_ARRAY = 0, CV_HIST_TREE = 1} CvHistType;typedef enum CvCompareMethod { CV_COMP_CORREL = 0, CV_COMP_CHISQR = 1, CV_COMP_INTERSECT = 2} CvCompareMethod;typedef enum CvHistFlag { CV_HIST_MEMALLOCATED = 1, CV_HIST_HEADERALLOCATED = 2, CV_HIST_UNIFORM = 4, CV_HIST_THRESHALLOCATED = 8} CvHistFlag;typedef struct CvHistogram{ int header_size; /* header's size */ CvHistType type; /* type of histogram */ int flags; int c_dims; int dims[CV_HIST_MAX_DIM]; int mdims[CV_HIST_MAX_DIM]; /* coefficients for fast calculation of number of element */ /* &m[a,b,c] = m + a*mdims[0] + b*mdims[1] + c*mdims[2] */ float* thresh[CV_HIST_MAX_DIM]; float* array; /* all the histogram data, expanded into the single row */ struct CvNode* root; struct CvSet* set; int* chdims[CV_HIST_MAX_DIM];} CvHistogram;/****************************************************************************************//* Data structures *//****************************************************************************************//******************************** Memory storage ****************************************/typedef struct CvMemBlock{ struct CvMemBlock* prev; struct CvMemBlock* next;} CvMemBlock;typedef struct CvMemStorage{ CvMemBlock* bottom;/* first allocated block */ CvMemBlock* top; /* current memory block - top of the stack */ struct CvMemStorage* parent; /* borrows new blocks from */ int block_size; /* block size */ int free_space; /* free space in the current block */} CvMemStorage;typedef struct CvMemStoragePos{ CvMemBlock* top; int free_space;}CvMemStoragePos;/*********************************** Sequence *******************************************/typedef struct CvSeqBlock{ struct CvSeqBlock* prev; /* previous sequence block */ struct CvSeqBlock* next; /* next sequence block */ int start_index; /* index of the first element in the block + sequence->first->start_index */ int count; /* number of elements in the block */ char* data; /* pointer to the first element of the block */} CvSeqBlock;/* Read/Write sequence. Elements can be dynamically inserted to or deleted from the sequence.*/#define CV_SEQUENCE_FIELDS() \ int header_size; /* size of sequence header */ \ struct CvSeq* h_prev; /* previous sequence */ \ struct CvSeq* h_next; /* next sequence */ \ struct CvSeq* v_prev; /* 2nd previous sequence */ \ struct CvSeq* v_next; /* 2nd next sequence */ \ int flags; /* micsellaneous flags */ \ int total; /* total number of elements */ \ int elem_size; /* size of sequence element in bytes */ \ char* block_max; /* maximal bound of the last block */ \ char* ptr; /* current write pointer */ \ int delta_elems; /* how many elements allocated when the seq grows */ \ CvMemStorage* storage; /* where the seq is stored */ \ CvSeqBlock* free_blocks; /* free blocks list */ \ CvSeqBlock* first; /* pointer to the first sequence block */typedef struct CvSeq{ CV_SEQUENCE_FIELDS()} CvSeq;/*************************************** Set ********************************************//* Set. Order isn't keeped. There can be gaps between sequence elements. After the element has been inserted it stays on the same place all the time. The LSB(least-significant bit) of the first field is 0 iff the element exists.*/#define CV_SET_ELEM_FIELDS() \ int* aligned_ptr;typedef struct CvSetElem{ CV_SET_ELEM_FIELDS()}CvSetElem;#define CV_SET_FIELDS() \ CV_SEQUENCE_FIELDS() \ CvMemBlock* free_elems;typedef struct CvSet{ CV_SET_FIELDS()}CvSet;/************************************* Graph ********************************************//* Graph is represented as a set of vertices. Vertices contain their adjacency lists (more exactly, pointers to first incoming or outcoming edge (or 0 if isolated vertex)). Edges are stored in another set. There is a single-linked list of incoming/outcoming edges for each vertex. Each edge consists of: two pointers to the starting and the ending vertices (vtx[0] and vtx[1], respectively). Graph may be oriented or not. In the second case, edges between vertex i to vertex j are not distingueshed (during the search operations). two pointers to next edges for the starting and the ending vertices. next[0] points to the next edge in the vtx[0] adjacency list and next[1] points to the next edge in the vtx[1] adjacency list.*/#define CV_GRAPH_EDGE_FIELDS() \ struct CvGraphEdge* next[2]; \ struct CvGraphVertex* vtx[2];#define CV_GRAPH_VERTEX_FIELDS() \ struct CvGraphEdge* first;typedef struct CvGraphEdge{ CV_GRAPH_EDGE_FIELDS()}CvGraphEdge;typedef struct CvGraphVertex{ CV_GRAPH_VERTEX_FIELDS()}CvGraphVtx;typedef struct CvGraphVtx2D{ CV_GRAPH_VERTEX_FIELDS() CvPoint2D32f* ptr;}CvGraphVtx2D;/* Graph is "derived" from the set (this is set a of vertices) and includes another set (edges)*/#define CV_GRAPH_FIELDS() \ CV_SET_FIELDS() \ CvSet* edges;typedef struct CvGraph{ CV_GRAPH_FIELDS()}CvGraph;/*********************************** Chain/Countour *************************************/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?