OpenCV  5.0.0-pre
Open Source Computer Vision
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
cv::Mat_< _Tp > Class Template Reference

Template matrix class derived from Mat. More...

#include <opencv2/core/mat.hpp>

Collaboration diagram for cv::Mat_< _Tp >:

Public Types

typedef DataType< _Tp >::channel_type channel_type
 
typedef MatConstIterator_< _Tpconst_iterator
 
typedef MatIterator_< _Tpiterator
 
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_ () CV_NOEXCEPT
 default constructor
 
 Mat_ (const Mat &m)
 copy/conversion constructor. If m is of different type, it's converted
 
 Mat_ (const Mat_ &m)
 copy constructor
 
 Mat_ (const Mat_ &m, const Range &rowRange, const Range &colRange=Range::all())
 selects a submatrix
 
 Mat_ (const Mat_ &m, const Range *ranges)
 selects a submatrix, n-dim version
 
 Mat_ (const Mat_ &m, const Rect &roi)
 selects a submatrix
 
 Mat_ (const Mat_ &m, const std::vector< Range > &ranges)
 selects a submatrix, n-dim version
 
 Mat_ (const MatCommaInitializer_< _Tp > &commaInitializer)
 
 Mat_ (const MatExpr &e)
 from a matrix expression
 
template<int m, int n>
 Mat_ (const Matx< typename DataType< _Tp >::channel_type, m, n > &mtx, bool copyData=true)
 
 Mat_ (const Point3_< typename DataType< _Tp >::channel_type > &pt, bool copyData=true)
 
 Mat_ (const Point_< typename DataType< _Tp >::channel_type > &pt, bool copyData=true)
 
template<std::size_t _Nm>
 Mat_ (const std::array< _Tp, _Nm > &arr, bool copyData=false)
 
 Mat_ (const std::initializer_list< int > sizes, const std::initializer_list< _Tp > values)
 
 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
 
template<int n>
 Mat_ (const Vec< typename DataType< _Tp >::channel_type, n > &vec, bool copyData=true)
 
 Mat_ (int _ndims, const int *_sizes)
 n-dim array constructor
 
 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_ (int _ndims, const int *_sizes, const _Tp &value)
 n-dim array constructor that sets each matrix element to specified value
 
 Mat_ (int _rows, int _cols)
 equivalent to Mat(_rows, _cols, DataType<_Tp>::type)
 
 Mat_ (int _rows, int _cols, _Tp *_data, size_t _step=AUTO_STEP)
 constructs a matrix on top of user-allocated data. step is in bytes(!!!), regardless of the type
 
 Mat_ (int _rows, int _cols, const _Tp &value)
 constructor that sets each matrix element to specified value
 
 Mat_ (Mat &&m)
 
 Mat_ (Mat_ &&m)
 
 Mat_ (MatExpr &&e)
 
 Mat_ (Size _size)
 equivalent to Mat(_size, DataType<_Tp>::type)
 
 Mat_ (Size _size, const _Tp &value)
 constructor that sets each matrix element to specified value
 
 Mat_ (std::initializer_list< _Tp > values)
 
Mat_adjustROI (int dtop, int dbottom, int dleft, int dright)
 some more overridden methods
 
iterator begin ()
 iterators; they are smart enough to skip gaps in the end of rows
 
const_iterator begin () const
 
int channels () const
 
CV_NODISCARD_STD Mat_ clone () const
 
Mat_ col (int x) const
 
void create (int _ndims, const int *_sizes)
 equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type)
 
void create (int _rows, int _cols)
 equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type)
 
void create (Size _size)
 equivalent to Mat::create(_size, DataType<_Tp>::type)
 
void createSameSize (InputArray arr)
 equivalent to Mat::create(arr.ndims, arr.size.p, DatType<_Tp>::type)
 
Mat_ cross (const Mat_ &m) const
 cross-product
 
int depth () const
 
Mat_ diag (int d=0) const
 
size_t elemSize () const
 overridden forms of Mat::elemSize() etc.
 
size_t elemSize1 () const
 
iterator end ()
 
const_iterator end () const
 
template<typename Functor >
void forEach (const Functor &operation)
 template methods for operation over all matrix elements.
 
template<typename Functor >
void forEach (const Functor &operation) const
 
template<typename T2 >
 operator Mat_< T2 > () const
 data type conversion
 
template<int m, int n>
 operator Matx< typename DataType< _Tp >::channel_type, m, n > () const
 conversion to Matx
 
template<std::size_t _Nm>
 operator std::array< _Tp, _Nm > () const
 conversion to array.
 
 operator std::vector< _Tp > () const
 conversion to vector.
 
template<int n>
 operator Vec< typename DataType< _Tp >::channel_type, n > () const
 conversion to Vec
 
_Tpoperator() (const int *idx)
 returns reference to the specified element
 
const _Tpoperator() (const int *idx) const
 returns read-only reference to the specified element
 
Mat_ operator() (const Range &rowRange, const Range &colRange) const
 
Mat_ operator() (const Range *ranges) const
 
Mat_ operator() (const Rect &roi) const
 
Mat_ operator() (const std::vector< Range > &ranges) const
 
template<int n>
_Tpoperator() (const Vec< int, n > &idx)
 returns reference to the specified element
 
template<int n>
const _Tpoperator() (const Vec< int, n > &idx) const
 returns read-only reference to the specified element
 
_Tpoperator() (int idx0)
 returns reference to the specified element (1D case)
 
const _Tpoperator() (int idx0) const
 returns read-only reference to the specified element (1D case)
 
_Tpoperator() (int idx0, int idx1, int idx2)
 returns reference to the specified element (3D case)
 
const _Tpoperator() (int idx0, int idx1, int idx2) const
 returns read-only reference to the specified element (3D case)
 
_Tpoperator() (int row, int col)
 returns reference to the specified element (2D case)
 
const _Tpoperator() (int row, int col) const
 returns read-only reference to the specified element (2D case)
 
_Tpoperator() (Point pt)
 
const _Tpoperator() (Point pt) const
 
Mat_operator= (const _Tp &s)
 set all the elements to s.
 
Mat_operator= (const Mat &m)
 
Mat_operator= (const Mat_ &m)
 
Mat_operator= (const MatExpr &e)
 assign a matrix expression
 
Mat_operator= (Mat &&m)
 
Mat_operator= (Mat_ &&m)
 
_Tpoperator[] (int y)
 more convenient forms of row and element access operators
 
const _Tpoperator[] (int y) const
 
std::reverse_iterator< iteratorrbegin ()
 
std::reverse_iterator< const_iteratorrbegin () const
 
void release ()
 equivalent to Mat::release()
 
std::reverse_iterator< iteratorrend ()
 
std::reverse_iterator< const_iteratorrend () const
 
Mat_ row (int y) const
 overridden forms of Mat::row() etc.
 
size_t step1 (int i=0) const
 
size_t stepT (int i=0) const
 returns step()/sizeof(_Tp)
 
int type () const
 
- Public Member Functions inherited from cv::Mat
 Mat () CV_NOEXCEPT
 
 Mat (const cuda::GpuMat &m)
 download data from GpuMat
 
 Mat (const Mat &m)
 
 Mat (const Mat &m, const Range &rowRange, const Range &colRange=Range::all())
 
 Mat (const Mat &m, const Range *ranges)
 
 Mat (const Mat &m, const Rect &roi)
 
 Mat (const Mat &m, const std::vector< Range > &ranges)
 
template<typename _Tp >
 Mat (const MatCommaInitializer_< _Tp > &commaInitializer)
 
 Mat (const MatShape &shape, int type)
 
 Mat (const MatShape &shape, int type, const Scalar &s)
 
 Mat (const MatShape &shape, int type, void *data, const size_t *steps=0)
 
template<typename _Tp , int m, int n>
 Mat (const Matx< _Tp, m, n > &mtx, bool copyData=true)
 
template<typename _Tp >
 Mat (const Point3_< _Tp > &pt, bool copyData=true)
 
template<typename _Tp >
 Mat (const Point_< _Tp > &pt, bool copyData=true)
 
template<typename _Tp , size_t _Nm>
 Mat (const std::array< _Tp, _Nm > &arr, bool copyData=false)
 
template<typename _Tp , typename = typename std::enable_if<std::is_arithmetic<_Tp>::value>::type>
 Mat (const std::initializer_list< _Tp > list)
 
template<typename _Tp >
 Mat (const std::initializer_list< int > sizes, const std::initializer_list< _Tp > list)
 
template<typename _Tp >
 Mat (const std::vector< _Tp > &vec, bool copyData=false)
 
 Mat (const std::vector< int > &sizes, int type)
 
 Mat (const std::vector< int > &sizes, int type, const Scalar &s)
 
 Mat (const std::vector< int > &sizes, int type, void *data, const size_t *steps=0)
 
template<typename _Tp , int n>
 Mat (const Vec< _Tp, n > &vec, bool copyData=true)
 
 Mat (int ndims, const int *sizes, int type)
 
 Mat (int ndims, const int *sizes, int type, const Scalar &s)
 
 Mat (int ndims, const int *sizes, int type, void *data, const size_t *steps=0)
 
 Mat (int rows, int cols, int type)
 
 Mat (int rows, int cols, int type, const Scalar &s)
 
 Mat (int rows, int cols, int type, void *data, size_t step=AUTO_STEP)
 
 Mat (Mat &&m) CV_NOEXCEPT
 
 Mat (Size size, int type)
 
 Mat (Size size, int type, const Scalar &s)
 
 Mat (Size size, int type, void *data, size_t step=AUTO_STEP)
 
 Mat (std::initializer_list< int > shape, int type)
 
 Mat (std::initializer_list< int > shape, int type, const Scalar &s)
 
 Mat (std::initializer_list< int > shape, int type, void *data, const size_t *steps=0)
 
 ~Mat ()
 destructor - calls release()
 
void addref ()
 Increments the reference counter.
 
MatadjustROI (int dtop, int dbottom, int dleft, int dright)
 Adjusts a submatrix size and position within the parent matrix.
 
void assignTo (Mat &m, int type=-1) const
 Provides a functional form of convertTo.
 
template<typename _Tp >
_Tpat (const int *idx)
 
template<typename _Tp >
const _Tpat (const int *idx) const
 
template<typename _Tp , int n>
_Tpat (const Vec< int, n > &idx)
 
template<typename _Tp , int n>
const _Tpat (const Vec< int, n > &idx) const
 
template<typename _Tp >
_Tpat (int i0, int i1, int i2)
 
template<typename _Tp >
const _Tpat (int i0, int i1, int i2) const
 
template<typename _Tp >
_Tpat (int i0=0)
 Returns a reference to the specified array element.
 
template<typename _Tp >
const _Tpat (int i0=0) const
 
template<typename _Tp >
_Tpat (int row, int col)
 
template<typename _Tp >
const _Tpat (int row, int col) const
 
template<typename _Tp >
_Tpat (Point pt)
 
template<typename _Tp >
const _Tpat (Point pt) const
 
template<typename _Tp >
MatIterator_< _Tpbegin ()
 Returns the matrix iterator and sets it to the first matrix element.
 
template<typename _Tp >
MatConstIterator_< _Tpbegin () const
 
int channels () const
 Returns the number of matrix channels.
 
int checkVector (int elemChannels, int depth=-1, bool requireContinuous=true) const
 
CV_NODISCARD_STD Mat clone () const
 Creates a full copy of the array and the underlying data.
 
Mat col (int x) const
 Creates a matrix header for the specified matrix column.
 
Mat colRange (const Range &r) const
 
Mat colRange (int startcol, int endcol) const
 Creates a matrix header for the specified column span.
 
void convertTo (OutputArray m, int rtype, double alpha=1, double beta=0) const
 Converts an array to another data type with optional scaling.
 
void copySize (const Mat &m)
 internal use function; properly re-allocates _size, _step arrays
 
void copyTo (OutputArray m) const
 Copies the matrix to another one.
 
void copyTo (OutputArray m, InputArray mask) const
 
void create (const MatShape &shape, int type)
 
void create (const std::vector< int > &sizes, int type)
 
void create (int ndims, const int *sizes, int type)
 
void create (int rows, int cols, int type)
 Allocates new array data if needed.
 
void create (Size size, int type)
 
void create (std::initializer_list< int > shape, int type)
 
void createSameSize (InputArray arr, int type)
 Creates the matrix of the same size as another array.
 
Mat cross (InputArray m) const
 Computes a cross-product of two 3-element vectors.
 
void deallocate ()
 internal use function, consider to use 'release' method instead; deallocates the matrix data
 
int depth () const
 Returns the depth of a matrix element.
 
Mat diag (int d=0) const
 Extracts a diagonal from a matrix.
 
double dot (InputArray m) const
 Computes a dot-product of two vectors.
 
size_t elemSize () const
 Returns the matrix element size in bytes.
 
size_t elemSize1 () const
 Returns the size of each matrix element channel in bytes.
 
bool empty () const
 Returns true if the array has no elements.
 
template<typename _Tp >
MatIterator_< _Tpend ()
 Returns the matrix iterator and sets it to the after-last matrix element.
 
template<typename _Tp >
MatConstIterator_< _Tpend () const
 
void fit (const MatShape &shape, int type)
 
void fit (const std::vector< int > &sizes, int type)
 
void fit (int ndims, const int *sizes, int type)
 
void fit (int rows, int cols, int type)
 Similar to create(rows, cols, type), but only reallocates memory if the existing buffer size is not enough.
 
void fit (Size size, int type)
 
void fit (std::initializer_list< int > shape, int type)
 
void fitSameSize (InputArray arr, int type)
 Similar to createSameSize(arr, type), but only reallocates memory if the existing buffer is not enough.
 
template<typename _Tp , typename Functor >
void forEach (const Functor &operation)
 Runs the given functor over all matrix elements in parallel.
 
template<typename _Tp , typename Functor >
void forEach (const Functor &operation) const
 
UMat getUMat (AccessFlag accessFlags, UMatUsageFlags usageFlags=USAGE_DEFAULT) const
 retrieve UMat from Mat
 
MatExpr inv (int method=DECOMP_LU) const
 Inverses a matrix.
 
bool isContinuous () const
 Reports whether the matrix is continuous or not.
 
bool isSubmatrix () const
 returns true if the matrix is a submatrix of another matrix
 
void locateROI (Size &wholeSize, Point &ofs) const
 Locates the matrix header within a parent matrix.
 
MatExpr mul (InputArray m, double scale=1) const
 Performs an element-wise multiplication or division of the two matrices.
 
template<typename _Tp , int m, int n>
 operator Matx< _Tp, m, n > () const
 
template<typename _Tp , std::size_t _Nm>
 operator std::array< _Tp, _Nm > () const
 
template<typename _Tp >
 operator std::vector< _Tp > () const
 
template<typename _Tp , int n>
 operator Vec< _Tp, n > () const
 
Mat operator() (const Range *ranges) const
 
Mat operator() (const Rect &roi) const
 
Mat operator() (const std::vector< Range > &ranges) const
 
Mat operator() (Range rowRange, Range colRange) const
 Extracts a rectangular submatrix.
 
Matoperator= (const Mat &m)
 assignment operators
 
Matoperator= (const MatExpr &expr)
 
Matoperator= (const Scalar &s)
 Sets all or some of the array elements to the specified value.
 
Matoperator= (Mat &&m)
 
void pop_back (size_t nelems=1)
 Removes elements from the bottom of the matrix.
 
ucharptr (const int *idx)
 
template<typename _Tp >
_Tpptr (const int *idx)
 
const ucharptr (const int *idx) const
 
template<typename _Tp >
const _Tpptr (const int *idx) const
 
template<int n>
ucharptr (const Vec< int, n > &idx)
 
template<typename _Tp , int n>
_Tpptr (const Vec< int, n > &idx)
 
template<int n>
const ucharptr (const Vec< int, n > &idx) const
 
template<typename _Tp , int n>
const _Tpptr (const Vec< int, n > &idx) const
 
ucharptr (int i0, int i1, int i2)
 
template<typename _Tp >
_Tpptr (int i0, int i1, int i2)
 
const ucharptr (int i0, int i1, int i2) const
 
template<typename _Tp >
const _Tpptr (int i0, int i1, int i2) const
 
ucharptr (int i0=0)
 Returns a pointer to the specified matrix row.
 
template<typename _Tp >
_Tpptr (int i0=0)
 
const ucharptr (int i0=0) const
 
template<typename _Tp >
const _Tpptr (int i0=0) const
 
ucharptr (int row, int col)
 
template<typename _Tp >
_Tpptr (int row, int col)
 
const ucharptr (int row, int col) const
 
template<typename _Tp >
const _Tpptr (int row, int col) const
 
template<typename _Tp >
void push_back (const _Tp &elem)
 Adds elements to the bottom of the matrix.
 
void push_back (const Mat &m)
 
template<typename _Tp >
void push_back (const Mat_< _Tp > &elem)
 
template<typename _Tp >
void push_back (const std::vector< _Tp > &elem)
 
void push_back_ (const void *elem)
 internal function
 
template<typename _Tp >
std::reverse_iterator< MatIterator_< _Tp > > rbegin ()
 Same as begin() but for inverse traversal.
 
template<typename _Tp >
std::reverse_iterator< MatConstIterator_< _Tp > > rbegin () const
 
void release ()
 Decrements the reference counter and deallocates the matrix if needed.
 
template<typename _Tp >
std::reverse_iterator< MatIterator_< _Tp > > rend ()
 Same as end() but for inverse traversal.
 
template<typename _Tp >
std::reverse_iterator< MatConstIterator_< _Tp > > rend () const
 
void reserve (size_t sz)
 Reserves space for the certain number of rows.
 
void reserveBuffer (size_t sz)
 Reserves space for the certain number of bytes.
 
Mat reshape (int cn, const MatShape &newshape) const
 
Mat reshape (int cn, const std::vector< int > &newshape) const
 
Mat reshape (int cn, int newndims, const int *newsz) const
 
Mat reshape (int cn, int rows=0) const
 Changes the shape and/or the number of channels of a 2D matrix without copying the data.
 
Mat reshape (int cn, std::initializer_list< int > newshape) const
 
void resize (size_t sz)
 Changes the number of matrix rows.
 
void resize (size_t sz, const Scalar &s)
 
Mat row (int y) const
 Creates a matrix header for the specified matrix row.
 
Mat rowRange (const Range &r) const
 
Mat rowRange (int startrow, int endrow) const
 Creates a matrix header for the specified row span.
 
MatsetTo (InputArray value, InputArray mask=noArray())
 Sets all or some of the array elements to the specified value.
 
MatsetZero ()
 Sets all the array elements to 0.
 
MatShape shape () const
 Returns the shape.
 
size_t step1 (int i=0) const
 Returns a normalized step.
 
MatExpr t () const
 Transposes a matrix.
 
size_t total () const
 Returns the total number of array elements.
 
size_t total (int startDim, int endDim=INT_MAX) const
 Returns the total number of array elements.
 
int type () const
 Returns the type of a matrix element.
 
void updateContinuityFlag ()
 internal use method: updates the continuity flag
 

Static Public Member Functions

static CV_NODISCARD_STD MatExpr eye (int rows, int cols)
 
static CV_NODISCARD_STD MatExpr eye (Size size)
 
static CV_NODISCARD_STD MatExpr ones (int _ndims, const int *_sizes)
 
static CV_NODISCARD_STD MatExpr ones (int rows, int cols)
 
static CV_NODISCARD_STD MatExpr ones (Size size)
 
static CV_NODISCARD_STD MatExpr zeros (int _ndims, const int *_sizes)
 
static CV_NODISCARD_STD MatExpr zeros (int rows, int cols)
 overridden forms of Mat::zeros() etc. Data type is omitted, of course
 
static CV_NODISCARD_STD MatExpr zeros (Size size)
 
- Static Public Member Functions inherited from cv::Mat
static CV_NODISCARD_STD Mat diag (const Mat &d)
 creates a diagonal matrix
 
static CV_NODISCARD_STD MatExpr eye (int rows, int cols, int type)
 Returns an identity matrix of the specified size and type.
 
static CV_NODISCARD_STD MatExpr eye (Size size, int type)
 
static MatAllocatorgetDefaultAllocator ()
 
static MatAllocatorgetStdAllocator ()
 and the standard allocator
 
static CV_NODISCARD_STD MatExpr ones (int ndims, const int *sz, int type)
 
static CV_NODISCARD_STD MatExpr ones (int rows, int cols, int type)
 Returns an array of all 1's of the specified size and type.
 
static CV_NODISCARD_STD MatExpr ones (Size size, int type)
 
static void setDefaultAllocator (MatAllocator *allocator)
 
static CV_NODISCARD_STD MatExpr zeros (int ndims, const int *sz, int type)
 
static CV_NODISCARD_STD MatExpr zeros (int rows, int cols, int type)
 Returns a zero array of the specified size and type.
 
static CV_NODISCARD_STD MatExpr zeros (Size size, int type)
 

Additional Inherited Members

- Public Attributes inherited from cv::Mat
MatAllocatorallocator
 custom allocator
 
int cols
 
uchardata
 pointer to the data
 
const uchardataend
 
const uchardatalimit
 
const uchardatastart
 helper fields used in locateROI and adjustROI
 
int dims
 the matrix dimensionality, >= 2
 
int dummy = 153
 
int flags
 
int rows
 the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
 
MatSize size
 
MatStep step
 
UMatDatau
 interaction with UMat
 
- Protected Member Functions inherited from cv::Mat
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
};
Template matrix class derived from Mat.
Definition mat.hpp:2517
n-dimensional dense array class
Definition mat.hpp:950

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.
// the program is likely to crash at the statement below
M1(99,99) = 1.f;
#define CV_8U
Definition interface.h:76

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);
_Tp & at(int i0=0)
Returns a reference to the specified array element.
bool eigen(InputArray src, OutputArray eigenvalues, OutputArray eigenvectors=noArray())
Calculates eigenvalues and eigenvectors of a symmetric matrix.

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);
Vec< uchar, 3 > Vec3b
Definition matx.hpp:451
unsigned char uchar
Definition interface.h:51

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];
}
}
Examples
samples/cpp/image_alignment.cpp, samples/cpp/snippets/kalman.cpp, samples/cpp/stitching_detailed.cpp, samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp, samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp, samples/cpp/tutorial_code/features/Homography/decompose_homography.cpp, samples/cpp/tutorial_code/features/Homography/homography_from_camera_displacement.cpp, samples/cpp/tutorial_code/features/Homography/pose_from_homography.cpp, and samples/dnn/object_detection.cpp.

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

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

◆ adjustROI()

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

some more overridden methods

◆ 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

◆ clone()

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

◆ col()

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

◆ create() [1/3]

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

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

◆ create() [2/3]

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

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

◆ create() [3/3]

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

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

◆ createSameSize()

template<typename _Tp >
void cv::Mat_< _Tp >::createSameSize ( InputArray  arr)

equivalent to Mat::create(arr.ndims, arr.size.p, DatType<_Tp>::type)

◆ cross()

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

cross-product

◆ depth()

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

◆ diag()

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

◆ 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

◆ 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/2]

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

◆ eye() [2/2]

template<typename _Tp >
static CV_NODISCARD_STD 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 operation over all matrix elements.

◆ forEach() [2/2]

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

◆ ones() [1/3]

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

◆ ones() [2/3]

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

◆ ones() [3/3]

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

◆ operator Mat_< T2 >()

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

data type conversion

◆ 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< 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/16]

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

returns reference to the specified element

◆ operator()() [2/16]

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

returns read-only reference to the specified element

◆ operator()() [3/16]

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

◆ operator()() [4/16]

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

◆ operator()() [5/16]

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

◆ operator()() [6/16]

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

◆ operator()() [7/16]

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

returns reference to the specified element

◆ operator()() [8/16]

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()() [9/16]

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

returns reference to the specified element (1D case)

◆ operator()() [10/16]

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

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

◆ operator()() [11/16]

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

returns reference to the specified element (3D case)

◆ operator()() [12/16]

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()() [13/16]

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

returns reference to the specified element (2D case)

◆ operator()() [14/16]

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()() [15/16]

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

◆ operator()() [16/16]

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

◆ operator=() [1/6]

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

set all the elements to s.

◆ operator=() [2/6]

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

◆ operator=() [3/6]

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

◆ 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 &&  m)

◆ operator=() [6/6]

template<typename _Tp >
Mat_ & cv::Mat_< _Tp >::operator= ( Mat_< _Tp > &&  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

◆ rbegin() [1/2]

template<typename _Tp >
std::reverse_iterator< iterator > cv::Mat_< _Tp >::rbegin ( )

◆ rbegin() [2/2]

template<typename _Tp >
std::reverse_iterator< const_iterator > cv::Mat_< _Tp >::rbegin ( ) const

◆ release()

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

equivalent to Mat::release()

◆ rend() [1/2]

template<typename _Tp >
std::reverse_iterator< iterator > cv::Mat_< _Tp >::rend ( )

◆ rend() [2/2]

template<typename _Tp >
std::reverse_iterator< const_iterator > cv::Mat_< _Tp >::rend ( ) const

◆ row()

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

overridden forms of Mat::row() etc.

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

◆ type()

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

◆ zeros() [1/3]

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

◆ zeros() [2/3]

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

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

◆ zeros() [3/3]

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

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