From 1b1eab8e6772bec0f5866c753e4b13666a8ade71 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sat, 16 Oct 2010 20:34:34 +0000 Subject: [PATCH] added helper macros to the function declarations --- modules/core/include/opencv2/core/core.hpp | 4 +- modules/core/include/opencv2/core/types_c.h | 5 +- .../include/opencv2/features2d/features2d.hpp | 56 +++--- .../include/opencv2/highgui/highgui.hpp | 14 +- .../include/opencv2/imgproc/imgproc.hpp | 183 +++++++++--------- modules/ml/include/opencv2/ml/ml.hpp | 8 +- .../include/opencv2/objdetect/objdetect.hpp | 12 +- .../include/opencv2/video/background_segm.hpp | 15 +- .../video/include/opencv2/video/tracking.hpp | 16 +- modules/video/src/bgfg_estimation.cpp | 15 +- 10 files changed, 177 insertions(+), 151 deletions(-) diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index d5690f0aae..59b319bcd3 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -212,7 +212,7 @@ CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, #define CV_DbgAssert(expr) #endif -CV_EXPORTS void setNumThreads(int); +CV_EXPORTS void setNumThreads(int nthreads); CV_EXPORTS int getNumThreads(); CV_EXPORTS int getThreadNum(); @@ -330,7 +330,7 @@ static inline size_t alignSize(size_t sz, int n) \note{Since optimization may imply using special data structures, it may be unsafe to call this function anywhere in the code. Instead, call it somewhere at the top level.} */ -CV_EXPORTS void setUseOptimized(bool); +CV_EXPORTS void setUseOptimized(bool onoff); /*! Returns the current optimization status diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index ed3b3bc8c5..7e7d7611b8 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -158,9 +158,12 @@ typedef unsigned short ushort; typedef signed char schar; /* special informative macros for wrapper generators */ -#define CV_OUT #define CV_CARRAY(counter) +#define CV_CUSTOM_CARRAY(args) #define CV_METHOD +#define CV_NO_WRAP +#define CV_OUT +#define CV_WRAP_AS(synonym) /* CvArr* is used to pass arbitrary * array-like data structures diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index d7d1fd4c03..e97ab96ad8 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -232,10 +232,12 @@ public: : pt(x, y), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {} //! converts vector of keypoints to vector of points - static void convert(const std::vector& keypoints, std::vector& points2f, + static void convert(const std::vector& keypoints, + CV_OUT std::vector& points2f, const std::vector& keypointIndexes=std::vector()); //! converts vector of points to the vector of keypoints, where each keypoint is assigned the same size and the same orientation - static void convert(const std::vector& points2f, std::vector& keypoints, + static void convert(const std::vector& points2f, + CV_OUT std::vector& keypoints, float size=1, float response=1, int octave=0, int class_id=-1); //! computes overlap for pair of keypoints; @@ -254,7 +256,7 @@ public: //! writes vector of keypoints to the file storage CV_EXPORTS void write(FileStorage& fs, const string& name, const vector& keypoints); //! reads vector of keypoints from the specified file storage node -CV_EXPORTS void read(const FileNode& node, vector& keypoints); +CV_EXPORTS void read(const FileNode& node, CV_OUT vector& keypoints); /*! SIFT implementation. @@ -357,12 +359,12 @@ public: //! returns the descriptor size in float's (64 or 128) int descriptorSize() const; //! finds the keypoints using fast hessian detector used in SURF - void operator()(const Mat& img, const Mat& mask, - vector& keypoints) const; + CV_WRAP_AS(detect) void operator()(const Mat& img, const Mat& mask, + CV_OUT vector& keypoints) const; //! finds the keypoints and computes their descriptors. Optionally it can compute descriptors for the user-provided keypoints - void operator()(const Mat& img, const Mat& mask, - vector& keypoints, - vector& descriptors, + CV_WRAP_AS(detect) void operator()(const Mat& img, const Mat& mask, + CV_OUT vector& keypoints, + CV_OUT vector& descriptors, bool useProvidedKeypoints=false) const; }; @@ -386,7 +388,8 @@ public: int _max_evolution, double _area_threshold, double _min_margin, int _edge_blur_size ); //! the operator that extracts the MSERs from the image or the specific part of it - void operator()( const Mat& image, vector >& msers, const Mat& mask ) const; + CV_WRAP_AS(detect) void operator()( const Mat& image, + CV_OUT vector >& msers, const Mat& mask ) const; }; /*! @@ -405,11 +408,13 @@ public: int _lineThresholdBinarized, int _suppressNonmaxSize); //! finds the keypoints in the image - void operator()(const Mat& image, vector& keypoints) const; + CV_WRAP_AS(detect) void operator()(const Mat& image, + CV_OUT vector& keypoints) const; }; //! detects corners using FAST algorithm by E. Rosten -CV_EXPORTS void FAST( const Mat& image, vector& keypoints, int threshold, bool nonmaxSupression=true ); +CV_EXPORTS void FAST( const Mat& image, CV_OUT vector& keypoints, + int threshold, bool nonmaxSupression=true ); /*! The Patch Generator class @@ -423,13 +428,14 @@ public: double _lambdaMin=0.6, double _lambdaMax=1.5, double _thetaMin=-CV_PI, double _thetaMax=CV_PI, double _phiMin=-CV_PI, double _phiMax=CV_PI ); - void operator()(const Mat& image, Point2f pt, Mat& patch, Size patchSize, RNG& rng) const; - void operator()(const Mat& image, const Mat& transform, Mat& patch, + CV_WRAP_AS(generate) void operator()(const Mat& image, Point2f pt, Mat& patch, Size patchSize, RNG& rng) const; + CV_WRAP_AS(generate) void operator()(const Mat& image, const Mat& transform, Mat& patch, Size patchSize, RNG& rng) const; void warpWholeImage(const Mat& image, Mat& matT, Mat& buf, - Mat& warped, int border, RNG& rng) const; + CV_OUT Mat& warped, int border, RNG& rng) const; void generateRandomTransform(Point2f srcCenter, Point2f dstCenter, - Mat& transform, RNG& rng, bool inverse=false) const; + CV_OUT Mat& transform, RNG& rng, + bool inverse=false) const; void setAffineParam(double lambda, double theta, double phi); double backgroundMin, backgroundMax; @@ -447,9 +453,13 @@ public: LDetector(); LDetector(int _radius, int _threshold, int _nOctaves, int _nViews, double _baseFeatureSize, double _clusteringDistance); - void operator()(const Mat& image, vector& keypoints, int maxCount=0, bool scaleCoords=true) const; - void operator()(const vector& pyr, vector& keypoints, int maxCount=0, bool scaleCoords=true) const; - void getMostStable2D(const Mat& image, vector& keypoints, + CV_WRAP_AS(detect) void operator()(const Mat& image, + CV_OUT vector& keypoints, + int maxCount=0, bool scaleCoords=true) const; + CV_WRAP_AS(detect) void operator()(const vector& pyr, + CV_OUT vector& keypoints, + int maxCount=0, bool scaleCoords=true) const; + void getMostStable2D(const Mat& image, CV_OUT vector& keypoints, int maxCount, const PatchGenerator& patchGenerator) const; void setVerbose(bool verbose); @@ -561,6 +571,7 @@ protected: vector posteriors; }; + class CV_EXPORTS PlanarObjectDetector { public: @@ -596,9 +607,10 @@ public: void read(const FileNode& node); void write(FileStorage& fs, const String& name=String()) const; - bool operator()(const Mat& image, Mat& H, vector& corners) const; - bool operator()(const vector& pyr, const vector& keypoints, - Mat& H, vector& corners, vector* pairs=0) const; + CV_WRAP_AS(detect) bool operator()(const Mat& image, CV_OUT Mat& H, CV_OUT vector& corners) const; + CV_WRAP_AS(detect) bool operator()(const vector& pyr, const vector& keypoints, + CV_OUT Mat& H, CV_OUT vector& corners, + CV_OUT vector* pairs=0) const; protected: bool verbose; @@ -735,7 +747,6 @@ struct CV_EXPORTS RTreeNode short offset1, offset2; RTreeNode() {} - RTreeNode(uchar x1, uchar y1, uchar x2, uchar y2) : offset1(y1*RandomizedTree::PATCH_SIZE + x1), offset2(y2*RandomizedTree::PATCH_SIZE + x2) @@ -755,7 +766,6 @@ public: static const size_t DEFAULT_NUM_QUANT_BITS = 4; RTreeClassifier(); - void train(std::vector const& base_set, RNG &rng, int num_trees = RTreeClassifier::DEFAULT_TREES, diff --git a/modules/highgui/include/opencv2/highgui/highgui.hpp b/modules/highgui/include/opencv2/highgui/highgui.hpp index 146d132498..4a0aa45dec 100644 --- a/modules/highgui/include/opencv2/highgui/highgui.hpp +++ b/modules/highgui/include/opencv2/highgui/highgui.hpp @@ -106,7 +106,7 @@ CV_EXPORTS bool imwrite( const string& filename, const Mat& img, const vector& params=vector()); CV_EXPORTS Mat imdecode( const Mat& buf, int flags ); CV_EXPORTS bool imencode( const string& ext, const Mat& img, - vector& buf, + CV_OUT vector& buf, const vector& params=vector()); CV_EXPORTS int waitKey(int delay=0); @@ -130,8 +130,8 @@ public: virtual void release(); virtual bool grab(); - virtual bool retrieve(Mat& image, int channel=0); - virtual VideoCapture& operator >> (Mat& image); + virtual bool retrieve(CV_OUT Mat& image, int channel=0); + virtual CV_WRAP_AS(query) VideoCapture& operator >> (Mat& image); virtual bool set(int propId, double value); virtual double get(int propId); @@ -145,12 +145,14 @@ class CV_EXPORTS VideoWriter { public: VideoWriter(); - VideoWriter(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true); + VideoWriter(const string& filename, int fourcc, double fps, + Size frameSize, bool isColor=true); virtual ~VideoWriter(); - virtual bool open(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true); + virtual bool open(const string& filename, int fourcc, double fps, + Size frameSize, bool isColor=true); virtual bool isOpened() const; - virtual VideoWriter& operator << (const Mat& image); + virtual CV_WRAP_AS(write) VideoWriter& operator << (const Mat& image); protected: Ptr writer; diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp index 0fa0aeb1ff..2c8e187ca0 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp @@ -327,7 +327,8 @@ CV_EXPORTS Ptr createGaussianFilter( int type, Size ksize, double sigma1, double sigma2=0, int borderType=BORDER_DEFAULT); //! initializes kernels of the generalized Sobel operator -CV_EXPORTS void getDerivKernels( Mat& kx, Mat& ky, int dx, int dy, int ksize, +CV_EXPORTS void getDerivKernels( CV_OUT Mat& kx, CV_OUT Mat& ky, + int dx, int dy, int ksize, bool normalize=false, int ktype=CV_32F ); //! returns filter engine for the generalized Sobel operator CV_EXPORTS Ptr createDerivFilter( int srcType, int dstType, @@ -335,16 +336,16 @@ CV_EXPORTS Ptr createDerivFilter( int srcType, int dstType, int borderType=BORDER_DEFAULT ); //! returns horizontal 1D box filter CV_EXPORTS Ptr getRowSumFilter(int srcType, int sumType, - int ksize, int anchor=-1); + int ksize, int anchor=-1); //! returns vertical 1D box filter -CV_EXPORTS Ptr getColumnSumFilter(int sumType, int dstType, - int ksize, int anchor=-1, - double scale=1); +CV_EXPORTS Ptr getColumnSumFilter( int sumType, int dstType, + int ksize, int anchor=-1, + double scale=1); //! returns box filter engine CV_EXPORTS Ptr createBoxFilter( int srcType, int dstType, Size ksize, - Point anchor=Point(-1,-1), - bool normalize=true, - int borderType=BORDER_DEFAULT); + Point anchor=Point(-1,-1), + bool normalize=true, + int borderType=BORDER_DEFAULT); //! type of morphological operation enum { MORPH_ERODE=0, MORPH_DILATE=1, MORPH_OPEN=2, MORPH_CLOSE=3, MORPH_GRADIENT=4, MORPH_TOPHAT=5, MORPH_BLACKHAT=6 }; @@ -374,27 +375,27 @@ CV_EXPORTS Mat getStructuringElement(int shape, Size ksize, Point anchor=Point(- template<> CV_EXPORTS void Ptr::delete_obj(); //! copies 2D array to a larger destination array with extrapolation of the outer part of src using the specified border mode -CV_EXPORTS void copyMakeBorder( const Mat& src, Mat& dst, +CV_EXPORTS void copyMakeBorder( const Mat& src, CV_OUT Mat& dst, int top, int bottom, int left, int right, int borderType, const Scalar& value=Scalar() ); //! smooths the image using median filter. -CV_EXPORTS void medianBlur( const Mat& src, Mat& dst, int ksize ); +CV_EXPORTS void medianBlur( const Mat& src, CV_OUT Mat& dst, int ksize ); //! smooths the image using Gaussian filter. -CV_EXPORTS void GaussianBlur( const Mat& src, Mat& dst, Size ksize, +CV_EXPORTS void GaussianBlur( const Mat& src, CV_OUT Mat& dst, Size ksize, double sigma1, double sigma2=0, int borderType=BORDER_DEFAULT ); //! smooths the image using bilateral filter -CV_EXPORTS void bilateralFilter( const Mat& src, Mat& dst, int d, +CV_EXPORTS void bilateralFilter( const Mat& src, CV_OUT Mat& dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT ); //! smooths the image using the box filter. Each pixel is processed in O(1) time -CV_EXPORTS void boxFilter( const Mat& src, Mat& dst, int ddepth, +CV_EXPORTS void boxFilter( const Mat& src, CV_OUT Mat& dst, int ddepth, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT ); //! a synonym for normalized box filter -static inline void blur( const Mat& src, Mat& dst, +static inline void blur( const Mat& src, CV_OUT Mat& dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT ) { @@ -402,54 +403,54 @@ static inline void blur( const Mat& src, Mat& dst, } //! applies non-separable 2D linear filter to the image -CV_EXPORTS void filter2D( const Mat& src, Mat& dst, int ddepth, +CV_EXPORTS void filter2D( const Mat& src, CV_OUT Mat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT ); //! applies separable 2D linear filter to the image -CV_EXPORTS void sepFilter2D( const Mat& src, Mat& dst, int ddepth, +CV_EXPORTS void sepFilter2D( const Mat& src, CV_OUT Mat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT ); //! applies generalized Sobel operator to the image -CV_EXPORTS void Sobel( const Mat& src, Mat& dst, int ddepth, +CV_EXPORTS void Sobel( const Mat& src, CV_OUT Mat& dst, int ddepth, int dx, int dy, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT ); //! applies the vertical or horizontal Scharr operator to the image -CV_EXPORTS void Scharr( const Mat& src, Mat& dst, int ddepth, +CV_EXPORTS void Scharr( const Mat& src, CV_OUT Mat& dst, int ddepth, int dx, int dy, double scale=1, double delta=0, int borderType=BORDER_DEFAULT ); //! applies Laplacian operator to the image -CV_EXPORTS void Laplacian( const Mat& src, Mat& dst, int ddepth, +CV_EXPORTS void Laplacian( const Mat& src, CV_OUT Mat& dst, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT ); //! applies Canny edge detector and produces the edge map. -CV_EXPORTS void Canny( const Mat& image, Mat& edges, +CV_EXPORTS void Canny( const Mat& image, CV_OUT Mat& edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false ); //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria -CV_EXPORTS void cornerMinEigenVal( const Mat& src, Mat& dst, +CV_EXPORTS void cornerMinEigenVal( const Mat& src, CV_OUT Mat& dst, int blockSize, int ksize=3, int borderType=BORDER_DEFAULT ); //! computes Harris cornerness criteria at each image pixel -CV_EXPORTS void cornerHarris( const Mat& src, Mat& dst, int blockSize, +CV_EXPORTS void cornerHarris( const Mat& src, CV_OUT Mat& dst, int blockSize, int ksize, double k, int borderType=BORDER_DEFAULT ); //! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix at each pixel. The output is stored as 6-channel matrix. -CV_EXPORTS void cornerEigenValsAndVecs( const Mat& src, Mat& dst, +CV_EXPORTS void cornerEigenValsAndVecs( const Mat& src, CV_OUT Mat& dst, int blockSize, int ksize, int borderType=BORDER_DEFAULT ); //! computes another complex cornerness criteria at each pixel -CV_EXPORTS void preCornerDetect( const Mat& src, Mat& dst, int ksize, +CV_EXPORTS void preCornerDetect( const Mat& src, CV_OUT Mat& dst, int ksize, int borderType=BORDER_DEFAULT ); //! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria @@ -458,41 +459,42 @@ CV_EXPORTS void cornerSubPix( const Mat& image, vector& corners, TermCriteria criteria ); //! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima -CV_EXPORTS void goodFeaturesToTrack( const Mat& image, vector& corners, +CV_EXPORTS void goodFeaturesToTrack( const Mat& image, CV_OUT vector& corners, int maxCorners, double qualityLevel, double minDistance, const Mat& mask=Mat(), int blockSize=3, bool useHarrisDetector=false, double k=0.04 ); //! finds lines in the black-n-white image using the standard or pyramid Hough transform -CV_EXPORTS void HoughLines( const Mat& image, vector& lines, +CV_EXPORTS void HoughLines( const Mat& image, CV_OUT vector& lines, double rho, double theta, int threshold, double srn=0, double stn=0 ); //! finds line segments in the black-n-white image using probabalistic Hough transform -CV_EXPORTS void HoughLinesP( Mat& image, vector& lines, +CV_EXPORTS void HoughLinesP( Mat& image, CV_OUT vector& lines, double rho, double theta, int threshold, double minLineLength=0, double maxLineGap=0 ); //! finds circles in the grayscale image using 2+1 gradient Hough transform -CV_EXPORTS void HoughCircles( const Mat& image, vector& circles, +CV_EXPORTS void HoughCircles( const Mat& image, CV_OUT vector& circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0 ); //! erodes the image (applies the local minimum operator) -CV_EXPORTS void erode( const Mat& src, Mat& dst, const Mat& kernel, +CV_EXPORTS void erode( const Mat& src, CV_OUT Mat& dst, const Mat& kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() ); //! dilates the image (applies the local maximum operator) -CV_EXPORTS void dilate( const Mat& src, Mat& dst, const Mat& kernel, +CV_EXPORTS void dilate( const Mat& src, CV_OUT Mat& dst, const Mat& kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() ); //! applies an advanced morphological operation to the image -CV_EXPORTS void morphologyEx( const Mat& src, Mat& dst, int op, const Mat& kernel, +CV_EXPORTS void morphologyEx( const Mat& src, CV_OUT Mat& dst, + int op, const Mat& kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() ); @@ -510,19 +512,19 @@ enum }; //! resizes the image -CV_EXPORTS void resize( const Mat& src, Mat& dst, +CV_EXPORTS void resize( const Mat& src, CV_OUT Mat& dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR ); //! warps the image using affine transformation -CV_EXPORTS void warpAffine( const Mat& src, Mat& dst, +CV_EXPORTS void warpAffine( const Mat& src, CV_OUT Mat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar()); //! warps the image using perspective transformation -CV_EXPORTS void warpPerspective( const Mat& src, Mat& dst, +CV_EXPORTS void warpPerspective( const Mat& src, CV_OUT Mat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, @@ -533,12 +535,13 @@ enum { INTER_BITS=5, INTER_BITS2=INTER_BITS*2, INTER_TAB_SIZE2=INTER_TAB_SIZE*INTER_TAB_SIZE }; //! warps the image using the precomputed maps. The maps are stored in either floating-point or integer fixed-point format -CV_EXPORTS void remap( const Mat& src, Mat& dst, const Mat& map1, const Mat& map2, +CV_EXPORTS void remap( const Mat& src, CV_OUT Mat& dst, const Mat& map1, const Mat& map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar()); //! converts maps for remap from floating-point to fixed-point format or backwards -CV_EXPORTS void convertMaps( const Mat& map1, const Mat& map2, Mat& dstmap1, Mat& dstmap2, +CV_EXPORTS void convertMaps( const Mat& map1, const Mat& map2, + CV_OUT Mat& dstmap1, CV_OUT Mat& dstmap2, int dstmap1type, bool nninterpolation=false ); //! returns 2x3 affine transformation matrix for the planar rotation. @@ -548,28 +551,28 @@ CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] //! returns 2x3 affine transformation for the corresponding 3 point pairs. CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] ); //! computes 2x3 affine transformation matrix that is inverse to the specified 2x3 affine transformation. -CV_EXPORTS void invertAffineTransform(const Mat& M, Mat& iM); +CV_EXPORTS void invertAffineTransform( const Mat& M, CV_OUT Mat& iM ); //! extracts rectangle from the image at sub-pixel location CV_EXPORTS void getRectSubPix( const Mat& image, Size patchSize, - Point2f center, Mat& patch, int patchType=-1 ); + Point2f center, CV_OUT Mat& patch, int patchType=-1 ); //! computes the integral image -CV_EXPORTS void integral( const Mat& src, Mat& sum, int sdepth=-1 ); +CV_EXPORTS void integral( const Mat& src, CV_OUT Mat& sum, int sdepth=-1 ); //! computes the integral image and integral for the squared image -CV_EXPORTS void integral( const Mat& src, Mat& sum, Mat& sqsum, int sdepth=-1 ); +CV_EXPORTS void integral( const Mat& src, CV_OUT Mat& sum, CV_OUT Mat& sqsum, int sdepth=-1 ); //! computes the integral image, integral for the squared image and the tilted integral image -CV_EXPORTS void integral( const Mat& src, Mat& sum, Mat& sqsum, Mat& tilted, int sdepth=-1 ); +CV_EXPORTS void integral( const Mat& src, CV_OUT Mat& sum, CV_OUT Mat& sqsum, CV_OUT Mat& tilted, int sdepth=-1 ); //! adds image to the accumulator (dst += src). Unlike cv::add, dst and src can have different types. -CV_EXPORTS void accumulate( const Mat& src, Mat& dst, const Mat& mask=Mat() ); +CV_EXPORTS void accumulate( const Mat& src, CV_OUT Mat& dst, const Mat& mask=Mat() ); //! adds squared src image to the accumulator (dst += src*src). -CV_EXPORTS void accumulateSquare( const Mat& src, Mat& dst, const Mat& mask=Mat() ); +CV_EXPORTS void accumulateSquare( const Mat& src, CV_OUT Mat& dst, const Mat& mask=Mat() ); //! adds product of the 2 images to the accumulator (dst += src1*src2). CV_EXPORTS void accumulateProduct( const Mat& src1, const Mat& src2, - Mat& dst, const Mat& mask=Mat() ); + CV_OUT Mat& dst, const Mat& mask=Mat() ); //! updates the running average (dst = dst*(1-alpha) + src*alpha) -CV_EXPORTS void accumulateWeighted( const Mat& src, Mat& dst, +CV_EXPORTS void accumulateWeighted( const Mat& src, CV_OUT Mat& dst, double alpha, const Mat& mask=Mat() ); //! type of the threshold operation @@ -577,30 +580,30 @@ enum { THRESH_BINARY=0, THRESH_BINARY_INV=1, THRESH_TRUNC=2, THRESH_TOZERO=3, THRESH_TOZERO_INV=4, THRESH_MASK=7, THRESH_OTSU=8 }; //! applies fixed threshold to the image -CV_EXPORTS double threshold( const Mat& src, Mat& dst, double thresh, double maxval, int type ); +CV_EXPORTS double threshold( const Mat& src, CV_OUT Mat& dst, double thresh, double maxval, int type ); //! adaptive threshold algorithm enum { ADAPTIVE_THRESH_MEAN_C=0, ADAPTIVE_THRESH_GAUSSIAN_C=1 }; //! applies variable (adaptive) threshold to the image -CV_EXPORTS void adaptiveThreshold( const Mat& src, Mat& dst, double maxValue, +CV_EXPORTS void adaptiveThreshold( const Mat& src, CV_OUT Mat& dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C ); //! smooths and downsamples the image -CV_EXPORTS void pyrDown( const Mat& src, Mat& dst, const Size& dstsize=Size()); +CV_EXPORTS void pyrDown( const Mat& src, CV_OUT Mat& dst, const Size& dstsize=Size()); //! upsamples and smoothes the image -CV_EXPORTS void pyrUp( const Mat& src, Mat& dst, const Size& dstsize=Size()); +CV_EXPORTS void pyrUp( const Mat& src, CV_OUT Mat& dst, const Size& dstsize=Size()); //! builds the gaussian pyramid using pyrDown() as a basic operation -CV_EXPORTS void buildPyramid( const Mat& src, vector& dst, int maxlevel ); +CV_EXPORTS void buildPyramid( const Mat& src, CV_OUT vector& dst, int maxlevel ); //! corrects lens distortion for the given camera matrix and distortion coefficients -CV_EXPORTS void undistort( const Mat& src, Mat& dst, const Mat& cameraMatrix, +CV_EXPORTS void undistort( const Mat& src, CV_OUT Mat& dst, const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& newCameraMatrix=Mat() ); //! initializes maps for cv::remap() to correct lens distortion and optionally rectify the image CV_EXPORTS void initUndistortRectifyMap( const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& R, const Mat& newCameraMatrix, - Size size, int m1type, Mat& map1, Mat& map2 ); + Size size, int m1type, CV_OUT Mat& map1, CV_OUT Mat& map2 ); enum { @@ -611,63 +614,65 @@ enum //! initializes maps for cv::remap() for wide-angle CV_EXPORTS float initWideAngleProjMap( const Mat& cameraMatrix, const Mat& distCoeffs, Size imageSize, int destImageWidth, - int m1type, Mat& map1, Mat& map2, + int m1type, CV_OUT Mat& map1, CV_OUT Mat& map2, int projType=PROJ_SPHERICAL_EQRECT, double alpha=0); //! returns the default new camera matrix (by default it is the same as cameraMatrix unless centerPricipalPoint=true) CV_EXPORTS Mat getDefaultNewCameraMatrix( const Mat& cameraMatrix, Size imgsize=Size(), bool centerPrincipalPoint=false ); //! returns points' coordinates after lens distortion correction -CV_EXPORTS void undistortPoints( const Mat& src, vector& dst, +CV_EXPORTS void undistortPoints( const Mat& src, CV_OUT vector& dst, const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& R=Mat(), const Mat& P=Mat()); //! returns points' coordinates after lens distortion correction -CV_EXPORTS void undistortPoints( const Mat& src, Mat& dst, +CV_EXPORTS void undistortPoints( const Mat& src, CV_OUT Mat& dst, const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& R=Mat(), const Mat& P=Mat()); template<> CV_EXPORTS void Ptr::delete_obj(); //! computes the joint dense histogram for a set of images. -CV_EXPORTS void calcHist( const Mat* images, int nimages, - const int* channels, const Mat& mask, - MatND& hist, int dims, const int* histSize, - const float** ranges, bool uniform=true, - bool accumulate=false ); +CV_EXPORTS void calcHist( CV_CARRAY(nimages) const Mat* images, int nimages, + CV_CARRAY(dims) const int* channels, const Mat& mask, + CV_OUT Mat& hist, int dims, CV_CARRAY(dims) const int* histSize, + CV_CUSTOM_CARRAY((dims,histSize,uniform)) const float** ranges, + bool uniform=true, bool accumulate=false ); //! computes the joint sparse histogram for a set of images. -CV_EXPORTS void calcHist( const Mat* images, int nimages, - const int* channels, const Mat& mask, - SparseMat& hist, int dims, const int* histSize, - const float** ranges, bool uniform=true, - bool accumulate=false ); +CV_EXPORTS void calcHist( CV_CARRAY(nimages) const Mat* images, int nimages, + CV_CARRAY(dims) const int* channels, const Mat& mask, + CV_OUT SparseMat& hist, int dims, CV_CARRAY(dims) const int* histSize, + CV_CUSTOM_CARRAY((dims,histSize,uniform)) const float** ranges, + bool uniform=true, bool accumulate=false ); //! computes back projection for the set of images -CV_EXPORTS void calcBackProject( const Mat* images, int nimages, - const int* channels, const MatND& hist, - Mat& backProject, const float** ranges, +CV_EXPORTS void calcBackProject( CV_CARRAY(nimages) const Mat* images, int nimages, + CV_CARRAY(hist.dims) const int* channels, const Mat& hist, + CV_OUT Mat& backProject, + CV_CUSTOM_CARRAY(hist) const float** ranges, double scale=1, bool uniform=true ); //! computes back projection for the set of images -CV_EXPORTS void calcBackProject( const Mat* images, int nimages, - const int* channels, const SparseMat& hist, - Mat& backProject, const float** ranges, +CV_EXPORTS void calcBackProject( CV_CARRAY(nimages) const Mat* images, int nimages, + CV_CARRAY(hist.dims()) const int* channels, + const SparseMat& hist, CV_OUT Mat& backProject, + CV_CUSTOM_CARRAY(hist) const float** ranges, double scale=1, bool uniform=true ); //! compares two histograms stored in dense arrays -CV_EXPORTS double compareHist( const MatND& H1, const MatND& H2, int method ); +CV_EXPORTS double compareHist( const Mat& H1, const Mat& H2, int method ); //! compares two histograms stored in sparse arrays CV_EXPORTS double compareHist( const SparseMat& H1, const SparseMat& H2, int method ); //! normalizes the grayscale image brightness and contrast by normalizing its histogram -CV_EXPORTS void equalizeHist( const Mat& src, Mat& dst ); +CV_EXPORTS void equalizeHist( const Mat& src, CV_OUT Mat& dst ); //! segments the image using watershed algorithm CV_EXPORTS void watershed( const Mat& image, Mat& markers ); //! filters image using meanshift algorithm -CV_EXPORTS void pyrMeanShiftFiltering( const Mat& src, Mat& dst, +CV_EXPORTS void pyrMeanShiftFiltering( const Mat& src, CV_OUT Mat& dst, double sp, double sr, int maxLevel=1, TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5,1) ); @@ -698,14 +703,14 @@ enum //! restores the damaged image areas using one of the available intpainting algorithms CV_EXPORTS void inpaint( const Mat& src, const Mat& inpaintMask, - Mat& dst, double inpaintRange, int flags ); + CV_OUT Mat& dst, double inpaintRange, int flags ); //! builds the discrete Voronoi diagram -CV_EXPORTS void distanceTransform( const Mat& src, Mat& dst, Mat& labels, +CV_EXPORTS void distanceTransform( const Mat& src, CV_OUT Mat& dst, Mat& labels, int distanceType, int maskSize ); //! computes the distance transform map -CV_EXPORTS void distanceTransform( const Mat& src, Mat& dst, +CV_EXPORTS void distanceTransform( const Mat& src, CV_OUT Mat& dst, int distanceType, int maskSize ); enum { FLOODFILL_FIXED_RANGE = 1 << 16, @@ -724,7 +729,7 @@ CV_EXPORTS int floodFill( Mat& image, Mat& mask, int flags=4 ); //! converts image from one color space to another -CV_EXPORTS void cvtColor( const Mat& src, Mat& dst, int code, int dstCn=0 ); +CV_EXPORTS void cvtColor( const Mat& src, CV_OUT Mat& dst, int code, int dstCn=0 ); //! raster image moments class CV_EXPORTS Moments @@ -758,7 +763,7 @@ CV_EXPORTS void HuMoments( const Moments& moments, double hu[7] ); enum { TM_SQDIFF=0, TM_SQDIFF_NORMED=1, TM_CCORR=2, TM_CCORR_NORMED=3, TM_CCOEFF=4, TM_CCOEFF_NORMED=5 }; //! computes the proximity map for the raster template and the image where the template is searched for -CV_EXPORTS void matchTemplate( const Mat& image, const Mat& templ, Mat& result, int method ); +CV_EXPORTS void matchTemplate( const Mat& image, const Mat& templ, CV_OUT Mat& result, int method ); //! mode of the contour retrieval algorithm enum @@ -779,12 +784,12 @@ enum }; //! retrieves contours and the hierarchical information from black-n-white image. -CV_EXPORTS void findContours( Mat& image, vector >& contours, +CV_EXPORTS void findContours( Mat& image, CV_OUT vector >& contours, vector& hierarchy, int mode, int method, Point offset=Point()); //! retrieves contours from black-n-white image. -CV_EXPORTS void findContours( Mat& image, vector >& contours, +CV_EXPORTS void findContours( Mat& image, CV_OUT vector >& contours, int mode, int method, Point offset=Point()); //! draws contours in the image @@ -796,11 +801,11 @@ CV_EXPORTS void drawContours( Mat& image, const vector >& contours //! approximates contour or a curve using Douglas-Peucker algorithm CV_EXPORTS void approxPolyDP( const Mat& curve, - vector& approxCurve, + CV_OUT vector& approxCurve, double epsilon, bool closed ); //! approximates contour or a curve using Douglas-Peucker algorithm CV_EXPORTS void approxPolyDP( const Mat& curve, - vector& approxCurve, + CV_OUT vector& approxCurve, double epsilon, bool closed ); //! computes the contour perimeter (closed=true) or a curve length CV_EXPORTS double arcLength( const Mat& curve, bool closed ); @@ -818,11 +823,11 @@ CV_EXPORTS double matchShapes( const Mat& contour1, const Mat& contour2, int method, double parameter ); //! computes convex hull for a set of 2D points. -CV_EXPORTS void convexHull( const Mat& points, vector& hull, bool clockwise=false ); +CV_EXPORTS void convexHull( const Mat& points, CV_OUT vector& hull, bool clockwise=false ); //! computes convex hull for a set of 2D points. -CV_EXPORTS void convexHull( const Mat& points, vector& hull, bool clockwise=false ); +CV_EXPORTS void convexHull( const Mat& points, CV_OUT vector& hull, bool clockwise=false ); //! computes convex hull for a set of 2D points. -CV_EXPORTS void convexHull( const Mat& points, vector& hull, bool clockwise=false ); +CV_EXPORTS void convexHull( const Mat& points, CV_OUT vector& hull, bool clockwise=false ); //! returns true iff the contour is convex. Does not support contours with self-intersection CV_EXPORTS bool isContourConvex( const Mat& contour ); @@ -831,10 +836,10 @@ CV_EXPORTS bool isContourConvex( const Mat& contour ); CV_EXPORTS RotatedRect fitEllipse( const Mat& points ); //! fits line to the set of 2D points using M-estimator algorithm -CV_EXPORTS void fitLine( const Mat& points, Vec4f& line, int distType, +CV_EXPORTS void fitLine( const Mat& points, CV_OUT Vec4f& line, int distType, double param, double reps, double aeps ); //! fits line to the set of 3D points using M-estimator algorithm -CV_EXPORTS void fitLine( const Mat& points, Vec6f& line, int distType, +CV_EXPORTS void fitLine( const Mat& points, CV_OUT Vec6f& line, int distType, double param, double reps, double aeps ); //! checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary CV_EXPORTS double pointPolygonTest( const Mat& contour, @@ -845,7 +850,7 @@ CV_EXPORTS Mat estimateRigidTransform( const Mat& A, const Mat& B, bool fullAffine ); //! computes the best-fit affine transformation that maps one 3D point set to another (RANSAC algorithm is used) -CV_EXPORTS int estimateAffine3D(const Mat& from, const Mat& to, Mat& out, +CV_EXPORTS int estimateAffine3D(const Mat& from, const Mat& to, CV_OUT Mat& dst, vector& outliers, double param1 = 3.0, double param2 = 0.99); diff --git a/modules/ml/include/opencv2/ml/ml.hpp b/modules/ml/include/opencv2/ml/ml.hpp index ceaf08ff5c..3131d421a3 100644 --- a/modules/ml/include/opencv2/ml/ml.hpp +++ b/modules/ml/include/opencv2/ml/ml.hpp @@ -247,23 +247,21 @@ public: CvNormalBayesClassifier(); virtual ~CvNormalBayesClassifier(); - CvNormalBayesClassifier( const CvMat* _train_data, const CvMat* _responses, + CV_NO_WRAP CvNormalBayesClassifier( const CvMat* _train_data, const CvMat* _responses, const CvMat* _var_idx=0, const CvMat* _sample_idx=0 ); - virtual bool train( const CvMat* _train_data, const CvMat* _responses, + CV_NO_WRAP virtual bool train( const CvMat* _train_data, const CvMat* _responses, const CvMat* _var_idx = 0, const CvMat* _sample_idx=0, bool update=false ); - virtual float predict( const CvMat* _samples, CvMat* results=0 ) const; + CV_NO_WRAP virtual float predict( const CvMat* _samples, CvMat* results=0 ) const; virtual void clear(); -#ifndef SWIG CvNormalBayesClassifier( const cv::Mat& _train_data, const cv::Mat& _responses, const cv::Mat& _var_idx=cv::Mat(), const cv::Mat& _sample_idx=cv::Mat() ); virtual bool train( const cv::Mat& _train_data, const cv::Mat& _responses, const cv::Mat& _var_idx = cv::Mat(), const cv::Mat& _sample_idx=cv::Mat(), bool update=false ); virtual float predict( const cv::Mat& _samples, cv::Mat* results=0 ) const; -#endif virtual void write( CvFileStorage* storage, const char* name ) const; virtual void read( CvFileStorage* storage, CvFileNode* node ); diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp index c86a81cf90..8a64c27bf9 100644 --- a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp @@ -271,7 +271,7 @@ namespace cv ///////////////////////////// Object Detection //////////////////////////// CV_EXPORTS void groupRectangles(vector& rectList, int groupThreshold, double eps=0.2); -CV_EXPORTS void groupRectangles(vector& rectList, vector& weights, int groupThreshold, double eps=0.2); +CV_EXPORTS void groupRectangles(vector& rectList, CV_OUT vector& weights, int groupThreshold, double eps=0.2); class CV_EXPORTS FeatureEvaluator { @@ -328,7 +328,7 @@ public: bool load(const string& filename); bool read(const FileNode& node); void detectMultiScale( const Mat& image, - vector& objects, + CV_OUT vector& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size()); @@ -401,18 +401,18 @@ public: virtual void copyTo(HOGDescriptor& c) const; virtual void compute(const Mat& img, - vector& descriptors, + CV_OUT vector& descriptors, Size winStride=Size(), Size padding=Size(), const vector& locations=vector()) const; - virtual void detect(const Mat& img, vector& foundLocations, + virtual void detect(const Mat& img, CV_OUT vector& foundLocations, double hitThreshold=0, Size winStride=Size(), Size padding=Size(), const vector& searchLocations=vector()) const; - virtual void detectMultiScale(const Mat& img, vector& foundLocations, + virtual void detectMultiScale(const Mat& img, CV_OUT vector& foundLocations, double hitThreshold=0, Size winStride=Size(), Size padding=Size(), double scale=1.05, int groupThreshold=2) const; - virtual void computeGradient(const Mat& img, Mat& grad, Mat& angleOfs, + virtual void computeGradient(const Mat& img, CV_OUT Mat& grad, CV_OUT Mat& angleOfs, Size paddingTL=Size(), Size paddingBR=Size()) const; static vector getDefaultPeopleDetector(); diff --git a/modules/video/include/opencv2/video/background_segm.hpp b/modules/video/include/opencv2/video/background_segm.hpp index 215fb43a4b..174b24ac6f 100644 --- a/modules/video/include/opencv2/video/background_segm.hpp +++ b/modules/video/include/opencv2/video/background_segm.hpp @@ -112,17 +112,11 @@ typedef struct CvBGStatModel // // Releases memory used by BGStatModel -CV_INLINE void cvReleaseBGStatModel( CvBGStatModel** bg_model ) -{ - if( bg_model && *bg_model && (*bg_model)->release ) - (*bg_model)->release( bg_model ); -} +CVAPI(void) cvReleaseBGStatModel( CvBGStatModel** bg_model ); // Updates statistical model and returns number of found foreground regions -CV_INLINE int cvUpdateBGStatModel( IplImage* current_frame, CvBGStatModel* bg_model, double learningRate CV_DEFAULT(-1)) -{ - return bg_model && bg_model->update ? bg_model->update( current_frame, bg_model, learningRate ) : 0; -} +CVAPI(int) cvUpdateBGStatModel( IplImage* current_frame, CvBGStatModel* bg_model, + double learningRate CV_DEFAULT(-1)); // Performs FG post-processing using segmentation // (all pixels of a region will be classified as foreground if majority of pixels of the region are FG). @@ -365,7 +359,8 @@ public: //! the virtual destructor virtual ~BackgroundSubtractor(); //! the update operator that takes the next video frame and returns the current foreground mask as 8-bit binary image. - virtual void operator()(const Mat& image, Mat& fgmask, double learningRate=0); + virtual CV_WRAP_AS(apply) void operator()(const Mat& image, CV_OUT Mat& fgmask, + double learningRate=0); }; diff --git a/modules/video/include/opencv2/video/tracking.hpp b/modules/video/include/opencv2/video/tracking.hpp index f6584df470..33f94b78b2 100644 --- a/modules/video/include/opencv2/video/tracking.hpp +++ b/modules/video/include/opencv2/video/tracking.hpp @@ -248,8 +248,8 @@ CV_EXPORTS void updateMotionHistory( const Mat& silhouette, Mat& mhi, double timestamp, double duration ); //! computes the motion gradient orientation image from the motion history image -CV_EXPORTS void calcMotionGradient( const Mat& mhi, Mat& mask, - Mat& orientation, +CV_EXPORTS void calcMotionGradient( const Mat& mhi, CV_OUT Mat& mask, + CV_OUT Mat& orientation, double delta1, double delta2, int apertureSize=3 ); @@ -260,11 +260,11 @@ CV_EXPORTS double calcGlobalOrientation( const Mat& orientation, const Mat& mask // TODO: need good API for cvSegmentMotion //! updates the object tracking window using CAMSHIFT algorithm -CV_EXPORTS RotatedRect CamShift( const Mat& probImage, Rect& window, +CV_EXPORTS RotatedRect CamShift( const Mat& probImage, CV_OUT Rect& window, TermCriteria criteria ); //! updates the object tracking window using meanshift algorithm -CV_EXPORTS int meanShift( const Mat& probImage, Rect& window, +CV_EXPORTS int meanShift( const Mat& probImage, CV_OUT Rect& window, TermCriteria criteria ); /*! @@ -313,8 +313,8 @@ enum { OPTFLOW_USE_INITIAL_FLOW=4, OPTFLOW_FARNEBACK_GAUSSIAN=256 }; //! computes sparse optical flow using multi-scale Lucas-Kanade algorithm CV_EXPORTS void calcOpticalFlowPyrLK( const Mat& prevImg, const Mat& nextImg, - const vector& prevPts, vector& nextPts, - vector& status, vector& err, + const vector& prevPts, CV_OUT vector& nextPts, + CV_OUT vector& status, CV_OUT vector& err, Size winSize=Size(15,15), int maxLevel=3, TermCriteria criteria=TermCriteria( TermCriteria::COUNT+TermCriteria::EPS, @@ -323,8 +323,8 @@ CV_EXPORTS void calcOpticalFlowPyrLK( const Mat& prevImg, const Mat& nextImg, int flags=0 ); //! computes dense optical flow using Farneback algorithm -CV_EXPORTS void calcOpticalFlowFarneback( const Mat& prev0, const Mat& next0, - Mat& flow0, double pyr_scale, int levels, int winsize, +CV_EXPORTS void calcOpticalFlowFarneback( const Mat& prev, const Mat& next, + CV_OUT Mat& flow, double pyr_scale, int levels, int winsize, int iterations, int poly_n, double poly_sigma, int flags ); } diff --git a/modules/video/src/bgfg_estimation.cpp b/modules/video/src/bgfg_estimation.cpp index e12abae3ed..33e9247d7f 100644 --- a/modules/video/src/bgfg_estimation.cpp +++ b/modules/video/src/bgfg_estimation.cpp @@ -56,9 +56,22 @@ CvBGStatModel* cvCreateBGStatModel( IplImage* first_frame, int model_type, void* return bg_model; } +void cvReleaseBGStatModel( CvBGStatModel** bg_model ) +{ + if( bg_model && *bg_model && (*bg_model)->release ) + (*bg_model)->release( bg_model ); +} + +int cvUpdateBGStatModel( IplImage* current_frame, + CvBGStatModel* bg_model, + double learningRate ) +{ + return bg_model && bg_model->update ? bg_model->update( current_frame, bg_model, learningRate ) : 0; +} + /* FOREGROUND DETECTOR INTERFACE */ -class CvFGDetectorBase:public CvFGDetector +class CvFGDetectorBase : public CvFGDetector { protected: CvBGStatModel* m_pFG;