OpenCV for Unity 2.6.5
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.UnityUtils.MatUtils Class Reference

Static Public Member Functions

static int copyFromMat (Mat mat, IntPtr intPtr)
 Copies the data from an OpenCV Mat to an IntPtr.
 
static int copyFromMat (Mat mat, IntPtr intPtr, int length)
 Copies the data from an OpenCV Mat to an IntPtr.
 
static int copyFromMat< T > (Mat mat, IntPtr intPtr, int length)
 Copies the data from an OpenCV Mat to an IntPtr.
 
static int copyFromMat< T > (Mat mat, NativeArray< T > array)
 Copies the data from an OpenCV Mat to a NativeArray.
 
static int copyFromMat< T > (Mat mat, NativeArray< T > array, int length)
 Copies the data from an OpenCV Mat to a NativeArray.
 
static int copyFromMat< T > (Mat mat, Span< T > array)
 Copies the data from an OpenCV Mat to a Span.
 
static int copyFromMat< T > (Mat mat, Span< T > array, int length)
 Copies the data from an OpenCV Mat to a Span.
 
static int copyFromMat< T > (Mat mat, T[] array)
 Copies the data from an OpenCV Mat to a managed array.
 
static int copyFromMat< T > (Mat mat, T[] array, int length)
 Copies the data from an OpenCV Mat to a managed array.
 
static int copyToMat (IntPtr intPtr, Mat mat)
 Copies the data from an IntPtr to an OpenCV Mat.
 
static int copyToMat (IntPtr intPtr, Mat mat, int length)
 Copies the data from an IntPtr to an OpenCV Mat.
 
static int copyToMat< T > (IntPtr intPtr, Mat mat, int length)
 Copies the data from an IntPtr to an OpenCV Mat.
 
static int copyToMat< T > (NativeArray< T > array, Mat mat)
 Copies the data from a NativeArray to an OpenCV Mat.
 
static int copyToMat< T > (NativeArray< T > array, Mat mat, int length)
 Copies the data from a NativeArray to an OpenCV Mat.
 
static int copyToMat< T > (Span< T > array, Mat mat)
 Copies the data from a Span to an OpenCV Mat.
 
static int copyToMat< T > (Span< T > array, Mat mat, int length)
 Copies the data from a Span to an OpenCV Mat.
 
static int copyToMat< T > (T[] array, Mat mat)
 Copies the data from a managed array to an OpenCV Mat.
 
static int copyToMat< T > (T[] array, Mat mat, int length)
 Copies the data from a managed array to an OpenCV Mat.
 

Member Function Documentation

◆ copyFromMat() [1/2]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat ( Mat mat,
IntPtr intPtr )
static

Copies the data from an OpenCV Mat to an IntPtr.

This method transfers the data stored in an OpenCV Mat object into an IntPtr. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

The entire range of data managed by the Mat will be copied to the IntPtr. If you want to specify the exact range of data to copy, please use the method that accepts a length argument.

Note: This method operates on unmanaged memory, and incorrect usage can lead to unpredictable behavior, crashes, or data corruption. Ensure that the source pointer points to a valid memory region and that the specified length does not exceed the allocated memory size for that region. Additionally, as this method involves unmanaged memory, be cautious about potential security risks. Accessing memory beyond the intended range can lead to buffer overflows and may compromise application stability and security. It is highly recommended to perform validation checks on the pointer and the specified length.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
intPtrThe destination IntPtr where the data will be copied. This pointer must reference a valid memory region.
Returns
The number of bytes copied from the Mat to the IntPtr.
Exceptions
ArgumentNullExceptionThrown when mat is null.
ArgumentExceptionThrown when intPtr == IntPtr.Zero. Thrown when !mat.isContinuous() && mat.dims() > 2.

◆ copyFromMat() [2/2]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat ( Mat mat,
IntPtr intPtr,
int length )
static

Copies the data from an OpenCV Mat to an IntPtr.

This method transfers the data stored in an OpenCV Mat object into an IntPtr. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size of the memory region pointed to by the IntPtr is smaller than the data size managed by the Mat, data will be copied up to the size of the IntPtr. If the data size of the memory region pointed to by the IntPtr is larger, data will be copied up to the size managed by the Mat.

Note: This method operates on unmanaged memory, and incorrect usage can lead to unpredictable behavior, crashes, or data corruption. Ensure that the source pointer points to a valid memory region and that the specified length does not exceed the allocated memory size for that region. Additionally, as this method involves unmanaged memory, be cautious about potential security risks. Accessing memory beyond the intended range can lead to buffer overflows and may compromise application stability and security. It is highly recommended to perform validation checks on the pointer and the specified length.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
intPtrThe destination IntPtr where the data will be copied. This pointer must reference a valid memory region.
lengthThe number of elements, in terms of byte size, to copy from the source Mat to the destination IntPtr. The length represents the size in bytes, regardless of the actual type of data in the Mat or the destination.
Returns
The number of bytes copied from the Mat to the IntPtr.
Exceptions
ArgumentNullExceptionThrown when mat is null.
ArgumentExceptionThrown when intPtr == IntPtr.Zero. Thrown when !mat.isContinuous() && mat.dims() > 2.

◆ copyFromMat< T >() [1/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat< T > ( Mat mat,
IntPtr intPtr,
int length )
static

Copies the data from an OpenCV Mat to an IntPtr.

This method transfers the data stored in an OpenCV Mat object into an IntPtr. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size of the memory region pointed to by the IntPtr is smaller than the data size managed by the Mat, data will be copied up to the size of the IntPtr. If the data size of the memory region pointed to by the IntPtr is larger, data will be copied up to the size managed by the Mat.

Note: This method operates on unmanaged memory, and incorrect usage can lead to unpredictable behavior, crashes, or data corruption. Ensure that the source pointer points to a valid memory region and that the specified length does not exceed the allocated memory size for that region. Additionally, as this method involves unmanaged memory, be cautious about potential security risks. Accessing memory beyond the intended range can lead to buffer overflows and may compromise application stability and security. It is highly recommended to perform validation checks on the pointer and the specified length.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements represented by the IntPtr. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
intPtrThe destination IntPtr where the data will be copied. This pointer must reference a valid memory region.
lengthThe number of elements of type T to copy from the source Mat to the destination IntPtr.
Returns
The number of bytes copied from the Mat to the IntPtr.
Exceptions
ArgumentNullExceptionThrown when mat is null.
ArgumentExceptionThrown when intPtr == IntPtr.Zero. Thrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyFromMat< T >() [2/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat< T > ( Mat mat,
NativeArray< T > array )
static

Copies the data from an OpenCV Mat to a NativeArray.

This method transfers the data stored in an OpenCV Mat object into a NativeArray. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size managed by the array is smaller than the data size managed by the Mat, data will be copied up to the size of the array. If the data size managed by the array is larger, data will be copied up to the size managed by the Mat.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the NativeArray. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
arrayThe destination NativeArray where the data will be copied.
Returns
The number of bytes copied from the Mat to the NativeArray.
Exceptions
ArgumentNullExceptionThrown when mat or array is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyFromMat< T >() [3/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat< T > ( Mat mat,
NativeArray< T > array,
int length )
static

Copies the data from an OpenCV Mat to a NativeArray.

This method transfers the data stored in an OpenCV Mat object into a NativeArray. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size managed by the array is smaller than the data size managed by the Mat, data will be copied up to the size of the array. If the data size managed by the array is larger, data will be copied up to the size managed by the Mat.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the NativeArray. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
arrayThe destination NativeArray where the data will be copied.
lengthThe number of elements of type T to copy from the source Mat to the destination managed array.
Returns
The number of bytes copied from the Mat to the NativeArray.
Exceptions
ArgumentNullExceptionThrown when mat or array is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyFromMat< T >() [4/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat< T > ( Mat mat,
Span< T > array )
static

Copies the data from an OpenCV Mat to a Span.

This method transfers the data stored in an OpenCV Mat object into a Span. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size managed by the array is smaller than the data size managed by the Mat, data will be copied up to the size of the array. If the data size managed by the array is larger, data will be copied up to the size managed by the Mat.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the Span. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
arrayThe destination Span where the data will be copied.
Returns
The number of bytes copied from the Mat to the Span.
Exceptions
ArgumentNullExceptionThrown when mat or array is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyFromMat< T >() [5/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat< T > ( Mat mat,
Span< T > array,
int length )
static

Copies the data from an OpenCV Mat to a Span.

This method transfers the data stored in an OpenCV Mat object into a Span. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size managed by the array is smaller than the data size managed by the Mat, data will be copied up to the size of the array. If the data size managed by the array is larger, data will be copied up to the size managed by the Mat.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the Span. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
arrayThe destination Span where the data will be copied.
lengthThe number of elements of type T to copy from the source Mat to the destination Span.
Returns
The number of bytes copied from the Mat to the Span.
Exceptions
ArgumentNullExceptionThrown when mat or array is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyFromMat< T >() [6/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat< T > ( Mat mat,
T[] array )
static

Copies the data from an OpenCV Mat to a managed array.

This method transfers the data stored in an OpenCV Mat object into a managed array. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size managed by the array is smaller than the data size managed by the Mat, data will be copied up to the size of the array. If the data size managed by the array is larger, data will be copied up to the size managed by the Mat.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the managed array. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
arrayThe destination managed array where the data will be copied.
Returns
The number of bytes copied from the Mat to the managed array.
Exceptions
ArgumentNullExceptionThrown when mat or array is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyFromMat< T >() [7/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyFromMat< T > ( Mat mat,
T[] array,
int length )
static

Copies the data from an OpenCV Mat to a managed array.

This method transfers the data stored in an OpenCV Mat object into a managed array. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size managed by the array is smaller than the data size managed by the Mat, data will be copied up to the size of the array. If the data size managed by the array is larger, data will be copied up to the size managed by the Mat.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the Mat and the array. Although its functionality is more limited compared to the Mat.get method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the managed array. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
matThe source Mat from which data will be copied. The Mat must not be disposed of or null.
arrayThe destination managed array where the data will be copied.
lengthThe number of elements of type T to copy from the source Mat to the destination managed array.
Returns
The number of bytes copied from the Mat to the managed array.
Exceptions
ArgumentNullExceptionThrown when mat or array is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyToMat() [1/2]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat ( IntPtr intPtr,
Mat mat )
static

Copies the data from an IntPtr to an OpenCV Mat.

This method transfers the data stored in an IntPtr to an OpenCV Mat. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

Data of the same size in bytes as the data managed by the Mat is copied from the IntPtr to the Mat. If you want to specify the exact range of data to copy, please use the method that accepts a length argument.

Note: This method operates on unmanaged memory, and incorrect usage can lead to unpredictable behavior, crashes, or data corruption. Ensure that the source pointer points to a valid memory region and that the specified length does not exceed the allocated memory size for that region. Additionally, as this method involves unmanaged memory, be cautious about potential security risks. Accessing memory beyond the intended range can lead to buffer overflows and may compromise application stability and security. It is highly recommended to perform validation checks on the pointer and the specified length.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Parameters
intPtrThe source IntPtr from which data will be copied. This pointer must reference a valid memory region.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
Returns
The number of bytes copied from the IntPtr to the Mat.
Exceptions
ArgumentNullExceptionThrown when mat is null.
ArgumentExceptionThrown when intPtr == IntPtr.Zero. Thrown when !mat.isContinuous() && mat.dims() > 2.

◆ copyToMat() [2/2]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat ( IntPtr intPtr,
Mat mat,
int length )
static

Copies the data from an IntPtr to an OpenCV Mat.

This method transfers the data stored in an IntPtr to an OpenCV Mat. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size managed by the Mat is smaller than the data size of the memory region pointed to by the IntPtr, data will be copied up to the size of the mat. If the data size managed by the Mat is larger, data will be copied up to the size of the memory region pointed to by the IntPtr.

Note: This method operates on unmanaged memory, and incorrect usage can lead to unpredictable behavior, crashes, or data corruption. Ensure that the source pointer points to a valid memory region and that the specified length does not exceed the allocated memory size for that region. Additionally, as this method involves unmanaged memory, be cautious about potential security risks. Accessing memory beyond the intended range can lead to buffer overflows and may compromise application stability and security. It is highly recommended to perform validation checks on the pointer and the specified length.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Parameters
intPtrThe source IntPtr from which data will be copied. This pointer must reference a valid memory region.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
lengthThe number of elements, in terms of byte size, to copy from the source IntPtr to the destination Mat. The length represents the size in bytes, regardless of the actual type of data in the IntPtr or the destination.
Returns
The number of bytes copied from the IntPtr to the Mat.
Exceptions
ArgumentNullExceptionThrown when mat is null.
ArgumentExceptionThrown when intPtr == IntPtr.Zero. Thrown when !mat.isContinuous() && mat.dims() > 2.

◆ copyToMat< T >() [1/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat< T > ( IntPtr intPtr,
Mat mat,
int length )
static

Copies the data from an IntPtr to an OpenCV Mat.

This method transfers the data stored in an IntPtr to an OpenCV Mat. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data from Mats with any number of dimensions.

If the data size managed by the Mat is smaller than the data size of the memory region pointed to by the IntPtr, data will be copied up to the size of the mat. If the data size managed by the Mat is larger, data will be copied up to the size of the memory region pointed to by the IntPtr.

Note: This method operates on unmanaged memory, and incorrect usage can lead to unpredictable behavior, crashes, or data corruption. Ensure that the source pointer points to a valid memory region and that the specified length does not exceed the allocated memory size for that region. Additionally, as this method involves unmanaged memory, be cautious about potential security risks. Accessing memory beyond the intended range can lead to buffer overflows and may compromise application stability and security. It is highly recommended to perform validation checks on the pointer and the specified length.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements represented by the IntPtr. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
intPtrThe source IntPtr from which data will be copied. This pointer must reference a valid memory region.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
lengthThe number of elements of type T to copy from the source IntPtr to the destination Mat.
Returns
The number of bytes copied from the IntPtr to the Mat.
Exceptions
ArgumentNullExceptionThrown when mat is null.
ArgumentExceptionThrown when intPtr == IntPtr.Zero. Thrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyToMat< T >() [2/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat< T > ( NativeArray< T > array,
Mat mat )
static

Copies the data from a NativeArray to an OpenCV Mat.

This method transfers the data stored in a NativeArray into an OpenCV Mat object. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data where Mats with any number of dimensions.

If the data size managed by the Mat is smaller than the data size managed by the array, data will be copied up to the size of the mat. If the data size managed by the Mat is larger, data will be copied up to the size managed by the array.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the NativeArray. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
arrayThe source NativeArray from which data will be copied.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
Returns
The number of bytes copied from the NativeArray to the Mat.
Exceptions
ArgumentNullExceptionThrown when array or mat is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyToMat< T >() [3/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat< T > ( NativeArray< T > array,
Mat mat,
int length )
static

Copies the data from a NativeArray to an OpenCV Mat.

This method transfers the data stored in a NativeArray into an OpenCV Mat object. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data where Mats with any number of dimensions.

If the data size managed by the Mat is smaller than the data size managed by the array, data will be copied up to the size of the mat. If the data size managed by the Mat is larger, data will be copied up to the size managed by the array.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the NativeArray. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
arrayThe source NativeArray from which data will be copied.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
lengthThe number of elements of type T to copy from the source NativeArray to the destination Mat.
Returns
The number of bytes copied from the NativeArray to the Mat.
Exceptions
ArgumentNullExceptionThrown when array or mat is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyToMat< T >() [4/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat< T > ( Span< T > array,
Mat mat )
static

Copies the data from a Span to an OpenCV Mat.

This method transfers the data stored in a Span into an OpenCV Mat object. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data where Mats with any number of dimensions.

If the data size managed by the Mat is smaller than the data size managed by the array, data will be copied up to the size of the mat. If the data size managed by the Mat is larger, data will be copied up to the size managed by the array.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the Span. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
arrayThe source Span from which data will be copied.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
Returns
The number of bytes copied from the Span to the Mat.
Exceptions
ArgumentNullExceptionThrown when array or mat is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyToMat< T >() [5/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat< T > ( Span< T > array,
Mat mat,
int length )
static

Copies the data from a Span to an OpenCV Mat.

This method transfers the data stored in a Span into an OpenCV Mat object. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data where Mats with any number of dimensions.

If the data size managed by the Mat is smaller than the data size managed by the array, data will be copied up to the size of the mat. If the data size managed by the Mat is larger, data will be copied up to the size managed by the array.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the Span. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
arrayThe source Span from which data will be copied.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
lengthThe number of elements of type T to copy from the source Span to the destination Mat.
Returns
The number of bytes copied from the Span to the Mat.
Exceptions
ArgumentNullExceptionThrown when array or mat is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyToMat< T >() [6/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat< T > ( T[] array,
Mat mat )
static

Copies the data from a managed array to an OpenCV Mat.

This method transfers the data stored in a managed array into an OpenCV Mat object. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data where Mats with any number of dimensions.

If the data size managed by the Mat is smaller than the data size managed by the array, data will be copied up to the size of the mat. If the data size managed by the Mat is larger, data will be copied up to the size managed by the array.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the managed array. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
arrayThe source managed array from which data will be copied.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
Returns
The number of bytes copied from the managed array to the Mat.
Exceptions
ArgumentNullExceptionThrown when array or mat is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

◆ copyToMat< T >() [7/7]

static int OpenCVForUnity.UnityUtils.MatUtils.copyToMat< T > ( T[] array,
Mat mat,
int length )
static

Copies the data from a managed array to an OpenCV Mat.

This method transfers the data stored in a managed array into an OpenCV Mat object. It supports both continuous and non-continuous Mat objects:

  • If mat.isContinuous() is false and mat.dims() exceeds 2, the method will throw an exception, as non-continuous Mats with more than 2 dimensions are unsupported.
  • If mat.isContinuous() is true, the method can copy data where Mats with any number of dimensions.

If the data size managed by the Mat is smaller than the data size managed by the array, data will be copied up to the size of the mat. If the data size managed by the Mat is larger, data will be copied up to the size managed by the array.

Note: This method is specialized for copying a continuous range of data regardless of differences in types between the array and the Mat. Although its functionality is more limited compared to the Mat.put method, it offers improved performance for such operations.

Template Parameters
TThe type of the elements in the managed array. This must be an unmanaged type (i.e., a type without references to managed objects) to allow for direct memory access.
Parameters
arrayThe source managed array from which data will be copied.
matThe destination Mat where the data will be copied. The Mat must not be disposed of or null.
lengthThe number of elements of type T to copy from the source managed array to the destination Mat.
Returns
The number of bytes copied from the managed array to the Mat.
Exceptions
ArgumentNullExceptionThrown when array or mat is null.
ArgumentExceptionThrown when !mat.isContinuous() && mat.dims() > 2.
Type Constraints
T :unmanaged 

The documentation for this class was generated from the following file: