OpenCV
3.1.0
Open Source Computer Vision
|
Template matrix class derived from Mat. More...
#include "mat.hpp"
Public Types | |
typedef DataType< _Tp >::channel_type | channel_type |
typedef MatConstIterator_< _Tp > | const_iterator |
typedef MatIterator_< _Tp > | iterator |
typedef _Tp | value_type |
Public Types inherited from cv::Mat | |
enum | { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG } |
enum | { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 } |
Public Member Functions | |
Mat_ () | |
default constructor More... | |
Mat_ (int _rows, int _cols) | |
equivalent to Mat(_rows, _cols, DataType<_Tp>::type) More... | |
Mat_ (int _rows, int _cols, const _Tp &value) | |
constructor that sets each matrix element to specified value More... | |
Mat_ (Size _size) | |
equivalent to Mat(_size, DataType<_Tp>::type) More... | |
Mat_ (Size _size, const _Tp &value) | |
constructor that sets each matrix element to specified value More... | |
Mat_ (int _ndims, const int *_sizes) | |
n-dim array constructor More... | |
Mat_ (int _ndims, const int *_sizes, const _Tp &value) | |
n-dim array constructor that sets each matrix element to specified value More... | |
Mat_ (const Mat &m) | |
copy/conversion contructor. If m is of different type, it's converted More... | |
Mat_ (const Mat_ &m) | |
copy constructor More... | |
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 More... | |
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 More... | |
Mat_ (const Mat_ &m, const Range &rowRange, const Range &colRange=Range::all()) | |
selects a submatrix More... | |
Mat_ (const Mat_ &m, const Rect &roi) | |
selects a submatrix More... | |
Mat_ (const Mat_ &m, const Range *ranges) | |
selects a submatrix, n-dim version More... | |
Mat_ (const MatExpr &e) | |
from a matrix expression More... | |
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 More... | |
template<int n> | |
Mat_ (const Vec< typename DataType< _Tp >::channel_type, n > &vec, bool copyData=true) | |
template<int m, int n> | |
Mat_ (const Matx< typename DataType< _Tp >::channel_type, m, n > &mtx, bool copyData=true) | |
Mat_ (const Point_< typename DataType< _Tp >::channel_type > &pt, bool copyData=true) | |
Mat_ (const Point3_< typename DataType< _Tp >::channel_type > &pt, bool copyData=true) | |
Mat_ (const MatCommaInitializer_< _Tp > &commaInitializer) | |
Mat_ & | adjustROI (int dtop, int dbottom, int dleft, int dright) |
some more overriden methods More... | |
iterator | begin () |
iterators; they are smart enough to skip gaps in the end of rows More... | |
const_iterator | begin () const |
int | channels () const |
Mat_ | clone () const |
Mat_ | col (int x) const |
void | create (int _rows, int _cols) |
equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type) More... | |
void | create (Size _size) |
equivalent to Mat::create(_size, DataType<_Tp>::type) More... | |
void | create (int _ndims, const int *_sizes) |
equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type) More... | |
Mat_ | cross (const Mat_ &m) const |
cross-product More... | |
int | depth () const |
Mat_ | diag (int d=0) const |
size_t | elemSize () const |
overridden forms of Mat::elemSize() etc. More... | |
size_t | elemSize1 () const |
iterator | end () |
const_iterator | end () const |
template<typename Functor > | |
void | forEach (const Functor &operation) |
template methods for for operation over all matrix elements. More... | |
template<typename Functor > | |
void | forEach (const Functor &operation) const |
template<typename T2 > | |
operator Mat_< T2 > () const | |
data type conversion More... | |
template<int m, int n> | |
operator Matx< typename DataType< _Tp >::channel_type, m, n > () const | |
conversion to Matx More... | |
operator std::vector< _Tp > () const | |
conversion to vector. More... | |
template<int n> | |
operator Vec< typename DataType< _Tp >::channel_type, n > () const | |
conversion to Vec More... | |
Mat_ | operator() (const Range &rowRange, const Range &colRange) const |
Mat_ | operator() (const Rect &roi) const |
Mat_ | operator() (const Range *ranges) const |
_Tp & | operator() (const int *idx) |
returns reference to the specified element More... | |
const _Tp & | operator() (const int *idx) const |
returns read-only reference to the specified element More... | |
template<int n> | |
_Tp & | operator() (const Vec< int, n > &idx) |
returns reference to the specified element More... | |
template<int n> | |
const _Tp & | operator() (const Vec< int, n > &idx) const |
returns read-only reference to the specified element More... | |
_Tp & | operator() (int idx0) |
returns reference to the specified element (1D case) More... | |
const _Tp & | operator() (int idx0) const |
returns read-only reference to the specified element (1D case) More... | |
_Tp & | operator() (int idx0, int idx1) |
returns reference to the specified element (2D case) More... | |
const _Tp & | operator() (int idx0, int idx1) const |
returns read-only reference to the specified element (2D case) More... | |
_Tp & | operator() (int idx0, int idx1, int idx2) |
returns reference to the specified element (3D case) More... | |
const _Tp & | operator() (int idx0, int idx1, int idx2) const |
returns read-only reference to the specified element (3D case) More... | |
_Tp & | operator() (Point pt) |
const _Tp & | operator() (Point pt) const |
Mat_ & | operator= (const Mat &m) |
Mat_ & | operator= (const Mat_ &m) |
Mat_ & | operator= (const _Tp &s) |
set all the elements to s. More... | |
Mat_ & | operator= (const MatExpr &e) |
assign a matrix expression More... | |
_Tp * | operator[] (int y) |
more convenient forms of row and element access operators More... | |
const _Tp * | operator[] (int y) const |
Mat_ | row (int y) const |
overridden forms of Mat::row() etc. More... | |
size_t | step1 (int i=0) const |
size_t | stepT (int i=0) const |
returns step()/sizeof(_Tp) More... | |
int | type () const |
Public Member Functions inherited from cv::Mat | |
Mat () | |
Mat (int rows, int cols, int type) | |
Mat (Size size, int type) | |
Mat (int rows, int cols, int type, const Scalar &s) | |
Mat (Size size, int type, const Scalar &s) | |
Mat (int ndims, const int *sizes, int type) | |
Mat (int ndims, const int *sizes, int type, const Scalar &s) | |
Mat (const Mat &m) | |
Mat (int rows, int cols, int type, void *data, size_t step=AUTO_STEP) | |
Mat (Size size, int type, void *data, size_t step=AUTO_STEP) | |
Mat (int ndims, const int *sizes, int type, void *data, const size_t *steps=0) | |
Mat (const Mat &m, const Range &rowRange, const Range &colRange=Range::all()) | |
Mat (const Mat &m, const Rect &roi) | |
Mat (const Mat &m, const Range *ranges) | |
template<typename _Tp > | |
Mat (const std::vector< _Tp > &vec, bool copyData=false) | |
template<typename _Tp , int n> | |
Mat (const Vec< _Tp, n > &vec, bool copyData=true) | |
template<typename _Tp , int m, int n> | |
Mat (const Matx< _Tp, m, n > &mtx, bool copyData=true) | |
template<typename _Tp > | |
Mat (const Point_< _Tp > &pt, bool copyData=true) | |
template<typename _Tp > | |
Mat (const Point3_< _Tp > &pt, bool copyData=true) | |
template<typename _Tp > | |
Mat (const MatCommaInitializer_< _Tp > &commaInitializer) | |
Mat (const cuda::GpuMat &m) | |
download data from GpuMat More... | |
~Mat () | |
destructor - calls release() More... | |
void | addref () |
Increments the reference counter. More... | |
Mat & | adjustROI (int dtop, int dbottom, int dleft, int dright) |
Adjusts a submatrix size and position within the parent matrix. More... | |
void | assignTo (Mat &m, int type=-1) const |
Provides a functional form of convertTo. More... | |
template<typename _Tp > | |
_Tp & | at (int i0=0) |
Returns a reference to the specified array element. More... | |
template<typename _Tp > | |
const _Tp & | at (int i0=0) const |
template<typename _Tp > | |
_Tp & | at (int i0, int i1) |
template<typename _Tp > | |
const _Tp & | at (int i0, int i1) const |
template<typename _Tp > | |
_Tp & | at (int i0, int i1, int i2) |
template<typename _Tp > | |
const _Tp & | at (int i0, int i1, int i2) const |
template<typename _Tp > | |
_Tp & | at (const int *idx) |
template<typename _Tp > | |
const _Tp & | at (const int *idx) const |
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) |
template<typename _Tp > | |
const _Tp & | at (Point pt) const |
template<typename _Tp > | |
MatIterator_< _Tp > | begin () |
Returns the matrix iterator and sets it to the first matrix element. More... | |
template<typename _Tp > | |
MatConstIterator_< _Tp > | begin () const |
int | channels () const |
Returns the number of matrix channels. More... | |
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 More... | |
Mat | clone () const |
Creates a full copy of the array and the underlying data. More... | |
Mat | col (int x) const |
Creates a matrix header for the specified matrix column. More... | |
Mat | colRange (int startcol, int endcol) const |
Creates a matrix header for the specified column span. More... | |
Mat | colRange (const Range &r) const |
void | convertTo (OutputArray m, int rtype, double alpha=1, double beta=0) const |
Converts an array to another data type with optional scaling. More... | |
void | copySize (const Mat &m) |
internal use function; properly re-allocates _size, _step arrays More... | |
void | copyTo (OutputArray m) const |
Copies the matrix to another one. More... | |
void | copyTo (OutputArray m, InputArray mask) const |
void | create (int rows, int cols, int type) |
Allocates new array data if needed. More... | |
void | create (Size size, int type) |
void | create (int ndims, const int *sizes, int type) |
Mat | cross (InputArray m) const |
Computes a cross-product of two 3-element vectors. More... | |
void | deallocate () |
deallocates the matrix data More... | |
int | depth () const |
Returns the depth of a matrix element. More... | |
Mat | diag (int d=0) const |
Extracts a diagonal from a matrix. More... | |
double | dot (InputArray m) const |
Computes a dot-product of two vectors. More... | |
size_t | elemSize () const |
Returns the matrix element size in bytes. More... | |
size_t | elemSize1 () const |
Returns the size of each matrix element channel in bytes. More... | |
bool | empty () const |
Returns true if the array has no elements. More... | |
template<typename _Tp > | |
MatIterator_< _Tp > | end () |
Returns the matrix iterator and sets it to the after-last matrix element. More... | |
template<typename _Tp > | |
MatConstIterator_< _Tp > | end () const |
template<typename _Tp , typename Functor > | |
void | forEach (const Functor &operation) |
Invoke with arguments functor, and runs the functor over all matrix element. More... | |
template<typename _Tp , typename Functor > | |
void | forEach (const Functor &operation) const |
UMat | getUMat (int accessFlags, UMatUsageFlags usageFlags=USAGE_DEFAULT) const |
retrieve UMat from Mat More... | |
MatExpr | inv (int method=DECOMP_LU) const |
Inverses a matrix. More... | |
bool | isContinuous () const |
Reports whether the matrix is continuous or not. More... | |
bool | isSubmatrix () const |
returns true if the matrix is a submatrix of another matrix More... | |
void | locateROI (Size &wholeSize, Point &ofs) const |
Locates the matrix header within a parent matrix. More... | |
MatExpr | mul (InputArray m, double scale=1) const |
Performs an element-wise multiplication or division of the two matrices. More... | |
template<typename _Tp , int m, int n> | |
operator Matx< _Tp, m, n > () const | |
template<typename _Tp > | |
operator std::vector< _Tp > () const | |
template<typename _Tp , int n> | |
operator Vec< _Tp, n > () const | |
Mat | operator() (Range rowRange, Range colRange) const |
Extracts a rectangular submatrix. More... | |
Mat | operator() (const Rect &roi) const |
Mat | operator() (const Range *ranges) const |
Mat & | operator= (const Mat &m) |
assignment operators More... | |
Mat & | operator= (const MatExpr &expr) |
Mat & | operator= (const Scalar &s) |
Sets all or some of the array elements to the specified value. More... | |
void | pop_back (size_t nelems=1) |
Removes elements from the bottom of the matrix. More... | |
uchar * | ptr (int i0=0) |
Returns a pointer to the specified matrix row. More... | |
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 > | |
void | push_back (const _Tp &elem) |
Adds elements to the bottom of the matrix. More... | |
template<typename _Tp > | |
void | push_back (const Mat_< _Tp > &elem) |
void | push_back (const Mat &m) |
void | push_back_ (const void *elem) |
internal function More... | |
void | release () |
Decrements the reference counter and deallocates the matrix if needed. More... | |
void | reserve (size_t sz) |
Reserves space for the certain number of rows. More... | |
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. More... | |
Mat | reshape (int cn, int newndims, const int *newsz) const |
void | resize (size_t sz) |
Changes the number of matrix rows. More... | |
void | resize (size_t sz, const Scalar &s) |
Mat | row (int y) const |
Creates a matrix header for the specified matrix row. More... | |
Mat | rowRange (int startrow, int endrow) const |
Creates a matrix header for the specified row span. More... | |
Mat | rowRange (const Range &r) const |
Mat & | setTo (InputArray value, InputArray mask=noArray()) |
Sets all or some of the array elements to the specified value. More... | |
size_t | step1 (int i=0) const |
Returns a normalized step. More... | |
MatExpr | t () const |
Transposes a matrix. More... | |
size_t | total () const |
Returns the total number of array elements. More... | |
int | type () const |
Returns the type of a matrix element. More... | |
Static Public Member Functions | |
static MatExpr | eye (int rows, int cols) |
static MatExpr | eye (Size size) |
static MatExpr | ones (int rows, int cols) |
static MatExpr | ones (Size size) |
static MatExpr | ones (int _ndims, const int *_sizes) |
static MatExpr | zeros (int rows, int cols) |
overridden forms of Mat::zeros() etc. Data type is omitted, of course More... | |
static MatExpr | zeros (Size size) |
static MatExpr | zeros (int _ndims, const int *_sizes) |
Static Public Member Functions inherited from cv::Mat | |
static Mat | diag (const Mat &d) |
creates a diagonal matrix More... | |
static MatExpr | eye (int rows, int cols, int type) |
Returns an identity matrix of the specified size and type. More... | |
static MatExpr | eye (Size size, int type) |
static MatAllocator * | getDefaultAllocator () |
static MatAllocator * | getStdAllocator () |
and the standard allocator More... | |
static MatExpr | ones (int rows, int cols, int type) |
Returns an array of all 1's of the specified size and type. More... | |
static MatExpr | ones (Size size, int type) |
static MatExpr | ones (int ndims, const int *sz, int type) |
static void | setDefaultAllocator (MatAllocator *allocator) |
static MatExpr | zeros (int rows, int cols, int type) |
Returns a zero array of the specified size and type. More... | |
static MatExpr | zeros (Size size, int type) |
static MatExpr | zeros (int ndims, const int *sz, int type) |
Additional Inherited Members | |
Public Attributes inherited from cv::Mat | |
MatAllocator * | allocator |
custom allocator More... | |
int | cols |
uchar * | data |
pointer to the data More... | |
const uchar * | dataend |
const uchar * | datalimit |
const uchar * | datastart |
helper fields used in locateROI and adjustROI More... | |
int | dims |
the matrix dimensionality, >= 2 More... | |
int | flags |
int | rows |
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions More... | |
MatSize | size |
MatStep | step |
UMatData * | u |
interaction with UMat More... | |
Protected Member Functions inherited from cv::Mat | |
template<typename _Tp , typename Functor > | |
void | forEach_impl (const Functor &operation) |
Template matrix class derived from Mat.
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:
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 Mat::at(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:
To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter:
typedef DataType<_Tp>::channel_type cv::Mat_< _Tp >::channel_type |
typedef MatConstIterator_<_Tp> cv::Mat_< _Tp >::const_iterator |
typedef MatIterator_<_Tp> cv::Mat_< _Tp >::iterator |
typedef _Tp cv::Mat_< _Tp >::value_type |
equivalent to Mat(_rows, _cols, DataType<_Tp>::type)
constructor that sets each matrix element to specified value
equivalent to Mat(_size, DataType<_Tp>::type)
constructor that sets each matrix element to specified value
n-dim array constructor
n-dim array constructor that sets each matrix element to specified value
copy/conversion contructor. If m is of different type, it's converted
cv::Mat_< _Tp >::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
cv::Mat_< _Tp >::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
cv::Mat_< _Tp >::Mat_ | ( | const Mat_< _Tp > & | m, |
const Range & | rowRange, | ||
const Range & | colRange = Range::all() |
||
) |
selects a submatrix
selects a submatrix
selects a submatrix, n-dim version
|
explicit |
|
explicit |
|
explicit |
|
explicit |
|
explicit |
Mat_& cv::Mat_< _Tp >::adjustROI | ( | int | dtop, |
int | dbottom, | ||
int | dleft, | ||
int | dright | ||
) |
some more overriden methods
iterators; they are smart enough to skip gaps in the end of rows
const_iterator cv::Mat_< _Tp >::begin | ( | ) | const |
int cv::Mat_< _Tp >::channels | ( | ) | const |
void cv::Mat_< _Tp >::create | ( | int | _rows, |
int | _cols | ||
) |
equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type)
equivalent to Mat::create(_size, DataType<_Tp>::type)
void cv::Mat_< _Tp >::create | ( | int | _ndims, |
const int * | _sizes | ||
) |
equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type)
int cv::Mat_< _Tp >::depth | ( | ) | const |
overridden forms of Mat::elemSize() etc.
const_iterator cv::Mat_< _Tp >::end | ( | ) | const |
void cv::Mat_< _Tp >::forEach | ( | const Functor & | operation | ) |
template methods for for operation over all matrix elements.
void cv::Mat_< _Tp >::forEach | ( | const Functor & | operation | ) | const |
|
static |
data type conversion
cv::Mat_< _Tp >::operator Matx< typename DataType< _Tp >::channel_type, m, n > | ( | ) | const |
conversion to Matx
cv::Mat_< _Tp >::operator std::vector< _Tp > | ( | ) | const |
conversion to vector.
cv::Mat_< _Tp >::operator Vec< typename DataType< _Tp >::channel_type, n > | ( | ) | const |
conversion to Vec
Mat_ cv::Mat_< _Tp >::operator() | ( | const Range & | rowRange, |
const Range & | colRange | ||
) | const |
_Tp& cv::Mat_< _Tp >::operator() | ( | const int * | idx | ) |
returns reference to the specified element
const _Tp& cv::Mat_< _Tp >::operator() | ( | const int * | idx | ) | const |
returns read-only reference to the specified element
_Tp& cv::Mat_< _Tp >::operator() | ( | const Vec< int, n > & | idx | ) |
returns reference to the specified element
const _Tp& cv::Mat_< _Tp >::operator() | ( | const Vec< int, n > & | idx | ) | const |
returns read-only reference to the specified element
_Tp& cv::Mat_< _Tp >::operator() | ( | int | idx0 | ) |
returns reference to the specified element (1D case)
const _Tp& cv::Mat_< _Tp >::operator() | ( | int | idx0 | ) | const |
returns read-only reference to the specified element (1D case)
_Tp& cv::Mat_< _Tp >::operator() | ( | int | idx0, |
int | idx1 | ||
) |
returns reference to the specified element (2D case)
const _Tp& cv::Mat_< _Tp >::operator() | ( | int | idx0, |
int | idx1 | ||
) | const |
returns read-only reference to the specified element (2D case)
_Tp& cv::Mat_< _Tp >::operator() | ( | int | idx0, |
int | idx1, | ||
int | idx2 | ||
) |
returns reference to the specified element (3D case)
const _Tp& cv::Mat_< _Tp >::operator() | ( | int | idx0, |
int | idx1, | ||
int | idx2 | ||
) | const |
returns read-only reference to the specified element (3D case)
assign a matrix expression
_Tp* cv::Mat_< _Tp >::operator[] | ( | int | y | ) |
more convenient forms of row and element access operators
const _Tp* cv::Mat_< _Tp >::operator[] | ( | int | y | ) | const |
overridden forms of Mat::row() etc.
int cv::Mat_< _Tp >::type | ( | ) | const |
overridden forms of Mat::zeros() etc. Data type is omitted, of course
|
static |