📄 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*/
/*
This is a set of macros and definitions intended to provide backward compatibility
with the previous versions of OpenCV
*/
#ifndef _CVCOMPAT_H_
#define _CVCOMPAT_H_
#include <string.h>
#if _MSC_VER>=1200 && !defined __ICL
#define CV_UNREFERENCED(arg) (arg)
#else
#define CV_UNREFERENCED(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 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));
CV_INLINE CvMat cvMatArray( int rows, int cols, int type,
int count, void* data )
{
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));
CV_INLINE double cvMean( const CvArr* image, const CvArr* mask )
{
CvScalar mean = cvAvg( image, mask );
return mean.val[0];
}
CV_INLINE double cvSumPixels( const CvArr* image );
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));
CV_INLINE void cvMean_StdDev( const CvArr* image, double* mean,
double* sdv, const CvArr* mask )
{
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 CvArr* mat, const CvArr* src,
CvArr* dst );
CV_INLINE void cvmPerspectiveProject( const CvArr* 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 );
CV_INLINE void cvFillImage( CvArr* mat, double color )
{
CvPoint left_top = { 0, 0 }, right_bottom = { 0, 0 };
cvGetRawData( mat, 0, 0, (CvSize*)&right_bottom );
right_bottom.x--;
right_bottom.y--;
cvRectangle( mat, left_top, right_bottom, color, CV_FILLED );
}
CV_INLINE void cvbRand( CvRandState* state, float* dst, int len );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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( const void* point_set, int update CV_DEFAULT(0));
CV_INLINE CvRect cvContourBoundingRect( const void* point_set, int update )
{
return cvBoundingRect( point_set, update );
}
CV_INLINE double cvPseudoInverse( const CvArr* src, CvArr* dst,
int flags CV_DEFAULT(0));
CV_INLINE double cvPseudoInverse( const CvArr* src, CvArr* dst, int flags )
{
CV_UNREFERENCED( flags );
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)
#define cvNormMask(imgA,imgB,mask,normType) cvNorm(imgA,imgB,normType,mask)
#define cvMinMaxLocMask(img, mask, min_val, max_val, min_loc, max_loc) \
cvMinMaxLoc(img, min_val, max_val, min_loc, max_loc, mask)
#define cvRemoveMemoryManager cvSetMemoryManager
#define cvmSetZero( mat ) cvSetZero( mat )
#define cvmSetIdentity( mat ) cvSetIdentity( mat )
#define cvmAdd( src1, src2, dst ) cvAdd( src1, src2, dst, 0 )
#define cvmSub( src1, src2, dst ) cvSub( src1, src2, dst, 0 )
#define cvmCopy( src, dst ) cvCopy( src, dst, 0 )
#define cvmMul( src1, src2, dst ) cvMatMulAdd( src1, src2, 0, dst )
#define cvmTranspose( src, dst ) cvT( src, dst )
#define cvmInvert( src, dst ) cvInv( src, dst )
#define cvmMahalanobis(vec1, vec2, mat) cvMahalanobis( vec1, vec2, mat )
#define cvmDotProduct( vec1, vec2 ) cvDotProduct( vec1, vec2 )
#define cvmCrossProduct(vec1, vec2,dst) cvCrossProduct( vec1, vec2, dst )
#define cvmTrace( mat ) (cvTrace( mat )).val[0]
#define cvmMulTransposed( src, dst, order ) cvMulTransposed( src, dst, order )
#define cvmEigenVV( mat, evec, eval, eps) cvEigenVV( mat, evec, eval, eps )
#define cvmDet( mat ) cvDet( mat )
#define cvmScale( src, dst, scale ) cvScale( src, dst, scale )
#define cvCopyImage( src, dst ) cvCopy( src, dst, 0 )
#define cvReleaseMatHeader cvReleaseMat
/* Calculates exact convex hull of 2d point set */
CV_INLINE void cvConvexHull( CvPoint* points, int num_points, CvRect* bound_rect,
int orientation, int* hull, int* hullsize );
CV_INLINE void cvConvexHull( CvPoint* points, int num_points, CvRect* bound_rect,
int orientation, int* hull, int* hullsize )
{
CvMat points1 = cvMat( 1, num_points, CV_32SC2, points );
CvMat hull1 = cvMat( 1, num_points, CV_32SC1, hull );
CV_UNREFERENCED( bound_rect );
cvConvexHull2( &points1, &hull1, orientation, 0 );
*hullsize = hull1.cols;
}
/* Calculates exact convex hull of 2d point set stored in a sequence */
#define cvContourConvexHull( contour, orientation, storage ) \
cvConvexHull2( contour, storage, orientation )
/* Calculates approximate convex hull of 2d point set */
#define cvConvexHullApprox( points, num_points, bound_rect, bandwidth, \
orientation, hull, hullsize ) \
cvConvexHull( points, num_points, bound_rect, orientation, hull, hullsize )
/* Calculates approximate convex hull of 2d point set stored in a sequence */
#define cvContourConvexHullApprox( contour, bandwidth, orientation, storage ) \
cvConvexHull2( contour, storage, orientation )
CV_INLINE void cvMinAreaRect( CvPoint* points, int n,
int left, int bottom, int right, int top,
CvPoint2D32f* anchor,
CvPoint2D32f* vect1,
CvPoint2D32f* vect2 );
CV_INLINE void cvMinAreaRect( CvPoint* points, int n,
int left, int bottom, int right, int top,
CvPoint2D32f* anchor,
CvPoint2D32f* vect1,
CvPoint2D32f* vect2 )
{
CvMat mat = cvMat( 1, n, CV_32SC2, points );
CvBox2D box = cvMinAreaRect2( &mat, 0 );
CvPoint2D32f pt[4];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -