OpenCV  4.1.1-pre
Open Source Computer Vision
Looking for a C++ dev who knows OpenCV?
I'm looking for work. Hire me!
cv::Mat_< _Tp > Class Template Reference

Template matrix class derived from Mat. More...

#include <opencv2/core/mat.hpp>

Inheritance diagram for cv::Mat_< _Tp >:
Collaboration diagram for cv::Mat_< _Tp >:

Public Types

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
}
 
typedef DataType< _Tp >::channel_type channel_type
 
typedef MatConstIterator_< _Tp > const_iterator
 
typedef MatIterator_< _Tp > iterator
 
typedef _Tp value_type
 

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 constructor. 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 Mat_ &m, const std::vector< 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_ (std::initializer_list< _Tp > values)
 
 Mat_ (const std::initializer_list< int > sizes, const std::initializer_list< _Tp > values)
 
template<std::size_t _Nm>
 Mat_ (const std::array< _Tp, _Nm > &arr, bool copyData=false)
 
 Mat_ (Mat_ &&m)
 
 Mat_ (Mat &&m)
 
 Mat_ (MatExpr &&e)
 
void addref ()
 Increments the reference counter. More...
 
Mat_adjustROI (int dtop, int dbottom, int dleft, int dright)
 some more overridden methods 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
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename _Tp >
_Tp & at (int row, int col)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename _Tp >
const _Tp & at (int row, int col) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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) More...
 
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) More...
 
iterator begin ()
 iterators; they are smart enough to skip gaps in the end of rows More...
 
const_iterator begin () const
 
int channels () const
 
int checkVector (int elemChannels, int depth=-1, bool requireContinuous=true) const
 
Mat_ clone () const CV_NODISCARD
 
Mat_ col (int x) const
 
Mat colRange (int startcol, int endcol) const
 Creates a matrix header for the specified column span. More...
 
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. More...
 
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
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void create (int rows, int cols, int type)
 Allocates new array data if needed. More...
 
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. More...
 
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. More...
 
void create (const std::vector< 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. More...
 
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 (InputArray m) const
 Computes a cross-product of two 3-element vectors. More...
 
Mat_ cross (const Mat_ &m) const
 cross-product More...
 
void deallocate ()
 internal use function, consider to use 'release' method instead; deallocates the matrix data More...
 
int depth () const
 
Mat_ diag (int d=0) const
 
double dot (InputArray m) const
 Computes a dot-product of two vectors. More...
 
size_t elemSize () const
 overridden forms of Mat::elemSize() etc. More...
 
size_t elemSize1 () const
 
bool empty () const
 Returns true if the array has no elements. More...
 
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
 
UMat getUMat (AccessFlag 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 T2 >
 operator Mat_< T2 > () const
 data type conversion More...
 
template<typename _Tp , int m, int n>
 operator Matx< _Tp, m, n > () const
 
template<int m, int n>
 operator Matx< typename DataType< _Tp >::channel_type, m, n > () const
 conversion to Matx More...
 
template<std::size_t _Nm>
 operator std::array< _Tp, _Nm > () const
 conversion to array. More...
 
 operator std::vector< _Tp > () const
 conversion to vector. More...
 
template<typename _Tp , int n>
 operator Vec< _Tp, n > () const
 
template<int n>
 operator Vec< typename DataType< _Tp >::channel_type, n > () const
 conversion to Vec More...
 
Mat operator() (Range rowRange, Range colRange) const
 Extracts a rectangular submatrix. More...
 
Mat_ operator() (const Range &rowRange, const Range &colRange) const
 
Mat_ operator() (const Rect &roi) const
 
Mat_ operator() (const Range *ranges) const
 
Mat_ operator() (const std::vector< 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 row, int col)
 returns reference to the specified element (2D case) More...
 
const _Tp & operator() (int row, int col) 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...
 
Mat_operator= (Mat_ &&m)
 
Mat_operator= (Mat &&m)
 
_Tp * operator[] (int y)
 more convenient forms of row and element access operators More...
 
const _Tp * operator[] (int y) const
 
void pop_back (size_t nelems=1)
 Removes elements from the bottom of the matrix. More...
 
ucharptr (int i0=0)
 Returns a pointer to the specified matrix row. More...
 
const ucharptr (int i0=0) const
 
ucharptr (int row, int col)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
const ucharptr (int row, int col) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
ucharptr (int i0, int i1, int i2)
 
const ucharptr (int i0, int i1, int i2) const
 
ucharptr (const int *idx)
 
const ucharptr (const int *idx) const
 
template<int n>
ucharptr (const Vec< int, n > &idx)
 
template<int n>
const ucharptr (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 row, int col)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename _Tp >
const _Tp * ptr (int row, int col) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename _Tp >
void push_back (const std::vector< _Tp > &elem)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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. More...
 
void push_back_ (const void *elem)
 internal function More...
 
void release ()
 equivalent to Mat::release() More...
 
void reserve (size_t sz)
 Reserves space for the certain number of rows. More...
 
void reserveBuffer (size_t sz)
 Reserves space for the certain number of bytes. 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
 
Mat reshape (int cn, const std::vector< int > &newshape) const
 
void resize (size_t sz)
 Changes the number of matrix rows. More...
 
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. More...
 
Mat_ row (int y) const
 overridden forms of Mat::row() etc. More...
 
Mat rowRange (int startrow, int endrow) const
 Creates a matrix header for the specified row span. More...
 
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. More...
 
MatsetTo (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
 
size_t stepT (int i=0) const
 returns step()/sizeof(_Tp) More...
 
MatExpr t () const
 Transposes a matrix. More...
 
size_t total () const
 Returns the total number of array elements. More...
 
size_t total (int startDim, int endDim=INT_MAX) const
 Returns the total number of array elements. More...
 
int type () const
 
void updateContinuityFlag ()
 internal use method: updates the continuity flag More...
 

Static Public Member Functions

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)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
static MatExpr eye (int rows, int cols)
 
static MatExpr eye (Size size)
 
static MatAllocatorgetDefaultAllocator ()
 
static MatAllocatorgetStdAllocator ()
 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)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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. More...
 
static MatExpr ones (int rows, int cols)
 
static MatExpr ones (Size size)
 
static MatExpr ones (int _ndims, const int *_sizes)
 
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)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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. More...
 
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)
 

Public Attributes

MatAllocatorallocator
 custom allocator More...
 
int cols
 
uchardata
 pointer to the data More...
 
const uchardataend
 
const uchardatalimit
 
const uchardatastart
 helper fields used in locateROI and adjustROI More...
 
int dims
 the matrix dimensionality, >= 2 More...
 
int flags
 includes several bit-fields: More...
 
int rows
 the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions More...
 
MatSize size
 
MatStep step
 
UMatDatau
 interaction with UMat More...
 

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 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:

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);

Mat_ is fully compatible with C++11 range-based for loop. For example such loop can be used to safely apply look-up table:

void applyTable(Mat_<uchar>& I, const uchar* const table)
{
for(auto& pixel : I)
{
pixel = table[pixel];
}
}

Member Typedef Documentation

◆ channel_type

template<typename _Tp>
typedef DataType<_Tp>::channel_type cv::Mat_< _Tp >::channel_type

◆ const_iterator

template<typename _Tp>
typedef MatConstIterator_<_Tp> cv::Mat_< _Tp >::const_iterator

◆ iterator

template<typename _Tp>
typedef MatIterator_<_Tp> cv::Mat_< _Tp >::iterator

◆ value_type

template<typename _Tp>
typedef _Tp cv::Mat_< _Tp >::value_type

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
MAGIC_VAL 
AUTO_STEP 
CONTINUOUS_FLAG 
SUBMATRIX_FLAG 

◆ anonymous enum

anonymous enum
inherited
Enumerator
MAGIC_MASK 
TYPE_MASK 
DEPTH_MASK 

Constructor & Destructor Documentation

