Constructor Mat
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Mat()
Creates empty Mat
public Mat()
Mat(Mat)
Initializes by Mat object. The Mat's element type must match TElem.
public Mat(Mat mat)
Parameters
matMatManaged Mat object
Mat(int, int)
constructs 2D matrix of the specified size and type
public Mat(int rows, int cols)
Parameters
Mat(Size)
constructs 2D matrix of the specified size and type
public Mat(Size size)
Parameters
sizeSize2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the number of columns go in the reverse order.
Mat(int, int, Scalar)
constructs 2D matrix and fills it with the specified Scalar value.
public Mat(int rows, int cols, Scalar s)
Parameters
rowsintNumber of rows in a 2D array.
colsintNumber of columns in a 2D array.
sScalarAn optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use SetTo(Scalar s) method .
Mat(Size, Scalar)
constructs 2D matrix and fills it with the specified Scalar value.
public Mat(Size size, Scalar s)
Parameters
sizeSize2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the number of columns go in the reverse order.
sScalarAn optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use SetTo(Scalar s) method .
Mat(Mat<TElem>, Range, Range?)
creates a matrix header for a part of the bigger matrix
public Mat(Mat<TElem> m, Range rowRange, Range? colRange = null)
Parameters
mMat<TElem>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() .
rowRangeRangeRange 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.
colRangeRange?Range of the m columns to take. Use Range.All to take all the columns.
Mat(Mat<TElem>, Range[])
creates a matrix header for a part of the bigger matrix
protected Mat(Mat<TElem> m, Range[] ranges)
Parameters
mMat<TElem>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() .
rangesRange[]Array of selected ranges of m along each dimensionality.
Mat(Mat<TElem>, Rect)
creates a matrix header for a part of the bigger matrix
public Mat(Mat<TElem> m, Rect roi)
Parameters
mMat<TElem>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() .
roiRectRegion of interest.
Mat(int, int, Array, long)
constructor for matrix headers pointing to user-allocated data
protected Mat(int rows, int cols, Array data, long step = 0)
Parameters
rowsintNumber of rows in a 2D array.
colsintNumber of columns in a 2D array.
dataArrayPointer 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 de-allocated, so you should take care of it.
steplongNumber 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() .
Mat(IEnumerable<int>, Array, IEnumerable<long>?)
constructor for matrix headers pointing to user-allocated data
public Mat(IEnumerable<int> sizes, Array data, IEnumerable<long>? steps = null)
Parameters
sizesIEnumerable<int>Array of integers specifying an n-dimensional array shape.
dataArrayPointer 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 de-allocated, so you should take care of it.
stepsIEnumerable<long>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(IEnumerable<int>)
constructs n-dimensional matrix
public Mat(IEnumerable<int> sizes)
Parameters
sizesIEnumerable<int>Array of integers specifying an n-dimensional array shape.
Mat(IEnumerable<int>, Scalar)
constructs n-dimensional matrix
public Mat(IEnumerable<int> sizes, Scalar s)
Parameters
sizesIEnumerable<int>Array of integers specifying an n-dimensional array shape.
sScalarAn optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use SetTo(Scalar s) method .