opencv on mbed
Mat_< _Tp > Class Template Reference
[Basic structures]
Template matrix class derived from Mat. More...
#include <mat.hpp>
Inherits cv::Mat.
Public Member Functions | |
Mat_ () | |
default constructor | |
Mat_ (int _rows, int _cols) | |
equivalent to Mat(_rows, _cols, DataType<_Tp>::type) | |
Mat_ (int _rows, int _cols, const _Tp &value) | |
constructor that sets each matrix element to specified value | |
Mat_ (Size _size) | |
equivalent to Mat(_size, DataType<_Tp>::type) | |
Mat_ (Size _size, const _Tp &value) | |
constructor that sets each matrix element to specified value | |
Mat_ (int _ndims, const int *_sizes) | |
n-dim array constructor | |
Mat_ (int _ndims, const int *_sizes, const _Tp &value) | |
n-dim array constructor that sets each matrix element to specified value | |
Mat_ (const Mat &m) | |
copy/conversion contructor. If m is of different type, it's converted | |
Mat_ (const Mat_ &m) | |
copy constructor | |
Mat_ (int _rows, int _cols, _Tp *_data, size_t _step=AUTO_STEP) | |
constructs a matrix on top of user-allocated data. step is in bytes(!!!), regardless of the type | |
Mat_ (int _ndims, const int *_sizes, _Tp *_data, const size_t *_steps=0) | |
constructs n-dim matrix on top of user-allocated data. steps are in bytes(!!!), regardless of the type | |
Mat_ (const Mat_ &m, const Range &rowRange, const Range &colRange=Range::all()) | |
selects a submatrix | |
Mat_ (const Mat_ &m, const Rect &roi) | |
selects a submatrix | |
Mat_ (const Mat_ &m, const Range *ranges) | |
selects a submatrix, n-dim version | |
Mat_ (const MatExpr &e) | |
from a matrix expression | |
Mat_ (const std::vector< _Tp > &vec, bool copyData=false) | |
makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column | |
Mat_ & | operator= (const Mat &m) |
assignment operators | |
Mat_ & | operator= (const _Tp &s) |
set all the elements to s. | |
Mat_ & | operator= (const MatExpr &e) |
assign a matrix expression | |
iterator | begin () |
iterators; they are smart enough to skip gaps in the end of rows | |
iterator | end () |
Returns the matrix iterator and sets it to the after-last matrix element. | |
template<typename Functor > | |
void | forEach (const Functor &operation) |
template methods for for operation over all matrix elements. | |
template<typename Functor > | |
void | forEach (const Functor &operation) const |
void | create (int _rows, int _cols) |
equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type) | |
void | create (Size _size) |
equivalent to Mat::create(_size, DataType<_Tp>::type) | |
void | create (int _ndims, const int *_sizes) |
equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type) | |
Mat_ | cross (const Mat_ &m) const |
cross-product | |
template<typename T2 > | |
operator Mat_< T2 > () const | |
data type conversion | |
Mat_ | row (int y) const |
overridden forms of Mat::row() etc. | |
Mat_ | col (int x) const |
Creates a matrix header for the specified matrix column. | |
Mat_ | diag (int d=0) const |
Extracts a diagonal from a matrix. | |
Mat_ | clone () const |
Creates a full copy of the array and the underlying data. | |
size_t | elemSize () const |
overridden forms of Mat::elemSize() etc. | |
size_t | elemSize1 () const |
Returns the size of each matrix element channel in bytes. | |
int | type () const |
Returns the type of a matrix element. | |
int | depth () const |
Returns the depth of a matrix element. | |
int | channels () const |
Returns the number of matrix channels. | |
size_t | step1 (int i=0) const |
Returns a normalized step. | |
size_t | stepT (int i=0) const |
returns step()/sizeof(_Tp) | |
Mat_ & | adjustROI (int dtop, int dbottom, int dleft, int dright) |
some more overriden methods | |
Mat_ | operator() (const Rect &roi) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Mat_ | operator() (const Range *ranges) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
_Tp * | operator[] (int y) |
more convenient forms of row and element access operators | |
_Tp & | operator() (const int *idx) |
returns reference to the specified element | |
const _Tp & | operator() (const int *idx) const |
returns read-only reference to the specified element | |
template<int n> | |
_Tp & | operator() (const Vec< int, n > &idx) |
returns reference to the specified element | |
template<int n> | |
const _Tp & | operator() (const Vec< int, n > &idx) const |
returns read-only reference to the specified element | |
_Tp & | operator() (int idx0) |
returns reference to the specified element (1D case) | |
const _Tp & | operator() (int idx0) const |
returns read-only reference to the specified element (1D case) | |
_Tp & | operator() (int idx0, int idx1) |
returns reference to the specified element (2D case) | |
const _Tp & | operator() (int idx0, int idx1) const |
returns read-only reference to the specified element (2D case) | |
_Tp & | operator() (int idx0, int idx1, int idx2) |
returns reference to the specified element (3D case) | |
const _Tp & | operator() (int idx0, int idx1, int idx2) const |
returns read-only reference to the specified element (3D case) | |
operator std::vector< _Tp > () const | |
conversion to vector. | |
template<int n> | |
operator Vec< typename DataType< _Tp >::channel_type, n > () const | |
conversion to Vec | |
template<int m, int n> | |
operator Matx< typename DataType< _Tp >::channel_type, m, n > () const | |
conversion to Matx | |
UMat | getUMat (int accessFlags, UMatUsageFlags usageFlags=USAGE_DEFAULT) const |
retrieve UMat from Mat | |
Mat | rowRange (int startrow, int endrow) const |
Creates a matrix header for the specified row span. | |
Mat | rowRange (const Range &r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Mat | colRange (int startcol, int endcol) const |
Creates a matrix header for the specified column span. | |
Mat | colRange (const Range &r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | copyTo (OutputArray m) const |
Copies the matrix to another one. | |
void | copyTo (OutputArray m, InputArray mask) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | convertTo (OutputArray m, int rtype, double alpha=1, double beta=0) const |
Converts an array to another data type with optional scaling. | |
void | assignTo (Mat &m, int type=-1) const |
Provides a functional form of convertTo. | |
Mat & | setTo (InputArray value, InputArray mask=noArray()) |
Sets all or some of the array elements to the specified value. | |
Mat | reshape (int cn, int rows=0) const |
Changes the shape and/or the number of channels of a 2D matrix without copying the data. | |
Mat | reshape (int cn, int newndims, const int *newsz) const |
MatExpr | t () const |
Transposes a matrix. | |
MatExpr | inv (int method=DECOMP_LU) const |
Inverses a matrix. | |
MatExpr | mul (InputArray m, double scale=1) const |
Performs an element-wise multiplication or division of the two matrices. | |
Mat | cross (InputArray m) const |
Computes a cross-product of two 3-element vectors. | |
double | dot (InputArray m) const |
Computes a dot-product of two vectors. | |
void | create (int rows, int cols, int type) |
Allocates new array data if needed. | |
void | create (Size size, int type) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | create (int ndims, const int *sizes, int type) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | addref () |
Increments the reference counter. | |
void | release () |
Decrements the reference counter and deallocates the matrix if needed. | |
void | deallocate () |
deallocates the matrix data | |
void | copySize (const Mat &m) |
internal use function; properly re-allocates _size, _step arrays | |
void | reserve (size_t sz) |
Reserves space for the certain number of rows. | |
void | resize (size_t sz) |
Changes the number of matrix rows. | |
void | resize (size_t sz, const Scalar &s) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | push_back_ (const void *elem) |
internal function | |
template<typename _Tp > | |
void | push_back (const _Tp &elem) |
Adds elements to the bottom of the matrix. | |
template<typename _Tp > | |
void | push_back (const Mat_< _Tp > &elem) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | push_back (const Mat &m) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | pop_back (size_t nelems=1) |
Removes elements from the bottom of the matrix. | |
void | locateROI (Size &wholeSize, Point &ofs) const |
Locates the matrix header within a parent matrix. | |
Mat | operator() (Range rowRange, Range colRange) const |
Extracts a rectangular submatrix. | |
bool | isContinuous () const |
Reports whether the matrix is continuous or not. | |
bool | isSubmatrix () const |
returns true if the matrix is a submatrix of another matrix | |
bool | empty () const |
Returns true if the array has no elements. | |
size_t | total () const |
Returns the total number of array elements. | |
int | checkVector (int elemChannels, int depth=-1, bool requireContinuous=true) const |
returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise | |
uchar * | ptr (int i0=0) |
Returns a pointer to the specified matrix row. | |
const uchar * | ptr (int i0=0) const |
uchar * | ptr (int i0, int i1) |
const uchar * | ptr (int i0, int i1) const |
uchar * | ptr (int i0, int i1, int i2) |
const uchar * | ptr (int i0, int i1, int i2) const |
uchar * | ptr (const int *idx) |
const uchar * | ptr (const int *idx) const |
template<int n> | |
uchar * | ptr (const Vec< int, n > &idx) |
template<int n> | |
const uchar * | ptr (const Vec< int, n > &idx) const |
template<typename _Tp > | |
_Tp * | ptr (int i0=0) |
template<typename _Tp > | |
const _Tp * | ptr (int i0=0) const |
template<typename _Tp > | |
_Tp * | ptr (int i0, int i1) |
template<typename _Tp > | |
const _Tp * | ptr (int i0, int i1) const |
template<typename _Tp > | |
_Tp * | ptr (int i0, int i1, int i2) |
template<typename _Tp > | |
const _Tp * | ptr (int i0, int i1, int i2) const |
template<typename _Tp > | |
_Tp * | ptr (const int *idx) |
template<typename _Tp > | |
const _Tp * | ptr (const int *idx) const |
template<typename _Tp , int n> | |
_Tp * | ptr (const Vec< int, n > &idx) |
template<typename _Tp , int n> | |
const _Tp * | ptr (const Vec< int, n > &idx) const |
template<typename _Tp > | |
_Tp & | at (int i0=0) |
Returns a reference to the specified array element. | |
template<typename _Tp > | |
const _Tp & | at (int i0=0) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename _Tp > | |
_Tp & | at (int i0, int i1) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename _Tp > | |
const _Tp & | at (int i0, int i1) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename _Tp > | |
_Tp & | at (int i0, int i1, int i2) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename _Tp > | |
const _Tp & | at (int i0, int i1, int i2) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename _Tp > | |
_Tp & | at (const int *idx) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename _Tp > | |
const _Tp & | at (const int *idx) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename _Tp , int n> | |
_Tp & | at (const Vec< int, n > &idx) |
template<typename _Tp , int n> | |
const _Tp & | at (const Vec< int, n > &idx) const |
template<typename _Tp > | |
_Tp & | at (Point pt) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. special versions for 2D arrays (especially convenient for referencing image pixels) | |
template<typename _Tp > | |
const _Tp & | at (Point pt) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. special versions for 2D arrays (especially convenient for referencing image pixels) | |
Static Public Member Functions | |
static MatExpr | zeros (int rows, int cols) |
overridden forms of Mat::zeros() etc. Data type is omitted, of course | |
static Mat | diag (const Mat &d) |
creates a diagonal matrix | |
static MatExpr | zeros (int rows, int cols, int type) |
Returns a zero array of the specified size and type. | |
static MatExpr | zeros (Size size, int type) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
static MatExpr | zeros (int ndims, const int *sz, int type) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
static MatExpr | ones (int rows, int cols, int type) |
Returns an array of all 1's of the specified size and type. | |
static MatExpr | ones (Size size, int type) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
static MatExpr | ones (int ndims, const int *sz, int type) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
static MatExpr | eye (int rows, int cols, int type) |
Returns an identity matrix of the specified size and type. | |
static MatExpr | eye (Size size, int type) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
static MatAllocator * | getStdAllocator () |
and the standard allocator | |
Data Fields | |
int | flags |
int | dims |
the matrix dimensionality, >= 2 | |
int | rows |
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions | |
uchar * | data |
pointer to the data | |
const uchar * | datastart |
helper fields used in locateROI and adjustROI | |
MatAllocator * | allocator |
custom allocator | |
UMatData * | u |
interaction with UMat | |
Protected Member Functions | |
template<typename _Tp , typename Functor > | |
void | forEach_impl (const Functor &operation) |
Detailed Description
template<typename _Tp>
class cv::Mat_< _Tp >
Template matrix class derived from Mat.
template<typename _Tp> class Mat_ : public Mat { public: // ... some specific methods // and // no new extra fields };
The class `Mat_<_Tp>` is a *thin* template wrapper on top of the Mat class. It does not have any extra data fields. Nor this class nor Mat has any virtual methods. Thus, references or pointers to these two classes can be freely but carefully converted one to another. For example:
// create a 100x100 8-bit matrix Mat M(100,100,CV_8U); // this will be compiled fine. no any data conversion will be done. Mat_<float>& M1 = (Mat_<float>&)M; // the program is likely to crash at the statement below M1(99,99) = 1.f;
While Mat is sufficient in most cases, Mat_ can be more convenient if you use a lot of element access operations and if you know matrix type at the compilation time. Note that `Matat(int y,int x)` and `Mat_operator()(int y,int x)` do absolutely the same and run at the same speed, but the latter is certainly shorter:
Mat_<double> M(20,20); for(int i = 0; i < M.rows; i++) for(int j = 0; j < M.cols; j++) M(i,j) = 1./(i+j+1); Mat E, V; eigen(M,E,V); cout << E.at<double>(0,0)/E.at<double>(M.rows-1,0);
To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter:
// allocate a 320x240 color image and fill it with green (in RGB space) Mat_<Vec3b> img(240, 320, Vec3b(0,255,0)); // now draw a diagonal white line for(int i = 0; i < 100; i++) img(i,i)=Vec3b(255,255,255); // and now scramble the 2nd (red) channel of each pixel for(int i = 0; i < img.rows; i++) for(int j = 0; j < img.cols; j++) img(i,j)[2] ^= (uchar)(i ^ j);
Definition at line 1962 of file mat.hpp.
Constructor & Destructor Documentation
Mat_ | ( | ) |
default constructor
Mat_ | ( | int | _rows, |
int | _cols | ||
) |
equivalent to Mat(_rows, _cols, DataType<_Tp>::type)
Mat_ | ( | int | _rows, |
int | _cols, | ||
const _Tp & | value | ||
) |
constructor that sets each matrix element to specified value
Mat_ | ( | int | _ndims, |
const int * | _sizes | ||
) |
n-dim array constructor
Mat_ | ( | int | _ndims, |
const int * | _sizes, | ||
const _Tp & | value | ||
) |
n-dim array constructor that sets each matrix element to specified value
Mat_ | ( | int | _rows, |
int | _cols, | ||
_Tp * | _data, | ||
size_t | _step = AUTO_STEP |
||
) |
constructs a matrix on top of user-allocated data. step is in bytes(!!!), regardless of the type
Mat_ | ( | int | _ndims, |
const int * | _sizes, | ||
_Tp * | _data, | ||
const size_t * | _steps = 0 |
||
) |
constructs n-dim matrix on top of user-allocated data. steps are in bytes(!!!), regardless of the type
selects a submatrix
Mat_ | ( | const std::vector< _Tp > & | vec, |
bool | copyData = false |
||
) | [explicit] |
Member Function Documentation
void addref | ( | ) | [inherited] |
Increments the reference counter.
The method increments the reference counter associated with the matrix data. If the matrix header points to an external data set (see Mat::Mat ), the reference counter is NULL, and the method has no effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It is called implicitly by the matrix assignment operator. The reference counter increment is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
Mat_& adjustROI | ( | int | dtop, |
int | dbottom, | ||
int | dleft, | ||
int | dright | ||
) |
some more overriden methods
Reimplemented from Mat.
void assignTo | ( | Mat & | m, |
int | type = -1 |
||
) | const [inherited] |
Provides a functional form of convertTo.
This is an internally used method called by the MatrixExpressions engine.
- Parameters:
-
m Destination array. type Desired destination array depth (or -1 if it should be the same as the source type).
_Tp& at | ( | int | i0 = 0 ) |
[inherited] |
Returns a reference to the specified array element.
The template methods return a reference to the specified array element. For the sake of higher performance, the index range checks are only performed in the Debug configuration.
Note that the variants with a single index (i) can be used to access elements of single-row or single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and B is an M x 1 integer matrix, you can simply write `A.at<float>(k+4)` and `B.at<int>(2*i+1)` instead of `A.at<float>(0,k+4)` and `B.at<int>(2*i+1,0)`, respectively.
The example below initializes a Hilbert matrix:
Mat H(100, 100, CV_64F); for(int i = 0; i < H.rows; i++) for(int j = 0; j < H.cols; j++) H.at<double>(i,j)=1./(i+j+1);
- Parameters:
-
i0 Index along the dimension 0
const _Tp& at | ( | int | i0 = 0 ) |
const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
i0 Index along the dimension 0
const _Tp& at | ( | Point | pt ) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. special versions for 2D arrays (especially convenient for referencing image pixels)
- Parameters:
-
pt Element position specified as Point(j,i) .
_Tp& at | ( | int | i0, |
int | i1 | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
i0 Index along the dimension 0 i1 Index along the dimension 1
const _Tp& at | ( | int | i0, |
int | i1 | ||
) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
i0 Index along the dimension 0 i1 Index along the dimension 1
_Tp& at | ( | int | i0, |
int | i1, | ||
int | i2 | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
i0 Index along the dimension 0 i1 Index along the dimension 1 i2 Index along the dimension 2
const _Tp& at | ( | int | i0, |
int | i1, | ||
int | i2 | ||
) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
i0 Index along the dimension 0 i1 Index along the dimension 1 i2 Index along the dimension 2
_Tp& at | ( | const int * | idx ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
idx Array of Mat::dims indices.
const _Tp& at | ( | const int * | idx ) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
idx Array of Mat::dims indices.
_Tp& at | ( | const Vec< int, n > & | idx ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const _Tp& at | ( | const Vec< int, n > & | idx ) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
_Tp& at | ( | Point | pt ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. special versions for 2D arrays (especially convenient for referencing image pixels)
- Parameters:
-
pt Element position specified as Point(j,i) .
iterator begin | ( | ) |
iterators; they are smart enough to skip gaps in the end of rows
Reimplemented from Mat.
int channels | ( | ) | const |
Returns the number of matrix channels.
The method returns the number of matrix channels.
Reimplemented from Mat.
int checkVector | ( | int | elemChannels, |
int | depth = -1 , |
||
bool | requireContinuous = true |
||
) | const [inherited] |
returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise
Mat_ clone | ( | ) | const |
Mat_ col | ( | int | x ) | const |
Creates a matrix header for the specified matrix column.
The method makes a new header for the specified matrix column and returns it. This is an O(1) operation, regardless of the matrix size. The underlying data of the new matrix is shared with the original matrix. See also the Mat::row description.
- Parameters:
-
x A 0-based column index.
Reimplemented from Mat.
Mat colRange | ( | int | startcol, |
int | endcol | ||
) | const [inherited] |
Creates a matrix header for the specified column span.
The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and Mat::col , this is an O(1) operation.
- Parameters:
-
startcol An inclusive 0-based start index of the column span. endcol An exclusive 0-based ending index of the column span.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
r Range structure containing both the start and the end indices.
void convertTo | ( | OutputArray | m, |
int | rtype, | ||
double | alpha = 1 , |
||
double | beta = 0 |
||
) | const [inherited] |
Converts an array to another data type with optional scaling.
The method converts source pixel values to the target data type. saturate_cast<> is applied at the end to avoid possible overflows:
- Parameters:
-
m output matrix; if it does not have a proper size or type before the operation, it is reallocated. rtype desired output matrix type or, rather, the depth since the number of channels are the same as the input has; if rtype is negative, the output matrix will have the same type as the input. alpha optional scale factor. beta optional delta added to the scaled values.
void copySize | ( | const Mat & | m ) | [inherited] |
internal use function; properly re-allocates _size, _step arrays
void copyTo | ( | OutputArray | m, |
InputArray | mask | ||
) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
m Destination matrix. If it does not have a proper size or type before the operation, it is reallocated. mask Operation mask. Its non-zero elements indicate which matrix elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.
void copyTo | ( | OutputArray | m ) | const [inherited] |
Copies the matrix to another one.
The method copies the matrix data to another matrix. Before copying the data, the method invokes :
m.create(this->size(), this->type());
so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the function does not handle the case of a partial overlap between the source and the destination matrices.
When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data.
- Parameters:
-
m Destination matrix. If it does not have a proper size or type before the operation, it is reallocated.
void create | ( | int | _rows, |
int | _cols | ||
) |
equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type)
void create | ( | int | rows, |
int | cols, | ||
int | type | ||
) | [inherited] |
Allocates new array data if needed.
This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays call this method for each output array. The method uses the following algorithm:
- If the current array shape and the type match the new ones, return immediately. Otherwise, de-reference the previous data by calling Mat::release.
- Initialize the new header.
- Allocate the new data of total()\*elemSize() bytes.
- Allocate the new, associated with the data, reference counter and set it to 1.
Such a scheme makes the memory management robust and efficient at the same time and helps avoid extra typing for you. This means that usually there is no need to explicitly allocate output arrays. That is, instead of writing:
Mat color; ... Mat gray(color.rows, color.cols, color.depth()); cvtColor(color, gray, COLOR_BGR2GRAY);
you can simply write:
Mat color; ... Mat gray; cvtColor(color, gray, COLOR_BGR2GRAY);
because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array internally.
- Parameters:
-
rows New number of rows. cols New number of columns. type New matrix type.
void create | ( | Size | size, |
int | type | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
size Alternative new matrix size specification: Size(cols, rows) type New matrix type.
void create | ( | int | ndims, |
const int * | sizes, | ||
int | type | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
ndims New array dimensionality. sizes Array of integers specifying a new array shape. type New matrix type.
void create | ( | Size | _size ) |
equivalent to Mat::create(_size, DataType<_Tp>::type)
void create | ( | int | _ndims, |
const int * | _sizes | ||
) |
equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type)
Mat cross | ( | InputArray | m ) | const [inherited] |
Computes a cross-product of two 3-element vectors.
The method computes a cross-product of two 3-element vectors. The vectors must be 3-element floating-point vectors of the same shape and size. The result is another 3-element vector of the same shape and type as operands.
- Parameters:
-
m Another cross-product operand.
void deallocate | ( | ) | [inherited] |
deallocates the matrix data
int depth | ( | ) | const |
Returns the depth of a matrix element.
The method returns the identifier of the matrix element depth (the type of each individual channel). For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of matrix types contains the following values:
- CV_8U - 8-bit unsigned integers ( 0..255 )
- CV_8S - 8-bit signed integers ( -128..127 )
- CV_16U - 16-bit unsigned integers ( 0..65535 )
- CV_16S - 16-bit signed integers ( -32768..32767 )
- CV_32S - 32-bit signed integers ( -2147483648..2147483647 )
- CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN )
- CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN )
Reimplemented from Mat.
Mat_ diag | ( | int | d = 0 ) |
const |
Extracts a diagonal from a matrix.
The method makes a new header for the specified matrix diagonal. The new matrix is represented as a single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation.
- Parameters:
-
d index of the diagonal, with the following values: - `d=0` is the main diagonal.
- `d>0` is a diagonal from the lower half. For example, d=1 means the diagonal is set immediately below the main one.
- `d<0` is a diagonal from the upper half. For example, d=-1 means the diagonal is set immediately above the main one.
Reimplemented from Mat.
double dot | ( | InputArray | m ) | const [inherited] |
Computes a dot-product of two vectors.
The method computes a dot-product of two matrices. If the matrices are not single-column or single-row vectors, the top-to-bottom left-to-right scan ordering is used to treat them as 1D vectors. The vectors must have the same size and type. If the matrices have more than one channel, the dot products from all the channels are summed together.
- Parameters:
-
m another dot-product operand.
size_t elemSize | ( | ) | const |
overridden forms of Mat::elemSize() etc.
Reimplemented from Mat.
size_t elemSize1 | ( | ) | const |
Returns the size of each matrix element channel in bytes.
The method returns the matrix element channel size in bytes, that is, it ignores the number of channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2.
Reimplemented from Mat.
bool empty | ( | ) | const [inherited] |
Returns true if the array has no elements.
The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and resize() methods `M.total() == 0` does not imply that `M.data == NULL`.
iterator end | ( | ) |
Returns the matrix iterator and sets it to the after-last matrix element.
The methods return the matrix read-only or read-write iterators, set to the point following the last matrix element.
Reimplemented from Mat.
static MatExpr eye | ( | int | rows, |
int | cols, | ||
int | type | ||
) | [static, inherited] |
Returns an identity matrix of the specified size and type.
The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently:
- Parameters:
-
rows Number of rows. cols Number of columns. type Created matrix type.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
size Alternative matrix size specification as Size(cols, rows) . type Created matrix type.
void forEach | ( | const Functor & | operation ) |
template methods for for operation over all matrix elements.
Reimplemented from Mat.
void forEach | ( | const Functor & | operation ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Reimplemented from Mat.
static MatAllocator* getStdAllocator | ( | ) | [static, inherited] |
and the standard allocator
UMat getUMat | ( | int | accessFlags, |
UMatUsageFlags | usageFlags = USAGE_DEFAULT |
||
) | const [inherited] |
MatExpr inv | ( | int | method = DECOMP_LU ) |
const [inherited] |
Inverses a matrix.
The method performs a matrix inversion by means of matrix expressions. This means that a temporary matrix inversion object is returned by the method and can be used further as a part of more complex matrix expressions or can be assigned to a matrix.
- Parameters:
-
method Matrix inversion method. One of cv::DecompTypes
bool isContinuous | ( | ) | const [inherited] |
Reports whether the matrix is continuous or not.
The method returns true if the matrix elements are stored continuously without gaps at the end of each row. Otherwise, it returns false. Obviously, 1x1 or 1xN matrices are always continuous. Matrices created with Mat::create are always continuous. But if you extract a part of the matrix using Mat::col, Mat::diag, and so on, or constructed a matrix header for externally allocated data, such matrices may no longer have this property.
The continuity flag is stored as a bit in the Mat::flags field and is computed automatically when you construct a matrix header. Thus, the continuity check is a very fast operation, though theoretically it could be done as follows:
// alternative implementation of Mat::isContinuous() bool myCheckMatContinuity(const Mat& m) { //return (m.flags & Mat::CONTINUOUS_FLAG) != 0; return m.rows == 1 || m.step == m.cols*m.elemSize(); }
The method is used in quite a few of OpenCV functions. The point is that element-wise operations (such as arithmetic and logical operations, math functions, alpha blending, color space transformations, and others) do not depend on the image geometry. Thus, if all the input and output arrays are continuous, the functions can process them as very long single-row vectors. The example below illustrates how an alpha-blending function can be implemented:
template<typename T> void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst) { const float alpha_scale = (float)std::numeric_limits<T>::max(), inv_scale = 1.f/alpha_scale; CV_Assert( src1.type() == src2.type() && src1.type() == CV_MAKETYPE(DataType<T>::depth, 4) && src1.size() == src2.size()); Size size = src1.size(); dst.create(size, src1.type()); // here is the idiom: check the arrays for continuity and, // if this is the case, // treat the arrays as 1D vectors if( src1.isContinuous() && src2.isContinuous() && dst.isContinuous() ) { size.width *= size.height; size.height = 1; } size.width *= 4; for( int i = 0; i < size.height; i++ ) { // when the arrays are continuous, // the outer loop is executed only once const T* ptr1 = src1.ptr<T>(i); const T* ptr2 = src2.ptr<T>(i); T* dptr = dst.ptr<T>(i); for( int j = 0; j < size.width; j += 4 ) { float alpha = ptr1[j+3]*inv_scale, beta = ptr2[j+3]*inv_scale; dptr[j] = saturate_cast<T>(ptr1[j]*alpha + ptr2[j]*beta); dptr[j+1] = saturate_cast<T>(ptr1[j+1]*alpha + ptr2[j+1]*beta); dptr[j+2] = saturate_cast<T>(ptr1[j+2]*alpha + ptr2[j+2]*beta); dptr[j+3] = saturate_cast<T>((1 - (1-alpha)*(1-beta))*alpha_scale); } } }
This approach, while being very simple, can boost the performance of a simple element-operation by 10-20 percents, especially if the image is rather small and the operation is quite simple.
Another OpenCV idiom in this function, a call of Mat::create for the destination array, that allocates the destination array unless it already has the proper size and type. And while the newly allocated arrays are always continuous, you still need to check the destination array because Mat::create does not always allocate a new matrix.
bool isSubmatrix | ( | ) | const [inherited] |
returns true if the matrix is a submatrix of another matrix
Locates the matrix header within a parent matrix.
After you extracted a submatrix from a matrix using Mat::row, Mat::col, Mat::rowRange, Mat::colRange, and others, the resultant submatrix points just to the part of the original big matrix. However, each submatrix contains information (represented by datastart and dataend fields) that helps reconstruct the original matrix size and the position of the extracted submatrix within the original matrix. The method locateROI does exactly that.
- Parameters:
-
wholeSize Output parameter that contains the size of the whole matrix containing *this* as a part. ofs Output parameter that contains an offset of *this* inside the whole matrix.
MatExpr mul | ( | InputArray | m, |
double | scale = 1 |
||
) | const [inherited] |
Performs an element-wise multiplication or division of the two matrices.
The method returns a temporary object encoding per-element array multiplication, with optional scale. Note that this is not a matrix multiplication that corresponds to a simpler "\*" operator.
Example:
Mat C = A.mul(5/B); // equivalent to divide(A, B, C, 5)
- Parameters:
-
m Another array of the same type and the same size as \*this, or a matrix expression. scale Optional scale factor.
static MatExpr ones | ( | int | rows, |
int | cols, | ||
int | type | ||
) | [static, inherited] |
Returns an array of all 1's of the specified size and type.
The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using this method you can initialize an array with an arbitrary value, using the following Matlab idiom:
The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it just remembers the scale factor (3 in this case) and use it when actually invoking the matrix initializer.
- Parameters:
-
rows Number of rows. cols Number of columns. type Created matrix type.
static MatExpr ones | ( | int | ndims, |
const int * | sz, | ||
int | type | ||
) | [static, inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
ndims Array dimensionality. sz Array of integers specifying the array shape. type Created matrix type.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
size Alternative to the matrix size specification Size(cols, rows) . type Created matrix type.
operator Mat_< T2 > | ( | ) | const |
data type conversion
operator std::vector< _Tp > | ( | ) | const |
conversion to vector.
Reimplemented from Mat.
Extracts a rectangular submatrix.
The operators make a new header for the specified sub-array of \*this . They are the most generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, the operators are O(1) operations, that is, no matrix data is copied.
- Parameters:
-
rowRange Start and end row of the extracted submatrix. The upper boundary is not included. To select all the rows, use Range::all(). colRange Start and end column of the extracted submatrix. The upper boundary is not included. To select all the columns, use Range::all().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
roi Extracted submatrix specified as a rectangle.
Reimplemented from Mat.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
ranges Array of selected ranges along each array dimension.
Reimplemented from Mat.
_Tp& operator() | ( | const int * | idx ) |
returns reference to the specified element
const _Tp& operator() | ( | const int * | idx ) | const |
returns read-only reference to the specified element
_Tp& operator() | ( | const Vec< int, n > & | idx ) |
returns reference to the specified element
const _Tp& operator() | ( | const Vec< int, n > & | idx ) | const |
returns read-only reference to the specified element
_Tp& operator() | ( | int | idx0 ) |
returns reference to the specified element (1D case)
const _Tp& operator() | ( | int | idx0 ) | const |
returns read-only reference to the specified element (1D case)
_Tp& operator() | ( | int | idx0, |
int | idx1 | ||
) |
returns reference to the specified element (2D case)
const _Tp& operator() | ( | int | idx0, |
int | idx1 | ||
) | const |
returns read-only reference to the specified element (2D case)
_Tp& operator() | ( | int | idx0, |
int | idx1, | ||
int | idx2 | ||
) |
returns reference to the specified element (3D case)
const _Tp& operator() | ( | int | idx0, |
int | idx1, | ||
int | idx2 | ||
) | const |
returns read-only reference to the specified element (3D case)
assignment operators
These are available assignment operators. Since they all are very different, make sure to read the operator parameters description.
- Parameters:
-
m Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that no data is copied but the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is de-referenced via Mat::release .
Reimplemented from Mat.
Mat_& operator= | ( | const _Tp & | s ) |
set all the elements to s.
_Tp* operator[] | ( | int | y ) |
more convenient forms of row and element access operators
void pop_back | ( | size_t | nelems = 1 ) |
[inherited] |
Removes elements from the bottom of the matrix.
The method removes one or more rows from the bottom of the matrix.
- Parameters:
-
nelems Number of removed rows. If it is greater than the total number of rows, an exception is thrown.
_Tp* ptr | ( | const int * | idx ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const _Tp* ptr | ( | const int * | idx ) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const uchar* ptr | ( | int | i0, |
int | i1 | ||
) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
uchar* ptr | ( | int | i0, |
int | i1, | ||
int | i2 | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const _Tp* ptr | ( | const Vec< int, n > & | idx ) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
uchar* ptr | ( | const int * | idx ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
_Tp* ptr | ( | const Vec< int, n > & | idx ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
_Tp* ptr | ( | int | i0, |
int | i1, | ||
int | i2 | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const uchar* ptr | ( | const int * | idx ) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const uchar* ptr | ( | int | i0 = 0 ) |
const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
_Tp* ptr | ( | int | i0 = 0 ) |
[inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const _Tp* ptr | ( | int | i0, |
int | i1 | ||
) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const _Tp* ptr | ( | int | i0 = 0 ) |
const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const uchar* ptr | ( | int | i0, |
int | i1, | ||
int | i2 | ||
) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
uchar* ptr | ( | int | i0 = 0 ) |
[inherited] |
Returns a pointer to the specified matrix row.
The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in Mat::isContinuous to know how to use these methods.
- Parameters:
-
i0 A 0-based row index.
uchar* ptr | ( | const Vec< int, n > & | idx ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const _Tp* ptr | ( | int | i0, |
int | i1, | ||
int | i2 | ||
) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
uchar* ptr | ( | int | i0, |
int | i1 | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const uchar* ptr | ( | const Vec< int, n > & | idx ) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
_Tp* ptr | ( | int | i0, |
int | i1 | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void push_back | ( | const Mat_< _Tp > & | elem ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
elem Added element(s).
void push_back | ( | const Mat & | m ) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
m Added line(s).
void push_back | ( | const _Tp & | elem ) | [inherited] |
Adds elements to the bottom of the matrix.
The methods add one or more elements to the bottom of the matrix. They emulate the corresponding method of the STL vector class. When elem is Mat , its type and the number of columns must be the same as in the container matrix.
- Parameters:
-
elem Added element(s).
void push_back_ | ( | const void * | elem ) | [inherited] |
internal function
void release | ( | ) | [inherited] |
Decrements the reference counter and deallocates the matrix if needed.
The method decrements the reference counter associated with the matrix data. When the reference counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers are set to NULL's. If the matrix header points to an external data set (see Mat::Mat ), the reference counter is NULL, and the method has no effect in this case.
This method can be called manually to force the matrix data deallocation. But since this method is automatically called in the destructor, or by any other method that changes the data pointer, it is usually not needed. The reference counter decrement and check for 0 is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
void reserve | ( | size_t | sz ) | [inherited] |
Reserves space for the certain number of rows.
The method reserves space for sz rows. If the matrix already has enough space to store sz rows, nothing happens. If the matrix is reallocated, the first Mat::rows rows are preserved. The method emulates the corresponding method of the STL vector class.
- Parameters:
-
sz Number of rows.
Mat reshape | ( | int | cn, |
int | rows = 0 |
||
) | const [inherited] |
Changes the shape and/or the number of channels of a 2D matrix without copying the data.
The method makes a new matrix header for \*this elements. The new matrix may have a different size and/or different number of channels. Any combination is possible if:
- No extra elements are included into the new matrix and no elements are excluded. Consequently, the product rows\*cols\*channels() must stay the same after the transformation.
- No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of rows, or the operation changes the indices of elements row in some other way, the matrix must be continuous. See Mat::isContinuous .
For example, if there is a set of 3D points stored as an STL vector, and you want to represent the points as a 3xN matrix, do the following:
std::vector<Point3f> vec; ... Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. // Also, an O(1) operation t(); // finally, transpose the Nx3 matrix. // This involves copying all the elements
- Parameters:
-
cn New number of channels. If the parameter is 0, the number of channels remains the same. rows New number of rows. If the parameter is 0, the number of rows remains the same.
Mat reshape | ( | int | cn, |
int | newndims, | ||
const int * | newsz | ||
) | const [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void resize | ( | size_t | sz, |
const Scalar & | s | ||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
sz New number of rows. s Value assigned to the newly added elements.
void resize | ( | size_t | sz ) | [inherited] |
Changes the number of matrix rows.
The methods change the number of matrix rows. If the matrix is reallocated, the first min(Mat::rows, sz) rows are preserved. The methods emulate the corresponding methods of the STL vector class.
- Parameters:
-
sz New number of rows.
Mat_ row | ( | int | y ) | const |
overridden forms of Mat::row() etc.
Reimplemented from Mat.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
r Range structure containing both the start and the end indices.
Mat rowRange | ( | int | startrow, |
int | endrow | ||
) | const [inherited] |
Creates a matrix header for the specified row span.
The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and Mat::col , this is an O(1) operation.
- Parameters:
-
startrow An inclusive 0-based start index of the row span. endrow An exclusive 0-based ending index of the row span.
Mat& setTo | ( | InputArray | value, |
InputArray | mask = noArray() |
||
) | [inherited] |
Sets all or some of the array elements to the specified value.
This is an advanced variant of the Mat::operator=(const Scalar& s) operator.
- Parameters:
-
value Assigned scalar converted to the actual array type. mask Operation mask of the same size as \*this.
size_t step1 | ( | int | i = 0 ) |
const |
Returns a normalized step.
The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access an arbitrary matrix element.
Reimplemented from Mat.
size_t stepT | ( | int | i = 0 ) |
const |
returns step()/sizeof(_Tp)
MatExpr t | ( | ) | const [inherited] |
Transposes a matrix.
The method performs matrix transposition by means of matrix expressions. It does not perform the actual transposition but returns a temporary matrix transposition object that can be further used as a part of more complex matrix expressions or can be assigned to a matrix:
size_t total | ( | ) | const [inherited] |
Returns the total number of array elements.
The method returns the number of array elements (a number of pixels if the array represents an image).
int type | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
size Alternative to the matrix size specification Size(cols, rows) . type Created matrix type.
static MatExpr zeros | ( | int | rows, |
int | cols | ||
) | [static] |
overridden forms of Mat::zeros() etc. Data type is omitted, of course
static MatExpr zeros | ( | int | ndims, |
const int * | sz, | ||
int | type | ||
) | [static, inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
ndims Array dimensionality. sz Array of integers specifying the array shape. type Created matrix type.
static MatExpr zeros | ( | int | rows, |
int | cols, | ||
int | type | ||
) | [static, inherited] |
Returns a zero array of the specified size and type.
The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant array as a function parameter, part of a matrix expression, or as a matrix initializer. :
Mat A; A = Mat::zeros(3, 3, CV_32F);
In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. Otherwise, the existing matrix A is filled with zeros.
- Parameters:
-
rows Number of rows. cols Number of columns. type Created matrix type.
Field Documentation
MatAllocator* allocator [inherited] |
const uchar* datastart [inherited] |
int flags [inherited] |
int rows [inherited] |
Generated on Tue Jul 12 2022 16:42:43 by 1.7.2