cv::Mat构造函数说明
#include <opencv2/core/mat.hpp>
构造函数列表:
Mat () CV_NOEXCEPT | |
Mat (int rows, int cols, int type) | |
Mat (Size size, int type) | |
Mat (int rows, int cols, int type, const Scalar &s) | |
Mat (Size size, int type, const Scalar &s) | |
Mat (int ndims, const int *sizes, int type) | |
Mat (const std::vector< int > &sizes, int type) | |
Mat (int ndims, const int *sizes, int type, const Scalar &s) | |
Mat (const std::vector< int > &sizes, int type, const Scalar &s) | |
Mat (const Mat &m) | |
Mat (int rows, int cols, int type, void *data, size_t step=AUTO_STEP) | |
Mat (Size size, int type, void *data, size_t step=AUTO_STEP) | |
Mat (int ndims, const int *sizes, int type, void *data, const size_t *steps=0) | |
Mat (const std::vector< int > &sizes, int type, void *data, const size_t *steps=0) | |
Mat (const Mat &m, const Range &rowRange, const Range &colRange=Range::all()) | |
Mat (const Mat &m, const Rect &roi) | |
Mat (const Mat &m, const Range *ranges) | |
Mat (const Mat &m, const std::vector< Range > &ranges) | |
template<typename _Tp > | |
Mat (const std::vector< _Tp > &vec, bool copyData=false) | |
template<typename _Tp , int n> | |
Mat (const Vec< _Tp, n > &vec, bool copyData=true) | |
template<typename _Tp , int m, int n> | |
Mat (const Matx< _Tp, m, n > &mtx, bool copyData=true) | |
template<typename _Tp > | |
Mat (const Point_< _Tp > &pt, bool copyData=true) | |
template<typename _Tp > | |
Mat (const Point3_< _Tp > &pt, bool copyData=true) | |
template<typename _Tp > | |
Mat (const MatCommaInitializer_< _Tp > &commaInitializer) | |
Mat (const cuda::GpuMat &m) |
cv::Mat::Mat(const Mat& m) (引用传参场景)
cv::Mat::Mat | (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.
Parameters
m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied by these constructors. Instead, the header pointing to m data or its sub-array is constructed and associated with it. The reference counter, if any, is incremented. So, when you modify the matrix formed using such a constructor, you also modify the corresponding elements of m . If you want to have an independent copy of the sub-array, use Mat::clone() .
Mat& operator= (const Mat &m) 赋值运算符重载
assignment operators
These are available assignment operators. Since they all are very different, make sure to read the operator parameters description.
Parameters
m Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that no data is copied but the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is de-referenced via Mat::release .
通过外部void * data指针构造cv::Mat对象是浅拷贝
cv::Mat::Mat | ( int | rows, |
int | cols, | |
int | type, | |
void * | data, | |
size_t | step = AUTO_STEP ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameters
rows Number of rows in a 2D array.
cols Number of columns in a 2D array.
type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
data Pointer to the user data. Matrix constructors that take data and step parameters do not allocate matrix data. Instead, they just initialize the matrix header that points to the specified data, which means that no data is copied. This operation is very efficient and can be used to process external data using OpenCV functions. The external data is not automatically deallocated, so you should take care of it.
step Number of bytes each matrix row occupies. The value should include the padding bytes at the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed and the actual step is calculated as cols*elemSize(). See Mat::elemSize.
cv::Mat::clone()函数
Mat cv::Mat::clone | () | const |
Creates a full copy of the array and the underlying data.
The method creates a full copy of the array. The original step[] is not taken into account. So, the array copy is a continuous array occupying total()*elemSize() bytes.