a big patch; use special proxy types (Input/OutputArray, Input/OutputArrayOfArrays) for passing in vectors, matrices etc.

This commit is contained in:
Vadim Pisarevsky
2011-04-17 13:14:45 +00:00
parent 335370a7c0
commit abeeb40d46
94 changed files with 10831 additions and 9631 deletions

View File

@@ -14,7 +14,7 @@
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -121,7 +121,7 @@ enum { DFT_INVERSE=1, DFT_SCALE=2, DFT_ROWS=4, DFT_COMPLEX_OUTPUT=16, DFT_REAL_O
class CV_EXPORTS Exception : public std::exception
{
public:
/*!
/*!
Default constructor
*/
Exception() { code = 0; line = 0; }
@@ -129,16 +129,16 @@ public:
Full constructor. Normally the constuctor is not called explicitly.
Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
*/
Exception(int _code, const string& _err, const string& _func, const string& _file, int _line)
: code(_code), err(_err), func(_func), file(_file), line(_line)
Exception(int _code, const string& _err, const string& _func, const string& _file, int _line)
: code(_code), err(_err), func(_func), file(_file), line(_line)
{ formatMessage(); }
virtual ~Exception() throw() {}
virtual ~Exception() throw() {}
/*!
\return the error description and the context as a text string.
*/
virtual const char *what() const throw() { return msg.c_str(); }
virtual const char *what() const throw() { return msg.c_str(); }
void formatMessage()
{
@@ -148,13 +148,13 @@ public:
msg = format("%s:%d: error: (%d) %s\n", file.c_str(), line, code, err.c_str());
}
string msg; ///< the formatted error message
string msg; ///< the formatted error message
int code; ///< error code @see CVStatus
string err; ///< error description
string func; ///< function name. Available only when the compiler supports __func__ macro
string file; ///< source file name where the error has occured
int line; ///< line number in the source file where the error has occured
int code; ///< error code @see CVStatus
string err; ///< error description
string func; ///< function name. Available only when the compiler supports __func__ macro
string file; ///< source file name where the error has occured
int line; ///< line number in the source file where the error has occured
};
@@ -641,6 +641,8 @@ typedef Vec<ushort, 4> Vec4w;
typedef Vec<int, 2> Vec2i;
typedef Vec<int, 3> Vec3i;
typedef Vec<int, 4> Vec4i;
typedef Vec<int, 6> Vec6i;
typedef Vec<int, 8> Vec8i;
typedef Vec<float, 2> Vec2f;
typedef Vec<float, 3> Vec3f;
@@ -748,7 +750,7 @@ public:
Point3_();
Point3_(_Tp _x, _Tp _y, _Tp _z);
Point3_(const Point3_& pt);
explicit Point3_(const Point_<_Tp>& pt);
explicit Point3_(const Point_<_Tp>& pt);
Point3_(const CvPoint3D32f& pt);
Point3_(const Vec<_Tp, 3>& v);
@@ -1252,10 +1254,90 @@ public:
protected:
_Tp* obj; //< the object pointer.
int* refcount; //< the associated bbbbbbbbbbbbbbbbbb reference counter
int* refcount; //< the associated reference counter
};
//////////////////////////////// Mat ////////////////////////////////
//////////////////////// Input/Output Array Arguments /////////////////////////////////
/*!
Proxy datatype for passing Mat's and vector<>'s as input parameters
*/
class CV_EXPORTS InputArray
{
public:
enum { KIND_SHIFT=16, NONE=0<<KIND_SHIFT, MAT=1<<KIND_SHIFT,
MATX=2<<KIND_SHIFT, STD_VECTOR=3<<KIND_SHIFT,
STD_VECTOR_VECTOR=4<<KIND_SHIFT,
STD_VECTOR_MAT=5<<KIND_SHIFT, EXPR=6<<KIND_SHIFT };
InputArray();
InputArray(const Mat& m);
InputArray(const MatExpr& expr);
template<typename _Tp> InputArray(const vector<_Tp>& vec);
template<typename _Tp> InputArray(const vector<vector<_Tp> >& vec);
InputArray(const vector<Mat>& vec);
template<typename _Tp, int m, int n> InputArray(const Matx<_Tp, m, n>& matx);
InputArray(const double& val);
Mat getMat(int i=-1) const;
void getMatVector(vector<Mat>& mv) const;
int kind() const;
Size size(int i=-1) const;
size_t total(int i=-1) const;
int type(int i=-1) const;
int depth(int i=-1) const;
int channels(int i=-1) const;
bool empty() const;
int flags;
void* obj;
Size sz;
};
enum
{
DEPTH_MASK_8U = 1 << CV_8U,
DEPTH_MASK_8S = 1 << CV_8S,
DEPTH_MASK_16U = 1 << CV_16U,
DEPTH_MASK_16S = 1 << CV_16S,
DEPTH_MASK_32S = 1 << CV_32S,
DEPTH_MASK_32F = 1 << CV_32F,
DEPTH_MASK_64F = 1 << CV_64F,
DEPTH_MASK_ALL = (DEPTH_MASK_64F<<1)-1,
DEPTH_MASK_ALL_BUT_8S = DEPTH_MASK_ALL & ~DEPTH_MASK_8S,
DEPTH_MASK_FLT = DEPTH_MASK_32F + DEPTH_MASK_64F
};
/*!
Proxy datatype for passing Mat's and vector<>'s as input parameters
*/
class CV_EXPORTS OutputArray : public InputArray
{
public:
OutputArray();
OutputArray(Mat& m);
template<typename _Tp> OutputArray(vector<_Tp>& vec);
template<typename _Tp> OutputArray(vector<vector<_Tp> >& vec);
OutputArray(vector<Mat>& vec);
template<typename _Tp, int m, int n> OutputArray(Matx<_Tp, m, n>& matx);
bool fixedSize() const;
bool fixedType() const;
bool needed() const;
Mat& getMatRef(int i=-1);
void create(Size sz, int type, int i=-1, bool allocateVector=false, int fixedDepthMask=0);
void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0);
void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0);
void release();
void clear();
};
typedef InputArray InputArrayOfArrays;
typedef OutputArray OutputArrayOfArrays;
typedef OutputArray InputOutputArray;
/////////////////////////////////////// Mat ///////////////////////////////////////////
enum { MAGIC_MASK=0xFFFF0000, TYPE_MASK=0x00000FFF, DEPTH_MASK=7 };
@@ -1563,19 +1645,18 @@ public:
Mat clone() const;
//! copies the matrix content to "m".
// It calls m.create(this->size(), this->type()).
void copyTo( Mat& m ) const;
template<typename _Tp> void copyTo( vector<_Tp>& v ) const;
void copyTo( OutputArray m ) const;
//! copies those matrix elements to "m" that are marked with non-zero mask elements.
void copyTo( Mat& m, const Mat& mask ) const;
void copyTo( OutputArray m, const InputArray& mask ) const;
//! converts matrix to another datatype with optional scalng. See cvConvertScale.
void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const;
void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const;
void assignTo( Mat& m, int type=-1 ) const;
//! sets every matrix element to s
Mat& operator = (const Scalar& s);
//! sets some of the matrix elements to s, according to the mask
Mat& setTo(const Scalar& s, const Mat& mask=Mat());
Mat& setTo(const Scalar& s, const InputArray& mask=InputArray());
//! creates alternative matrix header for the same data, with different
// number of channels and/or different number of rows. see cvReshape.
Mat reshape(int _cn, int _rows=0) const;
@@ -1586,13 +1667,13 @@ public:
//! matrix inversion by means of matrix expressions
MatExpr inv(int method=DECOMP_LU) const;
//! per-element matrix multiplication by means of matrix expressions
MatExpr mul(const Mat& m, double scale=1) const;
MatExpr mul(const InputArray& m, double scale=1) const;
MatExpr mul(const MatExpr& m, double scale=1) const;
//! computes cross-product of 2 3D vectors
Mat cross(const Mat& m) const;
Mat cross(const InputArray& m) const;
//! computes dot-product
double dot(const Mat& m) const;
double dot(const InputArray& m) const;
//! Matlab-style matrix initialization
static MatExpr zeros(int rows, int cols, int type);
@@ -1809,7 +1890,7 @@ public:
MStep step;
};
/*!
Random Number Generator
@@ -1830,9 +1911,9 @@ public:
operator ushort();
operator short();
operator unsigned();
//! returns a random integer sampled uniformly from [0, N).
unsigned operator()(unsigned N);
unsigned operator ()();
//! returns a random integer sampled uniformly from [0, N).
unsigned operator()(unsigned N);
unsigned operator ()();
operator int();
operator float();
operator double();
@@ -1842,14 +1923,12 @@ public:
float uniform(float a, float b);
//! returns uniformly distributed double-precision floating-point random number from [a,b) range
double uniform(double a, double b);
void fill( Mat& mat, int distType, const Scalar& a, const Scalar& b );
//! returns Gaussian random variate with mean zero.
double gaussian(double sigma);
void fill( InputOutputArray mat, int distType, const InputArray& a, const InputArray& b );
//! returns Gaussian random variate with mean zero.
double gaussian(double sigma);
uint64 state;
};
/*!
@@ -1879,6 +1958,7 @@ public:
double epsilon; // the desired accuracy
};
//! swaps two matrices
CV_EXPORTS void swap(Mat& a, Mat& b);
@@ -1886,79 +1966,75 @@ CV_EXPORTS void swap(Mat& a, Mat& b);
CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false,
bool allowND=true, int coiMode=0);
//! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it.
CV_EXPORTS void extractImageCOI(const CvArr* arr, CV_OUT Mat& coiimg, int coi=-1);
CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1);
//! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage
CV_EXPORTS void insertImageCOI(const Mat& coiimg, CvArr* arr, int coi=-1);
CV_EXPORTS void insertImageCOI(const InputArray& coiimg, CvArr* arr, int coi=-1);
//! adds one matrix to another (dst = src1 + src2)
CV_EXPORTS_W void add(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, const Mat& mask CV_WRAP_DEFAULT(Mat()));
CV_EXPORTS_W void add(const InputArray& src1, const InputArray& src2, OutputArray dst,
const InputArray& mask=InputArray(), int dtype=-1);
//! subtracts one matrix from another (dst = src1 - src2)
CV_EXPORTS_W void subtract(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, const Mat& mask CV_WRAP_DEFAULT(Mat()));
//! adds one matrix to another (dst = src1 + src2)
CV_EXPORTS void add(const Mat& src1, const Mat& src2, CV_OUT Mat& dst);
//! subtracts one matrix from another (dst = src1 - src2)
CV_EXPORTS void subtract(const Mat& src1, const Mat& src2, CV_OUT Mat& dst);
//! adds scalar to a matrix (dst = src1 + src2)
CV_EXPORTS_W void add(const Mat& src1, const Scalar& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
//! subtracts scalar from a matrix (dst = src1 - src2)
CV_EXPORTS_W void subtract(const Mat& src1, const Scalar& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
//! subtracts matrix from scalar (dst = src1 - src2)
CV_EXPORTS_W void subtract(const Scalar& src1, const Mat& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
CV_EXPORTS_W void subtract(const InputArray& src1, const InputArray& src2, OutputArray dst,
const InputArray& mask=InputArray(), int dtype=-1);
//! computes element-wise weighted product of the two arrays (dst = scale*src1*src2)
CV_EXPORTS_W void multiply(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, double scale=1);
CV_EXPORTS_W void multiply(const InputArray& src1, const InputArray& src2,
OutputArray dst, double scale=1, int dtype=-1);
//! computes element-wise weighted quotient of the two arrays (dst = scale*src1/src2)
CV_EXPORTS_W void divide(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, double scale=1);
CV_EXPORTS_W void divide(const InputArray& src1, const InputArray& src2, OutputArray dst,
double scale=1, int dtype=-1);
//! computes element-wise weighted reciprocal of an array (dst = scale/src2)
CV_EXPORTS_W void divide(double scale, const Mat& src2, CV_OUT Mat& dst);
CV_EXPORTS_W void divide(double scale, const InputArray& src2,
OutputArray dst, int dtype=-1);
//! adds scaled array to another one (dst = alpha*src1 + src2)
CV_EXPORTS_W void scaleAdd(const Mat& src1, double alpha, const Mat& src2, CV_OUT Mat& dst);
CV_EXPORTS_W void scaleAdd(const InputArray& src1, double alpha, const InputArray& src2, OutputArray dst);
//! computes weighted sum of two arrays (dst = alpha*src1 + beta*src2 + gamma)
CV_EXPORTS_W void addWeighted(const Mat& src1, double alpha, const Mat& src2,
double beta, double gamma, CV_OUT Mat& dst);
CV_EXPORTS_W void addWeighted(const InputArray& src1, double alpha, const InputArray& src2,
double beta, double gamma, OutputArray dst, int dtype=-1);
//! scales array elements, computes absolute values and converts the results to 8-bit unsigned integers: dst(i)=saturate_cast<uchar>abs(src(i)*alpha+beta)
CV_EXPORTS_W void convertScaleAbs(const Mat& src, CV_OUT Mat& dst, double alpha=1, double beta=0);
//! transforms 8-bit unsigned integers using lookup table: dst(i)=lut(src(i))
CV_EXPORTS_W void LUT(const Mat& src, const Mat& lut, CV_OUT Mat& dst);
CV_EXPORTS_W void convertScaleAbs(const InputArray& src, OutputArray dst,
double alpha=1, double beta=0);
//! transforms array of numbers using a lookup table: dst(i)=lut(src(i))
CV_EXPORTS_W void LUT(const InputArray& src, const InputArray& lut, OutputArray dst,
int interpolation=0);
//! computes sum of array elements
CV_EXPORTS_W Scalar sum(const Mat& src);
CV_EXPORTS_W Scalar sum(const InputArray& src);
//! computes the number of nonzero array elements
CV_EXPORTS_W int countNonZero( const Mat& src );
//! computes mean value of array elements
CV_EXPORTS Scalar mean(const Mat& src);
CV_EXPORTS_W int countNonZero( const InputArray& src );
//! computes mean value of selected array elements
CV_EXPORTS_W Scalar mean(const Mat& src, const Mat& mask CV_WRAP_DEFAULT(Mat()));
CV_EXPORTS_W Scalar mean(const InputArray& src, const InputArray& mask=InputArray());
//! computes mean value and standard deviation of all or selected array elements
CV_EXPORTS_W void meanStdDev(const Mat& src, CV_OUT Scalar& mean, CV_OUT Scalar& stddev, const Mat& mask=Mat());
//! computes norm of array
CV_EXPORTS double norm(const Mat& src1, int normType=NORM_L2);
//! computes norm of the difference between two arrays
CV_EXPORTS double norm(const Mat& src1, const Mat& src2, int normType=NORM_L2);
CV_EXPORTS_W void meanStdDev(const InputArray& src, OutputArray mean, OutputArray stddev,
const InputArray& mask=InputArray());
//! computes norm of the selected array part
CV_EXPORTS_W double norm(const Mat& src1, int normType, const Mat& mask CV_WRAP_DEFAULT(Mat()));
CV_EXPORTS_W double norm(const InputArray& src1, int normType=NORM_L2, const InputArray& mask=InputArray());
//! computes norm of selected part of the difference between two arrays
CV_EXPORTS_W double norm(const Mat& src1, const Mat& src2,
int normType, const Mat& mask CV_WRAP_DEFAULT(Mat()));
CV_EXPORTS_W double norm(const InputArray& src1, const InputArray& src2,
int normType=NORM_L2, const InputArray& mask=InputArray());
//! scales and shifts array elements so that either the specified norm (alpha) or the minimum (alpha) and maximum (beta) array values get the specified values
CV_EXPORTS_W void normalize( const Mat& src, CV_OUT Mat& dst, double alpha=1, double beta=0,
int norm_type=NORM_L2, int rtype=-1, const Mat& mask=Mat());
CV_EXPORTS_W void normalize( const InputArray& src, OutputArray dst, double alpha=1, double beta=0,
int norm_type=NORM_L2, int dtype=-1, const InputArray& mask=InputArray());
//! finds global minimum and maximum array elements and returns their values and their locations
CV_EXPORTS_W void minMaxLoc(const Mat& src, CV_OUT double* minVal,
CV_OUT double* maxVal=0, CV_OUT Point* minLoc=0,
CV_OUT Point* maxLoc=0, const Mat& mask=Mat());
CV_EXPORTS void minMaxIdx(const Mat& src, double* minVal, double* maxVal,
int* minIdx=0, int* maxIdx=0, const Mat& mask=Mat());
CV_EXPORTS_W void minMaxLoc(const InputArray& src, CV_OUT double* minVal,
CV_OUT double* maxVal=0, CV_OUT Point* minLoc=0,
CV_OUT Point* maxLoc=0, const InputArray& mask=InputArray());
CV_EXPORTS void minMaxIdx(const InputArray& src, double* minVal, double* maxVal,
int* minIdx=0, int* maxIdx=0, const InputArray& mask=InputArray());
//! transforms 2D matrix to 1D row or column vector by taking sum, minimum, maximum or mean value over all the rows
CV_EXPORTS_W void reduce(const Mat& src, CV_OUT Mat& dst, int dim, int rtype, int dtype=-1);
CV_EXPORTS_W void reduce(const InputArray& src, OutputArray dst, int dim, int rtype, int dtype=-1);
//! makes multi-channel array out of several single-channel arrays
CV_EXPORTS void merge(const Mat* mv, size_t count, CV_OUT Mat& dst);
CV_EXPORTS void merge(const Mat* mv, size_t count, OutputArray dst);
//! makes multi-channel array out of several single-channel arrays
CV_EXPORTS_W void merge(const vector<Mat>& mv, Mat& dst);
CV_EXPORTS_W void merge(const vector<Mat>& mv, OutputArray dst);
//! copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS void split(const Mat& src, Mat* mvbegin);
@@ -1969,133 +2045,131 @@ CV_EXPORTS_W void split(const Mat& m, vector<Mat>& mv);
CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts,
const int* fromTo, size_t npairs);
CV_EXPORTS void mixChannels(const vector<Mat>& src, vector<Mat>& dst,
const int* fromTo, int npairs);
const int* fromTo, size_t npairs);
//! reverses the order of the rows, columns or both in a matrix
CV_EXPORTS_W void flip(const Mat& src, CV_OUT Mat& dst, int flipCode);
CV_EXPORTS_W void flip(const InputArray& src, OutputArray dst, int flipCode);
//! replicates the input matrix the specified number of times in the horizontal and/or vertical direction
CV_EXPORTS_W void repeat(const Mat& src, int ny, int nx, CV_OUT Mat& dst);
CV_EXPORTS_W void repeat(const InputArray& src, int ny, int nx, OutputArray dst);
CV_EXPORTS Mat repeat(const Mat& src, int ny, int nx);
CV_EXPORTS void hconcat(const Mat* src, size_t nsrc, Mat& dst);
CV_EXPORTS void hconcat(const Mat& src1, const Mat& src2, Mat& dst);
CV_EXPORTS_W void hconcat(const vector<Mat>& src, CV_OUT Mat& dst);
CV_EXPORTS void hconcat(const Mat* src, size_t nsrc, OutputArray dst);
CV_EXPORTS void hconcat(const InputArray& src1, const InputArray& src2, OutputArray dst);
CV_EXPORTS_W void hconcat(const InputArray& src, OutputArray dst);
CV_EXPORTS void vconcat(const Mat* src, size_t nsrc, Mat& dst);
CV_EXPORTS void vconcat(const Mat& src1, const Mat& src2, Mat& dst);
CV_EXPORTS_W void vconcat(const vector<Mat>& src, CV_OUT Mat& dst);
CV_EXPORTS void vconcat(const Mat* src, size_t nsrc, OutputArray dst);
CV_EXPORTS void vconcat(const InputArray& src1, const InputArray& src2, OutputArray dst);
CV_EXPORTS_W void vconcat(const InputArray& src, OutputArray dst);
//! computes bitwise conjunction of the two arrays (dst = src1 & src2)
CV_EXPORTS_W void bitwise_and(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
CV_EXPORTS_W void bitwise_and(const InputArray& src1, const InputArray& src2,
OutputArray dst, const InputArray& mask=InputArray());
//! computes bitwise disjunction of the two arrays (dst = src1 | src2)
CV_EXPORTS_W void bitwise_or(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
CV_EXPORTS_W void bitwise_or(const InputArray& src1, const InputArray& src2,
OutputArray dst, const InputArray& mask=InputArray());
//! computes bitwise exclusive-or of the two arrays (dst = src1 ^ src2)
CV_EXPORTS_W void bitwise_xor(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
//! computes bitwise conjunction of an array and scalar (dst = src1 & src2)
CV_EXPORTS_W void bitwise_and(const Mat& src1, const Scalar& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
//! computes bitwise disjunction of an array and scalar (dst = src1 | src2)
CV_EXPORTS_W void bitwise_or(const Mat& src1, const Scalar& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
//! computes bitwise exclusive-or of an array and scalar (dst = src1 ^ src2)
CV_EXPORTS_W void bitwise_xor(const Mat& src1, const Scalar& src2, CV_OUT Mat& dst, const Mat& mask=Mat());
CV_EXPORTS_W void bitwise_xor(const InputArray& src1, const InputArray& src2,
OutputArray dst, const InputArray& mask=InputArray());
//! inverts each bit of array (dst = ~src)
CV_EXPORTS_W void bitwise_not(const Mat& src, CV_OUT Mat& dst);
CV_EXPORTS_W void bitwise_not(const InputArray& src, OutputArray dst,
const InputArray& mask=InputArray());
//! computes element-wise absolute difference of two arrays (dst = abs(src1 - src2))
CV_EXPORTS_W void absdiff(const Mat& src1, const Mat& src2, CV_OUT Mat& dst);
//! computes element-wise absolute difference of array and scalar (dst = abs(src1 - src2))
CV_EXPORTS_W void absdiff(const Mat& src1, const Scalar& src2, CV_OUT Mat& dst);
CV_EXPORTS_W void absdiff(const InputArray& src1, const InputArray& src2, OutputArray dst);
//! set mask elements for those array elements which are within the element-specific bounding box (dst = lowerb <= src && src < upperb)
CV_EXPORTS_W void inRange(const Mat& src, const Mat& lowerb,
const Mat& upperb, CV_OUT Mat& dst);
//! set mask elements for those array elements which are within the fixed bounding box (dst = lowerb <= src && src < upperb)
CV_EXPORTS_W void inRange(const Mat& src, const Scalar& lowerb,
const Scalar& upperb, CV_OUT Mat& dst);
CV_EXPORTS_W void inRange(const InputArray& src, const InputArray& lowerb,
const InputArray& upperb, OutputArray dst);
//! compares elements of two arrays (dst = src1 <cmpop> src2)
CV_EXPORTS_W void compare(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, int cmpop);
//! compares elements of array with scalar (dst = src1 <cmpop> src2)
CV_EXPORTS_W void compare(const Mat& src1, double s, CV_OUT Mat& dst, int cmpop);
CV_EXPORTS_W void compare(const InputArray& src1, const InputArray& src2, OutputArray dst, int cmpop);
//! computes per-element minimum of two arrays (dst = min(src1, src2))
CV_EXPORTS_W void min(const Mat& src1, const Mat& src2, CV_OUT Mat& dst);
//! computes per-element minimum of array and scalar (dst = min(src1, src2))
CV_EXPORTS_W void min(const Mat& src1, double src2, CV_OUT Mat& dst);
CV_EXPORTS_W void min(const InputArray& src1, const InputArray& src2, OutputArray dst);
//! computes per-element maximum of two arrays (dst = max(src1, src2))
CV_EXPORTS_W void max(const Mat& src1, const Mat& src2, CV_OUT Mat& dst);
//! computes per-element maximum of array and scalar (dst = max(src1, src2))
CV_EXPORTS_W void max(const Mat& src1, double src2, CV_OUT Mat& dst);
CV_EXPORTS_W void max(const InputArray& src1, const InputArray& src2, OutputArray dst);
//! computes per-element minimum of two arrays (dst = min(src1, src2))
CV_EXPORTS void min(const Mat& src1, const Mat& src2, Mat& dst);
//! computes per-element minimum of array and scalar (dst = min(src1, src2))
CV_EXPORTS void min(const Mat& src1, double src2, Mat& dst);
//! computes per-element maximum of two arrays (dst = max(src1, src2))
CV_EXPORTS void max(const Mat& src1, const Mat& src2, Mat& dst);
//! computes per-element maximum of array and scalar (dst = max(src1, src2))
CV_EXPORTS void max(const Mat& src1, double src2, Mat& dst);
//! computes square root of each matrix element (dst = src**0.5)
CV_EXPORTS_W void sqrt(const Mat& src, CV_OUT Mat& dst);
CV_EXPORTS_W void sqrt(const InputArray& src, OutputArray dst);
//! raises the input matrix elements to the specified power (b = a**power)
CV_EXPORTS_W void pow(const Mat& src, double power, CV_OUT Mat& dst);
CV_EXPORTS_W void pow(const InputArray& src, double power, OutputArray dst);
//! computes exponent of each matrix element (dst = e**src)
CV_EXPORTS_W void exp(const Mat& src, CV_OUT Mat& dst);
CV_EXPORTS_W void exp(const InputArray& src, OutputArray dst);
//! computes natural logarithm of absolute value of each matrix element: dst = log(abs(src))
CV_EXPORTS_W void log(const Mat& src, CV_OUT Mat& dst);
CV_EXPORTS_W void log(const InputArray& src, OutputArray dst);
//! computes cube root of the argument
CV_EXPORTS_W float cubeRoot(float val);
//! computes the angle in degrees (0..360) of the vector (x,y)
CV_EXPORTS_W float fastAtan2(float y, float x);
//! converts polar coordinates to Cartesian
CV_EXPORTS_W void polarToCart(const Mat& magnitude, const Mat& angle,
CV_OUT Mat& x, CV_OUT Mat& y, bool angleInDegrees=false);
CV_EXPORTS_W void polarToCart(const InputArray& magnitude, const InputArray& angle,
OutputArray x, OutputArray y, bool angleInDegrees=false);
//! converts Cartesian coordinates to polar
CV_EXPORTS_W void cartToPolar(const Mat& x, const Mat& y,
CV_OUT Mat& magnitude, CV_OUT Mat& angle,
bool angleInDegrees=false);
CV_EXPORTS_W void cartToPolar(const InputArray& x, const InputArray& y,
OutputArray magnitude, OutputArray angle,
bool angleInDegrees=false);
//! computes angle (angle(i)) of each (x(i), y(i)) vector
CV_EXPORTS_W void phase(const Mat& x, const Mat& y, CV_OUT Mat& angle,
CV_EXPORTS_W void phase(const InputArray& x, const InputArray& y, OutputArray angle,
bool angleInDegrees=false);
//! computes magnitude (magnitude(i)) of each (x(i), y(i)) vector
CV_EXPORTS_W void magnitude(const Mat& x, const Mat& y, CV_OUT Mat& magnitude);
CV_EXPORTS_W void magnitude(const InputArray& x, const InputArray& y, OutputArray magnitude);
//! checks that each matrix element is within the specified range.
CV_EXPORTS_W bool checkRange(const Mat& a, bool quiet=true, CV_OUT Point* pt=0,
CV_EXPORTS_W bool checkRange(const InputArray& a, bool quiet=true, CV_OUT Point* pt=0,
double minVal=-DBL_MAX, double maxVal=DBL_MAX);
//! implements generalized matrix product algorithm GEMM from BLAS
CV_EXPORTS_W void gemm(const Mat& src1, const Mat& src2, double alpha,
const Mat& src3, double gamma, CV_OUT Mat& dst, int flags=0);
CV_EXPORTS_W void gemm(const InputArray& src1, const InputArray& src2, double alpha,
const InputArray& src3, double gamma, OutputArray dst, int flags=0);
//! multiplies matrix by its transposition from the left or from the right
CV_EXPORTS_W void mulTransposed( const Mat& src, CV_OUT Mat& dst, bool aTa,
const Mat& delta=Mat(),
double scale=1, int rtype=-1 );
CV_EXPORTS_W void mulTransposed( const InputArray& src, OutputArray dst, bool aTa,
const InputArray& delta=InputArray(),
double scale=1, int dtype=-1 );
//! transposes the matrix
CV_EXPORTS_W void transpose(const Mat& src, CV_OUT Mat& dst);
CV_EXPORTS_W void transpose(const InputArray& src, OutputArray dst);
//! performs affine transformation of each element of multi-channel input matrix
CV_EXPORTS_W void transform(const Mat& src, CV_OUT Mat& dst, const Mat& m );
CV_EXPORTS_W void transform(const InputArray& src, OutputArray dst, const InputArray& m );
//! performs perspective transformation of each element of multi-channel input matrix
CV_EXPORTS_W void perspectiveTransform(const Mat& src, CV_OUT Mat& dst, const Mat& m );
CV_EXPORTS_W void perspectiveTransform(const InputArray& src, OutputArray dst, const InputArray& m );
//! extends the symmetrical matrix from the lower half or from the upper half
CV_EXPORTS_W void completeSymm(Mat& mtx, bool lowerToUpper=false);
CV_EXPORTS_W void completeSymm(InputOutputArray mtx, bool lowerToUpper=false);
//! initializes scaled identity matrix
CV_EXPORTS_W void setIdentity(Mat& mtx, const Scalar& s=Scalar(1));
CV_EXPORTS_W void setIdentity(InputOutputArray mtx, const Scalar& s=Scalar(1));
//! computes determinant of a square matrix
CV_EXPORTS_W double determinant(const Mat& mtx);
CV_EXPORTS_W double determinant(const InputArray& mtx);
//! computes trace of a matrix
CV_EXPORTS_W Scalar trace(const Mat& mtx);
CV_EXPORTS_W Scalar trace(const InputArray& mtx);
//! computes inverse or pseudo-inverse matrix
CV_EXPORTS_W double invert(const Mat& src, CV_OUT Mat& dst, int flags=DECOMP_LU);
CV_EXPORTS_W double invert(const InputArray& src, OutputArray dst, int flags=DECOMP_LU);
//! solves linear system or a least-square problem
CV_EXPORTS_W bool solve(const Mat& src1, const Mat& src2, CV_OUT Mat& dst, int flags=DECOMP_LU);
CV_EXPORTS_W bool solve(const InputArray& src1, const InputArray& src2,
OutputArray dst, int flags=DECOMP_LU);
//! sorts independently each matrix row or each matrix column
CV_EXPORTS_W void sort(const Mat& src, CV_OUT Mat& dst, int flags);
CV_EXPORTS_W void sort(const InputArray& src, OutputArray dst, int flags);
//! sorts independently each matrix row or each matrix column
CV_EXPORTS_W void sortIdx(const Mat& src, CV_OUT Mat& dst, int flags);
CV_EXPORTS_W void sortIdx(const InputArray& src, OutputArray dst, int flags);
//! finds real roots of a cubic polynomial
CV_EXPORTS_W int solveCubic(const Mat& coeffs, CV_OUT Mat& roots);
CV_EXPORTS_W int solveCubic(const InputArray& coeffs, OutputArray roots);
//! finds real and complex roots of a polynomial
CV_EXPORTS_W double solvePoly(const Mat& coeffs, CV_OUT Mat& roots, int maxIters=300);
CV_EXPORTS_W double solvePoly(const InputArray& coeffs, OutputArray roots, int maxIters=300);
//! finds eigenvalues of a symmetric matrix
CV_EXPORTS bool eigen(const Mat& src, CV_OUT Mat& eigenvalues, int lowindex=-1,
CV_EXPORTS bool eigen(const InputArray& src, OutputArray eigenvalues, int lowindex=-1,
int highindex=-1);
//! finds eigenvalues and eigenvectors of a symmetric matrix
CV_EXPORTS bool eigen(const Mat& src, CV_OUT Mat& eigenvalues, CV_OUT Mat& eigenvectors,
CV_EXPORTS bool eigen(const InputArray& src, OutputArray eigenvalues,
OutputArray eigenvectors,
int lowindex=-1, int highindex=-1);
//! computes covariation matrix of a set of samples
CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean,
int flags, int ctype=CV_64F);
//! computes covariation matrix of a set of samples
CV_EXPORTS_W void calcCovarMatrix( const Mat& samples, CV_OUT Mat& covar, CV_OUT Mat& mean,
int flags, int ctype=CV_64F);
CV_EXPORTS_W void calcCovarMatrix( const InputArray& samples, OutputArray covar,
OutputArray mean, int flags, int ctype=CV_64F);
/*!
Principal Component Analysis
@@ -2157,17 +2231,17 @@ public:
//! default constructor
PCA();
//! the constructor that performs PCA
PCA(const Mat& data, const Mat& mean, int flags, int maxComponents=0);
PCA(const InputArray& data, const InputArray& mean, int flags, int maxComponents=0);
//! operator that performs PCA. The previously stored data, if any, is released
PCA& operator()(const Mat& data, const Mat& mean, int flags, int maxComponents=0);
PCA& operator()(const InputArray& data, const InputArray& mean, int flags, int maxComponents=0);
//! projects vector from the original space to the principal components subspace
Mat project(const Mat& vec) const;
Mat project(const InputArray& vec) const;
//! projects vector from the original space to the principal components subspace
void project(const Mat& vec, CV_OUT Mat& result) const;
void project(const InputArray& vec, OutputArray result) const;
//! reconstructs the original vector from the projection
Mat backProject(const Mat& vec) const;
Mat backProject(const InputArray& vec) const;
//! reconstructs the original vector from the projection
void backProject(const Mat& vec, CV_OUT Mat& result) const;
void backProject(const InputArray& vec, OutputArray result) const;
Mat eigenvectors; //!< eigenvectors of the covariation matrix
Mat eigenvalues; //!< eigenvalues of the covariation matrix
@@ -2194,17 +2268,19 @@ public:
//! the default constructor
SVD();
//! the constructor that performs SVD
SVD( const Mat& src, int flags=0 );
SVD( const InputArray& src, int flags=0 );
//! the operator that performs SVD. The previously allocated SVD::u, SVD::w are SVD::vt are released.
SVD& operator ()( const Mat& src, int flags=0 );
SVD& operator ()( const InputArray& src, int flags=0 );
//! decomposes matrix and stores the results to user-provided matrices
static void compute( const Mat& src, CV_OUT Mat& w, CV_OUT Mat& u, CV_OUT Mat& vt, int flags=0 );
static void compute( const InputArray& src, OutputArray w,
OutputArray u, OutputArray vt, int flags=0 );
//! computes singular values of a matrix
static void compute( const Mat& src, CV_OUT Mat& w, int flags=0 );
static void compute( const InputArray& src, OutputArray w, int flags=0 );
//! performs back substitution
static void backSubst( const Mat& w, const Mat& u, const Mat& vt,
const Mat& rhs, CV_OUT Mat& dst );
static void backSubst( const InputArray& w, const InputArray& u,
const InputArray& vt, const InputArray& rhs,
OutputArray dst );
template<typename _Tp, int m, int n, int nm> static void compute( const Matx<_Tp, m, n>& a,
Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt );
@@ -2214,29 +2290,29 @@ public:
const Matx<_Tp, m, nm>& u, const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs, Matx<_Tp, n, nb>& dst );
//! finds dst = arg min_{|dst|=1} |m*dst|
static void solveZ( const Mat& src, CV_OUT Mat& dst );
static void solveZ( const InputArray& src, OutputArray dst );
//! performs back substitution, so that dst is the solution or pseudo-solution of m*dst = rhs, where m is the decomposed matrix
void backSubst( const Mat& rhs, CV_OUT Mat& dst ) const;
void backSubst( const InputArray& rhs, OutputArray dst ) const;
Mat u, w, vt;
};
//! computes Mahalanobis distance between two vectors: sqrt((v1-v2)'*icovar*(v1-v2)), where icovar is the inverse covariation matrix
CV_EXPORTS_W double Mahalanobis(const Mat& v1, const Mat& v2, const Mat& icovar);
CV_EXPORTS_W double Mahalanobis(const InputArray& v1, const InputArray& v2, const InputArray& icovar);
//! a synonym for Mahalanobis
CV_EXPORTS double Mahalonobis(const Mat& v1, const Mat& v2, const Mat& icovar);
CV_EXPORTS double Mahalonobis(const InputArray& v1, const InputArray& v2, const InputArray& icovar);
//! performs forward or inverse 1D or 2D Discrete Fourier Transformation
CV_EXPORTS_W void dft(const Mat& src, CV_OUT Mat& dst, int flags=0, int nonzeroRows=0);
CV_EXPORTS_W void dft(const InputArray& src, OutputArray dst, int flags=0, int nonzeroRows=0);
//! performs inverse 1D or 2D Discrete Fourier Transformation
CV_EXPORTS_W void idft(const Mat& src, CV_OUT Mat& dst, int flags=0, int nonzeroRows=0);
CV_EXPORTS_W void idft(const InputArray& src, OutputArray dst, int flags=0, int nonzeroRows=0);
//! performs forward or inverse 1D or 2D Discrete Cosine Transformation
CV_EXPORTS_W void dct(const Mat& src, CV_OUT Mat& dst, int flags=0);
CV_EXPORTS_W void dct(const InputArray& src, OutputArray dst, int flags=0);
//! performs inverse 1D or 2D Discrete Cosine Transformation
CV_EXPORTS_W void idct(const Mat& src, CV_OUT Mat& dst, int flags=0);
CV_EXPORTS_W void idct(const InputArray& src, OutputArray dst, int flags=0);
//! computes element-wise product of the two Fourier spectrums. The second spectrum can optionally be conjugated before the multiplication
CV_EXPORTS_W void mulSpectrums(const Mat& a, const Mat& b, CV_OUT Mat& c,
int flags, bool conjB=false);
CV_EXPORTS_W void mulSpectrums(const InputArray& a, const InputArray& b, OutputArray c,
int flags, bool conjB=false);
//! computes the minimal vector size vecsize1 >= vecsize so that the dft() of the vector of length vecsize1 can be computed efficiently
CV_EXPORTS_W int getOptimalDFTSize(int vecsize);
@@ -2250,9 +2326,9 @@ enum
KMEANS_USE_INITIAL_LABELS=1 // Uses the user-provided labels for K-Means initialization
};
//! clusters the input data using k-Means algorithm
CV_EXPORTS_W double kmeans( const Mat& data, int K, CV_OUT Mat& bestLabels,
TermCriteria criteria, int attempts,
int flags, CV_OUT Mat* centers=0 );
CV_EXPORTS_W double kmeans( const InputArray& data, int K, CV_OUT InputOutputArray bestLabels,
TermCriteria criteria, int attempts,
int flags, OutputArray centers=OutputArray() );
//! returns the thread-local Random number generator
CV_EXPORTS RNG& theRNG();
@@ -2261,13 +2337,13 @@ CV_EXPORTS RNG& theRNG();
template<typename _Tp> static inline _Tp randu() { return (_Tp)theRNG(); }
//! fills array with uniformly-distributed random numbers from the range [low, high)
CV_EXPORTS_W void randu(CV_OUT Mat& dst, const Scalar& low, const Scalar& high);
CV_EXPORTS_W void randu(CV_IN_OUT OutputArray dst, const InputArray& low, const InputArray& high);
//! fills array with normally-distributed random numbers with the specified mean and the standard deviation
CV_EXPORTS_W void randn(CV_OUT Mat& dst, const Scalar& mean, const Scalar& stddev);
CV_EXPORTS_W void randn(CV_IN_OUT OutputArray dst, const InputArray& mean, const InputArray& stddev);
//! shuffles the input array elements
CV_EXPORTS void randShuffle(Mat& dst, double iterFactor=1., RNG* rng=0);
CV_EXPORTS void randShuffle(InputOutputArray dst, double iterFactor=1., RNG* rng=0);
//! draws the line segment (pt1, pt2) in the image
CV_EXPORTS_W void line(Mat& img, Point pt1, Point pt2, const Scalar& color,
@@ -2351,8 +2427,8 @@ public:
//! converts elliptic arc to a polygonal curve
CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle,
int arcStart, int arcEnd, int delta,
CV_OUT vector<Point>& pts );
int arcStart, int arcEnd, int delta,
CV_OUT vector<Point>& pts );
enum
{
@@ -2828,6 +2904,7 @@ template<typename _Tp, size_t fixed_size=4096/sizeof(_Tp)+8> class CV_EXPORTS Au
{
public:
typedef _Tp value_type;
enum { buffer_padding = (int)((16 + sizeof(_Tp) - 1)/sizeof(_Tp)) };
//! the default contructor
AutoBuffer();
@@ -2851,7 +2928,7 @@ protected:
//! size of the real buffer
size_t size;
//! pre-allocated buffer
_Tp buf[fixed_size];
_Tp buf[fixed_size+buffer_padding];
};
/////////////////////////// multi-dimensional dense matrix //////////////////////////
@@ -2912,9 +2989,11 @@ public:
//! the default constructor
NAryMatIterator();
//! the full constructor taking arbitrary number of n-dim matrices
NAryMatIterator(const Mat** arrays, uchar** ptrs, int narrays=-1);
//! the full constructor taking arbitrary number of n-dim matrices
NAryMatIterator(const Mat** arrays, Mat* planes, int narrays=-1);
//! the separate iterator initialization method
void init(const Mat** arrays, Mat* planes, int narrays=-1);
void init(const Mat** arrays, Mat* planes, uchar** ptrs, int narrays=-1);
//! proceeds to the next plane of every iterated matrix
NAryMatIterator& operator ++();
@@ -2925,12 +3004,17 @@ public:
const Mat** arrays;
//! the current planes
Mat* planes;
//! data pointers
uchar** ptrs;
//! the number of arrays
int narrays;
//! the number of planes in each array
int nplanes;
//! the number of hyper-planes that the iterator steps through
size_t nplanes;
//! the size of each segment (in elements)
size_t size;
protected:
int iterdepth, idx;
int iterdepth;
size_t idx;
};
//typedef NAryMatIterator NAryMatNDIterator;
@@ -3081,7 +3165,7 @@ public:
\param try1d if true and m is a single-column matrix (Nx1),
then the sparse matrix will be 1-dimensional.
*/
SparseMat(const Mat& m);
explicit SparseMat(const Mat& m);
//! converts old-style sparse matrix to the new-style. All the data is copied
SparseMat(const CvSparseMat* m);
//! the destructor
@@ -3563,39 +3647,30 @@ public:
//! the default constructor
CV_WRAP KDTree();
//! the full constructor that builds the search tree
CV_WRAP KDTree(const Mat& _points, bool copyAndReorderPoints=false);
CV_WRAP KDTree(const InputArray& points, bool copyAndReorderPoints=false);
//! the full constructor that builds the search tree
CV_WRAP KDTree(const Mat& _points, const Mat& _labels, bool copyAndReorderPoints=false);
CV_WRAP KDTree(const InputArray& points, const InputArray& _labels,
bool copyAndReorderPoints=false);
//! builds the search tree
CV_WRAP void build(const Mat& _points, bool copyAndReorderPoints=false);
CV_WRAP void build(const InputArray& points, bool copyAndReorderPoints=false);
//! builds the search tree
CV_WRAP void build(const Mat& _points, const Mat& _labels, bool copyAndReorderPoints=false);
CV_WRAP void build(const InputArray& points, const InputArray& labels,
bool copyAndReorderPoints=false);
//! finds the K nearest neighbors of "vec" while looking at Emax (at most) leaves
int findNearest(const float* vec,
int K, int Emax, int* neighborsIdx,
Mat* neighbors=0, float* dist=0, int* labels=0) const;
//! finds the K nearest neighbors while looking at Emax (at most) leaves
int findNearest(const float* vec, int K, int Emax,
vector<int>* neighborsIdx,
Mat* neighbors=0,
vector<float>* dist=0,
vector<int>* labels=0) const;
CV_WRAP int findNearest(const vector<float>& vec, int K, int Emax,
CV_OUT vector<int>* neighborsIdx,
CV_OUT Mat* neighbors=0,
CV_OUT vector<float>* dist=0,
CV_OUT vector<int>* labels=0) const;
CV_WRAP int findNearest(const InputArray& vec, int K, int Emax,
OutputArray neighborsIdx,
OutputArray neighbors=OutputArray(),
OutputArray dist=OutputArray(),
OutputArray labels=OutputArray()) const;
//! finds all the points from the initial set that belong to the specified box
void findOrthoRange(const float* minBounds, const float* maxBounds,
vector<int>* neighborsIdx, Mat* neighbors=0,
vector<int>* labels=0) const;
CV_WRAP void findOrthoRange(const vector<float>& minBounds, const vector<float>& maxBounds,
CV_OUT vector<int>* neighborsIdx, CV_OUT Mat* neighbors=0,
CV_OUT vector<int>* labels=0) const;
CV_WRAP void findOrthoRange(const InputArray& minBounds,
const InputArray& maxBounds,
OutputArray neighborsIdx,
OutputArray neighbors=OutputArray(),
OutputArray labels=OutputArray()) const;
//! returns vectors with the specified indices
void getPoints(const int* idx, size_t nidx, Mat& pts, vector<int>* labels=0) const;
//! returns vectors with the specified indices
CV_WRAP void getPoints(const vector<int>& idxs, Mat& pts, CV_OUT vector<int>* labels=0) const;
CV_WRAP void getPoints(const InputArray& idx, OutputArray pts,
OutputArray labels=OutputArray()) const;
//! return a vector with the specified index
const float* getPoint(int ptidx, int* label=0) const;
//! returns the search space dimensionality
@@ -4042,7 +4117,7 @@ public:
int index;
};
#if 0
class CV_EXPORTS AlgorithmImpl;
/*!
@@ -4088,7 +4163,6 @@ protected:
Ptr<AlgorithmImpl> impl;
};
#endif
}

View File

@@ -608,21 +608,6 @@ template<typename _Tp> inline MatIterator_<_Tp> Mat::end()
return it;
}
template<typename _Tp> inline void Mat::copyTo(vector<_Tp>& v) const
{
int n = checkVector(DataType<_Tp>::channels);
if( empty() || n == 0 )
{
v.clear();
return;
}
CV_Assert( n > 0 );
v.resize(n);
Mat temp(dims, size.p, DataType<_Tp>::type, &v[0]);
convertTo(temp, DataType<_Tp>::type);
}
template<typename _Tp> inline Mat::operator vector<_Tp>() const
{
vector<_Tp> v;
@@ -726,10 +711,12 @@ static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMod
///////////////////////////////////////////// SVD //////////////////////////////////////////////////////
inline SVD::SVD() {}
inline SVD::SVD( const Mat& m, int flags ) { operator ()(m, flags); }
inline void SVD::solveZ( const Mat& m, Mat& dst )
inline SVD::SVD( const InputArray& m, int flags ) { operator ()(m, flags); }
inline void SVD::solveZ( const InputArray& m, OutputArray _dst )
{
SVD svd(m);
_dst.create(svd.vt.cols, 1, svd.vt.type());
Mat dst = _dst.getMat();
svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst);
}
@@ -1075,6 +1062,22 @@ process( const Mat_<T1>& m1, const Mat_<T2>& m2, Mat_<T3>& m3, Op op )
}
}
/////////////////////////////// Input/Output Arrays /////////////////////////////////
template<typename _Tp> InputArray::InputArray(const vector<_Tp>& vec)
: flags(STD_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {}
template<typename _Tp> InputArray::InputArray(const vector<vector<_Tp> >& vec)
: flags(STD_VECTOR_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {}
template<typename _Tp, int m, int n> InputArray::InputArray(const Matx<_Tp, m, n>& mtx)
: flags(MATX + DataType<_Tp>::type), obj((void*)&mtx), sz(n, m) {}
template<typename _Tp> OutputArray::OutputArray(vector<_Tp>& vec) : InputArray(vec) {}
template<typename _Tp> OutputArray::OutputArray(vector<vector<_Tp> >& vec) : InputArray(vec) {}
template<typename _Tp, int m, int n> OutputArray::OutputArray(Matx<_Tp, m, n>& mtx) : InputArray(mtx) {}
//////////////////////////////////// Matrix Expressions /////////////////////////////////////////
class CV_EXPORTS MatOp
@@ -1113,6 +1116,9 @@ public:
virtual void transpose(const MatExpr& expr, MatExpr& res) const;
virtual void matmul(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const;
virtual void invert(const MatExpr& expr, int method, MatExpr& res) const;
virtual Size size(const MatExpr& expr) const;
virtual int type(const MatExpr& expr) const;
};
@@ -1152,6 +1158,9 @@ public:
MatExpr mul(const MatExpr& e, double scale=1) const;
MatExpr mul(const Mat& m, double scale=1) const;
Size size() const;
int type() const;
const MatOp* op;
int flags;

View File

@@ -2298,10 +2298,17 @@ inline Point LineIterator::pos() const
/////////////////////////////// AutoBuffer ////////////////////////////////////////
template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::AutoBuffer()
: ptr(buf), size(fixed_size) {}
{
ptr = alignPtr(buf, 16);
size = fixed_size;
}
template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::AutoBuffer(size_t _size)
: ptr(buf), size(fixed_size) { allocate(_size); }
{
ptr = alignPtr(buf, 16);
size = fixed_size;
allocate(_size);
}
template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::~AutoBuffer()
{ deallocate(); }
@@ -2320,10 +2327,11 @@ template<typename _Tp, size_t fixed_size> inline void AutoBuffer<_Tp, fixed_size
template<typename _Tp, size_t fixed_size> inline void AutoBuffer<_Tp, fixed_size>::deallocate()
{
if( ptr != buf )
_Tp* buf0 = alignPtr(buf, 16);
if( ptr != buf0 )
{
cv::deallocate<_Tp>(ptr, size);
ptr = buf;
ptr = buf0;
size = fixed_size;
}
}
@@ -3550,7 +3558,6 @@ template<typename _Tp> static inline std::ostream& operator << (std::ostream& ou
return out;
}
#if 0
template<typename _Tp> struct AlgorithmParamType {};
template<> struct AlgorithmParamType<int> { enum { type = CV_PARAM_TYPE_INT }; };
template<> struct AlgorithmParamType<double> { enum { type = CV_PARAM_TYPE_REAL }; };
@@ -3594,7 +3601,6 @@ template<typename _Tp> void Algorithm::setParamRange(int propId, const _Tp& minV
{
setParamRange_(propId, AlgorithmParamType<_Tp>::type, &minVal, &maxVal);
}
#endif
}