Table of Contents

Method FromPixelData

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

FromPixelData(int, int, nint, long)

constructor for matrix headers pointing to user-allocated data

public static Mat<TElem> FromPixelData(int rows, int cols, nint data, long step = 0)

Parameters

rows int

Number of rows in a 2D array.

cols int

Number of columns in a 2D array.

data nint

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 de-allocated, so you should take care of it.

step long

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() .

Returns

Mat<TElem>

FromPixelData(int, int, Array, long)

constructor for matrix headers pointing to user-allocated data

public static Mat<TElem> FromPixelData(int rows, int cols, Array data, long step = 0)

Parameters

rows int

Number of rows in a 2D array.

cols int

Number of columns in a 2D array.

data Array

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 de-allocated, so you should take care of it.

step long

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() .

Returns

Mat<TElem>

FromPixelData(IEnumerable<int>, nint, IEnumerable<long>?)

constructor for matrix headers pointing to user-allocated data

public static Mat<TElem> FromPixelData(IEnumerable<int> sizes, nint data, IEnumerable<long>? steps = null)

Parameters

sizes IEnumerable<int>

Array of integers specifying an n-dimensional array shape.

data nint

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 de-allocated, so you should take care of it.

steps IEnumerable<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.

Returns

Mat<TElem>