📄 cvcompat.h
字号:
/*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*/
/*
A few macros and definitions for backward compatibility
with the previous versions of OpenCV. They are obsolete and
are likely to be removed in future. To check whether your code
uses any of these, define CV_NO_BACKWARD_COMPATIBILITY before
including cv.h.
*/
#ifndef _CVCOMPAT_H_
#define _CVCOMPAT_H_
#include <string.h>
#ifdef __cplusplus
#define CV_UNREFERENCED(arg)
#else
#define CV_UNREFERENCED(arg) arg
#endif
#define CvMatType int
#define CvDisMaskType int
#define CvMatArray CvMat
#define CvThreshType int
#define CvAdaptiveThreshMethod int
#define CvCompareMethod int
#define CvFontFace int
#define CvPolyApproxMethod int
#define CvContoursMatchMethod int
#define CvContourTreesMatchMethod int
#define CvCoeffType int
#define CvRodriguesType int
#define CvElementShape int
#define CvMorphOp int
#define CvTemplMatchMethod int
#define CvPoint2D64d CvPoint2D64f
#define CvPoint3D64d CvPoint3D64f
#define CV_MAT32F CV_32FC1
#define CV_MAT3x1_32F CV_32FC1
#define CV_MAT4x1_32F CV_32FC1
#define CV_MAT3x3_32F CV_32FC1
#define CV_MAT4x4_32F CV_32FC1
#define CV_MAT64D CV_64FC1
#define CV_MAT3x1_64D CV_64FC1
#define CV_MAT4x1_64D CV_64FC1
#define CV_MAT3x3_64D CV_64FC1
#define CV_MAT4x4_64D CV_64FC1
#define IPL_GAUSSIAN_5x5 7
#define CvBox2D32f CvBox2D
/* allocation/deallocation macros */
#define cvCreateImageData cvCreateData
#define cvReleaseImageData cvReleaseData
#define cvSetImageData cvSetData
#define cvGetImageRawData cvGetRawData
#define cvmAlloc cvCreateData
#define cvmFree cvReleaseData
#define cvmAllocArray cvCreateData
#define cvmFreeArray cvReleaseData
#define cvIntegralImage cvIntegral
#define cvMatchContours cvMatchShapes
CV_INLINE CvMat cvMatArray( int rows, int cols, int type,
int count, void* data CV_DEFAULT(0))
{
return cvMat( rows*count, cols, type, data );
}
#define cvUpdateMHIByTime cvUpdateMotionHistory
#define cvAccMask cvAcc
#define cvSquareAccMask cvSquareAcc
#define cvMultiplyAccMask cvMultiplyAcc
#define cvRunningAvgMask(imgY, imgU, mask, alpha) cvRunningAvg(imgY, imgU, alpha, mask)
#define cvSetHistThresh cvSetHistBinRanges
#define cvCalcHistMask(img, mask, hist, doNotClear) cvCalcHist(img, hist, doNotClear, mask)
CV_INLINE double cvMean( const CvArr* image, const CvArr* mask CV_DEFAULT(0))
{
CvScalar mean = cvAvg( image, mask );
return mean.val[0];
}
CV_INLINE double cvSumPixels( const CvArr* image )
{
CvScalar scalar = cvSum( image );
return scalar.val[0];
}
CV_INLINE void cvMean_StdDev( const CvArr* image, double* mean, double* sdv,
const CvArr* mask CV_DEFAULT(0))
{
CvScalar _mean, _sdv;
cvAvgSdv( image, &_mean, &_sdv, mask );
if( mean )
*mean = _mean.val[0];
if( sdv )
*sdv = _sdv.val[0];
}
CV_INLINE void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst )
{
CvMat tsrc, tdst;
cvReshape( src, &tsrc, 3, 0 );
cvReshape( dst, &tdst, 3, 0 );
cvPerspectiveTransform( &tsrc, &tdst, mat );
}
CV_INLINE void cvFillImage( CvArr* mat, double color )
{
cvSet( mat, cvColorToScalar(color, cvGetElemType(mat)), 0 );
}
#define cvCvtPixToPlane cvSplit
#define cvCvtPlaneToPix cvMerge
typedef struct CvRandState
{
CvRNG state; /* RNG state (the current seed and carry)*/
int disttype; /* distribution type */
CvScalar param[2]; /* parameters of RNG */
}
CvRandState;
/* Changes RNG range while preserving RNG state */
CV_INLINE void cvRandSetRange( CvRandState* state, double param1,
double param2, int index CV_DEFAULT(-1))
{
if( !state )
{
cvError( CV_StsNullPtr, "cvRandSetRange", "Null pointer to RNG state", "cvcompat.h", 0 );
return;
}
if( (unsigned)(index + 1) > 4 )
{
cvError( CV_StsOutOfRange, "cvRandSetRange", "index is not in -1..3", "cvcompat.h", 0 );
return;
}
if( index < 0 )
{
state->param[0].val[0] = state->param[0].val[1] =
state->param[0].val[2] = state->param[0].val[3] = param1;
state->param[1].val[0] = state->param[1].val[1] =
state->param[1].val[2] = state->param[1].val[3] = param2;
}
else
{
state->param[0].val[index] = param1;
state->param[1].val[index] = param2;
}
}
CV_INLINE void cvRandInit( CvRandState* state, double param1,
double param2, int seed,
int disttype CV_DEFAULT(CV_RAND_UNI))
{
if( !state )
{
cvError( CV_StsNullPtr, "cvRandInit", "Null pointer to RNG state", "cvcompat.h", 0 );
return;
}
if( disttype != CV_RAND_UNI && disttype != CV_RAND_NORMAL )
{
cvError( CV_StsBadFlag, "cvRandInit", "Unknown distribution type", "cvcompat.h", 0 );
return;
}
state->state = (uint64)(seed ? seed : -1);
state->disttype = disttype;
cvRandSetRange( state, param1, param2, -1 );
}
/* Fills array with random numbers */
CV_INLINE void cvRand( CvRandState* state, CvArr* arr )
{
if( !state )
{
cvError( CV_StsNullPtr, "cvRand", "Null pointer to RNG state", "cvcompat.h", 0 );
return;
}
cvRandArr( &state->state, arr, state->disttype, state->param[0], state->param[1] );
}
#define cvRandNext( _state ) cvRandInt( &(_state)->state )
CV_INLINE void cvbRand( CvRandState* state, float* dst, int len )
{
CvMat mat = cvMat( 1, len, CV_32F, (void*)dst );
cvRand( state, &mat );
}
CV_INLINE void cvbCartToPolar( const float* y, const float* x,
float* magnitude, float* angle, int len )
{
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
CvMat my = mx;
CvMat mm = mx;
CvMat ma = mx;
my.data.fl = (float*)y;
mm.data.fl = (float*)magnitude;
ma.data.fl = (float*)angle;
cvCartToPolar( &mx, &my, &mm, angle ? &ma : NULL, 1 );
}
CV_INLINE void cvbFastArctan( const float* y, const float* x,
float* angle, int len )
{
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
CvMat my = mx;
CvMat ma = mx;
my.data.fl = (float*)y;
ma.data.fl = (float*)angle;
cvCartToPolar( &mx, &my, NULL, &ma, 1 );
}
CV_INLINE void cvbSqrt( const float* x, float* y, int len )
{
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
CvMat my = mx;
my.data.fl = (float*)y;
cvPow( &mx, &my, 0.5 );
}
CV_INLINE void cvbInvSqrt( const float* x, float* y, int len )
{
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
CvMat my = mx;
my.data.fl = (float*)y;
cvPow( &mx, &my, -0.5 );
}
CV_INLINE void cvbReciprocal( const float* x, float* y, int len )
{
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
CvMat my = mx;
my.data.fl = (float*)y;
cvPow( &mx, &my, -1 );
}
CV_INLINE void cvbFastExp( const float* x, double* y, int len )
{
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
CvMat my = cvMat( 1, len, CV_64F, y );
cvExp( &mx, &my );
}
CV_INLINE void cvbFastLog( const double* x, float* y, int len )
{
CvMat mx = cvMat( 1, len, CV_64F, (void*)x );
CvMat my = cvMat( 1, len, CV_32F, y );
cvLog( &mx, &my );
}
CV_INLINE CvRect cvContourBoundingRect( void* point_set, int update CV_DEFAULT(0))
{
return cvBoundingRect( point_set, update );
}
CV_INLINE double cvPseudoInverse( const CvArr* src, CvArr* dst )
{
return cvInvert( src, dst, CV_SVD );
}
#define cvPseudoInv cvPseudoInverse
#define cvContourMoments( contour, moments ) \
cvMoments( contour, moments, 0 )
#define cvGetPtrAt cvPtr2D
#define cvGetAt cvGet2D
#define cvSetAt(arr,val,y,x) cvSet2D((arr),(y),(x),(val))
#define cvMeanMask cvMean
#define cvMean_StdDevMask(img,mask,mean,sdv) cvMean_StdDev(img,mean,sdv,mask)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -