#include <core.hpp>
Classes | |
struct | MSize |
struct | MStep |
Public Types | |
enum | { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG } |
Public Member Functions | |
void | addref () |
increases the reference counter; use with care to avoid memleaks | |
Mat & | adjustROI (int dtop, int dbottom, int dleft, int dright) |
moves/resizes the current matrix ROI inside the parent matrix. | |
void | assignTo (Mat &m, int type=-1) const |
template<typename _Tp > | |
const _Tp & | at (Point pt) const |
template<typename _Tp > | |
_Tp & | at (Point pt) |
special versions for 2D arrays (especially convenient for referencing image pixels) | |
template<typename _Tp , int n> | |
const _Tp & | at (const Vec< int, n > &idx) const |
template<typename _Tp , int n> | |
_Tp & | at (const Vec< int, n > &idx) |
template<typename _Tp > | |
const _Tp & | at (const int *idx) const |
template<typename _Tp > | |
_Tp & | at (const int *idx) |
template<typename _Tp > | |
const _Tp & | at (int i0, int i1, int i2) const |
template<typename _Tp > | |
_Tp & | at (int i0, int i1, int i2) |
template<typename _Tp > | |
const _Tp & | at (int i0, int i1) const |
template<typename _Tp > | |
_Tp & | at (int i0, int i1) |
template<typename _Tp > | |
const _Tp & | at (int i0=0) const |
template<typename _Tp > | |
_Tp & | at (int i0=0) |
the same as above, with the pointer dereferencing | |
template<typename _Tp > | |
MatConstIterator_< _Tp > | begin () const |
template<typename _Tp > | |
MatIterator_< _Tp > | begin () |
template methods for iteration over matrix elements. | |
int | channels () const |
returns element type, similar to CV_MAT_CN(cvmat->type) | |
int | checkVector (int elemChannels, int depth=-1, bool requireContinuous=true) const |
returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise | |
Mat | clone () const |
returns deep copy of the matrix, i.e. the data is copied | |
Mat | col (int x) const |
returns a new matrix header for the specified column | |
Mat | colRange (const Range &r) const |
Mat | colRange (int startcol, int endcol) const |
... for the specified column span | |
void | convertTo (Mat &m, int rtype, double alpha=1, double beta=0) const |
converts matrix to another datatype with optional scalng. See cvConvertScale. | |
void | copySize (const Mat &m) |
internal use function; properly re-allocates _size, _step arrays | |
void | copyTo (Mat &m, const Mat &mask) const |
copies those matrix elements to "m" that are marked with non-zero mask elements. | |
template<typename _Tp > | |
void | copyTo (vector< _Tp > &v) const |
void | copyTo (Mat &m) const |
copies the matrix content to "m". | |
void | create (int _ndims, const int *_sizes, int _type) |
void | create (Size _size, int _type) |
void | create (int _rows, int _cols, int _type) |
allocates new matrix data unless the matrix already has specified size and type. | |
Mat | cross (const Mat &m) const |
computes cross-product of 2 3D vectors | |
void | deallocate () |
deallocates the matrix data | |
int | depth () const |
returns element type, similar to CV_MAT_DEPTH(cvmat->type) | |
Mat | diag (int d=0) const |
... for the specified diagonal | |
double | dot (const Mat &m) const |
computes dot-product | |
size_t | elemSize () const |
returns element size in bytes, | |
size_t | elemSize1 () const |
returns the size of element channel in bytes. | |
bool | empty () const |
returns true if matrix data is NULL | |
template<typename _Tp > | |
MatConstIterator_< _Tp > | end () const |
template<typename _Tp > | |
MatIterator_< _Tp > | end () |
MatExpr | inv (int method=DECOMP_LU) const |
matrix inversion by means of matrix expressions | |
bool | isContinuous () const |
returns true iff the matrix data is continuous | |
bool | isSubmatrix () const |
returns true if the matrix is a submatrix of another matrix | |
void | locateROI (Size &wholeSize, Point &ofs) const |
locates matrix header within a parent matrix. See below | |
template<typename _Tp > | |
Mat (const MatCommaInitializer_< _Tp > &commaInitializer) | |
builds matrix from comma initializer | |
template<typename _Tp > | |
Mat (const Point3_< _Tp > &pt, bool copyData=true) | |
builds matrix from a 3D point | |
template<typename _Tp > | |
Mat (const Point_< _Tp > &pt, bool copyData=true) | |
builds matrix from a 2D point | |
template<typename _Tp , int m, int n> | |
Mat (const Matx< _Tp, m, n > &mtx, bool copyData=true) | |
builds matrix from cv::Matx; the data is copied by default | |
template<typename _Tp , int n> | |
Mat (const Vec< _Tp, n > &vec, bool copyData=true) | |
builds matrix from cv::Vec; the data is copied by default | |
template<typename _Tp > | |
Mat (const vector< _Tp > &vec, bool copyData=false) | |
builds matrix from std::vector with or without copying the data | |
Mat (const IplImage *img, bool copyData=false) | |
converts old-style IplImage to the new matrix; the data is not copied by default | |
Mat (const CvMatND *m, bool copyData=false) | |
converts old-style CvMatND to the new matrix; the data is not copied by default | |
Mat (const CvMat *m, bool copyData=false) | |
converts old-style CvMat to the new matrix; the data is not copied by default | |
Mat (const Mat &m, const Range *ranges) | |
Mat (const Mat &m, const Rect &roi) | |
Mat (const Mat &m, const Range &rowRange, const Range &colRange=Range::all()) | |
creates a matrix header for a part of the bigger matrix | |
Mat (int _ndims, const int *_sizes, int _type, void *_data, const size_t *_steps=0) | |
Mat (Size _size, int _type, void *_data, size_t _step=AUTO_STEP) | |
Mat (int _rows, int _cols, int _type, void *_data, size_t _step=AUTO_STEP) | |
constructor for matrix headers pointing to user-allocated data | |
Mat (const Mat &m) | |
copy constructor | |
Mat (int _ndims, const int *_sizes, int _type, const Scalar &_s) | |
Mat (int _ndims, const int *_sizes, int _type) | |
constructs n-dimensional matrix | |
Mat (Size _size, int _type, const Scalar &_s) | |
Mat (int _rows, int _cols, int _type, const Scalar &_s) | |
constucts 2D matrix and fills it with the specified value _s. | |
Mat (Size _size, int _type) | |
Mat (int _rows, int _cols, int _type) | |
constructs 2D matrix of the specified size and type | |
Mat () | |
default constructor | |
MatExpr | mul (const MatExpr &m, double scale=1) const |
MatExpr | mul (const Mat &m, double scale=1) const |
per-element matrix multiplication by means of matrix expressions | |
operator CvMat () const | |
converts header to CvMat; no data is copied | |
operator CvMatND () const | |
converts header to CvMatND; no data is copied | |
operator IplImage () const | |
converts header to IplImage; no data is copied | |
template<typename _Tp , int m, int n> | |
operator Matx< _Tp, m, n > () const | |
template<typename _Tp , int n> | |
operator Vec< _Tp, n > () const | |
template<typename _Tp > | |
operator vector< _Tp > () const | |
Mat | operator() (const Range *ranges) const |
Mat | operator() (const Rect &roi) const |
Mat | operator() (Range rowRange, Range colRange) const |
extracts a rectangular sub-matrix | |
Mat & | operator= (const Scalar &s) |
sets every matrix element to s | |
Mat & | operator= (const MatExpr &expr) |
Mat & | operator= (const Mat &m) |
assignment operators | |
void | pop_back (size_t nelems=1) |
removes several hyper-planes from bottom of the matrix | |
template<typename _Tp , int n> | |
const _Tp * | ptr (const Vec< int, n > &idx) const |
template<typename _Tp , int n> | |
_Tp * | ptr (const Vec< int, n > &idx) |
template<typename _Tp > | |
const _Tp * | ptr (const int *idx) const |
template<typename _Tp > | |
_Tp * | ptr (const int *idx) |
template<typename _Tp > | |
const _Tp * | ptr (int i0, int i1, int i2) const |
template<typename _Tp > | |
_Tp * | ptr (int i0, int i1, int i2) |
template<typename _Tp > | |
const _Tp * | ptr (int i0, int i1) const |
template<typename _Tp > | |
_Tp * | ptr (int i0, int i1) |
template<typename _Tp > | |
const _Tp * | ptr (int i0=0) const |
template<typename _Tp > | |
_Tp * | ptr (int i0=0) |
template version of the above method | |
template<int n> | |
const uchar * | ptr (const Vec< int, n > &idx) const |
template<int n> | |
uchar * | ptr (const Vec< int, n > &idx) |
const uchar * | ptr (const int *idx) const |
returns read-only pointer to the matrix element | |
uchar * | ptr (const int *idx) |
returns pointer to the matrix element | |
const uchar * | ptr (int i0, int i1, int i2) const |
uchar * | ptr (int i0, int i1, int i2) |
returns pointer to (i0,i1,i3) submatrix along the dimensions #0, #1, #2 | |
const uchar * | ptr (int i0, int i1) const |
uchar * | ptr (int i0, int i1) |
returns pointer to (i0,i1) submatrix along the dimensions #0 and #1 | |
const uchar * | ptr (int i0=0) const |
uchar * | ptr (int i0=0) |
returns pointer to i0-th submatrix along the dimension #0 | |
void | push_back (const Mat &m) |
template<typename _Tp > | |
void | push_back (const Mat_< _Tp > &elem) |
template<typename _Tp > | |
void | push_back (const _Tp &elem) |
adds element to the end of 1d matrix (or possibly multiple elements when _Tp=Mat) | |
void | push_back_ (const void *elem) |
internal function | |
void | release () |
decreases reference counter; | |
void | reserve (size_t sz) |
reserves enough space to fit sz hyper-planes | |
Mat | reshape (int _cn, int _newndims, const int *_newsz) const |
Mat | reshape (int _cn, int _rows=0) const |
creates alternative matrix header for the same data, with different | |
void | resize (size_t sz, const Scalar &s) |
resizes matrix to the specified number of hyper-planes; initializes the newly added elements | |
void | resize (size_t sz) |
resizes matrix to the specified number of hyper-planes | |
Mat | row (int y) const |
returns a new matrix header for the specified row | |
Mat | rowRange (const Range &r) const |
Mat | rowRange (int startrow, int endrow) const |
... for the specified row span | |
Mat & | setTo (const Scalar &s, const Mat &mask=Mat()) |
sets some of the matrix elements to s, according to the mask | |
size_t | step1 (int i=0) const |
returns step/elemSize1() | |
MatExpr | t () const |
matrix transposition by means of matrix expressions | |
size_t | total () const |
returns the total number of matrix elements | |
int | type () const |
returns element type, similar to CV_MAT_TYPE(cvmat->type) | |
~Mat () | |
destructor - calls release() | |
Static Public Member Functions | |
static Mat | diag (const Mat &d) |
constructs a square diagonal matrix which main diagonal is vector "d" | |
static MatExpr | eye (Size size, int type) |
static MatExpr | eye (int rows, int cols, int type) |
static MatExpr | ones (int ndims, const int *sz, int type) |
static MatExpr | ones (Size size, int type) |
static MatExpr | ones (int rows, int cols, int type) |
static MatExpr | zeros (int ndims, const int *sz, int type) |
static MatExpr | zeros (Size size, int type) |
static MatExpr | zeros (int rows, int cols, int type) |
Matlab-style matrix initialization. | |
Public Attributes | |
MatAllocator * | allocator |
custom allocator | |
int | cols |
uchar * | data |
pointer to the data | |
uchar * | dataend |
uchar * | datalimit |
uchar * | datastart |
helper fields used in locateROI and adjustROI | |
int | dims |
the matrix dimensionality, >= 2 | |
int | flags |
int * | refcount |
pointer to the reference counter; | |
int | rows |
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions | |
MSize | size |
MStep | step |
The class represents an n-dimensional dense numerical array that can act as a matrix, image, optical flow map, 3-focal tensor etc. It is very similar to CvMat and CvMatND types from earlier versions of OpenCV, and similarly to those types, the matrix can be multi-channel. It also fully supports ROI mechanism.
There are many different ways to create cv::Mat object. Here are the some popular ones:
// make 7x7 complex matrix filled with 1+3j. cv::Mat M(7,7,CV_32FC2,Scalar(1,3)); // and now turn M to 100x60 15-channel 8-bit matrix. // The old content will be deallocated M.create(100,60,CV_8UC(15));
As noted in the introduction of this chapter, Mat::create() will only allocate a new matrix when the current matrix dimensionality or type are different from the specified.
// add 5-th row, multiplied by 3 to the 3rd row M.row(3) = M.row(3) + M.row(5)*3; // now copy 7-th column to the 1-st column // M.col(1) = M.col(7); // this will not work Mat M1 = M.col(1); M.col(7).copyTo(M1); // create new 320x240 image cv::Mat img(Size(320,240),CV_8UC3); // select a roi cv::Mat roi(img, Rect(10,10,100,100)); // fill the ROI with (0,255,0) (which is green in RGB space); // the original 320x240 image will be modified roi = Scalar(0,255,0);
Thanks to the additional cv::Mat::datastart and cv::Mat::dataend members, it is possible to compute the relative sub-matrix position in the main "container" matrix using cv::Mat::locateROI():
Mat A = Mat::eye(10, 10, CV_32S); // extracts A columns, 1 (inclusive) to 3 (exclusive). Mat B = A(Range::all(), Range(1, 3)); // extracts B rows, 5 (inclusive) to 9 (exclusive). // that is, C ~ A(Range(5, 9), Range(1, 3)) Mat C = B(Range(5, 9), Range::all()); Size size; Point ofs; C.locateROI(size, ofs); // size will be (width=10,height=10) and the ofs will be (x=1, y=5)
As in the case of whole matrices, if you need a deep copy, use cv::Mat::clone() method of the extracted sub-matrices.
void process_video_frame(const unsigned char* pixels, int width, int height, int step) { cv::Mat img(height, width, CV_8UC3, pixels, step); cv::GaussianBlur(img, img, cv::Size(7,7), 1.5, 1.5); }
partial yet very common cases of this "user-allocated data" case are conversions from CvMat and IplImage to cv::Mat. For this purpose there are special constructors taking pointers to CvMat or IplImage and the optional flag indicating whether to copy the data or not.
Backward conversion from cv::Mat to CvMat or IplImage is provided via cast operators cv::Mat::operator CvMat() an cv::Mat::operator IplImage(). The operators do not copy the data.
IplImage* img = cvLoadImage("greatwave.jpg", 1); Mat mtx(img); // convert IplImage* -> cv::Mat CvMat oldmat = mtx; // convert cv::Mat -> CvMat CV_Assert(oldmat.cols == img->width && oldmat.rows == img->height && oldmat.data.ptr == (uchar*)img->imageData && oldmat.step == img->widthStep);
// create a double-precision identity martix and add it to M. M += Mat::eye(M.rows, M.cols, CV_64F);
// create 3x3 double-precision identity matrix Mat M = (Mat_<double>(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);
here we first call constructor of cv::Mat_ class (that we describe further) with the proper matrix, and then we just put "<<" operator followed by comma-separated values that can be constants, variables, expressions etc. Also, note the extra parentheses that are needed to avoid compiler errors.
Once matrix is created, it will be automatically managed by using reference-counting mechanism (unless the matrix header is built on top of user-allocated data, in which case you should handle the data by yourself). The matrix data will be deallocated when no one points to it; if you want to release the data pointed by a matrix header before the matrix destructor is called, use cv::Mat::release().
The next important thing to learn about the matrix class is element access. Here is how the matrix is stored. The elements are stored in row-major order (row by row). The cv::Mat::data member points to the first element of the first row, cv::Mat::rows contains the number of matrix rows and cv::Mat::cols - the number of matrix columns. There is yet another member, cv::Mat::step that is used to actually compute address of a matrix element. cv::Mat::step is needed because the matrix can be a part of another matrix or because there can some padding space in the end of each row for a proper alignment.
Given these parameters, address of the matrix element M_{ij} is computed as following:
addr(M_{ij})=M.data + M.step*i + j*M.elemSize()
if you know the matrix element type, e.g. it is float, then you can use cv::Mat::at() method:
addr(M_{ij})=&M.at<float>(i,j)
(where & is used to convert the reference returned by cv::Mat::at() to a pointer). if you need to process a whole row of matrix, the most efficient way is to get the pointer to the row first, and then just use plain C operator []:
// compute sum of positive matrix elements // (assuming that M is double-precision matrix) double sum=0; for(int i = 0; i < M.rows; i++) { const double* Mi = M.ptr<double>(i); for(int j = 0; j < M.cols; j++) sum += std::max(Mi[j], 0.); }
Some operations, like the above one, do not actually depend on the matrix shape, they just process elements of a matrix one by one (or elements from multiple matrices that are sitting in the same place, e.g. matrix addition). Such operations are called element-wise and it makes sense to check whether all the input/output matrices are continuous, i.e. have no gaps in the end of each row, and if yes, process them as a single long row:
// compute sum of positive matrix elements, optimized variant double sum=0; int cols = M.cols, rows = M.rows; if(M.isContinuous()) { cols *= rows; rows = 1; } for(int i = 0; i < rows; i++) { const double* Mi = M.ptr<double>(i); for(int j = 0; j < cols; j++) sum += std::max(Mi[j], 0.); }
Finally, there are STL-style iterators that are smart enough to skip gaps between successive rows:
// compute sum of positive matrix elements, iterator-based variant double sum=0; MatConstIterator_<double> it = M.begin<double>(), it_end = M.end<double>(); for(; it != it_end; ++it) sum += std::max(*it, 0.);
The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, including std::sort().
cv::Mat::Mat | ( | ) | [inline] |
default constructor
cv::Mat::Mat | ( | int | _rows, | |
int | _cols, | |||
int | _type | |||
) | [inline] |
constructs 2D matrix of the specified size and type
cv::Mat::Mat | ( | Size | _size, | |
int | _type | |||
) | [inline] |
cv::Mat::Mat | ( | int | _rows, | |
int | _cols, | |||
int | _type, | |||
const Scalar & | _s | |||
) | [inline] |
constucts 2D matrix and fills it with the specified value _s.
cv::Mat::Mat | ( | int | _ndims, | |
const int * | _sizes, | |||
int | _type | |||
) | [inline] |
constructs n-dimensional matrix
cv::Mat::Mat | ( | int | _ndims, | |
const int * | _sizes, | |||
int | _type, | |||
const Scalar & | _s | |||
) | [inline] |
cv::Mat::Mat | ( | const Mat & | m | ) | [inline] |
copy constructor
cv::Mat::Mat | ( | int | _rows, | |
int | _cols, | |||
int | _type, | |||
void * | _data, | |||
size_t | _step = AUTO_STEP | |||
) | [inline] |
constructor for matrix headers pointing to user-allocated data
cv::Mat::Mat | ( | Size | _size, | |
int | _type, | |||
void * | _data, | |||
size_t | _step = AUTO_STEP | |||
) | [inline] |
cv::Mat::Mat | ( | int | _ndims, | |
const int * | _sizes, | |||
int | _type, | |||
void * | _data, | |||
const size_t * | _steps = 0 | |||
) |
creates a matrix header for a part of the bigger matrix
cv::Mat::Mat | ( | const CvMat * | m, | |
bool | copyData = false | |||
) | [inline] |
converts old-style CvMat to the new matrix; the data is not copied by default
cv::Mat::Mat | ( | const CvMatND * | m, | |
bool | copyData = false | |||
) |
converts old-style CvMatND to the new matrix; the data is not copied by default
cv::Mat::Mat | ( | const IplImage * | img, | |
bool | copyData = false | |||
) |
converts old-style IplImage to the new matrix; the data is not copied by default
cv::Mat::Mat | ( | const vector< _Tp > & | vec, | |
bool | copyData = false | |||
) | [inline, explicit] |
builds matrix from std::vector with or without copying the data
cv::Mat::Mat | ( | const Vec< _Tp, n > & | vec, | |
bool | copyData = true | |||
) | [inline, explicit] |
builds matrix from cv::Vec; the data is copied by default
cv::Mat::Mat | ( | const Matx< _Tp, m, n > & | mtx, | |
bool | copyData = true | |||
) | [inline, explicit] |
builds matrix from cv::Matx; the data is copied by default
cv::Mat::Mat | ( | const Point_< _Tp > & | pt, | |
bool | copyData = true | |||
) | [inline, explicit] |
builds matrix from a 2D point
cv::Mat::Mat | ( | const Point3_< _Tp > & | pt, | |
bool | copyData = true | |||
) | [inline, explicit] |
builds matrix from a 3D point
cv::Mat::Mat | ( | const MatCommaInitializer_< _Tp > & | commaInitializer | ) | [inline, explicit] |
builds matrix from comma initializer
cv::Mat::~Mat | ( | ) | [inline] |
destructor - calls release()
void cv::Mat::addref | ( | ) | [inline] |
increases the reference counter; use with care to avoid memleaks
Mat& cv::Mat::adjustROI | ( | int | dtop, | |
int | dbottom, | |||
int | dleft, | |||
int | dright | |||
) |
void cv::Mat::assignTo | ( | Mat & | m, | |
int | type = -1 | |||
) | const [inline] |
const _Tp & cv::Mat::at | ( | Point | pt | ) | const [inline] |
_Tp & cv::Mat::at | ( | Point | pt | ) | [inline] |
special versions for 2D arrays (especially convenient for referencing image pixels)
const _Tp& cv::Mat::at | ( | const Vec< int, n > & | idx | ) | const [inline] |
_Tp& cv::Mat::at | ( | const Vec< int, n > & | idx | ) | [inline] |
const _Tp & cv::Mat::at | ( | const int * | idx | ) | const [inline] |
_Tp & cv::Mat::at | ( | const int * | idx | ) | [inline] |
const _Tp & cv::Mat::at | ( | int | i0, | |
int | i1, | |||
int | i2 | |||
) | const [inline] |
_Tp & cv::Mat::at | ( | int | i0, | |
int | i1, | |||
int | i2 | |||
) | [inline] |
const _Tp & cv::Mat::at | ( | int | i0, | |
int | i1 | |||
) | const [inline] |
_Tp & cv::Mat::at | ( | int | i0, | |
int | i1 | |||
) | [inline] |
const _Tp & cv::Mat::at | ( | int | i0 = 0 |
) | const [inline] |
_Tp & cv::Mat::at | ( | int | i0 = 0 |
) | [inline] |
the same as above, with the pointer dereferencing
MatConstIterator_< _Tp > cv::Mat::begin | ( | ) | const [inline] |
Reimplemented in cv::Mat_< _Tp >.
MatIterator_< _Tp > cv::Mat::begin | ( | ) | [inline] |
int cv::Mat::channels | ( | ) | const [inline] |
int cv::Mat::checkVector | ( | int | elemChannels, | |
int | depth = -1 , |
|||
bool | requireContinuous = true | |||
) | const |
returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise
Mat cv::Mat::clone | ( | ) | const [inline] |
Mat cv::Mat::col | ( | int | x | ) | const [inline] |
Mat cv::Mat::colRange | ( | int | startcol, | |
int | endcol | |||
) | const [inline] |
... for the specified column span
void cv::Mat::convertTo | ( | Mat & | m, | |
int | rtype, | |||
double | alpha = 1 , |
|||
double | beta = 0 | |||
) | const |
converts matrix to another datatype with optional scalng. See cvConvertScale.
void cv::Mat::copySize | ( | const Mat & | m | ) |
internal use function; properly re-allocates _size, _step arrays
copies those matrix elements to "m" that are marked with non-zero mask elements.
void cv::Mat::copyTo | ( | vector< _Tp > & | v | ) | const [inline] |
void cv::Mat::copyTo | ( | Mat & | m | ) | const |
copies the matrix content to "m".
void cv::Mat::create | ( | int | _ndims, | |
const int * | _sizes, | |||
int | _type | |||
) |
void cv::Mat::create | ( | Size | _size, | |
int | _type | |||
) | [inline] |
void cv::Mat::create | ( | int | _rows, | |
int | _cols, | |||
int | _type | |||
) | [inline] |
allocates new matrix data unless the matrix already has specified size and type.
void cv::Mat::deallocate | ( | ) |
deallocates the matrix data
int cv::Mat::depth | ( | ) | const [inline] |
constructs a square diagonal matrix which main diagonal is vector "d"
Mat cv::Mat::diag | ( | int | d = 0 |
) | const |
double cv::Mat::dot | ( | const Mat & | m | ) | const |
computes dot-product
size_t cv::Mat::elemSize | ( | ) | const [inline] |
size_t cv::Mat::elemSize1 | ( | ) | const [inline] |
bool cv::Mat::empty | ( | ) | const [inline] |
returns true if matrix data is NULL
MatConstIterator_< _Tp > cv::Mat::end | ( | ) | const [inline] |
Reimplemented in cv::Mat_< _Tp >.
MatIterator_< _Tp > cv::Mat::end | ( | ) | [inline] |
Reimplemented in cv::Mat_< _Tp >.
static MatExpr cv::Mat::eye | ( | int | rows, | |
int | cols, | |||
int | type | |||
) | [static] |
MatExpr cv::Mat::inv | ( | int | method = DECOMP_LU |
) | const |
matrix inversion by means of matrix expressions
bool cv::Mat::isContinuous | ( | ) | const [inline] |
returns true iff the matrix data is continuous
bool cv::Mat::isSubmatrix | ( | ) | const [inline] |
returns true if the matrix is a submatrix of another matrix
locates matrix header within a parent matrix. See below
per-element matrix multiplication by means of matrix expressions
static MatExpr cv::Mat::ones | ( | int | ndims, | |
const int * | sz, | |||
int | type | |||
) | [static] |
static MatExpr cv::Mat::ones | ( | int | rows, | |
int | cols, | |||
int | type | |||
) | [static] |
cv::Mat::operator IplImage | ( | ) | const |
converts header to IplImage; no data is copied
cv::Mat::operator Matx< _Tp, m, n > | ( | ) | const [inline] |
cv::Mat::operator Vec< _Tp, n > | ( | ) | const [inline] |
cv::Mat::operator vector< _Tp > | ( | ) | const [inline] |
Reimplemented in cv::Mat_< _Tp >.
Reimplemented in cv::Mat_< _Tp >.
Reimplemented in cv::Mat_< _Tp >.
extracts a rectangular sub-matrix
Reimplemented in cv::Mat_< _Tp >.
void cv::Mat::pop_back | ( | size_t | nelems = 1 |
) |
removes several hyper-planes from bottom of the matrix
const _Tp* cv::Mat::ptr | ( | const Vec< int, n > & | idx | ) | const [inline] |
_Tp* cv::Mat::ptr | ( | const Vec< int, n > & | idx | ) | [inline] |
const _Tp* cv::Mat::ptr | ( | const int * | idx | ) | const [inline] |
_Tp* cv::Mat::ptr | ( | const int * | idx | ) | [inline] |
const _Tp* cv::Mat::ptr | ( | int | i0, | |
int | i1, | |||
int | i2 | |||
) | const [inline] |
_Tp* cv::Mat::ptr | ( | int | i0, | |
int | i1, | |||
int | i2 | |||
) | [inline] |
const _Tp* cv::Mat::ptr | ( | int | i0, | |
int | i1 | |||
) | const [inline] |
_Tp* cv::Mat::ptr | ( | int | i0, | |
int | i1 | |||
) | [inline] |
const _Tp* cv::Mat::ptr | ( | int | i0 = 0 |
) | const [inline] |
_Tp* cv::Mat::ptr | ( | int | i0 = 0 |
) | [inline] |
template version of the above method
const uchar * cv::Mat::ptr | ( | const int * | idx | ) | const [inline] |
returns read-only pointer to the matrix element
uchar * cv::Mat::ptr | ( | const int * | idx | ) | [inline] |
returns pointer to the matrix element
const uchar * cv::Mat::ptr | ( | int | i0, | |
int | i1, | |||
int | i2 | |||
) | const [inline] |
uchar * cv::Mat::ptr | ( | int | i0, | |
int | i1, | |||
int | i2 | |||
) | [inline] |
returns pointer to (i0,i1,i3) submatrix along the dimensions #0, #1, #2
const uchar * cv::Mat::ptr | ( | int | i0, | |
int | i1 | |||
) | const [inline] |
uchar * cv::Mat::ptr | ( | int | i0, | |
int | i1 | |||
) | [inline] |
returns pointer to (i0,i1) submatrix along the dimensions #0 and #1
const _Tp * cv::Mat::ptr | ( | int | i0 = 0 |
) | const [inline] |
_Tp * cv::Mat::ptr | ( | int | i0 = 0 |
) | [inline] |
returns pointer to i0-th submatrix along the dimension #0
void cv::Mat::push_back | ( | const Mat & | m | ) |
void cv::Mat::push_back | ( | const Mat_< _Tp > & | elem | ) | [inline] |
void cv::Mat::push_back | ( | const _Tp & | elem | ) | [inline] |
adds element to the end of 1d matrix (or possibly multiple elements when _Tp=Mat)
void cv::Mat::push_back_ | ( | const void * | elem | ) |
internal function
void cv::Mat::release | ( | ) | [inline] |
decreases reference counter;
void cv::Mat::reserve | ( | size_t | sz | ) |
reserves enough space to fit sz hyper-planes
Mat cv::Mat::reshape | ( | int | _cn, | |
int | _newndims, | |||
const int * | _newsz | |||
) | const |
Mat cv::Mat::reshape | ( | int | _cn, | |
int | _rows = 0 | |||
) | const |
creates alternative matrix header for the same data, with different
void cv::Mat::resize | ( | size_t | sz, | |
const Scalar & | s | |||
) |
resizes matrix to the specified number of hyper-planes; initializes the newly added elements
void cv::Mat::resize | ( | size_t | sz | ) |
resizes matrix to the specified number of hyper-planes
Mat cv::Mat::row | ( | int | y | ) | const [inline] |
Mat cv::Mat::rowRange | ( | int | startrow, | |
int | endrow | |||
) | const [inline] |
... for the specified row span
sets some of the matrix elements to s, according to the mask
size_t cv::Mat::step1 | ( | int | i = 0 |
) | const [inline] |
MatExpr cv::Mat::t | ( | ) | const |
matrix transposition by means of matrix expressions
size_t cv::Mat::total | ( | ) | const [inline] |
returns the total number of matrix elements
int cv::Mat::type | ( | ) | const [inline] |
static MatExpr cv::Mat::zeros | ( | int | ndims, | |
const int * | sz, | |||
int | type | |||
) | [static] |
static MatExpr cv::Mat::zeros | ( | int | rows, | |
int | cols, | |||
int | type | |||
) | [static] |
Matlab-style matrix initialization.
custom allocator
int cv::Mat::cols |
pointer to the data
helper fields used in locateROI and adjustROI
int cv::Mat::dims |
the matrix dimensionality, >= 2
int cv::Mat::flags |
includes several bit-fields:
int* cv::Mat::refcount |
pointer to the reference counter;
int cv::Mat::rows |
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions