⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cv.h

📁 HMM用于人脸识别
💻 H
📖 第 1 页 / 共 5 页
字号:

/* Changes RNG range while preserving RNG state */
OPENCVAPI  void  cvRandSetRange( CvRandState* state, double param1, double param2,
                                 int index CV_DEFAULT(-1));

/* Fills array with random numbers */
OPENCVAPI  void  cvRand( CvRandState* state, CvArr* arr );

/* Returns 32-bit random number (ranges are not used)
   and updates RNG state */
CV_INLINE  unsigned  cvRandNext( CvRandState* state );
CV_INLINE  unsigned  cvRandNext( CvRandState* state )
{
    uint64 temp = 0;

    if( state )
    {
        temp = state->state;
        temp = (uint64)(unsigned)temp*1554115554 + (temp >> 32);
        state->state = temp;
    }

    return (unsigned)temp;
}


/****************************************************************************************\
*                                Matrix operations                                       *
\****************************************************************************************/

/* Calculates cross product of two 3d vectors */
OPENCVAPI  void  cvCrossProduct( const CvArr* srcA, const CvArr* srcB, CvArr* dst );

/* Matrix transform: dst = A*B + C, C is optional */
OPENCVAPI  void  cvMatMulAdd( const CvArr* srcA, const CvArr* srcB,
                              const CvArr* srcC, CvArr* dst );
#define cvMatMul( srcA, srcB, dst )  cvMatMulAdd( (srcA), (srcB), NULL, (dst))

#define CV_GEMM_A_T 1
#define CV_GEMM_B_T 2
#define CV_GEMM_C_T 4
/* Extended matrix transform:
   dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */
OPENCVAPI  void  cvGEMM( const CvArr* srcA, const CvArr* srcB, double alpha,
                         const CvArr* srcC, double beta, CvArr* dst,
                         int tABC CV_DEFAULT(0));
#define cvMatMulAddEx cvGEMM

/* Transforms each element of source array and stores
   resultant vectors in destination array */
OPENCVAPI  void  cvMatMulAddS( const CvArr* src, CvArr* dst,
                               const CvMat* transform,
                               const CvMat* shiftvec CV_DEFAULT(NULL));
#define cvTransform cvMatMulAddS

/* Calculates A*A^T (order=0) or A^T*A (order=1) */
OPENCVAPI void cvMulTransposed( const CvArr* srcarr,
                                CvArr* dstarr, int order );

/* Tranposes matrix. Square matrices can be transposed in-place */
OPENCVAPI  void  cvTranspose( const CvArr* src, CvArr* dst );
#define cvT cvTranspose


/* Mirror array data around horizontal (flip=0),
   vertical (flip=1) or both(flip=-1) axises:
   cvFlip(src) flips images vertically and sequences horizontally (inplace) */
OPENCVAPI  void  cvFlip( const CvArr* src, CvArr* dst CV_DEFAULT(NULL),
                         int flip_mode CV_DEFAULT(0));
#define cvMirror cvFlip


#define CV_SVD_MODIFY_A   1
#define CV_SVD_U_T        2
#define CV_SVD_V_T        4

/* Performs Singular Value Decomposition of a matrix */
OPENCVAPI  void   cvSVD( CvArr* A, CvArr* W CV_DEFAULT(NULL),
                         CvArr* U CV_DEFAULT(NULL),
                         CvArr* V CV_DEFAULT(NULL),
                         int flags CV_DEFAULT(0));

/* Performs Singular Value Back Substitution:
   flags must be the same as in cvSVD */
OPENCVAPI  void   cvSVBkSb( const CvArr* warr, const CvArr* uarr,
                            const CvArr* varr, const CvArr* barr,
                            CvArr* xarr, int flags );

#define CV_LU  0
#define CV_SVD 1
/* Inverts matrix */
OPENCVAPI  double  cvInvert( const CvArr* src, CvArr* dst,
                             int method CV_DEFAULT(CV_LU));
#define cvInv cvInvert

/* Solves linear system Ax = b
   (returns 0 if A is singular) */
OPENCVAPI  int  cvSolve( const CvArr* A, const CvArr* b, CvArr* x,
                         int method CV_DEFAULT(CV_LU));

/* Calculates determinant of input matrix */
OPENCVAPI  double cvDet( const CvArr* mat );

/* Calculates trace of the matrix (sum of elements on the main diagonal) */
OPENCVAPI  CvScalar cvTrace( const CvArr* mat );

/* Finds eigen values and vectors of a _symmetric_ matrix */
OPENCVAPI  void  cvEigenVV( CvArr* src, CvArr* evects, CvArr* evals, double eps );

/* Makes an identity matrix (mat_ij = i == j) */
OPENCVAPI  void  cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvScalar(1)) );

/* Does perspective transform on every element of input array */
OPENCVAPI  void  cvPerspectiveTransform( const CvArr* src, CvArr* dst, const CvArr* mat );

/* Calculates covariation matrix for a set of vectors */
OPENCVAPI  void  cvCalcCovarMatrix( const CvArr** vects, CvArr* covarMatrix, CvArr* avg );

/* Calculates Mahalanobis(weighted) distance */
OPENCVAPI  double  cvMahalanobis( const CvArr* srcA, const CvArr* srcB, CvArr* mat );
#define cvMahalonobis  cvMahalanobis

/****************************************************************************************\
*                                    Array Statistics                                    *
\****************************************************************************************/

/* Finds sum of array elements */
OPENCVAPI  CvScalar  cvSum( const CvArr* array );


/* Calculates number of non-zero pixels */
OPENCVAPI  int  cvCountNonZero( const CvArr* array );


/* Calculates mean value of array elements */
OPENCVAPI  CvScalar  cvAvg( const CvArr* array, const CvArr* mask CV_DEFAULT(NULL) );

/* Calculates mean and standard deviation of pixel values */
OPENCVAPI  void  cvAvgSdv( const CvArr* array, CvScalar* mean, CvScalar* std_dev,
                           const CvArr* mask CV_DEFAULT(NULL) );

/* Finds global minimum, maximum among the input array elements and positions
   of the extremums */
OPENCVAPI  void  cvMinMaxLoc( const CvArr* array, double* min_val, double* max_val,
                              CvPoint* min_loc CV_DEFAULT(NULL),
                              CvPoint* max_loc CV_DEFAULT(NULL),
                              const CvArr* mask CV_DEFAULT(NULL) );

/* spatial and central moments */
typedef struct CvMoments
{
    double  m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; /* spatial moments */
    double  mu20, mu11, mu02, mu30, mu21, mu12, mu03; /* central moments */
    double  inv_sqrt_m00; /* m00 != 0 ? 1/sqrt(m00) : 0 */
} CvMoments;

/* Calculates all spatial and central moments up to the 3rd order */
OPENCVAPI void cvMoments( const CvArr* array, CvMoments* moments, int binary CV_DEFAULT(0));

/* Retrieve particular spatial, central or normalized central moments */
OPENCVAPI  double  cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
OPENCVAPI  double  cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
OPENCVAPI  double  cvGetNormalizedCentralMoment( CvMoments* moments,
                                                 int x_order, int y_order );

/* Hu invariants */
typedef struct CvHuMoments
{
    double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /* Hu invariants */
} CvHuMoments;

/* Calculates 7 Hu's invariants from precalculated spatial and central moments */
OPENCVAPI void cvGetHuMoments( CvMoments*  moments, CvHuMoments*  hu_moments );

/* types of array norm */
#define CV_C            1
#define CV_L1           2
#define CV_L2           4
#define CV_NORM_MASK    7
#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)

/* Finds norm, difference norm or relative difference norm for an array (two arrays) */
OPENCVAPI  double  cvNorm( const CvArr* imgA, const CvArr* imgB CV_DEFAULT(NULL),
                           int normType CV_DEFAULT(CV_L2),
                           const CvArr* mask CV_DEFAULT(NULL) );

/****************************************************************************************\
*                              Dynamic data structures                                   *
\****************************************************************************************/

/* Creates new memory storage.
   block_size == 0 means that default,
   somewhat optimal size, is used (currently, it is 64K) */
OPENCVAPI  CvMemStorage*  cvCreateMemStorage( int block_size CV_DEFAULT(0));


/* Creates a memory storage that will borrow memory blocks from parent storage */
OPENCVAPI  CvMemStorage*  cvCreateChildMemStorage( CvMemStorage* parent );


/* Releases memory storage. All the children of a parent must be released before
   the parent. A child storage returns all the blocks to parent when it is released */
OPENCVAPI  void  cvReleaseMemStorage( CvMemStorage** storage );


/* Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos)
   to reuse memory allocated for the storage - cvClearSeq,cvClearSet ...
   do not free any memory.
   A child storage returns all the blocks to the parent when it is cleared */
OPENCVAPI  void  cvClearMemStorage( CvMemStorage* storage );

/* Remember a storage "free memory" position */
OPENCVAPI  void  cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos );

/* Restore a storage "free memory" position */
OPENCVAPI  void  cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos );

/* Allocates continuous buffer of the specified size in the storage */
OPENCVAPI  void* cvMemStorageAlloc( CvMemStorage* storage, int size );

/* Creates new empty sequence that will reside in the specified storage */
OPENCVAPI  CvSeq*  cvCreateSeq( int seq_flags, int header_size,
                             int elem_size, CvMemStorage* storage );

/* Changes default size (granularity) of sequence blocks.
   The default size is ~1Kbyte */
OPENCVAPI  void  cvSetSeqBlockSize( CvSeq* seq, int delta_elements );


/* Adds new element to the end of sequence. Returns pointer to the element */
OPENCVAPI  char*  cvSeqPush( CvSeq* seq, void* element CV_DEFAULT(NULL));


/* Adds new element to the beginning of sequence. Returns pointer to it */
OPENCVAPI  char*  cvSeqPushFront( CvSeq* seq, void* element CV_DEFAULT(NULL));


/* Removes the last element from sequence and optionally saves it */
OPENCVAPI  void  cvSeqPop( CvSeq* seq, void* element CV_DEFAULT(NULL));


/* Removes the first element from sequence and optioanally saves it */
OPENCVAPI  void  cvSeqPopFront( CvSeq* seq, void* element CV_DEFAULT(NULL));


#define CV_FRONT 1
#define CV_BACK 0
/* Adds several new elements to the end of sequence */
OPENCVAPI  void  cvSeqPushMulti( CvSeq* seq, void* elements,
                                 int count, int in_front CV_DEFAULT(0) );

/* Removes several elements from the end of sequence and optionally saves them */
OPENCVAPI  void  cvSeqPopMulti( CvSeq* seq, void* elements,
                                int count, int in_front CV_DEFAULT(0) );

/* Inserts a new element in the middle of sequence.
   cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */
OPENCVAPI  char*  cvSeqInsert( CvSeq* seq, int before_index,
                               void* element CV_DEFAULT(NULL));

/* Removes specified sequence element */
OPENCVAPI  void  cvSeqRemove( CvSeq* seq, int index );


/* Removes all the elements from the sequence. The freed memory
   can be reused later only by the same sequence unless cvClearMemStorage
   or cvRestoreMemStoragePos is called */
OPENCVAPI  void  cvClearSeq( CvSeq* seq );


/* Retrives pointer to specified sequence element.
   Negative indices are supported and mean counting from the end
   (e.g -1 means the last sequence element) */
OPENCVAPI  char*  cvGetSeqElem( CvSeq* seq, int index, CvSeqBlock** block CV_DEFAULT(NULL) );


/* Calculates index of the specified sequence element.
   Returns -1 if element does not belong to the sequence */
OPENCVAPI int  cvSeqElemIdx( const CvSeq* seq, const void* element,
                             CvSeqBlock** block CV_DEFAULT(NULL) );

/* Initializes sequence writer. The new elements will be added to the end of sequence */
OPENCVAPI  void  cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer );


/* Combination of cvCreateSeq and cvStartAppendToSeq */
OPENCVAPI  void  cvStartWriteSeq( int seq_flags, int header_size,
                                  int elem_size, CvMemStorage* storage,
                                  CvSeqWriter* writer );

/* Closes sequence writer, updates sequence header and returns pointer
   to the resultant sequence
   (which may be useful if the sequence was created using cvStartWriteSeq))
*/
OPENCVAPI  CvSeq*  cvEndWriteSeq( CvSeqWriter* writer );


/* Updates sequence header. May be useful to get access to some of previously
   written elements via cvGetSeqElem or sequence reader */
OPENCVAPI  void   cvFlushSeqWriter( CvSeqWriter* writer );


/* Initializes sequence reader.
   The sequence can be read in forward or backward direction */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -