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

📄 cv.h

📁 HMM用于人脸识别
💻 H
📖 第 1 页 / 共 5 页
字号:
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                        Intel License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of Intel Corporation may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/


#ifndef _CV_H_
#define _CV_H_

#ifdef __IPL_H__
#define HAVE_IPL /* On Windows IPL is needed by default */
#endif

#if defined(_CH_)
#include <cvch.h>
CV_CH_LOAD_CODE(cv,Cv)
#endif

#ifdef HAVE_IPL
#ifndef _INC_WINDOWS
    #define CV_PRETEND_WINDOWS
    #define _INC_WINDOWS
    typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER;
    typedef int BOOL;
#endif
#include "ipl.h"
#ifdef CV_PRETEND_WINDOWS
    #undef _INC_WINDOWS
#endif
#endif

#include "cvtypes.h"
#include "cverror.h"

#ifdef __cplusplus
extern "C" {
#endif

/****************************************************************************************\
*                                     Allocation/deallocation                            *
\****************************************************************************************/

/* <malloc> wrapper.
   If there is no enough memory the function
   (as well as other OpenCV functions that call cvAlloc)
   raises an error. */
OPENCVAPI  void*  cvAlloc( int size );

/* <free> wrapper.
   Here and further all the memory releasing functions
   (that all call cvFree) take double pointer which is used
   to clear user pointer to the data after releasing it.
   Passing pointer to NULL pointer is Ok: nothing happens in this case
*/
OPENCVAPI  void   cvFree( void** ptr );

/* Allocates and initializes IplImage header */
OPENCVAPI  IplImage*  cvCreateImageHeader( CvSize size, int depth, int channels );

/* Inializes IplImage header */
OPENCVAPI IplImage* cvInitImageHeader( IplImage* image, CvSize size, int depth,
                                       int channels, int origin CV_DEFAULT(0),
                                       int align CV_DEFAULT(4));

/* Creates IPL image (header and data) */
OPENCVAPI  IplImage*  cvCreateImage( CvSize size, int depth, int channels );

/* Releases (i.e. deallocates) IPL image header */
OPENCVAPI  void  cvReleaseImageHeader( IplImage** image );

/* Releases IPL image header and data */
OPENCVAPI  void  cvReleaseImage( IplImage** image );

/* Creates a copy of IPL image (widthStep may differ) */
OPENCVAPI IplImage* cvCloneImage( const IplImage* image );

/* Sets a Channel Of Interest (only a few functions support COI) - 
   use cvCopy to extract the selected channel and/or put it back */
OPENCVAPI  void  cvSetImageCOI( IplImage* image, int coi );

/* Retrieves image Channel Of Interest */
OPENCVAPI  int  cvGetImageCOI( IplImage* image );

/* Sets image ROI (region of interest) (COI is not changed) */
OPENCVAPI  void  cvSetImageROI( IplImage* image, CvRect rect );

/* Resets image ROI and COI */
OPENCVAPI  void  cvResetImageROI( IplImage* image );

/* Retrieves image ROI */
OPENCVAPI  CvRect cvGetImageROI( const IplImage* image );

/* Allocates and initalizes CvMat header */
OPENCVAPI  CvMat*  cvCreateMatHeader( int rows, int cols, int type );

#define CV_AUTOSTEP  0x7fffffff

/* Initializes CvMat header */
OPENCVAPI CvMat* cvInitMatHeader( CvMat* mat, int rows, int cols,
                                  int type, void* data CV_DEFAULT(NULL),
                                  int step CV_DEFAULT(CV_AUTOSTEP) );

/* Allocates and initializes CvMat header and allocates data */
OPENCVAPI  CvMat*  cvCreateMat( int rows, int cols, int type );

/* Releases CvMat header and deallocates matrix data
   (reference counting is used for data) */
OPENCVAPI  void  cvReleaseMat( CvMat** mat );

/* Decrements CvMat data reference counter and deallocates the data if
   it reaches 0 */
CV_INLINE  void  cvDecRefData( CvArr* arr );
CV_INLINE  void  cvDecRefData( CvArr* arr )
{
    if( CV_IS_MAT( arr ) || CV_IS_MATND( arr ))
    {
        CvMat* mat = (CvMat*)arr; /* the first few fields of CvMat and CvMatND are the same */
        mat->data.ptr = NULL;
        if( mat->refcount != NULL && --*mat->refcount == 0 )
        {
            uchar* data = (uchar*)mat->refcount + 2*sizeof(mat->refcount);
            cvFree( (void**)&data );
        }
        mat->refcount = NULL;
    }
}

/* Increments CvMat data reference counter */
CV_INLINE  int  cvIncRefData( CvArr* arr );
CV_INLINE  int  cvIncRefData( CvArr* arr )
{
    int refcount = 0;
    if( CV_IS_MAT( arr ) || CV_IS_MATND( arr ))
    {
        CvMat* mat = (CvMat*)arr;
        if( mat->refcount != NULL )
            refcount = ++*mat->refcount;
    }
    return refcount;
}


/* Creates an exact copy of the input matrix (except, may be, step value) */
OPENCVAPI CvMat* cvCloneMat( const CvMat* mat );


/* Makes a new matrix from <rect> subrectangle of input array.
   No data is copied */
OPENCVAPI CvMat* cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect );
#define cvGetSubArr cvGetSubRect

/* Partial case of the cvGetSubArr:
    row span of the input array is selected
    (end_row is not included into the span). */
OPENCVAPI CvMat* cvGetRows( const CvArr* arr, CvMat* submat,
                            int start_row, int end_row );

CV_INLINE  void  cvGetRow( const CvArr* arr, CvMat* submat, int row );
CV_INLINE  void  cvGetRow( const CvArr* arr, CvMat* submat, int row )
{
    cvGetRows( arr, submat, row, row + 1 );
}


/* Partial case of the cvGetSubArr:
    column span of the input array is selected
    (end_col is not included into the span) */
OPENCVAPI CvMat* cvGetCols( const CvArr* arr, CvMat* submat,
                               int start_col, int end_col );

CV_INLINE  void  cvGetCol( const CvArr* arr, CvMat* submat, int col );
CV_INLINE  void  cvGetCol( const CvArr* arr, CvMat* submat, int col )
{
    cvGetCols( arr, submat, col, col + 1 );
}

/* Partial case of the cvGetSubArr:
    a single diagonal of the input array is selected
   (diag = 0 means main diagonal, >0 means some diagonal above the main one,
   <0 - below the main one).
   The diagonal will be represented as a column (nx1 matrix). */
OPENCVAPI CvMat* cvGetDiag( const CvArr* arr, CvMat* submat,
                            int diag CV_DEFAULT(0));

/* low-level scalar <-> raw data conversion functions */
OPENCVAPI void cvScalarToRawData( const CvScalar* scalar, void* data, int type,
                                  int extend_to_12 CV_DEFAULT(0) );

OPENCVAPI void cvRawDataToScalar( const void* data, int type, CvScalar* scalar );

/* Allocates and initializes CvMatND header */
OPENCVAPI  CvMatND*  cvCreateMatNDHeader( int dims, const int* sizes, int type );

/* Allocates and initializes CvMatND header and allocates data */
OPENCVAPI  CvMatND*  cvCreateMatND( int dims, const int* sizes, int type );

/* Initializes preallocated CvMatND header */
OPENCVAPI  CvMatND*  cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes,
                                        int type, void* data CV_DEFAULT(NULL) );

/* Releases CvMatND */
CV_INLINE  void  cvReleaseMatND( CvMatND** mat );
CV_INLINE  void  cvReleaseMatND( CvMatND** mat )
{
    cvReleaseMat( (CvMat**)mat );
}

/* Creates a copy of CvMatND (except, may be, steps) */
OPENCVAPI  CvMatND* cvCloneMatND( const CvMatND* mat );

/* Allocates and initializes CvSparseMat header and allocates data */
OPENCVAPI  CvSparseMat*  cvCreateSparseMat( int dims, const int* sizes, int type );

/* Releases CvSparseMat */
OPENCVAPI  void  cvReleaseSparseMat( CvSparseMat** mat );

/* Creates a copy of CvSparseMat (except, may be, zero items) */
OPENCVAPI  CvSparseMat* cvCloneSparseMat( const CvSparseMat* mat );

/* Initializes sparse array iterator
   (returns the first node or NULL if the array is empty) */
OPENCVAPI  CvSparseNode* cvInitSparseMatIterator( const CvSparseMat* mat,
                                                  CvSparseMatIterator* matIterator );

// returns next sparse array node (or NULL if there is no more nodes)
CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* matIterator );
CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* matIterator )
{
    if( matIterator->node->next )
        return matIterator->node = matIterator->node->next;
    else
    {
        int idx;
        for( idx = ++matIterator->curidx; idx < matIterator->mat->hashsize; idx++ )
        {
            CvSparseNode* node = (CvSparseNode*)matIterator->mat->hashtable[idx];
            if( node )
            {
                matIterator->curidx = idx;
                return matIterator->node = node;
            }
        }
        return NULL;
    }
}

/* Returns type of array elements:
   CV_8UC1 ... CV_64FC4 ... */
OPENCVAPI  int cvGetElemType( const CvArr* arr );

/* Retrieves number of an array dimensions and
   optionally sizes of the dimensions */
OPENCVAPI  int cvGetDims( const CvArr* arr, int* sizes CV_DEFAULT(NULL) );


/* Retrieves size of a particular array dimension.
   For 2d arrays cvGetDimSize(arr,0) returns number of rows (image height)
   and cvGetDimSize(arr,1) returns number of columns (image width) */
OPENCVAPI  int cvGetDimSize( const CvArr* arr, int index );


/* ptr = &arr(idx1,idx2,...). All indexes are zero-based,
   the major dimensions go first (e.g. (y,x) for 2D, (z,y,x) for 3D */
OPENCVAPI uchar* cvPtr1D( const CvArr* arr, int idx1, int* type CV_DEFAULT(NULL));
OPENCVAPI uchar* cvPtr2D( const CvArr* arr, int idx1, int idx2, int* type CV_DEFAULT(NULL) );
OPENCVAPI uchar* cvPtr3D( const CvArr* arr, int idx1, int idx2, int idx3,
                          int* type CV_DEFAULT(NULL));

/* For CvMat or IplImage number of indices should be 2
   (row index (y) goes first, column index (x) goes next).
   For CvMatND or CvSparseMat number of infices should match number of <dims> and
   indices order should match the array dimension order. */
OPENCVAPI uchar* cvPtrND( const CvArr* arr, int* idx, int* type CV_DEFAULT(NULL) );

/* value = arr(idx1,idx2,...) */
OPENCVAPI CvScalar cvGet1D( const CvArr* arr, int idx1 );

⌨️ 快捷键说明

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