◆ Mat_() [1/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( )

default constructor

◆ Mat_() [2/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( int  _rows,
int  _cols 
)

equivalent to Mat(_rows, _cols, DataType<_Tp>::type)

◆ Mat_() [3/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( int  _rows,
int  _cols,
const _Tp &  value 
)

constructor that sets each matrix element to specified value

◆ Mat_() [4/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( Size  _size)
explicit

equivalent to Mat(_size, DataType<_Tp>::type)

◆ Mat_() [5/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( Size  _size,
const _Tp &  value 
)

constructor that sets each matrix element to specified value

◆ Mat_() [6/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( int  _ndims,
const int *  _sizes 
)

n-dim array constructor

◆ Mat_() [7/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( int  _ndims,
const int *  _sizes,
const _Tp &  value 
)

n-dim array constructor that sets each matrix element to specified value

◆ Mat_() [8/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const Mat m)

copy/conversion constructor. If m is of different type, it's converted

◆ Mat_() [9/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const Mat_< _Tp > &  m)

copy constructor

◆ Mat_() [10/28]

template<typename _Tp>
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

◆ Mat_() [11/28]

template<typename _Tp>
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

◆ Mat_() [12/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const Mat_< _Tp > &  m,
const Range rowRange,
const Range colRange = Range::all() 
)

selects a submatrix

◆ Mat_() [13/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const Mat_< _Tp > &  m,
const Rect roi 
)

selects a submatrix

◆ Mat_() [14/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const Mat_< _Tp > &  m,
const Range ranges 
)

selects a submatrix, n-dim version

◆ Mat_() [15/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const Mat_< _Tp > &  m,
const std::vector< Range > &  ranges 
)

selects a submatrix, n-dim version

◆ Mat_() [16/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const MatExpr e)
explicit

from a matrix expression

◆ Mat_() [17/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const std::vector< _Tp > &  vec,
bool  copyData = false 
)
explicit

makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column

◆ Mat_() [18/28]

template<typename _Tp>
template<int n>
cv::Mat_< _Tp >::Mat_ ( const Vec< typename DataType< _Tp >::channel_type, n > &  vec,
bool  copyData = true 
)
explicit

◆ Mat_() [19/28]

template<typename _Tp>
template<int m, int n>
cv::Mat_< _Tp >::Mat_ ( const Matx< typename DataType< _Tp >::channel_type, m, n > &  mtx,
bool  copyData = true 
)
explicit

◆ Mat_() [20/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const Point_< typename DataType< _Tp >::channel_type > &  pt,
bool  copyData = true 
)
explicit

◆ Mat_() [21/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const Point3_< typename DataType< _Tp >::channel_type > &  pt,
bool  copyData = true 
)
explicit

◆ Mat_() [22/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const MatCommaInitializer_< _Tp > &  commaInitializer)
explicit

◆ Mat_() [23/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( std::initializer_list< _Tp >  values)

◆ Mat_() [24/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( const std::initializer_list< int >  sizes,
const std::initializer_list< _Tp >  values 
)
explicit

◆ Mat_() [25/28]

template<typename _Tp>
template<std::size_t _Nm>
cv::Mat_< _Tp >::Mat_ ( const std::array< _Tp, _Nm > &  arr,
bool  copyData = false 
)
explicit

◆ Mat_() [26/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( Mat_< _Tp > &&  m)

◆ Mat_() [27/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( Mat &&  m)

◆ Mat_() [28/28]

template<typename _Tp>
cv::Mat_< _Tp >::Mat_ ( MatExpr &&  e)

Member Function Documentation

◆ addref()

void cv::Mat::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.

◆ adjustROI()

template<typename _Tp>
Mat_& cv::Mat_< _Tp >::adjustROI ( int  dtop,
int  dbottom,
int  dleft,
int  dright 
)

some more overridden methods

◆ assignTo()

void cv::Mat::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
mDestination array.
typeDesired destination array depth (or -1 if it should be the same as the source type).

◆ at() [1/12]

template<typename _Tp >
_Tp& cv::Mat::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);

Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends on the image from which you are trying to retrieve the data. The table below gives a better insight in this:

  • If matrix is of type CV_8U then use Mat.at<uchar>(y,x).
  • If matrix is of type CV_8S then use Mat.at<schar>(y,x).
  • If matrix is of type CV_16U then use Mat.at<ushort>(y,x).
  • If matrix is of type CV_16S then use Mat.at<short>(y,x).
  • If matrix is of type CV_32S then use Mat.at<int>(y,x).
  • If matrix is of type CV_32F then use Mat.at<float>(y,x).
  • If matrix is of type CV_64F then use Mat.at<double>(y,x).
Parameters
i0Index along the dimension 0
Examples:
samples/cpp/camshiftdemo.cpp, samples/cpp/connected_components.cpp, samples/cpp/cout_mat.cpp, samples/cpp/demhist.cpp, samples/cpp/fitellipse.cpp, samples/cpp/image_alignment.cpp, samples/cpp/kalman.cpp, samples/cpp/kmeans.cpp, samples/cpp/train_HOG.cpp, samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp, samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp, samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp, samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp, and samples/cpp/watershed.cpp.

◆ at() [2/12]

template<typename _Tp >
const _Tp& cv::Mat::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
i0Index along the dimension 0

◆ at() [3/12]

template<typename _Tp >
_Tp& cv::Mat::at ( int  row,
int  col 
)
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rowIndex along the dimension 0
colIndex along the dimension 1

◆ at() [4/12]

template<typename _Tp >
const _Tp& cv::Mat::at ( int  row,
int  col 
) 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
rowIndex along the dimension 0
colIndex along the dimension 1

◆ at() [5/12]

template<typename _Tp >
_Tp& cv::Mat::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
i0Index along the dimension 0
i1Index along the dimension 1
i2Index along the dimension 2

◆ at() [6/12]

template<typename _Tp >
const _Tp& cv::Mat::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
i0Index along the dimension 0
i1Index along the dimension 1
i2Index along the dimension 2

◆ at() [7/12]

template<typename _Tp >
_Tp& cv::Mat::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
idxArray of Mat::dims indices.

◆ at() [8/12]

template<typename _Tp >
const _Tp& cv::Mat::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
idxArray of Mat::dims indices.

◆ at() [9/12]

template<typename _Tp , int n>
_Tp& cv::Mat::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.

◆ at() [10/12]

template<typename _Tp , int n>
const _Tp& cv::Mat::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.

◆ at() [11/12]

template<typename _Tp >
_Tp& cv::Mat::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
ptElement position specified as Point(j,i) .

◆ at() [12/12]

template<typename _Tp >
const _Tp& cv::Mat::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
ptElement position specified as Point(j,i) .

◆ begin() [1/2]

template<typename _Tp>
iterator cv::Mat_< _Tp >::begin ( )

iterators; they are smart enough to skip gaps in the end of rows

◆ begin() [2/2]

template<typename _Tp>
const_iterator cv::Mat_< _Tp >::begin ( ) const

◆ channels()

template<typename _Tp>
int cv::Mat_< _Tp >::channels ( ) const

◆ checkVector()

int cv::Mat::checkVector ( int  elemChannels,
int  depth = -1,
bool  requireContinuous = true 
) const
inherited
Parameters
elemChannelsNumber of channels or number of columns the matrix should have. For a 2-D matrix, when the matrix has only 1 column, then it should have elemChannels channels; When the matrix has only 1 channel, then it should have elemChannels columns. For a 3-D matrix, it should have only one channel. Furthermore, if the number of planes is not one, then the number of rows within every plane has to be 1; if the number of rows within every plane is not 1, then the number of planes has to be 1.
depthThe depth the matrix should have. Set it to -1 when any depth is fine.
requireContinuousSet it to true to require the matrix to be continuous
Returns
-1 if the requirement is not satisfied. Otherwise, it returns the number of elements in the matrix. Note that an element may have multiple channels.

The following code demonstrates its usage for a 2-d matrix:

cv::Mat mat(20, 1, CV_32FC2);
int n = mat.checkVector(2);
CV_Assert(n == 20); // mat has 20 elements
mat.create(20, 2, CV_32FC1);
n = mat.checkVector(1);
CV_Assert(n == -1); // mat is neither a column nor a row vector
n = mat.checkVector(2);
CV_Assert(n == 20); // the 2 columns are considered as 1 element

The following code demonstrates its usage for a 3-d matrix:

int dims[] = {1, 3, 5}; // 1 plane, every plane has 3 rows and 5 columns
mat.create(3, dims, CV_32FC1); // for 3-d mat, it MUST have only 1 channel
n = mat.checkVector(5); // the 5 columns are considered as 1 element
CV_Assert(n == 3);
int dims2[] = {3, 1, 5}; // 3 planes, every plane has 1 row and 5 columns
mat.create(3, dims2, CV_32FC1);
n = mat.checkVector(5); // the 5 columns are considered as 1 element
CV_Assert(n == 3);

◆ clone()

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::clone ( ) const

◆ col()

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::col ( int  x) const

◆ colRange() [1/2]

Mat cv::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
startcolAn inclusive 0-based start index of the column span.
endcolAn exclusive 0-based ending index of the column span.

◆ colRange() [2/2]

Mat cv::Mat::colRange ( const Range r) 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
rRange structure containing both the start and the end indices.

◆ convertTo()

void cv::Mat::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:

\[m(x,y) = saturate \_ cast<rType>( \alpha (*this)(x,y) + \beta )\]

Parameters
moutput matrix; if it does not have a proper size or type before the operation, it is reallocated.
rtypedesired 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.
alphaoptional scale factor.
betaoptional delta added to the scaled values.
Examples:
samples/cpp/demhist.cpp, samples/cpp/distrans.cpp, samples/cpp/fitellipse.cpp, samples/cpp/pca.cpp, samples/cpp/stitching_detailed.cpp, and samples/dnn/colorization.cpp.

Referenced by cv::cv2eigen().

Here is the caller graph for this function:

◆ copySize()

void cv::Mat::copySize ( const Mat m)
inherited

internal use function; properly re-allocates _size, _step arrays

◆ copyTo() [1/2]

void cv::Mat::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
mDestination matrix. If it does not have a proper size or type before the operation, it is reallocated.
Examples:
samples/cpp/camshiftdemo.cpp, samples/cpp/edge.cpp, samples/cpp/grabcut.cpp, samples/cpp/image_alignment.cpp, samples/cpp/lkdemo.cpp, samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp, samples/cpp/watershed.cpp, samples/tapi/hog.cpp, and samples/tapi/squares.cpp.

Referenced by cv::cv2eigen(), and cv::eigen2cv().

Here is the caller graph for this function:

◆ copyTo() [2/2]

void cv::Mat::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
mDestination matrix. If it does not have a proper size or type before the operation, it is reallocated.
maskOperation mask of the same size as *this. 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.

◆ create() [1/7]

void cv::Mat::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:

  1. If the current array shape and the type match the new ones, return immediately. Otherwise, de-reference the previous data by calling Mat::release.
  2. Initialize the new header.
  3. Allocate the new data of total()*elemSize() bytes.
  4. 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
rowsNew number of rows.
colsNew number of columns.
typeNew matrix type.
Examples:
samples/cpp/camshiftdemo.cpp, samples/cpp/edge.cpp, samples/cpp/ffilldemo.cpp, samples/cpp/grabcut.cpp, samples/cpp/stitching_detailed.cpp, samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp, and samples/dnn/segmentation.cpp.

◆ create() [2/7]

void cv::Mat::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
sizeAlternative new matrix size specification: Size(cols, rows)
typeNew matrix type.

◆ create() [3/7]

void cv::Mat::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
ndimsNew array dimensionality.
sizesArray of integers specifying a new array shape.
typeNew matrix type.

◆ create() [4/7]

void cv::Mat::create ( const std::vector< 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
sizesArray of integers specifying a new array shape.
typeNew matrix type.

◆ create() [5/7]

template<typename _Tp>
void cv::Mat_< _Tp >::create ( int  _rows,
int  _cols 
)

equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type)

◆ create() [6/7]

template<typename _Tp>
void cv::Mat_< _Tp >::create ( Size  _size)

equivalent to Mat::create(_size, DataType<_Tp>::type)

◆ create() [7/7]

template<typename _Tp>
void cv::Mat_< _Tp >::create ( int  _ndims,
const int *  _sizes 
)

equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type)

◆ cross() [1/2]

Mat cv::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
mAnother cross-product operand.
Examples:
samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp.

◆ cross() [2/2]

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::cross ( const Mat_< _Tp > &  m) const

cross-product

◆ deallocate()

void cv::Mat::deallocate ( )
inherited

internal use function, consider to use 'release' method instead; deallocates the matrix data

◆ depth()

template<typename _Tp>
int cv::Mat_< _Tp >::depth ( ) const

◆ diag() [1/2]

static Mat cv::Mat::diag ( const Mat d)
staticinherited

creates a diagonal matrix

The method creates a square diagonal matrix from specified main diagonal.

Parameters
dOne-dimensional matrix that represents the main diagonal.

◆ diag() [2/2]

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::diag ( int  d = 0) const

◆ dot()

double cv::Mat::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
manother dot-product operand.
Examples:
samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp, and samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp.

◆ elemSize()

template<typename _Tp>
size_t cv::Mat_< _Tp >::elemSize ( ) const

overridden forms of Mat::elemSize() etc.

◆ elemSize1()

template<typename _Tp>
size_t cv::Mat_< _Tp >::elemSize1 ( ) const

◆ empty()

◆ end() [1/2]

template<typename _Tp>
iterator cv::Mat_< _Tp >::end ( )

◆ end() [2/2]

template<typename _Tp>
const_iterator cv::Mat_< _Tp >::end ( ) const

◆ eye() [1/4]

static MatExpr cv::Mat::eye ( int  rows,
int  cols,
int  type 
)
staticinherited

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:

// make a 4x4 diagonal matrix with 0.1's on the diagonal.
Mat A = Mat::eye(4, 4, CV_32F)*0.1;
Note
In case of multi-channels type, identity matrix will be initialized only for the first channel, the others will be set to 0's
Parameters
rowsNumber of rows.
colsNumber of columns.
typeCreated matrix type.
Examples:
samples/cpp/image_alignment.cpp.

◆ eye() [2/4]

static MatExpr cv::Mat::eye ( Size  size,
int  type 
)
staticinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
sizeAlternative matrix size specification as Size(cols, rows) .
typeCreated matrix type.

◆ eye() [3/4]

template<typename _Tp>
static MatExpr cv::Mat_< _Tp >::eye ( int  rows,
int  cols 
)
static

◆ eye() [4/4]

template<typename _Tp>
static MatExpr cv::Mat_< _Tp >::eye ( Size  size)
static

◆ forEach() [1/2]

template<typename _Tp>
template<typename Functor >
void cv::Mat_< _Tp >::forEach ( const Functor &  operation)

template methods for for operation over all matrix elements.

◆ forEach() [2/2]

template<typename _Tp>
template<typename Functor >
void cv::Mat_< _Tp >::forEach ( const Functor &  operation) const

◆ getDefaultAllocator()

static MatAllocator* cv::Mat::getDefaultAllocator ( )
staticinherited

◆ getStdAllocator()

static MatAllocator* cv::Mat::getStdAllocator ( )
staticinherited

and the standard allocator

◆ getUMat()

UMat cv::Mat::getUMat ( AccessFlag  accessFlags,
UMatUsageFlags  usageFlags = USAGE_DEFAULT 
) const
inherited

retrieve UMat from Mat

◆ inv()

MatExpr cv::Mat::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
methodMatrix inversion method. One of cv::DecompTypes
Examples:
samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp, and samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp.

◆ isContinuous()

bool cv::Mat::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(traits::Depth<T>::value, 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.

Referenced by cv::flann::GenericIndex< Distance >::getIndexParameters(), cv::flann::hierarchicalClustering(), cv::flann::Index_< T >::Index_(), cv::flann::Index_< T >::knnSearch(), and cv::flann::Index_< T >::radiusSearch().

Here is the caller graph for this function:

◆ isSubmatrix()

bool cv::Mat::isSubmatrix ( ) const
inherited

returns true if the matrix is a submatrix of another matrix

◆ locateROI()

void cv::Mat::locateROI ( Size wholeSize,
Point ofs 
) const
inherited

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
wholeSizeOutput parameter that contains the size of the whole matrix containing this as a part.
ofsOutput parameter that contains an offset of this inside the whole matrix.

◆ mul()

MatExpr cv::Mat::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
mAnother array of the same type and the same size as *this, or a matrix expression.
scaleOptional scale factor.

◆ ones() [1/6]

static MatExpr cv::Mat::ones ( int  rows,
int  cols,
int  type 
)
staticinherited

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:

Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3.

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.

Note
In case of multi-channels type, only the first channel will be initialized with 1's, the others will be set to 0's.
Parameters
rowsNumber of rows.
colsNumber of columns.
typeCreated matrix type.
Examples:
samples/cpp/demhist.cpp.

Referenced by cv::detail::BundleAdjusterBase::BundleAdjusterBase().

Here is the caller graph for this function:

◆ ones() [2/6]

static MatExpr cv::Mat::ones ( Size  size,
int  type 
)
staticinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
sizeAlternative to the matrix size specification Size(cols, rows) .
typeCreated matrix type.

◆ ones() [3/6]

static MatExpr cv::Mat::ones ( int  ndims,
const int *  sz,
int  type 
)
staticinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
ndimsArray dimensionality.
szArray of integers specifying the array shape.
typeCreated matrix type.

◆ ones() [4/6]

template<typename _Tp>
static MatExpr cv::Mat_< _Tp >::ones ( int  rows,
int  cols 
)
static

◆ ones() [5/6]

template<typename _Tp>
static MatExpr cv::Mat_< _Tp >::ones ( Size  size)
static

◆ ones() [6/6]

template<typename _Tp>
static MatExpr cv::Mat_< _Tp >::ones ( int  _ndims,
const int *  _sizes 
)
static

◆ operator Mat_< T2 >()

template<typename _Tp>
template<typename T2 >
cv::Mat_< _Tp >::operator Mat_< T2 > ( ) const

data type conversion

◆ operator Matx< _Tp, m, n >()

template<typename _Tp , int m, int n>
cv::Mat::operator Matx< _Tp, m, n > ( ) const
inherited

◆ operator Matx< typename DataType< _Tp >::channel_type, m, n >()

template<typename _Tp>
template<int m, int n>
cv::Mat_< _Tp >::operator Matx< typename DataType< _Tp >::channel_type, m, n > ( ) const

conversion to Matx

◆ operator std::array< _Tp, _Nm >()

template<typename _Tp>
template<std::size_t _Nm>
cv::Mat_< _Tp >::operator std::array< _Tp, _Nm > ( ) const

conversion to array.

◆ operator std::vector< _Tp >()

template<typename _Tp>
cv::Mat_< _Tp >::operator std::vector< _Tp > ( ) const

conversion to vector.

◆ operator Vec< _Tp, n >()

template<typename _Tp , int n>
cv::Mat::operator Vec< _Tp, n > ( ) const
inherited

◆ operator Vec< typename DataType< _Tp >::channel_type, n >()

template<typename _Tp>
template<int n>
cv::Mat_< _Tp >::operator Vec< typename DataType< _Tp >::channel_type, n > ( ) const

conversion to Vec

◆ operator()() [1/17]

Mat cv::Mat::operator() ( Range  rowRange,
Range  colRange 
) const
inherited

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
rowRangeStart and end row of the extracted submatrix. The upper boundary is not included. To select all the rows, use Range::all().
colRangeStart and end column of the extracted submatrix. The upper boundary is not included. To select all the columns, use Range::all().

◆ operator()() [2/17]

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::operator() ( const Range rowRange,
const Range colRange 
) const

◆ operator()() [3/17]

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::operator() ( const Rect roi) const

◆ operator()() [4/17]

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::operator() ( const Range ranges) const

◆ operator()() [5/17]

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::operator() ( const std::vector< Range > &  ranges) const

◆ operator()() [6/17]

template<typename _Tp>
_Tp& cv::Mat_< _Tp >::operator() ( const int *  idx)

returns reference to the specified element

◆ operator()() [7/17]

template<typename _Tp>
const _Tp& cv::Mat_< _Tp >::operator() ( const int *  idx) const

returns read-only reference to the specified element

◆ operator()() [8/17]

template<typename _Tp>
template<int n>
_Tp& cv::Mat_< _Tp >::operator() ( const Vec< int, n > &  idx)

returns reference to the specified element

◆ operator()() [9/17]

template<typename _Tp>
template<int n>
const _Tp& cv::Mat_< _Tp >::operator() ( const Vec< int, n > &  idx) const

returns read-only reference to the specified element

◆ operator()() [10/17]

template<typename _Tp>
_Tp& cv::Mat_< _Tp >::operator() ( int  idx0)

returns reference to the specified element (1D case)

◆ operator()() [11/17]

template<typename _Tp>
const _Tp& cv::Mat_< _Tp >::operator() ( int  idx0) const

returns read-only reference to the specified element (1D case)

◆ operator()() [12/17]

template<typename _Tp>
_Tp& cv::Mat_< _Tp >::operator() ( int  row,
int  col 
)

returns reference to the specified element (2D case)

◆ operator()() [13/17]

template<typename _Tp>
const _Tp& cv::Mat_< _Tp >::operator() ( int  row,
int  col 
) const

returns read-only reference to the specified element (2D case)

◆ operator()() [14/17]

template<typename _Tp>
_Tp& cv::Mat_< _Tp >::operator() ( int  idx0,
int  idx1,
int  idx2 
)

returns reference to the specified element (3D case)

◆ operator()() [15/17]

template<typename _Tp>
const _Tp& cv::Mat_< _Tp >::operator() ( int  idx0,
int  idx1,
int  idx2 
) const

returns read-only reference to the specified element (3D case)

◆ operator()() [16/17]

template<typename _Tp>
_Tp& cv::Mat_< _Tp >::operator() ( Point  pt)

◆ operator()() [17/17]

template<typename _Tp>
const _Tp& cv::Mat_< _Tp >::operator() ( Point  pt) const

◆ operator=() [1/6]

template<typename _Tp>
Mat_& cv::Mat_< _Tp >::operator= ( const Mat m)

◆ operator=() [2/6]

template<typename _Tp>
Mat_& cv::Mat_< _Tp >::operator= ( const Mat_< _Tp > &  m)

◆ operator=() [3/6]

template<typename _Tp>
Mat_& cv::Mat_< _Tp >::operator= ( const _Tp &  s)

set all the elements to s.

◆ operator=() [4/6]

template<typename _Tp>
Mat_& cv::Mat_< _Tp >::operator= ( const MatExpr e)

assign a matrix expression

◆ operator=() [5/6]

template<typename _Tp>
Mat_& cv::Mat_< _Tp >::operator= ( Mat_< _Tp > &&  m)

◆ operator=() [6/6]

template<typename _Tp>
Mat_& cv::Mat_< _Tp >::operator= ( Mat &&  m)

◆ operator[]() [1/2]

template<typename _Tp>
_Tp* cv::Mat_< _Tp >::operator[] ( int  y)

more convenient forms of row and element access operators

◆ operator[]() [2/2]

template<typename _Tp>
const _Tp* cv::Mat_< _Tp >::operator[] ( int  y) const

◆ pop_back()

void cv::Mat::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
nelemsNumber of removed rows. If it is greater than the total number of rows, an exception is thrown.

◆ ptr() [1/20]

uchar* cv::Mat::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
i0A 0-based row index.
Examples:
samples/cpp/image_alignment.cpp, samples/cpp/train_HOG.cpp, samples/dnn/colorization.cpp, samples/dnn/openpose.cpp, samples/dnn/segmentation.cpp, and samples/dnn/text_detection.cpp.

Referenced by cv::flann::GenericIndex< Distance >::getIndexParameters(), cv::dnn::getPlane(), cv::flann::hierarchicalClustering(), cv::flann::Index_< T >::Index_(), cv::flann::Index_< T >::knnSearch(), and cv::flann::Index_< T >::radiusSearch().

Here is the caller graph for this function:

◆ ptr() [2/20]

const uchar* cv::Mat::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.

◆ ptr() [3/20]

uchar* cv::Mat::ptr ( int  row,
int  col 
)
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rowIndex along the dimension 0
colIndex along the dimension 1

◆ ptr() [4/20]

const uchar* cv::Mat::ptr ( int  row,
int  col 
) 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
rowIndex along the dimension 0
colIndex along the dimension 1

◆ ptr() [5/20]

uchar* cv::Mat::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.

◆ ptr() [6/20]

const uchar* cv::Mat::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.

◆ ptr() [7/20]

uchar* cv::Mat::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.

◆ ptr() [8/20]

const uchar* cv::Mat::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.

◆ ptr() [9/20]

template<int n>
uchar* cv::Mat::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.

◆ ptr() [10/20]

template<int n>
const uchar* cv::Mat::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.

◆ ptr() [11/20]

template<typename _Tp >
_Tp* cv::Mat::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.

◆ ptr() [12/20]

template<typename _Tp >
const _Tp* cv::Mat::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.

◆ ptr() [13/20]

template<typename _Tp >
_Tp* cv::Mat::ptr ( int  row,
int  col 
)
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rowIndex along the dimension 0
colIndex along the dimension 1

◆ ptr() [14/20]

template<typename _Tp >
const _Tp* cv::Mat::ptr ( int  row,
int  col 
) 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
rowIndex along the dimension 0
colIndex along the dimension 1

◆ ptr() [15/20]

template<typename _Tp >
_Tp* cv::Mat::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.

◆ ptr() [16/20]

template<typename _Tp >
const _Tp* cv::Mat::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.

◆ ptr() [17/20]

template<typename _Tp >
_Tp* cv::Mat::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.

◆ ptr() [18/20]

template<typename _Tp >
const _Tp* cv::Mat::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.

◆ ptr() [19/20]

template<typename _Tp , int n>
_Tp* cv::Mat::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.

◆ ptr() [20/20]

template<typename _Tp , int n>
const _Tp* cv::Mat::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.

◆ push_back() [1/4]

template<typename _Tp >
void cv::Mat::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
elemAdded element(s).
Examples:
samples/cpp/create_mask.cpp.

◆ push_back() [2/4]

template<typename _Tp >
void cv::Mat::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
elemAdded element(s).

◆ push_back() [3/4]

template<typename _Tp >
void cv::Mat::push_back ( const std::vector< _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
elemAdded element(s).

◆ push_back() [4/4]

void cv::Mat::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
mAdded line(s).

◆ push_back_()

void cv::Mat::push_back_ ( const void *  elem)
inherited

internal function

◆ release()

template<typename _Tp>
void cv::Mat_< _Tp >::release ( )

equivalent to Mat::release()

◆ reserve()

void cv::Mat::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
szNumber of rows.

◆ reserveBuffer()

void cv::Mat::reserveBuffer ( size_t  sz)
inherited

Reserves space for the certain number of bytes.

The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes, nothing happens. If matrix has to be reallocated its previous content could be lost.

Parameters
szNumber of bytes.

◆ reshape() [1/3]

Mat cv::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
cnNew number of channels. If the parameter is 0, the number of channels remains the same.
rowsNew number of rows. If the parameter is 0, the number of rows remains the same.
Examples:
samples/cpp/pca.cpp, and samples/dnn/classification.cpp.

◆ reshape() [2/3]

Mat cv::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.

◆ reshape() [3/3]

Mat cv::Mat::reshape ( int  cn,
const std::vector< int > &  newshape 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ resize() [1/2]

void cv::Mat::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
szNew number of rows.

◆ resize() [2/2]

void cv::Mat::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
szNew number of rows.
sValue assigned to the newly added elements.

◆ row()

template<typename _Tp>
Mat_ cv::Mat_< _Tp >::row ( int  y) const

overridden forms of Mat::row() etc.

◆ rowRange() [1/2]

Mat cv::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
startrowAn inclusive 0-based start index of the row span.
endrowAn exclusive 0-based ending index of the row span.
Examples:
samples/cpp/kmeans.cpp, and samples/dnn/segmentation.cpp.

◆ rowRange() [2/2]

Mat cv::Mat::rowRange ( const Range r) 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
rRange structure containing both the start and the end indices.

◆ setDefaultAllocator()

static void cv::Mat::setDefaultAllocator ( MatAllocator allocator)
staticinherited

◆ setTo()

Mat& cv::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
valueAssigned scalar converted to the actual array type.
maskOperation mask of the same size as *this. 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
Examples:
samples/cpp/stitching_detailed.cpp, and samples/dnn/segmentation.cpp.

◆ step1()

template<typename _Tp>
size_t cv::Mat_< _Tp >::step1 ( int  i = 0) const

◆ stepT()

template<typename _Tp>
size_t cv::Mat_< _Tp >::stepT ( int  i = 0) const

returns step()/sizeof(_Tp)

◆ t()

MatExpr cv::Mat::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:

Mat A1 = A + Mat::eye(A.size(), A.type())*lambda;
Mat C = A1.t()*A1; // compute (A + lambda*I)^t * (A + lamda*I)
Examples:
samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp, and samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp.

Referenced by cv::cv2eigen().

Here is the caller graph for this function:

◆ total() [1/2]

size_t cv::Mat::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).

Examples:
samples/cpp/train_HOG.cpp.

◆ total() [2/2]

size_t cv::Mat::total ( int  startDim,
int  endDim = INT_MAX 
) const
inherited

Returns the total number of array elements.

The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim

◆ type()

template<typename _Tp>
int cv::Mat_< _Tp >::type ( ) const

◆ updateContinuityFlag()

void cv::Mat::updateContinuityFlag ( )
inherited

internal use method: updates the continuity flag

◆ zeros() [1/6]

static MatExpr cv::Mat::zeros ( int  rows,
int  cols,
int  type 
)
staticinherited

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
rowsNumber of rows.
colsNumber of columns.
typeCreated matrix type.
Examples:
samples/cpp/camshiftdemo.cpp, samples/cpp/contours2.cpp, samples/cpp/falsecolor.cpp, samples/cpp/fitellipse.cpp, samples/cpp/kalman.cpp, samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp, samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_2.cpp, and samples/dnn/segmentation.cpp.

◆ zeros() [2/6]

static MatExpr cv::Mat::zeros ( Size  size,
int  type 
)
staticinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
sizeAlternative to the matrix size specification Size(cols, rows) .
typeCreated matrix type.

◆ zeros() [3/6]

static MatExpr cv::Mat::zeros ( int  ndims,
const int *  sz,
int  type 
)
staticinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
ndimsArray dimensionality.
szArray of integers specifying the array shape.
typeCreated matrix type.

◆ zeros() [4/6]

template<typename _Tp>
static MatExpr cv::Mat_< _Tp >::zeros ( int  rows,
int  cols 
)
static

overridden forms of Mat::zeros() etc. Data type is omitted, of course

Examples:
samples/cpp/filestorage.cpp.

◆ zeros() [5/6]

template<typename _Tp>
static MatExpr cv::Mat_< _Tp >::zeros ( Size  size)
static

◆ zeros() [6/6]

template<typename _Tp>
static MatExpr cv::Mat_< _Tp >::zeros ( int  _ndims,
const int *  _sizes 
)
static

Member Data Documentation

◆ allocator

MatAllocator* cv::Mat::allocator
inherited

custom allocator

◆ cols

◆ data

◆ dataend

const uchar* cv::Mat::dataend
inherited

◆ datalimit

const uchar* cv::Mat::datalimit
inherited

◆ datastart

const uchar* cv::Mat::datastart
inherited

helper fields used in locateROI and adjustROI

◆ dims

int cv::Mat::dims
inherited

the matrix dimensionality, >= 2

Examples:
samples/dnn/text_detection.cpp.

Referenced by cv::dnn::getPlane(), cv::dnn::shape(), and cv::dnn::slice().

◆ flags

int cv::Mat::flags
inherited

includes several bit-fields:

  • the magic signature
  • continuity flag
  • depth
  • number of channels

◆ rows

◆ size

◆ step

MatStep cv::Mat::step
inherited

Referenced by cv::to_own().

◆ u

UMatData* cv::Mat::u
inherited

interaction with UMat


The documentation for this class was generated from the following file: