/home/fwph/code/wurde/modules/visionModule/Operators/face/MyHaar.H

Go to the documentation of this file.
00001 #ifndef MYHAAR
00002 #define MYHAAR
00003 
00004 #if defined _MSC_VER && _MSC_VER >= 1200
00005     /* disable warnings related to inline functions */
00006     #pragma warning( disable: 4711 4710 4514 )
00007 #endif
00008 
00009 #include "cv.h"
00010 #include "cxmisc.h"
00011 #include <math.h>
00012 #include <assert.h>
00013 #include <string.h>
00014 #include <stdlib.h>
00015 #include <stdio.h>
00016 #include <limits.h>
00017 #include <float.h>
00018 
00019 typedef unsigned char uchar;
00020 typedef unsigned short ushort;
00021 
00022 #ifdef __BORLANDC__
00023     #define     WIN32
00024     #define     CV_DLL
00025     #undef      _CV_ALWAYS_PROFILE_
00026     #define     _CV_ALWAYS_NO_PROFILE_
00027 #endif
00028 
00029 /* helper tables */
00030 extern const uchar icvSaturate8u[];
00031 #define CV_FAST_CAST_8U(t)  (assert(-256 <= (t) || (t) <= 512), icvSaturate8u[(t)+256])
00032 #define CV_CALC_MIN_8U(a,b) (a) -= CV_FAST_CAST_8U((a) - (b))
00033 #define CV_CALC_MAX_8U(a,b) (a) += CV_FAST_CAST_8U((b) - (a))
00034 
00035 // -128.f ... 255.f
00036 extern const float icv8x32fTab_cv[];
00037 #define CV_8TO32F(x)  icv8x32fTab_cv[(x)+128]
00038 
00039 // (-128.f)^2 ... (255.f)^2
00040 extern const float icv8x32fSqrTab[];
00041 #define CV_8TO32F_SQR(x)  icv8x32fSqrTab[(x)+128]
00042 
00043 CV_INLINE  CvDataType icvDepthToDataType( int type );
00044 CV_INLINE  CvDataType icvDepthToDataType( int type )
00045 {
00046     return (CvDataType)(
00047             ((((int)cv8u)|((int)cv8s << 4)|((int)cv16u << 8)|
00048               ((int)cv16s << 12)|((int)cv32s << 16)|((int)cv32f << 20)|
00049               ((int)cv64f << 24)) >> CV_MAT_DEPTH(type)*4) & 15);
00050 }
00051 
00052 #define CV_HIST_DEFAULT_TYPE CV_32F
00053 
00054 CV_EXTERN_C_FUNCPTR( void (CV_CDECL * CvWriteNodeFunction)(void* seq,void* node) )
00055 
00056 #define _CvConvState CvFilterState
00057 
00058 typedef struct CvPyramid
00059 {
00060     uchar **ptr;
00061     CvSize *sz;
00062     double *rate;
00063     int *step;
00064     uchar *state;
00065     int level;
00066 }
00067 CvPyramid;
00068 
00069 #define IPCV_COPY_BORDER( bordertype, flavor, arrtype )                             \
00070 IPCVAPI_EX( CvStatus, icvCopy##bordertype##Border_##flavor,                         \
00071             "ippiCopy" #bordertype "Border_" #flavor, CV_PLUGINS1(CV_PLUGIN_IPPI),  \
00072             ( const arrtype* pSrc,  int srcStep, CvSize srcRoiSize,                 \
00073                     arrtype* pDst,  int dstStep, CvSize dstRoiSize,                 \
00074                     int topBorderWidth, int leftBorderWidth ))
00075 
00076 IPCV_COPY_BORDER( Replicate, 8u_C1R, uchar )
00077 IPCV_COPY_BORDER( Replicate, 16s_C1R, ushort )
00078 IPCV_COPY_BORDER( Replicate, 8u_C3R, uchar )
00079 IPCV_COPY_BORDER( Replicate, 32s_C1R, int )
00080 IPCV_COPY_BORDER( Replicate, 16s_C3R, ushort )
00081 IPCV_COPY_BORDER( Replicate, 16s_C4R, int )
00082 IPCV_COPY_BORDER( Replicate, 32s_C3R, int )
00083 IPCV_COPY_BORDER( Replicate, 32s_C4R, int )
00084 IPCV_COPY_BORDER( Replicate, 64f_C3R, int )
00085 IPCV_COPY_BORDER( Replicate, 64f_C4R, int )
00086 
00087 #undef IPCV_COPY_BORDER
00088 
00089 #define IPCV_COPY_CONST_BORDER_C1( flavor, arrtype )                                \
00090 IPCVAPI_EX( CvStatus, icvCopyConstBorder_##flavor,                                  \
00091             "ippiCopyConstBorder_" #flavor, CV_PLUGINS1(CV_PLUGIN_IPPI),            \
00092             ( const arrtype* pSrc,  int srcStep, CvSize srcRoiSize,                 \
00093                     arrtype* pDst,  int dstStep, CvSize dstRoiSize,                 \
00094                     int topBorderWidth, int leftBorderWidth, arrtype value ))
00095 
00096 IPCV_COPY_CONST_BORDER_C1( 8u_C1R, uchar )
00097 IPCV_COPY_CONST_BORDER_C1( 16s_C1R, ushort )
00098 IPCV_COPY_CONST_BORDER_C1( 32s_C1R, int )
00099 
00100 #undef IPCV_COPY_CONST_BORDER_C1
00101 
00102 #define IPCV_COPY_CONST_BORDER_CN( flavor, arrtype )                                \
00103 IPCVAPI_EX( CvStatus, icvCopyConstBorder_##flavor,                                  \
00104             "ippiCopyConstBorder_" #flavor, CV_PLUGINS1(CV_PLUGIN_IPPI),            \
00105             ( const arrtype* pSrc,  int srcStep, CvSize srcRoiSize,                 \
00106                     arrtype* pDst,  int dstStep, CvSize dstRoiSize,                 \
00107                     int topBorderWidth, int leftBorderWidth, const arrtype* value ))
00108 
00109 IPCV_COPY_CONST_BORDER_CN( 8u_C3R, uchar )
00110 IPCV_COPY_CONST_BORDER_CN( 16s_C3R, ushort )
00111 IPCV_COPY_CONST_BORDER_CN( 16s_C4R, int )
00112 IPCV_COPY_CONST_BORDER_CN( 32s_C3R, int )
00113 IPCV_COPY_CONST_BORDER_CN( 32s_C4R, int )
00114 IPCV_COPY_CONST_BORDER_CN( 64f_C3R, int )
00115 IPCV_COPY_CONST_BORDER_CN( 64f_C4R, int )
00116 
00117 #undef IPCV_COPY_CONST_BORDER_CN
00118 
00119 /****************************************************************************************\
00120 *                                        Moments                                         *
00121 \****************************************************************************************/
00122 
00123 #define IPCV_MOMENTS( suffix, ipp_suffix, cn )                      \
00124 IPCVAPI_EX( CvStatus, icvMoments##suffix##_C##cn##R,                \
00125 "ippiMoments" #ipp_suffix "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
00126 ( const void* img, int step, CvSize size, void* momentstate ))
00127 
00128 IPCV_MOMENTS( _8u, 64f_8u, 1 )
00129 IPCV_MOMENTS( _32f, 64f_32f, 1 )
00130 
00131 #undef IPCV_MOMENTS
00132 
00133 IPCVAPI_EX( CvStatus, icvMomentInitAlloc_64f,
00134             "ippiMomentInitAlloc_64f", CV_PLUGINS1(CV_PLUGIN_IPPI),
00135             (void** momentstate, CvHintAlgorithm hint ))
00136 
00137 IPCVAPI_EX( CvStatus, icvMomentFree_64f,
00138             "ippiMomentFree_64f", CV_PLUGINS1(CV_PLUGIN_IPPI),
00139             (void* momentstate ))
00140 
00141 IPCVAPI_EX( CvStatus, icvGetSpatialMoment_64f,
00142             "ippiGetSpatialMoment_64f", CV_PLUGINS1(CV_PLUGIN_IPPI),
00143             (const void* momentstate, int mOrd, int nOrd,
00144              int nChannel, CvPoint roiOffset, double* value ))
00145 
00146 /****************************************************************************************\
00147 *                                  Background differencing                               *
00148 \****************************************************************************************/
00149 
00151 
00152 #define IPCV_ACCUM( flavor, arrtype, acctype )                                      \
00153 IPCVAPI_EX( CvStatus, icvAdd_##flavor##_C1IR,                                       \
00154     "ippiAdd_" #flavor "_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV),                       \
00155     ( const arrtype* src, int srcstep, acctype* dst, int dststep, CvSize size ))    \
00156 IPCVAPI_EX( CvStatus, icvAddSquare_##flavor##_C1IR,                                 \
00157     "ippiAddSquare_" #flavor "_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV),                 \
00158     ( const arrtype* src, int srcstep, acctype* dst, int dststep, CvSize size ))    \
00159 IPCVAPI_EX( CvStatus, icvAddProduct_##flavor##_C1IR,                                \
00160     "ippiAddProduct_" #flavor "_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV),                \
00161     ( const arrtype* src1, int srcstep1, const arrtype* src2, int srcstep2,         \
00162       acctype* dst, int dststep, CvSize size ))                                     \
00163 IPCVAPI_EX( CvStatus, icvAddWeighted_##flavor##_C1IR,                               \
00164     "ippiAddWeighted_" #flavor "_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV),               \
00165     ( const arrtype* src, int srcstep, acctype* dst, int dststep,                   \
00166       CvSize size, acctype alpha ))                                                 \
00167                                                                                     \
00168 IPCVAPI_EX( CvStatus, icvAdd_##flavor##_C1IMR,                                      \
00169     "ippiAdd_" #flavor "_C1IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV),                      \
00170     ( const arrtype* src, int srcstep, const uchar* mask, int maskstep,             \
00171       acctype* dst, int dststep, CvSize size ))                                     \
00172 IPCVAPI_EX( CvStatus, icvAddSquare_##flavor##_C1IMR,                                \
00173     "ippiAddSquare_" #flavor "_C1IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV),                \
00174     ( const arrtype* src, int srcstep, const uchar* mask, int maskstep,             \
00175       acctype* dst, int dststep, CvSize size ))                                     \
00176 IPCVAPI_EX( CvStatus, icvAddProduct_##flavor##_C1IMR,                               \
00177     "ippiAddProduct_" #flavor "_C1IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV),               \
00178     ( const arrtype* src1, int srcstep1, const arrtype* src2, int srcstep2,         \
00179       const uchar* mask, int maskstep, acctype* dst, int dststep, CvSize size ))    \
00180 IPCVAPI_EX( CvStatus, icvAddWeighted_##flavor##_C1IMR,                              \
00181     "ippiAddWeighted_" #flavor "_C1IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV),              \
00182     ( const arrtype* src, int srcstep, const uchar* mask, int maskstep,             \
00183       acctype* dst, int dststep, CvSize size, acctype alpha ))                      \
00184                                                                                     \
00185 IPCVAPI_EX( CvStatus, icvAdd_##flavor##_C3IMR,                                      \
00186     "ippiAdd_" #flavor "_C3IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV),                      \
00187     ( const arrtype* src, int srcstep, const uchar* mask, int maskstep,             \
00188       acctype* dst, int dststep, CvSize size ))                                     \
00189 IPCVAPI_EX( CvStatus, icvAddSquare_##flavor##_C3IMR,                                \
00190     "ippiAddSquare_" #flavor "_C3IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV),                \
00191     ( const arrtype* src, int srcstep, const uchar* mask, int maskstep,             \
00192       acctype* dst, int dststep, CvSize size ))                                     \
00193 IPCVAPI_EX( CvStatus, icvAddProduct_##flavor##_C3IMR,                               \
00194     "ippiAddProduct_" #flavor "_C3IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV),               \
00195     ( const arrtype* src1, int srcstep1, const arrtype* src2, int srcstep2,         \
00196       const uchar* mask, int maskstep, acctype* dst, int dststep, CvSize size ))    \
00197 IPCVAPI_EX( CvStatus, icvAddWeighted_##flavor##_C3IMR,                              \
00198     "ippiAddWeighted_" #flavor "_C3IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV),              \
00199     ( const arrtype* src, int srcstep, const uchar* mask, int maskstep,             \
00200       acctype* dst, int dststep, CvSize size, acctype alpha ))
00201 
00202 IPCV_ACCUM( 8u32f, uchar, float )
00203 IPCV_ACCUM( 32f, float, float )
00204 
00205 #undef IPCV_ACCUM
00206 
00207 /****************************************************************************************\
00208 *                                       Pyramids                                         *
00209 \****************************************************************************************/
00210 
00211 IPCVAPI_EX( CvStatus, icvPyrDownGetBufSize_Gauss5x5,
00212            "ippiPyrDownGetBufSize_Gauss5x5", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00213             ( int roiWidth, CvDataType dataType, int channels, int* bufSize ))
00214 
00215 IPCVAPI_EX( CvStatus, icvPyrUpGetBufSize_Gauss5x5,
00216            "ippiPyrUpGetBufSize_Gauss5x5", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00217             ( int roiWidth, CvDataType dataType, int channels, int* bufSize ))
00218 
00219 #define ICV_PYRDOWN( flavor, cn )                                           \
00220 IPCVAPI_EX( CvStatus, icvPyrDown_Gauss5x5_##flavor##_C##cn##R,              \
00221 "ippiPyrDown_Gauss5x5_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
00222 ( const void* pSrc, int srcStep, void* pDst, int dstStep,                   \
00223   CvSize roiSize, void* pBuffer ))
00224 
00225 #define ICV_PYRUP( flavor, cn )                                             \
00226 IPCVAPI_EX( CvStatus, icvPyrUp_Gauss5x5_##flavor##_C##cn##R,                \
00227 "ippiPyrUp_Gauss5x5_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPCV),   \
00228 ( const void* pSrc, int srcStep, void* pDst, int dstStep,                   \
00229   CvSize roiSize, void* pBuffer ))
00230 
00231 ICV_PYRDOWN( 8u, 1 )
00232 ICV_PYRDOWN( 8u, 3 )
00233 ICV_PYRDOWN( 32f, 1 )
00234 ICV_PYRDOWN( 32f, 3 )
00235 
00236 ICV_PYRUP( 8u, 1 )
00237 ICV_PYRUP( 8u, 3 )
00238 ICV_PYRUP( 32f, 1 )
00239 ICV_PYRUP( 32f, 3 )
00240 
00241 #undef ICV_PYRDOWN
00242 #undef ICV_PYRUP
00243 
00244 /****************************************************************************************\
00245 *                                Geometric Transformations                               *
00246 \****************************************************************************************/
00247 
00248 /*#define IPCV_REMAP( flavor, cn, arrtype )                                   \
00249 IPCVAPI_EX( CvStatus, icvRemap_##flavor##_C##cn##R,                         \
00250     "ippiRemap_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),         \
00251     ( const arrtype* src, CvSize srcsize, int srcstep, CvSize srcroi,       \
00252       const float* xmap, int xmapstep, const float* ymap, int ymapstep,     \
00253       arrtype* dst, int dststep, CvSize dstroi, int interpolation ))
00254 
00255 IPCV_REMAP( 8u, 1, uchar )
00256 IPCV_REMAP( 8u, 3, uchar )
00257 IPCV_REMAP( 8u, 4, uchar )
00258 
00259 IPCV_REMAP( 32f, 1, float )
00260 IPCV_REMAP( 32f, 3, float )
00261 IPCV_REMAP( 32f, 4, float )
00262 
00263 #undef IPCV_REMAP*/
00264 
00265 #define IPCV_RESIZE( flavor, cn )                                           \
00266 IPCVAPI_EX( CvStatus, icvResize_##flavor##_C##cn##R,                        \
00267             "ippiResize_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
00268            (const void* src, CvSize srcsize, int srcstep, CvRect srcroi,    \
00269             void* dst, int dststep, CvSize dstroi,                          \
00270             double xfactor, double yfactor, int interpolation ))
00271 
00272 IPCV_RESIZE( 8u, 1 )
00273 IPCV_RESIZE( 8u, 3 )
00274 IPCV_RESIZE( 8u, 4 )
00275 
00276 IPCV_RESIZE( 16u, 1 )
00277 IPCV_RESIZE( 16u, 3 )
00278 IPCV_RESIZE( 16u, 4 )
00279 
00280 IPCV_RESIZE( 32f, 1 )
00281 IPCV_RESIZE( 32f, 3 )
00282 IPCV_RESIZE( 32f, 4 )
00283 
00284 #undef IPCV_RESIZE
00285 
00286 #define IPCV_WARPAFFINE_BACK( flavor, cn )                                  \
00287 IPCVAPI_EX( CvStatus, icvWarpAffineBack_##flavor##_C##cn##R,                \
00288     "ippiWarpAffineBack_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
00289     (const void* src, CvSize srcsize, int srcstep, CvRect srcroi,           \
00290     void* dst, int dststep, CvRect dstroi,                                  \
00291     const double* coeffs, int interpolate ))
00292 
00293 IPCV_WARPAFFINE_BACK( 8u, 1 )
00294 IPCV_WARPAFFINE_BACK( 8u, 3 )
00295 IPCV_WARPAFFINE_BACK( 8u, 4 )
00296 
00297 IPCV_WARPAFFINE_BACK( 32f, 1 )
00298 IPCV_WARPAFFINE_BACK( 32f, 3 )
00299 IPCV_WARPAFFINE_BACK( 32f, 4 )
00300 
00301 #undef IPCV_WARPAFFINE_BACK
00302 
00303 #define IPCV_WARPPERSPECTIVE_BACK( flavor, cn )                             \
00304 IPCVAPI_EX( CvStatus, icvWarpPerspectiveBack_##flavor##_C##cn##R,           \
00305     "ippiWarpPerspectiveBack_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
00306     (const void* src, CvSize srcsize, int srcstep, CvRect srcroi,           \
00307     void* dst, int dststep, CvRect dstroi,                                  \
00308     const double* coeffs, int interpolate ))
00309 
00310 IPCV_WARPPERSPECTIVE_BACK( 8u, 1 )
00311 IPCV_WARPPERSPECTIVE_BACK( 8u, 3 )
00312 IPCV_WARPPERSPECTIVE_BACK( 8u, 4 )
00313 
00314 IPCV_WARPPERSPECTIVE_BACK( 32f, 1 )
00315 IPCV_WARPPERSPECTIVE_BACK( 32f, 3 )
00316 IPCV_WARPPERSPECTIVE_BACK( 32f, 4 )
00317 
00318 #undef IPCV_WARPPERSPECTIVE_BACK
00319 
00320 
00321 #define IPCV_WARPPERSPECTIVE( flavor, cn )                                  \
00322 IPCVAPI_EX( CvStatus, icvWarpPerspective_##flavor##_C##cn##R,               \
00323     "ippiWarpPerspective_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
00324     (const void* src, CvSize srcsize, int srcstep, CvRect srcroi,           \
00325     void* dst, int dststep, CvRect dstroi,                                  \
00326     const double* coeffs, int interpolate ))
00327 
00328 IPCV_WARPPERSPECTIVE( 8u, 1 )
00329 IPCV_WARPPERSPECTIVE( 8u, 3 )
00330 IPCV_WARPPERSPECTIVE( 8u, 4 )
00331 
00332 IPCV_WARPPERSPECTIVE( 32f, 1 )
00333 IPCV_WARPPERSPECTIVE( 32f, 3 )
00334 IPCV_WARPPERSPECTIVE( 32f, 4 )
00335 
00336 #undef IPCV_WARPPERSPECTIVE
00337 
00338 #define IPCV_REMAP( flavor, cn )                                        \
00339 IPCVAPI_EX( CvStatus, icvRemap_##flavor##_C##cn##R,                     \
00340     "ippiRemap_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),     \
00341     ( const void* src, CvSize srcsize, int srcstep, CvRect srcroi,      \
00342       const float* xmap, int xmapstep, const float* ymap, int ymapstep, \
00343       void* dst, int dststep, CvSize dstsize, int interpolation )) 
00344 
00345 IPCV_REMAP( 8u, 1 )
00346 IPCV_REMAP( 8u, 3 )
00347 IPCV_REMAP( 8u, 4 )
00348 
00349 IPCV_REMAP( 32f, 1 )
00350 IPCV_REMAP( 32f, 3 )
00351 IPCV_REMAP( 32f, 4 )
00352 
00353 #undef IPCV_REMAP
00354 
00355 /****************************************************************************************\
00356 *                                      Morphology                                        *
00357 \****************************************************************************************/
00358 
00359 #define IPCV_MORPHOLOGY( minmaxtype, morphtype, flavor, cn )            \
00360 IPCVAPI_EX( CvStatus, icv##morphtype##Rect_##flavor##_C##cn##R,         \
00361             "ippiFilter" #minmaxtype "_" #flavor "_C" #cn "R",          \
00362             CV_PLUGINS1(CV_PLUGIN_IPPI),                                \
00363             ( const void* src, int srcstep, void* dst, int dststep,     \
00364               CvSize roi, CvSize esize, CvPoint anchor ))               \
00365 IPCVAPI_EX( CvStatus, icv##morphtype##Any_##flavor##_C##cn##R,          \
00366             "ippi" #morphtype "_" #flavor "_C" #cn "R",                 \
00367             CV_PLUGINS1(CV_PLUGIN_IPPI),                                \
00368             ( const void* src, int srcstep, void* dst, int dststep,     \
00369               CvSize roi, const uchar* element,                         \
00370               CvSize esize, CvPoint anchor ))
00371 
00372 IPCV_MORPHOLOGY( Min, Erode, 8u, 1 )
00373 IPCV_MORPHOLOGY( Min, Erode, 8u, 3 )
00374 IPCV_MORPHOLOGY( Min, Erode, 8u, 4 )
00375 IPCV_MORPHOLOGY( Min, Erode, 32f, 1 )
00376 IPCV_MORPHOLOGY( Min, Erode, 32f, 3 )
00377 IPCV_MORPHOLOGY( Min, Erode, 32f, 4 )
00378 IPCV_MORPHOLOGY( Max, Dilate, 8u, 1 )
00379 IPCV_MORPHOLOGY( Max, Dilate, 8u, 3 )
00380 IPCV_MORPHOLOGY( Max, Dilate, 8u, 4 )
00381 IPCV_MORPHOLOGY( Max, Dilate, 32f, 1 )
00382 IPCV_MORPHOLOGY( Max, Dilate, 32f, 3 )
00383 IPCV_MORPHOLOGY( Max, Dilate, 32f, 4 )
00384 
00385 #undef IPCV_MORPHOLOGY
00386 
00387 /****************************************************************************************\
00388 *                                 Smoothing Filters                                      *
00389 \****************************************************************************************/
00390 
00391 #define IPCV_FILTER_MEDIAN( flavor, cn )                                            \
00392 IPCVAPI_EX( CvStatus, icvFilterMedian_##flavor##_C##cn##R,                          \
00393             "ippiFilterMedian_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),  \
00394             ( const void* src, int srcstep, void* dst, int dststep,                 \
00395               CvSize roi, CvSize ksize, CvPoint anchor ))
00396 
00397 IPCV_FILTER_MEDIAN( 8u, 1 )
00398 IPCV_FILTER_MEDIAN( 8u, 3 )
00399 IPCV_FILTER_MEDIAN( 8u, 4 )
00400 
00401 #define IPCV_FILTER_BOX( flavor, cn )                                               \
00402 IPCVAPI_EX( CvStatus, icvFilterBox_##flavor##_C##cn##R,                             \
00403             "ippiFilterBox_" #flavor "_C" #cn "R", 0/*CV_PLUGINS1(CV_PLUGIN_IPPI)*/,\
00404             ( const void* src, int srcstep, void* dst, int dststep,                 \
00405               CvSize roi, CvSize ksize, CvPoint anchor ))
00406 
00407 IPCV_FILTER_BOX( 8u, 1 )
00408 IPCV_FILTER_BOX( 8u, 3 )
00409 IPCV_FILTER_BOX( 8u, 4 )
00410 IPCV_FILTER_BOX( 32f, 1 )
00411 IPCV_FILTER_BOX( 32f, 3 )
00412 IPCV_FILTER_BOX( 32f, 4 )
00413 
00414 #undef IPCV_FILTER_BOX
00415 
00416 /****************************************************************************************\
00417 *                                 Derivative Filters                                     *
00418 \****************************************************************************************/
00419 
00420 #define IPCV_FILTER_SOBEL( suffix, ipp_suffix, flavor )                             \
00421 IPCVAPI_EX( CvStatus, icvFilterSobel##suffix##_##flavor##_C1R,                      \
00422     "ippiFilterSobel" #ipp_suffix "_" #flavor "_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),  \
00423     ( const void* src, int srcstep, void* dst, int dststep, CvSize roi, int aperture ))
00424 
00425 IPCV_FILTER_SOBEL( Vert, Vert, 8u16s )
00426 IPCV_FILTER_SOBEL( Horiz, Horiz, 8u16s )
00427 IPCV_FILTER_SOBEL( VertSecond, VertSecond, 8u16s )
00428 IPCV_FILTER_SOBEL( HorizSecond, HorizSecond, 8u16s )
00429 IPCV_FILTER_SOBEL( Cross, Cross, 8u16s )
00430 
00431 IPCV_FILTER_SOBEL( Vert, VertMask, 32f )
00432 IPCV_FILTER_SOBEL( Horiz, HorizMask, 32f )
00433 IPCV_FILTER_SOBEL( VertSecond, VertSecond, 32f )
00434 IPCV_FILTER_SOBEL( HorizSecond, HorizSecond, 32f )
00435 IPCV_FILTER_SOBEL( Cross, Cross, 32f )
00436 
00437 #undef IPCV_FILTER_SOBEL
00438 
00439 #define IPCV_FILTER_SCHARR( suffix, ipp_suffix, flavor )                            \
00440 IPCVAPI_EX( CvStatus, icvFilterScharr##suffix##_##flavor##_C1R,                     \
00441     "ippiFilterScharr" #ipp_suffix "_" #flavor "_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI), \
00442     ( const void* src, int srcstep, void* dst, int dststep, CvSize roi ))
00443 
00444 IPCV_FILTER_SCHARR( Vert, Vert, 8u16s )
00445 IPCV_FILTER_SCHARR( Horiz, Horiz, 8u16s )
00446 IPCV_FILTER_SCHARR( Vert, Vert, 32f )
00447 IPCV_FILTER_SCHARR( Horiz, Horiz, 32f )
00448 
00449 #undef IPCV_FILTER_SCHARR
00450 
00451 /****************************************************************************************\
00452 *                                   Generic Filters                                      *
00453 \****************************************************************************************/
00454 
00455 #define IPCV_FILTER( suffix, ipp_suffix, cn, ksizetype, anchortype )                    \
00456 IPCVAPI_EX( CvStatus, icvFilter##suffix##_C##cn##R,                                     \
00457             "ippiFilter" #ipp_suffix "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),         \
00458             ( const void* src, int srcstep, void* dst, int dststep, CvSize size,        \
00459               const float* kernel, ksizetype ksize, anchortype anchor ))
00460 
00461 IPCV_FILTER( _8u, 32f_8u, 1, CvSize, CvPoint )
00462 IPCV_FILTER( _8u, 32f_8u, 3, CvSize, CvPoint )
00463 IPCV_FILTER( _8u, 32f_8u, 4, CvSize, CvPoint )
00464 
00465 IPCV_FILTER( _16s, 32f_16s, 1, CvSize, CvPoint )
00466 IPCV_FILTER( _16s, 32f_16s, 3, CvSize, CvPoint )
00467 IPCV_FILTER( _16s, 32f_16s, 4, CvSize, CvPoint )
00468 
00469 IPCV_FILTER( _32f, _32f, 1, CvSize, CvPoint )
00470 IPCV_FILTER( _32f, _32f, 3, CvSize, CvPoint )
00471 IPCV_FILTER( _32f, _32f, 4, CvSize, CvPoint )
00472 
00473 IPCV_FILTER( Column_8u, Column32f_8u, 1, int, int )
00474 IPCV_FILTER( Column_8u, Column32f_8u, 3, int, int )
00475 IPCV_FILTER( Column_8u, Column32f_8u, 4, int, int )
00476 
00477 IPCV_FILTER( Column_16s, Column32f_16s, 1, int, int )
00478 IPCV_FILTER( Column_16s, Column32f_16s, 3, int, int )
00479 IPCV_FILTER( Column_16s, Column32f_16s, 4, int, int )
00480 
00481 IPCV_FILTER( Column_32f, Column_32f, 1, int, int )
00482 IPCV_FILTER( Column_32f, Column_32f, 3, int, int )
00483 IPCV_FILTER( Column_32f, Column_32f, 4, int, int )
00484 
00485 IPCV_FILTER( Row_8u, Row32f_8u, 1, int, int )
00486 IPCV_FILTER( Row_8u, Row32f_8u, 3, int, int )
00487 IPCV_FILTER( Row_8u, Row32f_8u, 4, int, int )
00488 
00489 IPCV_FILTER( Row_16s, Row32f_16s, 1, int, int )
00490 IPCV_FILTER( Row_16s, Row32f_16s, 3, int, int )
00491 IPCV_FILTER( Row_16s, Row32f_16s, 4, int, int )
00492 
00493 IPCV_FILTER( Row_32f, Row_32f, 1, int, int )
00494 IPCV_FILTER( Row_32f, Row_32f, 3, int, int )
00495 IPCV_FILTER( Row_32f, Row_32f, 4, int, int )
00496 
00497 #undef IPCV_FILTER
00498 
00499 
00500 /****************************************************************************************\
00501 *                                  Color Transformations                                 *
00502 \****************************************************************************************/
00503 
00504 #define IPCV_COLOR( funcname, ipp_funcname, flavor )                            \
00505 IPCVAPI_EX( CvStatus, icv##funcname##_##flavor##_C3R,                           \
00506         "ippi" #ipp_funcname "_" #flavor "_C3R,"                                \
00507         "ippi" #ipp_funcname "_" #flavor "_C3R",                                \
00508         CV_PLUGINS2(CV_PLUGIN_IPPI,CV_PLUGIN_IPPCC),                            \
00509         ( const void* src, int srcstep, void* dst, int dststep, CvSize size ))
00510 
00511 IPCV_COLOR( RGB2XYZ, RGBToXYZ, 8u )
00512 IPCV_COLOR( RGB2XYZ, RGBToXYZ, 16u )
00513 IPCV_COLOR( RGB2XYZ, RGBToXYZ, 32f )
00514 IPCV_COLOR( XYZ2RGB, XYZToRGB, 8u )
00515 IPCV_COLOR( XYZ2RGB, XYZToRGB, 16u )
00516 IPCV_COLOR( XYZ2RGB, XYZToRGB, 32f )
00517 
00518 IPCV_COLOR( RGB2HSV, RGBToHSV, 8u )
00519 IPCV_COLOR( HSV2RGB, HSVToRGB, 8u )
00520 
00521 IPCV_COLOR( RGB2HLS, RGBToHLS, 8u )
00522 IPCV_COLOR( RGB2HLS, RGBToHLS, 32f )
00523 IPCV_COLOR( HLS2RGB, HLSToRGB, 8u )
00524 IPCV_COLOR( HLS2RGB, HLSToRGB, 32f )
00525 
00526 IPCV_COLOR( BGR2Lab, BGRToLab, 8u )
00527 IPCV_COLOR( Lab2BGR, LabToBGR, 8u )
00528 
00529 IPCV_COLOR( RGB2Luv, RGBToLUV, 8u )
00530 /*IPCV_COLOR( RGB2Luv, RGBToLUV, 32f )*/
00531 IPCV_COLOR( Luv2RGB, LUVToRGB, 8u )
00532 /*IPCV_COLOR( Luv2RGB, LUVToRGB, 32f )*/
00533 
00534 /****************************************************************************************\
00535 *                                  Motion Templates                                      *
00536 \****************************************************************************************/
00537 
00538 IPCVAPI_EX( CvStatus, icvUpdateMotionHistory_8u32f_C1IR,
00539     "ippiUpdateMotionHistory_8u32f_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00540     ( const uchar* silIm, int silStep, float* mhiIm, int mhiStep,
00541       CvSize size,float  timestamp, float  mhi_duration ))
00542 
00543 /****************************************************************************************\
00544 *                                 Template Matching                                      *
00545 \****************************************************************************************/
00546 
00547 #define ICV_MATCHTEMPLATE( flavor, arrtype )                        \
00548 IPCVAPI_EX( CvStatus, icvCrossCorrValid_Norm_##flavor##_C1R,        \
00549         "ippiCrossCorrValid_Norm_" #flavor "_C1R",                  \
00550         CV_PLUGINS1(CV_PLUGIN_IPPI),                                \
00551         ( const arrtype* pSrc, int srcStep, CvSize srcRoiSize,      \
00552         const arrtype* pTpl, int tplStep, CvSize tplRoiSize,        \
00553         float* pDst, int dstStep ))                                 \
00554 IPCVAPI_EX( CvStatus, icvCrossCorrValid_NormLevel_##flavor##_C1R,   \
00555         "ippiCrossCorrValid_NormLevel_" #flavor "_C1R",             \
00556         CV_PLUGINS1(CV_PLUGIN_IPPI),                                \
00557         ( const arrtype* pSrc, int srcStep, CvSize srcRoiSize,      \
00558         const arrtype* pTpl, int tplStep, CvSize tplRoiSize,        \
00559         float* pDst, int dstStep ))                                 \
00560 IPCVAPI_EX( CvStatus, icvSqrDistanceValid_Norm_##flavor##_C1R,      \
00561         "ippiSqrDistanceValid_Norm_" #flavor "_C1R",                \
00562         CV_PLUGINS1(CV_PLUGIN_IPPI),                                \
00563         ( const arrtype* pSrc, int srcStep, CvSize srcRoiSize,      \
00564         const arrtype* pTpl, int tplStep, CvSize tplRoiSize,        \
00565         float* pDst, int dstStep ))
00566 
00567 ICV_MATCHTEMPLATE( 8u32f, uchar )
00568 ICV_MATCHTEMPLATE( 32f, float )
00569 
00570 /****************************************************************************************/
00571 /*                                Distance Transform                                    */
00572 /****************************************************************************************/
00573 
00574 IPCVAPI_EX(CvStatus, icvDistanceTransform_3x3_8u32f_C1R,
00575     "ippiDistanceTransform_3x3_8u32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00576     ( const uchar* pSrc, int srcStep, float* pDst,
00577       int dstStep, CvSize roiSize, const float* pMetrics ))
00578 
00579 IPCVAPI_EX(CvStatus, icvDistanceTransform_5x5_8u32f_C1R,
00580     "ippiDistanceTransform_5x5_8u32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00581     ( const uchar* pSrc, int srcStep, float* pDst,
00582       int dstStep, CvSize roiSize, const float* pMetrics ))
00583 
00584 /****************************************************************************************\
00585 *                               Thresholding functions                                   *
00586 \****************************************************************************************/
00587 
00588 IPCVAPI_EX( CvStatus, icvCompareC_8u_C1R,
00589             "ippiCompareC_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
00590             ( const uchar* src1, int srcstep1, uchar scalar,
00591               uchar* dst, int dststep, CvSize size, int cmp_op ))
00592 IPCVAPI_EX( CvStatus, icvAndC_8u_C1R,
00593             "ippiAndC_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
00594             ( const uchar* src1, int srcstep1, uchar scalar,
00595               uchar* dst, int dststep, CvSize size ))
00596 IPCVAPI_EX( CvStatus, icvThreshold_GTVal_8u_C1R,
00597             "ippiThreshold_GTVal_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
00598             ( const uchar* pSrc, int srcstep, uchar* pDst, int dststep,
00599               CvSize size, uchar threshold, uchar value ))
00600 IPCVAPI_EX( CvStatus, icvThreshold_GTVal_32f_C1R,
00601             "ippiThreshold_GTVal_32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
00602             ( const float* pSrc, int srcstep, float* pDst, int dststep,
00603               CvSize size, float threshold, float value ))
00604 IPCVAPI_EX( CvStatus, icvThreshold_LTVal_8u_C1R,
00605             "ippiThreshold_LTVal_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
00606             ( const uchar* pSrc, int srcstep, uchar* pDst, int dststep,
00607               CvSize size, uchar threshold, uchar value ))
00608 IPCVAPI_EX( CvStatus, icvThreshold_LTVal_32f_C1R,
00609             "ippiThreshold_LTVal_32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
00610             ( const float* pSrc, int srcstep, float* pDst, int dststep,
00611               CvSize size, float threshold, float value ))
00612 
00613 /****************************************************************************************\
00614 *                                 Canny Edge Detector                                    *
00615 \****************************************************************************************/
00616 
00617 IPCVAPI_EX( CvStatus, icvCannyGetSize, "ippiCannyGetSize", 0/*CV_PLUGINS1(CV_PLUGIN_IPPCV)*/,
00618            ( CvSize roiSize, int* bufferSize ))
00619 
00620 IPCVAPI_EX( CvStatus, icvCanny_16s8u_C1R, "ippiCanny_16s8u_C1R", 0/*CV_PLUGINS1(CV_PLUGIN_IPPCV)*/,
00621     ( const short* pSrcDx, int srcDxStep, const short* pSrcDy, int srcDyStep,
00622       uchar*  pDstEdges, int dstEdgeStep, CvSize roiSize, float lowThresh,
00623       float  highThresh, void* pBuffer ))
00624 
00625 
00626 /****************************************************************************************\
00627 *                                 Radial Distortion Removal                              *
00628 \****************************************************************************************/
00629 
00630 IPCVAPI_EX( CvStatus, icvUndistortGetSize, "ippiUndistortGetSize",
00631             CV_PLUGINS1(CV_PLUGIN_IPPCV), ( CvSize roiSize, int *pBufsize ))
00632 
00633 IPCVAPI_EX( CvStatus, icvCreateMapCameraUndistort_32f_C1R,
00634             "ippiCreateMapCameraUndistort_32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00635             (float *pxMap, int xStep, float *pyMap, int yStep, CvSize roiSize,
00636             float fx, float fy, float cx, float cy, float k1, float k2,
00637             float p1, float p2, uchar *pBuffer ))
00638 
00639 #define ICV_UNDISTORT_RADIAL( flavor, cn, arrtype )                                 \
00640 IPCVAPI_EX( CvStatus, icvUndistortRadial_##flavor##_C##cn##R,                       \
00641     "ippiUndistortRadial_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPCV),      \
00642     ( const arrtype* pSrc, int srcStep, uchar* pDst, int dstStep, CvSize roiSize,   \
00643       float fx, float fy, float cx, float cy, float k1, float k2, uchar *pBuffer ))
00644 
00645 ICV_UNDISTORT_RADIAL( 8u, 1, uchar )
00646 ICV_UNDISTORT_RADIAL( 8u, 3, uchar )
00647 
00648 #undef ICV_UNDISTORT_RADIAL
00649 
00650 /****************************************************************************************\
00651 *                            Subpixel-accurate rectangle extraction                      *
00652 \****************************************************************************************/
00653 
00654 #define ICV_COPY_SUBPIX( flavor, cn, srctype, dsttype )                     \
00655 IPCVAPI_EX( CvStatus, icvCopySubpix_##flavor##_C##cn##R,                    \
00656     "ippiCopySubpix_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPCV),   \
00657     ( const srctype* pSrc, int srcStep, dsttype* pDst, int dstStep,         \
00658     CvSize size, float dx, float dy ))
00659 
00660 ICV_COPY_SUBPIX( 8u, 1, uchar, uchar )
00661 ICV_COPY_SUBPIX( 8u32f, 1, uchar, float )
00662 //ICV_COPY_SUBPIX( 32f, 1, float, float )
00663 
00664 IPCVAPI_EX( CvStatus, icvCopySubpix_32f_C1R,
00665     "ippiCopySubpix_32f_C1R", 0,
00666     ( const float* pSrc, int srcStep, float* pDst, int dstStep,
00667     CvSize size, float dx, float dy ))
00668 
00669 #undef ICV_COPY_SUBPIX
00670 
00671 /****************************************************************************************\
00672 *                                Lucas-Kanade Optical Flow                               *
00673 \****************************************************************************************/
00674 
00675 IPCVAPI_EX( CvStatus, icvOpticalFlowPyrLKInitAlloc_8u_C1R,
00676             "ippiOpticalFlowPyrLKInitAlloc_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00677             ( void** ppState, CvSize roiSize, int winSize, int hint ))
00678 
00679 IPCVAPI_EX( CvStatus, icvOpticalFlowPyrLKFree_8u_C1R,
00680             "ippiOpticalFlowPyrLKFree_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00681             ( void* pState ))
00682 
00683 IPCVAPI_EX( CvStatus, icvOpticalFlowPyrLK_8u_C1R,
00684             "ippiOpticalFlowPyrLK_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00685             ( CvPyramid *pPyr1, CvPyramid *pPyr2,
00686             const float *pPrev, float* pNext, char *pStatus,
00687             float *pError, int numFeat, int winSize,
00688             int maxLev, int maxIter, float threshold, void* state ))
00689 
00690 
00691 /****************************************************************************************\
00692 *                                 Haar Object Detector                                   *
00693 \****************************************************************************************/
00694 
00695 IPCVAPI_EX( CvStatus, icvIntegral_8u32s_C1R,
00696             "ippiIntegral_8u32s_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00697             ( const uchar* pSrc, int srcStep, int* pDst, int dstStep,
00698               CvSize roiSize, int val ))
00699 
00700 IPCVAPI_EX( CvStatus, icvSqrIntegral_8u32s64f_C1R,
00701             "ippiSqrIntegral_8u32s64f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00702             ( const uchar* pSrc, int srcStep,
00703               int* pDst, int dstStep, double* pSqr, int sqrStep,
00704               CvSize roiSize, int val, double valSqr ))
00705 
00706 IPCVAPI_EX( CvStatus, icvRectStdDev_32s32f_C1R,
00707             "ippiRectStdDev_32s32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00708             ( const int* pSrc, int srcStep,
00709               const double* pSqr, int sqrStep, float* pDst, int dstStep,
00710               CvSize roiSize, CvRect rect ))
00711 
00712 IPCVAPI_EX( CvStatus, icvHaarClassifierInitAlloc_32f,
00713             "ippiHaarClassifierInitAlloc_32f", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00714             ( void **pState, const CvRect* pFeature, const float* pWeight,
00715               const float* pThreshold, const float* pVal1,
00716               const float* pVal2, const int* pNum, int length ))
00717 
00718 IPCVAPI_EX( CvStatus, icvHaarClassifierFree_32f,
00719             "ippiHaarClassifierFree_32f", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00720             ( void *pState ))
00721 
00722 IPCVAPI_EX( CvStatus, icvApplyHaarClassifier_32s32f_C1R,
00723             "ippiApplyHaarClassifier_32s32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
00724             ( const int* pSrc, int srcStep, const float* pNorm,
00725               int normStep, uchar* pMask, int maskStep,
00726               CvSize roi, int *pPositive, float threshold,
00727               void *pState ))
00728 
00729 #define icvCopyVector( src, dst, len ) memcpy( (dst), (src), (len)*sizeof((dst)[0]))
00730 #define icvSetZero( dst, len ) memset( (dst), 0, (len)*sizeof((dst)[0]))
00731 
00732 #define icvCopyVector_32f( src, len, dst ) memcpy((dst),(src),(len)*sizeof(float))
00733 #define icvSetZero_32f( dst, cols, rows ) memset((dst),0,(rows)*(cols)*sizeof(float))
00734 #define icvCopyVector_64d( src, len, dst ) memcpy((dst),(src),(len)*sizeof(double))
00735 #define icvSetZero_64d( dst, cols, rows ) memset((dst),0,(rows)*(cols)*sizeof(double))
00736 #define icvCopyMatrix_32f( src, w, h, dst ) memcpy((dst),(src),(w)*(h)*sizeof(float))
00737 #define icvCopyMatrix_64d( src, w, h, dst ) memcpy((dst),(src),(w)*(h)*sizeof(double))
00738 
00739 #define icvCreateVector_32f( len )  (float*)cvAlloc( (len)*sizeof(float))
00740 #define icvCreateVector_64d( len )  (double*)cvAlloc( (len)*sizeof(double))
00741 #define icvCreateMatrix_32f( w, h )  (float*)cvAlloc( (w)*(h)*sizeof(float))
00742 #define icvCreateMatrix_64d( w, h )  (double*)cvAlloc( (w)*(h)*sizeof(double))
00743 
00744 #define icvDeleteVector( vec )  cvFree( (void**)&(vec) )
00745 #define icvDeleteMatrix icvDeleteVector
00746 
00747 #define icvAddMatrix_32f( src1, src2, dst, w, h ) \
00748     icvAddVector_32f( (src1), (src2), (dst), (w)*(h))
00749 
00750 #define icvSubMatrix_32f( src1, src2, dst, w, h ) \
00751     icvSubVector_32f( (src1), (src2), (dst), (w)*(h))
00752 
00753 #define icvNormVector_32f( src, len )  \
00754     sqrt(icvDotProduct_32f( src, src, len ))
00755 
00756 #define icvNormVector_64d( src, len )  \
00757     sqrt(icvDotProduct_64d( src, src, len ))
00758 
00759 
00760 #define icvDeleteMatrix icvDeleteVector
00761 
00762 #define icvCheckVector_64f( ptr, len )
00763 #define icvCheckVector_32f( ptr, len )
00764 
00765 CV_INLINE double icvSum_32f( const float* src, int len )
00766 {
00767     double s = 0;
00768     for( int i = 0; i < len; i++ ) s += src[i];
00769 
00770     icvCheckVector_64f( &s, 1 );
00771 
00772     return s;
00773 }
00774 
00775 CV_INLINE double icvDotProduct_32f( const float* src1, const float* src2, int len )
00776 {
00777     double s = 0;
00778     for( int i = 0; i < len; i++ ) s += src1[i]*src2[i];
00779 
00780     icvCheckVector_64f( &s, 1 );
00781 
00782     return s;
00783 }
00784 
00785 
00786 CV_INLINE double icvDotProduct_64f( const double* src1, const double* src2, int len )
00787 {
00788     double s = 0;
00789     for( int i = 0; i < len; i++ ) s += src1[i]*src2[i];
00790 
00791     icvCheckVector_64f( &s, 1 );
00792 
00793     return s;
00794 }
00795 
00796 
00797 CV_INLINE void icvMulVectors_32f( const float* src1, const float* src2,
00798                                   float* dst, int len )
00799 {
00800     int i;
00801     for( i = 0; i < len; i++ )
00802         dst[i] = src1[i] * src2[i];
00803 
00804     icvCheckVector_32f( dst, len );
00805 }
00806 
00807 CV_INLINE void icvMulVectors_64d( const double* src1, const double* src2,
00808                                   double* dst, int len )
00809 {
00810     int i;
00811     for( i = 0; i < len; i++ )
00812         dst[i] = src1[i] * src2[i];
00813 
00814     icvCheckVector_64f( dst, len );
00815 }
00816 
00817 
00818 CV_INLINE void icvAddVector_32f( const float* src1, const float* src2,
00819                                   float* dst, int len )
00820 {
00821     int i;
00822     for( i = 0; i < len; i++ )
00823         dst[i] = src1[i] + src2[i];
00824 
00825     icvCheckVector_32f( dst, len );
00826 }
00827 
00828 CV_INLINE void icvAddVector_64d( const double* src1, const double* src2,
00829                                   double* dst, int len )
00830 {
00831     int i;
00832     for( i = 0; i < len; i++ )
00833         dst[i] = src1[i] + src2[i];
00834 
00835     icvCheckVector_64f( dst, len );
00836 }
00837 
00838 
00839 CV_INLINE void icvSubVector_32f( const float* src1, const float* src2,
00840                                   float* dst, int len )
00841 {
00842     int i;
00843     for( i = 0; i < len; i++ )
00844         dst[i] = src1[i] - src2[i];
00845 
00846     icvCheckVector_32f( dst, len );
00847 }
00848 
00849 CV_INLINE void icvSubVector_64d( const double* src1, const double* src2,
00850                                   double* dst, int len )
00851 {
00852     int i;
00853     for( i = 0; i < len; i++ )
00854         dst[i] = src1[i] - src2[i];
00855 
00856     icvCheckVector_64f( dst, len );
00857 }
00858 
00859 
00860 #define icvAddMatrix_64d( src1, src2, dst, w, h ) \
00861     icvAddVector_64d( (src1), (src2), (dst), (w)*(h))
00862 
00863 #define icvSubMatrix_64d( src1, src2, dst, w, h ) \
00864     icvSubVector_64d( (src1), (src2), (dst), (w)*(h))
00865 
00866 
00867 CV_INLINE void icvSetIdentity_32f( float* dst, int w, int h )
00868 {
00869     int i, len = MIN( w, h );
00870     icvSetZero_32f( dst, w, h );
00871     for( i = 0; len--; i += w+1 )
00872         dst[i] = 1.f;
00873 }
00874 
00875 
00876 CV_INLINE void icvSetIdentity_64d( double* dst, int w, int h )
00877 {
00878     int i, len = MIN( w, h );
00879     icvSetZero_64d( dst, w, h );
00880     for( i = 0; len--; i += w+1 )
00881         dst[i] = 1.;
00882 }
00883 
00884 
00885 CV_INLINE void icvTrace_32f( const float* src, int w, int h, float* trace )
00886 {
00887     int i, len = MIN( w, h );
00888     double sum = 0;
00889     for( i = 0; len--; i += w+1 )
00890         sum += src[i];
00891     *trace = (float)sum;
00892 
00893     icvCheckVector_64f( &sum, 1 );
00894 }
00895 
00896 
00897 CV_INLINE void icvTrace_64d( const double* src, int w, int h, double* trace )
00898 {
00899     int i, len = MIN( w, h );
00900     double sum = 0;
00901     for( i = 0; len--; i += w+1 )
00902         sum += src[i];
00903     *trace = sum;
00904 
00905     icvCheckVector_64f( &sum, 1 );
00906 }
00907 
00908 
00909 CV_INLINE void icvScaleVector_32f( const float* src, float* dst,
00910                                    int len, double scale )
00911 {
00912     int i;
00913     for( i = 0; i < len; i++ )
00914         dst[i] = (float)(src[i]*scale);
00915 
00916     icvCheckVector_32f( dst, len );
00917 }
00918 
00919 
00920 CV_INLINE void icvScaleVector_64d( const double* src, double* dst,
00921                                    int len, double scale )
00922 {
00923     int i;
00924     for( i = 0; i < len; i++ )
00925         dst[i] = src[i]*scale;
00926 
00927     icvCheckVector_64f( dst, len );
00928 }
00929 
00930 
00931 CV_INLINE void icvTransposeMatrix_32f( const float* src, int w, int h, float* dst )
00932 {
00933     int i, j;
00934 
00935     for( i = 0; i < w; i++ )
00936         for( j = 0; j < h; j++ )
00937             *dst++ = src[j*w + i];
00938         
00939     icvCheckVector_32f( dst, w*h );
00940 }
00941 
00942 CV_INLINE void icvTransposeMatrix_64d( const double* src, int w, int h, double* dst )
00943 {
00944     int i, j;
00945 
00946     for( i = 0; i < w; i++ )
00947         for( j = 0; j < h; j++ )
00948             *dst++ = src[j*w + i];
00949 
00950     icvCheckVector_64f( dst, w*h );
00951 }
00952 
00953 CV_INLINE void icvDetMatrix3x3_64d( const double* mat, double* det )
00954 {
00955     #define m(y,x) mat[(y)*3 + (x)]
00956     
00957     *det = m(0,0)*(m(1,1)*m(2,2) - m(1,2)*m(2,1)) -
00958            m(0,1)*(m(1,0)*m(2,2) - m(1,2)*m(2,0)) +
00959            m(0,2)*(m(1,0)*m(2,1) - m(1,1)*m(2,0));
00960 
00961     #undef m
00962 
00963     icvCheckVector_64f( det, 1 );
00964 }
00965 
00966 
00967 CV_INLINE void icvMulMatrix_32f( const float* src1, int w1, int h1,
00968                                  const float* src2, int w2, int h2,
00969                                  float* dst )
00970 {
00971     int i, j, k;
00972 
00973     if( w1 != h2 )
00974     {
00975         assert(0);
00976         return;
00977     }
00978 
00979     for( i = 0; i < h1; i++, src1 += w1, dst += w2 )
00980         for( j = 0; j < w2; j++ )
00981         {
00982             double s = 0;
00983             for( k = 0; k < w1; k++ )
00984                 s += src1[k]*src2[j + k*w2];
00985             dst[j] = (float)s;
00986         }
00987 
00988     icvCheckVector_32f( dst, h1*w2 );
00989 }
00990 
00991 
00992 CV_INLINE void icvMulMatrix_64d( const double* src1, int w1, int h1,
00993                                  const double* src2, int w2, int h2,
00994                                  double* dst )
00995 {
00996     int i, j, k;
00997 
00998     if( w1 != h2 )
00999     {
01000         assert(0);
01001         return;
01002     }
01003 
01004     for( i = 0; i < h1; i++, src1 += w1, dst += w2 )
01005         for( j = 0; j < w2; j++ )
01006         {
01007             double s = 0;
01008             for( k = 0; k < w1; k++ )
01009                 s += src1[k]*src2[j + k*w2];
01010             dst[j] = s;
01011         }
01012 
01013     icvCheckVector_64f( dst, h1*w2 );
01014 }
01015 
01016 
01017 #define icvTransformVector_32f( matr, src, dst, w, h ) \
01018     icvMulMatrix_32f( matr, w, h, src, 1, w, dst )
01019 
01020 #define icvTransformVector_64d( matr, src, dst, w, h ) \
01021     icvMulMatrix_64d( matr, w, h, src, 1, w, dst )
01022 
01023 
01024 #define icvScaleMatrix_32f( src, dst, w, h, scale ) \
01025     icvScaleVector_32f( (src), (dst), (w)*(h), (scale) )
01026 
01027 #define icvScaleMatrix_64d( src, dst, w, h, scale ) \
01028     icvScaleVector_64d( (src), (dst), (w)*(h), (scale) )
01029 
01030 #define icvDotProduct_64d icvDotProduct_64f
01031 
01032 
01033 CV_INLINE void icvInvertMatrix_64d( double* A, int n, double* invA )
01034 {
01035     CvMat Am = cvMat( n, n, CV_64F, A );
01036     CvMat invAm = cvMat( n, n, CV_64F, invA );
01037 
01038     cvInvert( &Am, &invAm, CV_SVD );
01039 }
01040 
01041 CV_INLINE void icvMulTransMatrixR_64d( double* src, int width, int height, double* dst )
01042 {
01043     CvMat srcMat = cvMat( height, width, CV_64F, src );
01044     CvMat dstMat = cvMat( width, width, CV_64F, dst );
01045 
01046     cvMulTransposed( &srcMat, &dstMat, 1 );
01047 }
01048 
01049 CV_INLINE void icvMulTransMatrixL_64d( double* src, int width, int height, double* dst )
01050 {
01051     CvMat srcMat = cvMat( height, width, CV_64F, src );
01052     CvMat dstMat = cvMat( height, height, CV_64F, dst );
01053 
01054     cvMulTransposed( &srcMat, &dstMat, 0 );
01055 }
01056 
01057 CV_INLINE void icvMulTransMatrixR_32f( float* src, int width, int height, float* dst )
01058 {
01059     CvMat srcMat = cvMat( height, width, CV_32F, src );
01060     CvMat dstMat = cvMat( width, width, CV_32F, dst );
01061 
01062     cvMulTransposed( &srcMat, &dstMat, 1 );
01063 }
01064 
01065 CV_INLINE void icvMulTransMatrixL_32f( float* src, int width, int height, float* dst )
01066 {
01067     CvMat srcMat = cvMat( height, width, CV_32F, src );
01068     CvMat dstMat = cvMat( height, height, CV_32F, dst );
01069 
01070     cvMulTransposed( &srcMat, &dstMat, 0 );
01071 }
01072 
01073 CV_INLINE void icvCvt_32f_64d( const float* src, double* dst, int len )
01074 {
01075     int i;
01076     for( i = 0; i < len; i++ )
01077         dst[i] = src[i];
01078 }
01079 
01080 CV_INLINE void icvCvt_64d_32f( const double* src, float* dst, int len )
01081 {
01082     int i;
01083     for( i = 0; i < len; i++ )
01084         dst[i] = (float)src[i];
01085 }
01086 
01087 /* Finds distance between two points */
01088 CV_INLINE  float  icvDistanceL2_32f( CvPoint2D32f pt1, CvPoint2D32f pt2 )
01089 {
01090     float dx = pt2.x - pt1.x;
01091     float dy = pt2.y - pt1.y;
01092 
01093     return cvSqrt( dx*dx + dy*dy );
01094 }
01095 
01096 
01097 int  icvIntersectLines( double x1, double dx1, double y1, double dy1,
01098                         double x2, double dx2, double y2, double dy2,
01099                         double* t2 );
01100 
01101 
01102 void icvCreateCenterNormalLine( CvSubdiv2DEdge edge, double* a, double* b, double* c );
01103 
01104 void icvIntersectLines3( double* a0, double* b0, double* c0,
01105                          double* a1, double* b1, double* c1,
01106                          CvPoint2D32f* point );
01107 
01108 
01109 #define _CV_BINTREE_LIST()                                          \
01110    struct _CvTrianAttr* prev_v;   /* pointer to the parent  element on the previous level of the tree  */    \
01111    struct _CvTrianAttr* next_v1;   /* pointer to the child  element on the next level of the tree  */        \
01112    struct _CvTrianAttr* next_v2;   /* pointer to the child  element on the next level of the tree  */        
01113 
01114 typedef struct _CvTrianAttr
01115 {
01116    CvPoint pt;    /* Coordinates x and y of the vertex  which don't lie on the base line LMIAT  */
01117    char sign;             /*  sign of the triangle   */
01118    double area;       /*   area of the triangle    */
01119    double r1;   /*  The ratio of the height of triangle to the base of the triangle  */
01120    double r2;  /*   The ratio of the projection of the left side of the triangle on the base to the base */
01121    _CV_BINTREE_LIST()    /* structure double list   */
01122 }
01123 _CvTrianAttr;
01124 
01125 
01126 /* curvature: 0 - 1-curvature, 1 - k-cosine curvature. */
01127 CvStatus  icvApproximateChainTC89( CvChain*      chain,
01128                                    int header_size,
01129                                    CvMemStorage* storage,
01130                                    CvSeq**   contour,
01131                                    int method );
01132 
01133 #define ICV_KERNEL_TYPE_MASK        (15<<16)
01134 #define ICV_GENERIC_KERNEL          (0<<16)
01135 #define ICV_SEPARABLE_KERNEL        (1<<16)
01136 #define ICV_BINARY_KERNEL           (2<<16)
01137 
01138 #define ICV_KERNEL_TYPE(flags)      ((flags) & ICV_KERNEL_TYPE_MASK)
01139 
01140 #define ICV_MAKE_SEPARABLE_KERNEL( x_type, y_type ) \
01141     (ICV_SEPARABLE_KERNEL | ((x_type)&255) | (((y_type)&255) << 8))
01142 
01143 #define ICV_X_KERNEL_TYPE(flags)    ((flags) & 255)
01144 #define ICV_Y_KERNEL_TYPE(flags)    (((flags) >> 8) & 255)
01145 #define ICV_SYMMETRIC_KERNEL        1
01146 #define ICV_ASYMMETRIC_KERNEL       2
01147 
01148 #define ICV_1_2_1_KERNEL            (4*1+ICV_SYMMETRIC_KERNEL)
01149 #define ICV_m1_0_1_KERNEL           (4*2+ICV_ASYMMETRIC_KERNEL)
01150 #define ICV_1_m2_1_KERNEL           (4*3+ICV_SYMMETRIC_KERNEL)
01151 #define ICV_3_10_3_KERNEL           (4*4+ICV_SYMMETRIC_KERNEL)
01152 #define ICV_DEFAULT_GAUSSIAN_KERNEL ICV_SYMMETRIC_KERNEL
01153 #define ICV_CUSTOM_GAUSSIAN_KERNEL  (4+ICV_SYMMETRIC_KERNEL)
01154 
01155 #define ICV_MAKE_BINARY_KERNEL( shape ) \
01156     (ICV_BINARY_KERNEL | (int)(shape))
01157 
01158 #define ICV_BINARY_KERNEL_SHAPE(flags) ((flags) & 255)
01159 
01160 typedef struct CvFilterState
01161 {
01162     /* kernel data */
01163     int ker_width;
01164     int ker_height;
01165     int ker_x;
01166     int ker_y;
01167     int kerType;
01168     uchar *ker0;
01169     uchar *ker1;
01170     double divisor;
01171 
01172     /* image data */
01173     int max_width;
01174     CvDataType dataType;
01175     int channels;
01176     int origin;
01177 
01178     /* cyclic buffer */
01179     char *buffer;
01180     int buffer_step;
01181     int crows;
01182     char **rows;
01183     char *tbuf;
01184 }
01185 CvFilterState;
01186 
01187 #define  CV_COPY( dst, src, len, idx ) \
01188     for( (idx) = 0; (idx) < (len); (idx)++) (dst)[idx] = (src)[idx]
01189 
01190 #define  CV_SET( dst, val, len, idx )  \
01191     for( (idx) = 0; (idx) < (len); (idx)++) (dst)[idx] = (val)
01192 
01193 /* performs convolution of 2d floating-point array with 3x1, 1x3 or separable 3x3 mask */
01194 void icvSepConvSmall3_32f( float* src, int src_step, float* dst, int dst_step,
01195             CvSize src_size, const float* kx, const float* ky, float* buffer );
01196 
01197 CvFilterState* icvFilterInitAlloc(
01198     int roiWidth, CvDataType dataType, int channels, CvSize elSize,
01199     CvPoint elAnchor, const void* elData, int elementFlags );
01200 
01201 void icvFilterFree( CvFilterState ** morphState );
01202 
01203 CvFilterState* icvSobelInitAlloc( int roiwidth, int depth, int kerSize,
01204                                   int origin, int dx, int dy );
01205 
01206 CvStatus CV_STDCALL icvSobel_8u16s_C1R( const uchar* pSrc, int srcStep,
01207                                         short* pDst, int dstStep, CvSize* roiSize,
01208                                         struct CvFilterState* state, int stage );
01209 
01210 CvStatus CV_STDCALL icvSobel_32f_C1R( const float* pSrc, int srcStep,
01211                                       float* pDst, int dstStep, CvSize* roiSize,
01212                                       struct CvFilterState* state, int stage );
01213 
01214 CvFilterState* icvBlurInitAlloc( int roiWidth, int depth, int channels, int kerSize );
01215 
01216 CvStatus CV_STDCALL icvBlur_8u16s_C1R( const uchar* pSrc, int srcStep,
01217                                        short* pDst, int dstStep, CvSize* roiSize,
01218                                        struct CvFilterState* state, int stage );
01219 
01220 CvStatus CV_STDCALL icvBlur_32f_CnR( const float* pSrc, int srcStep,
01221                                      float* pDst, int dstStep, CvSize* roiSize,
01222                                      struct CvFilterState* state, int stage );
01223 
01224 #define icvBlur_32f_C1R icvBlur_32f_CnR
01225 
01226 typedef CvStatus (CV_STDCALL * CvSobelFixedIPPFunc)
01227 ( const void* src, int srcstep, void* dst, int dststep, CvSize roi, int aperture );
01228 
01229 typedef CvStatus (CV_STDCALL * CvFilterFixedIPPFunc)
01230 ( const void* src, int srcstep, void* dst, int dststep, CvSize roi );
01231 
01232 #undef   CV_CALC_MIN
01233 #define  CV_CALC_MIN(a, b) if((a) > (b)) (a) = (b)
01234 
01235 #undef   CV_CALC_MAX
01236 #define  CV_CALC_MAX(a, b) if((a) < (b)) (a) = (b)
01237 
01238 #define CV_MORPH_ALIGN  4
01239 
01240 typedef CvStatus( CV_STDCALL* CvFilterFunc )( const void* src, int src_step,
01241                                               void* dst, int dst_step,
01242                                               CvSize* size, struct CvFilterState * state,
01243                                               int stage );
01244 
01245 #define CvMorphFunc CvFilterFunc
01246 
01247 #define CV_WHOLE   0
01248 #define CV_START   1
01249 #define CV_END     2
01250 #define CV_MIDDLE  4
01251 
01252 typedef CvStatus (CV_STDCALL * CvCopyNonConstBorderFunc)(
01253     const void* src, int srcstep, CvSize srcsize,
01254     void* dst, int dststep, CvSize dstsize, int top, int left );
01255 
01256 typedef CvStatus (CV_STDCALL * CvCopyConstBorderFunc_Cn)(
01257     const void* src, int srcstep, CvSize srcsize,
01258     void* dst, int dststep, CvSize dstsize,
01259     int top, int left, const void* value );
01260 
01261 CvCopyNonConstBorderFunc icvGetCopyNonConstBorderFunc(
01262     int pixsize, int bordertype=IPL_BORDER_REPLICATE );
01263 
01264 CvCopyConstBorderFunc_Cn icvGetCopyConstBorderFunc_Cn(
01265     int pixsize );
01266 
01267 CvMat* icvIPPFilterInit( const CvMat* src, int stripe_size, CvSize ksize );
01268 
01269 int icvIPPFilterNextStripe( const CvMat* src, CvMat* temp, int y,
01270                             CvSize ksize, CvPoint anchor );
01271 
01272 int icvIPPSepFilter( const CvMat* src, CvMat* dst, const CvMat* kernelX,
01273                      const CvMat* kernelY, CvPoint anchor );
01274 
01275 #define ICV_WARP_SHIFT          10
01276 #define ICV_WARP_MASK           ((1 << ICV_WARP_SHIFT) - 1)
01277 
01278 #define ICV_LINEAR_TAB_SIZE     (ICV_WARP_MASK+1)
01279 extern float icvLinearCoeffs[(ICV_LINEAR_TAB_SIZE+1)*2];
01280 void icvInitLinearCoeffTab();
01281 
01282 #define ICV_CUBIC_TAB_SIZE   (ICV_WARP_MASK+1)
01283 extern float icvCubicCoeffs[(ICV_CUBIC_TAB_SIZE+1)*2];
01284 
01285 void icvInitCubicCoeffTab();
01286 
01287 CvStatus CV_STDCALL icvGetRectSubPix_8u_C1R
01288 ( const uchar* src, int src_step, CvSize src_size,
01289   uchar* dst, int dst_step, CvSize win_size, CvPoint2D32f center );
01290 CvStatus CV_STDCALL icvGetRectSubPix_8u32f_C1R
01291 ( const uchar* src, int src_step, CvSize src_size,
01292   float* dst, int dst_step, CvSize win_size, CvPoint2D32f center );
01293 CvStatus CV_STDCALL icvGetRectSubPix_32f_C1R
01294 ( const float* src, int src_step, CvSize src_size,
01295   float* dst, int dst_step, CvSize win_size, CvPoint2D32f center );
01296 
01297 
01298 #define CV_ADJUST_FEATURES 1
01299 #define CV_ADJUST_WEIGHTS  0
01300 
01301 typedef int sumtype;
01302 typedef double sqsumtype;
01303 
01304 typedef struct CvHidHaarFeature
01305 {
01306     struct
01307     {
01308         sumtype *p0, *p1, *p2, *p3;
01309         float weight;
01310     }
01311     rect[CV_HAAR_FEATURE_MAX];
01312 }
01313 CvHidHaarFeature;
01314 
01315 
01316 typedef struct CvHidHaarTreeNode
01317 {
01318     CvHidHaarFeature feature;
01319     float threshold;
01320     int left;
01321     int right;
01322 }
01323 CvHidHaarTreeNode;
01324 
01325 
01326 typedef struct CvHidHaarClassifier
01327 {
01328     int count;
01329     //CvHaarFeature* orig_feature;
01330     CvHidHaarTreeNode* node;
01331     float* alpha;
01332 }
01333 CvHidHaarClassifier;
01334 
01335 
01336 typedef struct CvHidHaarStageClassifier
01337 {
01338     int  count;
01339     float threshold;
01340     CvHidHaarClassifier* classifier;
01341     int two_rects;
01342     
01343     struct CvHidHaarStageClassifier* next;
01344     struct CvHidHaarStageClassifier* child;
01345     struct CvHidHaarStageClassifier* parent;
01346 }
01347 CvHidHaarStageClassifier;
01348 
01349 
01350 struct CvHidHaarClassifierCascade
01351 {
01352     int  count;
01353     int  is_stump_based;
01354     int  has_tilted_features;
01355     int  is_tree;
01356     double inv_window_area;
01357     CvMat sum, sqsum, tilted;
01358     CvHidHaarStageClassifier* stage_classifier;
01359     sqsumtype *pq0, *pq1, *pq2, *pq3;
01360     sumtype *p0, *p1, *p2, *p3;
01361 
01362     void** ipp_stages;
01363 };
01364 
01365 static int is_equal( const void* _r1, const void* _r2, void* )
01366 {
01367     const CvRect* r1 = (const CvRect*)_r1;
01368     const CvRect* r2 = (const CvRect*)_r2;
01369     int distance = cvRound(r1->width*0.2);
01370 
01371     return r2->x <= r1->x + distance &&
01372            r2->x >= r1->x - distance &&
01373            r2->y <= r1->y + distance &&
01374            r2->y >= r1->y - distance &&
01375            r2->width <= cvRound( r1->width * 1.2 ) &&
01376            cvRound( r2->width * 1.2 ) >= r1->width;
01377 }
01378 
01379 extern CvHidHaarClassifierCascade* icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade );
01380 
01381 const int icv_object_win_border = 1;
01382 
01383 CvSeq*
01384 myHaarDetectObjects( const CvArr* _img,
01385                      CvHaarClassifierCascade* cascade,
01386                      CvMemStorage* storage, double scale_factor,
01387                      int min_neighbors, int flags, CvSize min_size, double *pRanges, double pPan, double pTilt, double pMinHeight, double pMaxHeight, IplImage *pImg,
01388                      double pMinSize, double pMaxSize);
01389 #endif

Generated on Thu Feb 1 15:31:52 2007 for WURDE by  doxygen 1.5.1