Mat-构造方法

Mat的构造方法

◆ Mat() [1/29]
cv::Mat::Mat ( )
These are various constructors that form a matrix. As noted in the AutomaticAllocation, often the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. The constructed matrix can further be assigned to another matrix or matrix expression or can be allocated with Mat::create . In the former case, the old content is de-referenced.

◆ Mat() [2/29]
cv::Mat::Mat ( int rows,
int cols,
int type
)
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.
◆ Mat() [3/29]
cv::Mat::Mat ( 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.

Parameters
size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the number of columns go in the reverse order.
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.
◆ Mat() [4/29]
cv::Mat::Mat ( int rows,
int cols,
int type,
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.

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.
s An optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) .
◆ Mat() [5/29]
cv::Mat::Mat ( Size size,
int type,
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.

Parameters
size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the number of columns go in the reverse order.
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.
s An optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) .
◆ Mat() [6/29]
cv::Mat::Mat ( 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.

Parameters
ndims Array dimensionality.
sizes Array of integers specifying an n-dimensional array shape.
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.
◆ Mat() [7/29]
cv::Mat::Mat ( 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.

Parameters
sizes Array of integers specifying an n-dimensional array shape.
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.
◆ Mat() [8/29]
cv::Mat::Mat ( int ndims,
const int * sizes,
int type,
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.

Parameters
ndims Array dimensionality.
sizes Array of integers specifying an n-dimensional array shape.
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.
s An optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) .
◆ Mat() [9/29]
cv::Mat::Mat ( const std::vector< int > & sizes,
int type,
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.

Parameters
sizes Array of integers specifying an n-dimensional array shape.
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.
s An optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) .
◆ Mat() [10/29]
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() [11/29]
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.
◆ Mat() [12/29]
cv::Mat::Mat ( Size size,
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
size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the number of columns go in the reverse order.
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.
◆ Mat() [13/29]
cv::Mat::Mat ( int ndims,
const int * sizes,
int type,
void * data,
const size_t * steps = 0
)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
ndims Array dimensionality.
sizes Array of integers specifying an n-dimensional array shape.
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.
steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always set to the element size). If not specified, the matrix is assumed to be continuous.
◆ Mat() [14/29]
cv::Mat::Mat ( const std::vector< int > & sizes,
int type,
void * data,
const size_t * steps = 0
)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
sizes Array of integers specifying an n-dimensional array shape.
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.
steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always set to the element size). If not specified, the matrix is assumed to be continuous.
◆ Mat() [15/29]
cv::Mat::Mat ( const Mat & m,
const Range & rowRange,
const Range & colRange = Range::all()
)
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() .
rowRange Range of the m rows to take. As usual, the range start is inclusive and the range end is exclusive. Use Range::all() to take all the rows.
colRange Range of the m columns to take. Use Range::all() to take all the columns.
◆ Mat() [16/29]
cv::Mat::Mat ( const Mat & m,
const Rect & roi
)
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() .
roi Region of interest.
◆ Mat() [17/29]
cv::Mat::Mat ( const Mat & m,
const Range * ranges
)
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() .
ranges Array of selected ranges of m along each dimensionality.
◆ Mat() [18/29]
cv::Mat::Mat ( const Mat & m,
const std::vector< Range > & ranges
)
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() .
ranges Array of selected ranges of m along each dimensionality.
◆ Mat() [19/29]
template
cv::Mat::Mat ( const std::vector< _Tp > & vec,
bool copyData = false
)
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
vec STL vector whose elements form the matrix. The matrix has a single column and the number of rows equal to the number of vector elements. Type of the matrix matches the type of vector elements. The constructor can handle arbitrary types, for which there is a properly declared DataType . This means that the vector elements must be primitive numbers or uni-type numerical tuples of numbers. Mixed-type structures are not supported. The corresponding constructor is explicit. Since STL vectors are not automatically converted to Mat instances, you should write Mat(vec) explicitly. Unless you copy the data into the matrix ( copyData=true ), no new elements will be added to the vector because it can potentially yield vector data reallocation, and, thus, the matrix data pointer will be invalid.
copyData Flag to specify whether the underlying data of the STL vector should be copied to (true) or shared with (false) the newly constructed matrix. When the data is copied, the allocated buffer is managed using Mat reference counting mechanism. While the data is shared, the reference counter is NULL, and you should not deallocate the data until the matrix is not destructed.
◆ Mat() [20/29]
template::value>::type>
cv::Mat::Mat ( const std::initializer_list< _Tp > list )
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Mat() [21/29]
template
cv::Mat::Mat ( const std::initializer_list< int > sizes,
const std::initializer_list< _Tp > list
)
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Mat() [22/29]
template
cv::Mat::Mat ( const std::array< _Tp, _Nm > & arr,
bool copyData = false
)
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Mat() [23/29]
template
cv::Mat::Mat ( const Vec< _Tp, n > & vec,
bool copyData = true
)
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Mat() [24/29]
template
cv::Mat::Mat ( const Matx< _Tp, m, n > & mtx,
bool copyData = true
)
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Mat() [25/29]
template
cv::Mat::Mat ( const Point_< _Tp > & pt,
bool copyData = true
)
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Mat() [26/29]
template
cv::Mat::Mat ( const Point3_< _Tp > & pt,
bool copyData = true
)
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Mat() [27/29]
template
cv::Mat::Mat ( const MatCommaInitializer_< _Tp > & commaInitializer )
explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Mat() [28/29]
cv::Mat::Mat ( const cuda::GpuMat & m )
explicit
download data from GpuMat

◆ ~Mat()
cv::Mat::~Mat ( )
destructor - calls release()

◆ Mat() [29/29]
cv::Mat::Mat ( Mat && m )

你可能感兴趣的:(OpenCv)