cvtypes.h

来自「微软的基于HMM的人脸识别原代码, 非常经典的说」· C头文件 代码 · 共 1,432 行 · 第 1/3 页

H
1,432
字号
/*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 _CVTYPES_H_#define _CVTYPES_H_#include <assert.h>#ifndef WIN32    #define CV_CDECL    #define CV_STDCALL#else    #define CV_CDECL __cdecl    #define CV_STDCALL __stdcall#endif#ifndef CV_EXTERN_C    #ifdef __cplusplus        #define CV_EXTERN_C extern "C"        #define CV_DEFAULT(val) = val    #else        #define CV_EXTERN_C        #define CV_DEFAULT(val)    #endif#endif#if defined WIN32 && defined CV#define CV_DLL_ENTRY __declspec(dllexport)#else#define CV_DLL_ENTRY#endif#ifndef OPENCVAPI    #define OPENCVAPI CV_EXTERN_C CV_DLL_ENTRY#endif#ifndef CV_INLINE    #if defined _MSC_VER || defined __GNUC__        #define CV_INLINE __inline    #elif defined __ICL        #define CV_INLINE static    #else        #define CV_INLINE __inline    #endif#endif /* CV_INLINE */#define CV_SWAP(a,b,t) ( (t) = (a), (a) = (b), (b) = (t))#define CV_DIM(array)  (sizeof(array)/sizeof((array)[0]))#ifndef MIN#define MIN(a,b)  ((a) > (b) ? (b) : (a))#endif#ifndef MAX#define MAX(a,b)  ((a) < (b) ? (b) : (a))#endiftypedef enum CvStatus{             CV_INPLACE_NOT_SUPPORTED_ERR= -112,    CV_UNMATCHED_ROI_ERR        = -111,    CV_NOTFOUND_ERR             = -110,    CV_BADCONVERGENCE_ERR       = -109,    CV_BADDEPTH_ERR             = -107,    CV_BADROI_ERR               = -106,    CV_BADHEADER_ERR            = -105,    CV_UNMATCHED_FORMATS_ERR    = -104,    CV_UNSUPPORTED_COI_ERR      = -103,    CV_UNSUPPORTED_CHANNELS_ERR = -102,    CV_UNSUPPORTED_DEPTH_ERR    = -101,    CV_UNSUPPORTED_FORMAT_ERR   = -100,                       
    CV_BADARG_ERR      = -49,  //ipp comp
    CV_NOTDEFINED_ERR  = -48,  //ipp comp

    CV_BADCHANNELS_ERR = -47,  //ipp comp
    CV_BADRANGE_ERR    = -44,  //ipp comp
    CV_BADSTEP_ERR     = -29,  //ipp comp
       CV_BADFLAG_ERR     =  -12,    CV_DIV_BY_ZERO_ERR =  -11, //ipp comp
    CV_BADCOEF_ERR     =  -10,    CV_BADQUAD_ERR     =  -9,    CV_BADINTER_ERR    =  -8,    CV_BADFACTOR_ERR   =  -7,    CV_BADPOINT_ERR    =  -6,    CV_BADSCALE_ERR    =  -4,    CV_OUTOFMEM_ERR    =  -3,    CV_NULLPTR_ERR     =  -2,
    CV_BADSIZE_ERR     =  -1,    CV_NO_ERR          =   0,    CV_OK              =   CV_NO_ERR} CvStatus;typedef enum CvMatType{    CV_MAT32F     = 32,    CV_MAT3x1_32F = 35,    CV_MAT4x1_32F = 36,    CV_MAT3x3_32F = 41,    CV_MAT4x4_32F = 48,    CV_MAT64D     = 64,    CV_MAT3x1_64D = 67,    CV_MAT4x1_64D = 68,    CV_MAT3x3_64D = 73,    CV_MAT4x4_64D = 80} CvMatType;typedef struct CvMat{    int rows;          int cols;     CvMatType type;    int step;    union    {        float* fl;        double* db;    }data;} CvMat;typedef struct CvMatArray{    int rows;    int cols;    int type;    int step;    int count;    union    {        float* fl;        double* db;    } data;} CvMatArray;typedef struct CvRect{    int x;    int y;    int width;    int height;} CvRect;typedef struct CvPoint{    int x;    int y;} CvPoint;typedef struct {    int width;    int height;} CvSize;typedef float*   CvVect32f;typedef float*   CvMatr32f;typedef double*  CvVect64d;typedef double*  CvMatr64d;#ifdef _MSC_VERtypedef __int64 int64;typedef unsigned __int64 uint64;#elsetypedef long long int64;typedef unsigned long long uint64;typedef long long _int64;#endif#define CV_TERMCRIT_ITER    1#define CV_TERMCRIT_NUMB    CV_TERMCRIT_ITER#define CV_TERMCRIT_EPS     2typedef struct CvTermCriteria{    int   type;  /* may be combination of                 CV_TERMCRIT_ITER                 CV_TERMCRIT_EPS */    int   maxIter;    float epsilon;} CvTermCriteria;typedef struct CvMatrix3{    float m[3][3];} CvMatrix3;typedef struct CvMatrix4{    float m[4][4];} CvMatrix4;typedef struct CvPoint2D32f{    float x;    float y;} CvPoint2D32f;typedef struct CvPoint3D32f{    float x;    float y;    float z;} CvPoint3D32f;typedef struct CvPoint2D64d{    double x;    double y;} CvPoint2D64d;typedef struct CvPoint3D64d{    double x;    double y;    double z;} CvPoint3D64d;typedef struct CvSize2D32f{    float width;    float height;} CvSize2D32f;typedef struct CvBox2D{    CvPoint2D32f center;    CvSize2D32f  size;    float angle;} CvBox2D;#define CvBox2D32f CvBox2Dtypedef enum CvCoeffType{    CV_VALUE = 1,    CV_ARRAY = 2} CvCoeffType;typedef struct CvSlice{    int  startIndex, endIndex;} CvSlice;#define CV_CALIPERS_MAXHEIGHT      0#define CV_CALIPERS_MINAREARECT    1#define CV_CALIPERS_MAXDIST        2#define CV_CLOCKWISE         1#define CV_COUNTER_CLOCKWISE 2CV_INLINE CvMat cvMat (int rows,int cols, CvMatType type, void* data){    CvMat m;    m.cols = cols;    m.rows = rows;    m.type = type;    m.step = 0;    m.data.fl =(float*)data;    return m; }CV_INLINE CvMatArray cvMatArray (int rows,int cols, CvMatType type, int number, void* data){    CvMatArray ma;    ma.cols = cols;    ma.rows =rows;    ma.type = type;    ma.count = number;    ma.step = 0;    ma.data.fl =(float*)data;    return ma; }CV_INLINE double cvmGet(CvMat* mat,int i, int j){    double elem;    if( (int)mat->type < 64 )        elem = (double)mat->data.fl[i*mat->cols+j];    else        elem = mat->data.db[i*mat->cols+j];    return elem;}CV_INLINE void cvmSet(CvMat* mat, int i, int j, double val){    if( (int)mat->type < 64 )        mat->data.fl[i*mat->cols+j] = (float)val;    else        mat->data.db[i*mat->cols+j] = val;}CV_INLINE CvMat* cvmGetMatArrayElem( CvMatArray* array, int index, CvMat* elem ){    assert( elem->rows == array->rows && elem->cols == array->cols &&            elem->type == array->type && index >= 0 && index < array->count );    if( array->type < CV_MAT64D )        elem->data.fl = array->data.fl + array->rows*array->cols*index;    else        elem->data.db = array->data.db + array->rows*array->cols*index;    return elem;}CV_INLINE CvRect cvRect( int x, int y, int width, int height ){    CvRect r;    r.x = x;    r.y = y;    r.width = width;    r.height = height;    return r;}CV_INLINE CvSize cvSize( int width, int height ){    CvSize s;    s.width = width;    s.height = height;    return s;}CV_INLINE CvPoint cvPoint( int x, int y ){    CvPoint p;    p.x = x;    p.y = y;    return p;}CV_INLINE CvPoint2D32f cvPoint2D32f( float x, float y ){    CvPoint2D32f p;    p.x = x;    p.y = y;    return p;}CV_INLINE CvTermCriteria cvTermCriteria( int type, int maxIter, double epsilon ){    CvTermCriteria t;    t.type = type;    t.maxIter = maxIter;    t.epsilon = (float)epsilon;    return t;}CV_INLINE CvSlice cvSlice( int start, int end ){    CvSlice slice;    slice.startIndex = start;    slice.endIndex = end;    return slice;}#define CV_WHOLE_SEQ(seq)  cvSlice(0, 0x3fffffff)/* substitutions for (int)floor(x+.49999), floor(x), ceil(x) */CV_INLINE int cvRound( double val ){    static const int round_delta = 0x59C00000;    double temp = (val + 1e-7) + *((float*)&round_delta);    return *((int*)&temp);}CV_INLINE int cvFloor( double val ){    static const int round_delta = 0x59C00000;    double temp = (val - 0.4999999) + *((float*)&round_delta);    return *((int*)&temp);}CV_INLINE int cvCeil( double val ){    static const int round_delta = 0x59C00000;    double temp = (val + 0.4999999) + *((float*)&round_delta);    return *((int*)&temp);}#define CV_SQRT_MAGIC  0xbe6f0000CV_INLINE float cvInvSqrt( float arg ){    float x, y;    unsigned iarg = *((unsigned*)&arg);    *((unsigned*)&x) = (CV_SQRT_MAGIC - iarg)>>1;    y = arg*0.5f;    x*= 1.5f - y*x*x;    x*= 1.5f - y*x*x;    return x;}CV_INLINE float cvSqrt( float arg ){    float x, y;    unsigned iarg = *((unsigned*)&arg);    *((unsigned*)&x) = (CV_SQRT_MAGIC - iarg)>>1;    y = arg*0.5f;    x*= 1.5f - y*x*x;    x*= 1.5f - y*x*x;

⌨️ 快捷键说明

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