Class Arr
Represents an arbitrary array-like data structure.
Namespace: OpenCV.Net
Assembly: OpenCV.Net.dll
Syntax
public abstract class Arr : CVHandle
Properties
| Improve this Doc View SourceElementType
Gets the type of array elements.
Declaration
public int ElementType { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Item[Int32]
Gets or sets a specific array element.
Declaration
public Scalar this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The zero-based element index. |
Property Value
| Type | Description |
|---|---|
| Scalar | The array element specified by |
Remarks
This method can be used for sequential access to 1D, 2D or nD dense arrays. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Item[Int32, Int32]
Gets or sets a specific array element.
Declaration
public Scalar this[int index0, int index1] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
Property Value
| Type | Description |
|---|---|
| Scalar | The array element specified by |
Remarks
The array must have two dimensions. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Item[Int32, Int32, Int32]
Gets or sets a specific array element.
Declaration
public Scalar this[int index0, int index1, int index2] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
| Int32 | index2 | The zero-based element index on the third array dimension. |
Property Value
| Type | Description |
|---|---|
| Scalar | The array element specified by |
Remarks
The array must have three dimensions. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Item[Int32[]]
Gets or sets a specific array element.
Declaration
public Scalar this[params int[] index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32[] | index | An array specifying the zero-based multi-dimensional element index.
The length of |
Property Value
| Type | Description |
|---|---|
| Scalar | The array element specified by the multi-dimensional |
Remarks
The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Size
Gets the pixel-accurate size of the array.
Declaration
public Size Size { get; }
Property Value
| Type | Description |
|---|---|
| Size |
Methods
| Improve this Doc View SourceCheckRange(CheckArrayFlags, Double, Double)
Checks that every array element is neither NaN nor Infinity. It can also check whether the elements are within a specified range.
Declaration
public bool CheckRange(CheckArrayFlags flags, double minVal, double maxVal)
Parameters
| Type | Name | Description |
|---|---|---|
| CheckArrayFlags | flags | The operation flags. A combination of CheckNanInfinity
and CheckRange. If the latter is set, the function
checks whether every value of the array is greater than or equal to |
| Double | minVal | The inclusive lower boundary of valid values range. |
| Double | maxVal | The exclusive upper boundary of valid values range. |
Returns
| Type | Description |
|---|---|
| Boolean | true if all array elements are valid and within range; false otherwise. |
ClearND(Int32[])
Clears a specific element of a multi-dimensional array. If the array is dense, the element is set to zero; in case of sparse arrays, it deletes the specified node.
Declaration
public void ClearND(params int[] index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32[] | index | An array specifying the zero-based multi-dimensional index of the element to be cleared. |
GetCol(Int32)
Returns a single column of the current matrix as a new Mat. No data is copied.
Declaration
public Mat GetCol(int col)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | col | Zero-based index of the selected column. |
Returns
| Type | Description |
|---|---|
| Mat | A new Mat that corresponds to the selected column of the current matrix. |
GetCols(Int32, Int32)
Returns a column span of the current matrix as a new Mat. No data is copied.
Declaration
public Mat GetCols(int startCol, int endCol)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | startCol | Zero-based index of the starting column (inclusive) of the span. |
| Int32 | endCol | Zero-based index of the ending column (exclusive) of the span |
Returns
| Type | Description |
|---|---|
| Mat | The multi-column matrix containing the column span. |
GetDiag(Int32)
Returns a specified diagonal of the current matrix.
Declaration
public Mat GetDiag(int diag = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | diag | The selected array diagonal. Zero corresponds to the main diagonal, negative one corresponds to the diagonal above the main, positive one corresponds to the diagonal below the main, and so forth. |
Returns
| Type | Description |
|---|---|
| Mat | A new Mat that corresponds to the specified diagonal of the current matrix. |
GetDims(Int32[])
Returns the number of array dimensions and their sizes.
Declaration
public int GetDims(int[] sizes = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32[] | sizes | The optional output array of the dimension sizes. For 2D arrays the number of rows (height) goes first and the number of columns (width) goes next. |
Returns
| Type | Description |
|---|---|
| Int32 | The number of array dimensions. |
GetDimSize(Int32)
Returns the size of a particular array dimension.
Declaration
public int GetDimSize(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The zero-based dimension index. For matrices, zero means number of rows and one means number of columns; for images zero means height and one means width. |
Returns
| Type | Description |
|---|---|
| Int32 | The number of elements in a particular array dimension. |
GetImage()
Returns image header for arbitrary array.
Declaration
public IplImage GetImage()
Returns
| Type | Description |
|---|---|
| IplImage | An image header for the array which can be an image or matrix. |
GetMat(Boolean)
Returns matrix header for arbitrary array.
Declaration
public Mat GetMat(bool allowND = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | allowND | If true, the function accepts multi-dimensional dense arrays of type MatND and returns a 2D matrix if the MatND has two dimensions or 1D matrix otherwise. The array must be continuous. |
Returns
| Type | Description |
|---|---|
| Mat | A matrix header for the array which can be an image, matrix or multi-dimensional dense array. |
GetRawData(out IntPtr)
Retrieves low-level information about the array.
Declaration
public void GetRawData(out IntPtr data)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | data | Output pointer to the whole image origin or ROI origin if ROI is set. |
GetRawData(out IntPtr, out Int32)
Retrieves low-level information about the array.
Declaration
public void GetRawData(out IntPtr data, out int step)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | data | Output pointer to the whole image origin or ROI origin if ROI is set. |
| Int32 | step | Output full row length in bytes. |
GetRawData(out IntPtr, out Int32, out Size)
Retrieves low-level information about the array.
Declaration
public void GetRawData(out IntPtr data, out int step, out Size roiSize)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | data | Output pointer to the whole image origin or ROI origin if ROI is set. |
| Int32 | step | Output full row length in bytes. |
| Size | roiSize | Output pixel-accurate ROI size. |
GetReal(Int32)
Returns a specific element of single-channel array.
Declaration
public double GetReal(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The zero-based element index. |
Returns
| Type | Description |
|---|---|
| Double | The array element specified by |
Remarks
This method can be used for sequential access to 1D, 2D or nD dense arrays. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
GetReal(Int32, Int32)
Returns a specific element of single-channel array.
Declaration
public double GetReal(int index0, int index1)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
Returns
| Type | Description |
|---|---|
| Double | The array element specified by |
Remarks
The array must have two dimensions. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
GetReal(Int32, Int32, Int32)
Returns a specific element of single-channel array.
Declaration
public double GetReal(int index0, int index1, int index2)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
| Int32 | index2 | The zero-based element index on the third array dimension. |
Returns
| Type | Description |
|---|---|
| Double | The array element specified by |
Remarks
The array must have three dimensions. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
GetReal(Int32[])
Returns a specific element of single-channel array.
Declaration
public double GetReal(params int[] index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32[] | index | An array specifying the zero-based multi-dimensional element index.
The length of |
Returns
| Type | Description |
|---|---|
| Double | The array element specified by the multi-dimensional |
Remarks
The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
GetRow(Int32)
Returns a single row of the current matrix as a new Mat. No data is copied.
Declaration
public Mat GetRow(int row)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | row | Zero-based index of the selected row. |
Returns
| Type | Description |
|---|---|
| Mat | A new Mat that corresponds to the selected row of the current matrix. |
GetRows(Int32, Int32, Int32)
Returns a row span of the current matrix as a new Mat. No data is copied.
Declaration
public Mat GetRows(int startRow, int endRow, int deltaRow = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | startRow | Zero-based index of the starting row (inclusive) of the span. |
| Int32 | endRow | Zero-based index of the ending row (exclusive) of the span |
| Int32 | deltaRow | Index step in the row span. |
Returns
| Type | Description |
|---|---|
| Mat | The multi-row matrix containing the row span. |
GetSubRect(Rect)
Creates a new Mat from a subrectangle of the current instance. No data is copied.
Declaration
public Mat GetSubRect(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Zero-based coordinates of the rectangle of interest. |
Returns
| Type | Description |
|---|---|
| Mat | A new Mat that corresponds to the specified rectangle of the current matrix. |
Ptr(Int32)
Returns a pointer to a specific array element.
Declaration
public IntPtr Ptr(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The zero-based element index. |
Returns
| Type | Description |
|---|---|
| IntPtr | The pointer to the array element specified by |
Remarks
This method can be used for sequential access to 1D, 2D or nD dense arrays. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Ptr(Int32, Int32)
Returns a pointer to a specific array element.
Declaration
public IntPtr Ptr(int index0, int index1)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
Returns
| Type | Description |
|---|---|
| IntPtr | The pointer to the array element specified by |
Remarks
The array must have two dimensions. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Ptr(Int32, Int32, Int32)
Returns a pointer to a specific array element.
Declaration
public IntPtr Ptr(int index0, int index1, int index2)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
| Int32 | index2 | The zero-based element index on the third array dimension. |
Returns
| Type | Description |
|---|---|
| IntPtr | The pointer to the array element specified by |
Remarks
The array must have three dimensions. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Ptr(Int32, Int32, Int32, out Int32)
Returns a pointer to a specific array element.
Declaration
public IntPtr Ptr(int index0, int index1, int index2, out int elementType)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
| Int32 | index2 | The zero-based element index on the third array dimension. |
| Int32 | elementType | When this method returns, contains the type of matrix elements. This parameter is passed uninitialized. |
Returns
| Type | Description |
|---|---|
| IntPtr | The pointer to the array element specified by |
Remarks
The array must have three dimensions. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Ptr(Int32, Int32, out Int32)
Returns a pointer to a specific array element.
Declaration
public IntPtr Ptr(int index0, int index1, out int elementType)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
| Int32 | elementType | When this method returns, contains the type of matrix elements. This parameter is passed uninitialized. |
Returns
| Type | Description |
|---|---|
| IntPtr | The pointer to the array element specified by |
Remarks
The array must have two dimensions. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Ptr(Int32, out Int32)
Returns a pointer to a specific array element.
Declaration
public IntPtr Ptr(int index, out int elementType)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The zero-based element index. |
| Int32 | elementType | When this method returns, contains the type of matrix elements. This parameter is passed uninitialized. |
Returns
| Type | Description |
|---|---|
| IntPtr | The pointer to the array element specified by |
Remarks
This method can be used for sequential access to 1D, 2D or nD dense arrays. The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Ptr(Int32[])
Returns a pointer to a specific array element.
Declaration
public IntPtr Ptr(int[] index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32[] | index | An array specifying the zero-based multi-dimensional element index.
The length of |
Returns
| Type | Description |
|---|---|
| IntPtr | The pointer to the array element specified by the multi-dimensional
|
Remarks
The method can be used for sparse arrays as well; if the requested node does not exist, it is created and set to zero.
Ptr(Int32[], out Int32, Boolean)
Returns a pointer to a specific array element.
Declaration
public IntPtr Ptr(int[] index, out int elementType, bool createNode = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32[] | index | An array specifying the zero-based multi-dimensional element index.
The length of |
| Int32 | elementType | When this method returns, contains the type of matrix elements. This parameter is passed uninitialized. |
| Boolean | createNode | Optional parameter for sparse arrays only. true means that the requested element is created if it does not exist already; otherwise, the array will not be changed. |
Returns
| Type | Description |
|---|---|
| IntPtr | The pointer to the array element specified by the multi-dimensional
|
Reshape(Int32, Int32)
Changes shape of matrix/image without copying data.
Declaration
public Mat Reshape(int channels, int rows = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | channels | The new number of channels. Zero means that the number of channels remains unchanged. |
| Int32 | rows | The new number of rows. Zero means that the number of rows remains
unchanged unless it needs to be changed according to |
Returns
| Type | Description |
|---|---|
| Mat | A new matrix header for the array with the newly specified shape. |
Set(Scalar, Arr)
Sets every element of the array to a given value.
Declaration
public void Set(Scalar value, Arr mask = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Scalar | value | The fill value. |
| Arr | mask | Optional operation mask, 8-bit single-channel array specifying the elements that should be changed. |
SetData(IntPtr, Int32)
Assigns the specified user data pointer to the array header.
Declaration
public void SetData(IntPtr data, int step)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | data | The user data pointer to the raw element data. |
| Int32 | step | The full row length in bytes. |
SetReal(Int32, Double)
Sets a specific element of single-channel array.
Declaration
public void SetReal(int index, double value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The zero-based element index. |
| Double | value | The assigned value. |
Remarks
The method can be used for sparse arrays as well; if the node does not
exist, it is created and set to the specified value.
SetReal(Int32, Int32, Double)
Sets a specific element of single-channel array.
Declaration
public void SetReal(int index0, int index1, double value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
| Double | value | The assigned value. |
Remarks
The method can be used for sparse arrays as well; if the node does not
exist, it is created and set to the specified value.
SetReal(Int32, Int32, Int32, Double)
Sets a specific element of single-channel array.
Declaration
public void SetReal(int index0, int index1, int index2, double value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index0 | The zero-based element index on the first array dimension. |
| Int32 | index1 | The zero-based element index on the second array dimension. |
| Int32 | index2 | The zero-based element index on the third array dimension. |
| Double | value | The assigned value. |
Remarks
The method can be used for sparse arrays as well; if the node does not
exist, it is created and set to the specified value.
SetReal(Int32[], Double)
Sets a specific element of single-channel array.
Declaration
public void SetReal(int[] index, double value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32[] | index | An array specifying the zero-based multi-dimensional element index.
The length of |
| Double | value | The assigned value. |
Remarks
The method can be used for sparse arrays as well; if the node does not
exist, it is created and set to the specified value.
SetZero()
Clears the array. In the case of dense arrays, all elements are set to zero; for sparse arrays all the elements are removed.
Declaration
public void SetZero()