opencv宏

 1.

CV_FUNCNAME 用于出错时可以报告出错的函数

__FILE__ 说明出错的函数所在源文件名

__LINE__ 说明出错位置的函数

 

cxerror.h 中

 /* CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */
#ifdef CV_NO_FUNC_NAMES
    #define CV_FUNCNAME( Name )
    #define cvFuncName ""
#else   
    #define CV_FUNCNAME( Name )  /
    static char cvFuncName[] = Name
#endif


/*
  CV_ERROR macro unconditionally raises error with passed code and message.
  After raising error, control will be transferred to the exit label.
*/
#define CV_ERROR( Code, Msg )                                       /
{                                                                   /
     cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ );        /
     EXIT;                                                          /
}

 

2.

__BEGIN__ 和__END__配套使用,当出现error时,EXIT

 

cxerror.h 中

#define __BEGIN__       {
#define __END__         goto exit; exit: ; }
#define __CLEANUP__
#define EXIT            goto exit

 

3.

16384 = (100 0000 0000 0000)

令 X = ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3)

((sizeof(size_t)/4+1)*16384|0x3a50) = (1011 1010 0101 0000) = (23, 22, 11, 00)当>> CV_MAT_DEPTH(type)*2时将两位两位向右移,即当DEPTH为CV_8U, CV_8S时, X =0;当DEPTH为CV_16U, CV_16S时, X = 1;

当DEPTH为CV_32S, CV_32F时, X = 2;当DEPTH为CV_64F时,X = 3;

CV_DEPTH_MAX = 8 = (1000)

CV_MAT_DEPTH_MASK = 7 = (0111)

CV_MAT_CN_MASK = (111111, 000)

CV_MAT_CN求得通道数

CV_MAT_DEPTH求得深度,共8中 0 ~ 7

CV_ELEM_SIZE = 通道数 x DEPTH占字节数 = 通道数 >> X = 一个像素字节数

 

 

cxtypes.h中

/* 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */
#define CV_ELEM_SIZE(type) /
    (CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3))

 

#define CV_CN_MAX     64

#define CV_MAT_CN_MASK          ((CV_CN_MAX - 1) << CV_CN_SHIFT)
#define CV_MAT_CN(flags)        ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)

 

#define CV_MAT_DEPTH(flags)     ((flags) & CV_MAT_DEPTH_MASK)

#define CV_MAT_DEPTH_MASK       (CV_DEPTH_MAX - 1)

#define CV_CN_SHIFT   3
#define CV_DEPTH_MAX  (1 << CV_CN_SHIFT)

你可能感兴趣的:(opencv学习)