Class cv::Mat_#
Template matrix class derived from Mat. View details
#include <opencv2/core/mat.hpp>Collaboration diagram for cv::Mat_:
Public Types#
Public Member Functions#
Public Member Functions inherited from cv::Mat
Return |
Name |
Description |
|---|---|---|
download data from GpuMat |
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
destructor - calls release() |
||
|
Increments the reference counter. |
|
|
Adjusts a submatrix size and position within the parent matrix. |
|
|
Provides a functional form of convertTo. |
|
|
||
|
||
|
||
|
||
|
||
|
||
|
Returns a reference to the specified array element. |
|
|
||
|
||
|
||
|
||
|
||
|
Returns the matrix iterator and sets it to the first matrix element. |
|
|
||
|
Returns the number of matrix channels. |
|
|
|
|
|
Creates a full copy of the array and the underlying data. |
|
Creates a matrix header for the specified matrix column. |
||
Creates a matrix header for the specified column span. |
||
|
|
Converts an array to another data type with optional scaling. |
|
Overwrites the existing matrix. |
|
|
||
|
internal use function; properly re-allocates _size, _step arrays |
|
|
Copies the matrix to another one. |
|
|
||
|
||
|
||
|
||
|
Allocates new array data if needed. |
|
|
||
|
||
|
Creates the matrix of the same size as another array. |
|
Computes a cross-product of two 3-element vectors. |
||
|
internal use function, consider to use ‘release’ method instead; deallocates the matrix data |
|
|
Returns the depth of a matrix element. |
|
Extracts a diagonal from a matrix. |
||
|
Computes a dot-product of two vectors. |
|
|
Returns the matrix element size in bytes. |
|
|
Returns the size of each matrix element channel in bytes. |
|
|
Returns true if the array has no elements. |
|
|
Returns the matrix iterator and sets it to the after-last matrix element. |
|
|
||
|
||
|
||
|
||
|
Similar to create(rows, cols, type), but only reallocates memory if the existing buffer size is not enough. |
|
|
||
|
||
|
Similar to createSameSize(arr, type), but only reallocates memory if the existing buffer is not enough. |
|
|
Runs the given functor over all matrix elements in parallel. |
|
|
||
|
retrieve UMat from Mat |
|
Inverses a matrix. |
||
|
Reports whether the matrix is continuous or not. |
|
|
returns true if the matrix is a submatrix of another matrix |
|
|
Locates the matrix header within a parent matrix. |
|
Performs an element-wise multiplication or division of the two matrices. |
||
Extracts a rectangular submatrix. |
||
|
assignment operators |
|
|
||
|
Sets all or some of the array elements to the specified value. |
|
|
||
|
Removes elements from the bottom of the matrix. |
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Returns a pointer to the specified matrix row. |
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Adds elements to the bottom of the matrix. |
|
|
||
|
||
|
||
|
internal function |
|
|
Same as begin() but for inverse traversal. |
|
|
||
Reset the type of matrix. |
||
|
Decrements the reference counter and deallocates the matrix if needed. |
|
|
Same as end() but for inverse traversal. |
|
|
||
|
Reserves space for the certain number of rows. |
|
|
Reserves space for the certain number of bytes. |
|
Changes the shape and/or the number of channels of a 2D matrix without copying the data. |
||
|
Changes the number of matrix rows. |
|
|
||
Creates a matrix header for the specified matrix row. |
||
Creates a matrix header for the specified row span. |
||
|
Sets all or some of the array elements to the specified value. |
|
|
Sets all the array elements to 0. |
|
Returns the shape. |
||
|
Returns a normalized step. |
|
Transposes a matrix. |
||
|
Returns the total number of array elements. |
|
|
Returns the total number of array elements. |
|
|
Returns the type of a matrix element. |
|
|
internal use method: updates the continuity flag |
Static Public Member Functions#
Static Public Member Functions inherited from cv::Mat
Return |
Name |
Description |
|---|---|---|
|
creates a diagonal matrix |
|
|
Returns an identity matrix of the specified size and type. |
|
|
||
|
||
|
and the standard allocator |
|
|
||
|
||
|
Returns an array of all 1’s of the specified size and type. |
|
|
||
|
||
|
||
|
||
|
Returns a zero array of the specified size and type. |
|
|
Public Attributes#
Public Attributes inherited from cv::Mat
Return |
Name |
Description |
|---|---|---|
custom allocator |
||
|
||
|
pointer to the data |
|
|
||
|
||
|
helper fields used in locateROI and adjustROI |
|
|
the matrix dimensionality, >= 2 |
|
|
||
|
||
|
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions |
|
|
||
|
||
|
interaction with UMat |
Detailed Description#
Template matrix class derived from Mat.
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: 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: // 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);
- Examples
- samples/cpp/image_alignment.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, and samples/cpp/tutorial_code/features/Homography/pose_from_homography.cpp.
Member Typedef Documentation#
channel_type#
typedef DataType< Tp >::channel_type cv::Mat::channel_type
const_iterator#
typedef MatConstIterator_< Tp > cv::Mat::const_iterator
iterator#
typedef MatIterator_< Tp > cv::Mat::iterator
value_type#
typedef Tp cv::Mat::value_type
Constructor & Destructor Documentation#
Mat_()#
default constructor
Mat_()#
copy/conversion constructor. If m is of different type, it’s converted
Mat_()#
cv::Mat_::Mat_(const Mat_ & m)
copy constructor
Mat_()#
cv::Mat_::Mat_(
const Mat_ & m,
const Range & rowRange,
const Range & colRange = Range::all() )
selects a submatrix
Mat_()#
cv::Mat_::Mat_(
const Mat_ & m,
const Range * ranges )
selects a submatrix, n-dim version
Mat_()#
cv::Mat_::Mat_(
const Mat_ & m,
const Rect & roi )
selects a submatrix
Mat_()#
cv::Mat_::Mat_(
const Mat_ & m,
const std::vector< Range > & ranges )
selects a submatrix, n-dim version
Mat_()#
cv::Mat_::Mat_(const MatCommaInitializer_< _Tp > & commaInitializer)
Mat_()#
cv::Mat_::Mat_(const MatExpr & e)
from a matrix expression
Mat_()#
template<int m, int n>
cv::Mat_::Mat_(
const Matx< typename DataType< _Tp >::channel_type, m, n > & mtx,
bool copyData = true )
Mat_()#
cv::Mat_::Mat_(
const Point3_< typename DataType< _Tp >::channel_type > & pt,
bool copyData = true )
Mat_()#
cv::Mat_::Mat_(
const Point_< typename DataType< _Tp >::channel_type > & pt,
bool copyData = true )
Mat_()#
template<std::size_t _Nm>
cv::Mat_::Mat_(
const std::array< _Tp, _Nm > & arr,
bool copyData = false )
Mat_()#
cv::Mat_::Mat_(
const std::initializer_list< int > sizes,
const std::initializer_list< _Tp > values )
Mat_()#
cv::Mat_::Mat_(
const std::vector< _Tp > & vec,
bool copyData = false )
makes a matrix out of Vec, std::vector, Point_ or Point3_. In OpenCV 5.x, from std::vector, creates a matrix with a single row (cols = vector size). (Previous versions: the matrix had a single column.)
Mat_()#
template<int n>
cv::Mat_::Mat_(
const Vec< typename DataType< _Tp >::channel_type, n > & vec,
bool copyData = true )
Mat_()#
cv::Mat_::Mat_(
int _ndims,
const int * _sizes )
n-dim array constructor
Mat_()#
cv::Mat_::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_()#
cv::Mat_::Mat_(
int _ndims,
const int * _sizes,
const _Tp & value )
n-dim array constructor that sets each matrix element to specified value
Mat_()#
cv::Mat_::Mat_(
int _rows,
int _cols )
equivalent to Mat(_rows, _cols, DataType<_Tp>::type)
Mat_()#
cv::Mat_::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_()#
cv::Mat_::Mat_(
int _rows,
int _cols,
const _Tp & value )
constructor that sets each matrix element to specified value
Mat_()#
Mat_()#
Mat_()#
Mat_()#
equivalent to Mat(_size, DataType<_Tp>::type)
Mat_()#
cv::Mat_::Mat_(
Size _size,
const _Tp & value )
constructor that sets each matrix element to specified value
Mat_()#
Member Function Documentation#
adjustROI()#
Mat_ & cv::Mat_::adjustROI(
int dtop,
int dbottom,
int dleft,
int dright )
some more overridden methods
begin()#
iterators; they are smart enough to skip gaps in the end of rows
begin()#
const_iterator cv::Mat_::begin()
channels()#
int cv::Mat_::channels()
clone()#
col()#
create()#
void cv::Mat_::create(
int _ndims,
const int * _sizes )
equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type)
create()#
void cv::Mat_::create(
int _rows,
int _cols )
equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type)
create()#
void cv::Mat_::create(Size _size)
equivalent to Mat::create(_size, DataType<_Tp>::type)
createSameSize()#
void cv::Mat_::createSameSize(InputArray arr)
equivalent to Mat::create(arr.ndims, arr.size.p, DatType<_Tp>::type)
cross()#
Mat_ cv::Mat_::cross(const Mat_ & m)
cross-product
depth()#
int cv::Mat_::depth()
diag()#
elemSize()#
size_t cv::Mat_::elemSize()
overridden forms of Mat::elemSize() etc.
elemSize1()#
size_t cv::Mat_::elemSize1()
end()#
end()#
const_iterator cv::Mat_::end()
forEach()#
template<typename Functor>
void cv::Mat_::forEach(const Functor & operation)
template methods for operation over all matrix elements.
forEach()#
template<typename Functor>
void cv::Mat_::forEach(const Functor & operation)
operator Mat_< T2 >()#
template<typename T2>
cv::Mat_::operator Mat_< T2 >()
data type conversion
operator Matx< typename DataType< _Tp >::channel_type, m, n >()#
template<int m, int n>
cv::Mat_::operator Matx< typename DataType< _Tp >::channel_type, m, n >()
conversion to Matx
operator std::array< _Tp, _Nm >()#
template<std::size_t _Nm>
cv::Mat_::operator std::array< _Tp, _Nm >()
conversion to array.
operator std::vector< _Tp >()#
cv::Mat_::operator std::vector< _Tp >()
conversion to vector.
operator Vec< typename DataType< _Tp >::channel_type, n >()#
template<int n>
cv::Mat_::operator Vec< typename DataType< _Tp >::channel_type, n >()
conversion to Vec
operator()()#
Tp & cv::Mat::operator()(const int * idx)
returns reference to the specified element
operator()()#
const Tp & cv::Mat::operator()(const int * idx)
returns read-only reference to the specified element
operator()()#
Mat_ cv::Mat_::operator()(
const Range & rowRange,
const Range & colRange )
operator()()#
operator()()#
operator()()#
Mat_ cv::Mat_::operator()(const std::vector< Range > & ranges)
operator()()#
template<int n>
Tp & cv::Mat::operator()(const Vec< int, n > & idx)
returns reference to the specified element
operator()()#
template<int n>
const Tp & cv::Mat::operator()(const Vec< int, n > & idx)
returns read-only reference to the specified element
operator()()#
Tp & cv::Mat::operator()(int idx0)
returns reference to the specified element (1D case)
operator()()#
const Tp & cv::Mat::operator()(int idx0)
returns read-only reference to the specified element (1D case)
operator()()#
Tp & cv::Mat::operator()(
int idx0,
int idx1,
int idx2 )
returns reference to the specified element (3D case)
operator()()#
const Tp & cv::Mat::operator()(
int idx0,
int idx1,
int idx2 )
returns read-only reference to the specified element (3D case)
operator()()#
Tp & cv::Mat::operator()(
int row,
int col )
returns reference to the specified element (2D case)
operator()()#
const Tp & cv::Mat::operator()(
int row,
int col )
returns read-only reference to the specified element (2D case)
operator()()#
operator()()#
operator=()#
Mat_ & cv::Mat_::operator=(const _Tp & s)
set all the elements to s.
operator=()#
operator=()#
operator=()#
Mat_ & cv::Mat_::operator=(const MatExpr & e)
assign a matrix expression
operator=()#
operator=()#
operator#
Tp * cv::Mat::operator[](int y)
more convenient forms of row and element access operators
operator#
const Tp * cv::Mat::operator[](int y)
rbegin()#
rbegin()#
std::reverse_iterator< const_iterator > cv::Mat_::rbegin()
release()#
void cv::Mat_::release()
equivalent to Mat::release()
rend()#
rend()#
std::reverse_iterator< const_iterator > cv::Mat_::rend()
row()#
overridden forms of Mat::row() etc.
step1()#
size_t cv::Mat_::step1(int i = 0)
stepT()#
size_t cv::Mat_::stepT(int i = 0)
returns step()/sizeof(_Tp)
type()#
eye()#
static CV_NODISCARD_STD MatExpr cv::Mat_::eye(
int rows,
int cols )
eye()#
ones()#
static CV_NODISCARD_STD MatExpr cv::Mat_::ones(
int _ndims,
const int * _sizes )
ones()#
static CV_NODISCARD_STD MatExpr cv::Mat_::ones(
int rows,
int cols )
ones()#
zeros()#
static CV_NODISCARD_STD MatExpr cv::Mat_::zeros(
int _ndims,
const int * _sizes )
zeros()#
static CV_NODISCARD_STD MatExpr cv::Mat_::zeros(
int rows,
int cols )
overridden forms of Mat::zeros() etc. Data type is omitted, of course
zeros()#
Source file#
The documentation for this class was generated from the following file:
opencv2/core/mat.hpp