using OpenCVForUnity.CoreModule; using System; using System.Runtime.InteropServices; #if OPENCV_USE_UNSAFE_CODE && UNITY_2018_1_OR_NEWER using Unity.Collections.LowLevel.Unsafe; using Unity.Collections; #endif namespace OpenCVForUnity.UtilsModule { public static class MatUtils { /** * Copies OpenCV Mat data to Pixel Data IntPtr. *
*
This method copies the OpenCV Mat data to the pixel data IntPtr.
*
The pixel data must have the same byte size as the Mat data ([total() * elemSize()] byte).
*
Because this method doesn't check bounds, is faster than Mat.get().
*
* @param mat a Mat object.
* @param intPtr the pixel data must have the same byte size as the Mat data ([total() * elemSize()] byte).
*/
public static void copyFromMat(Mat mat, IntPtr intPtr)
{
if (mat == null)
throw new ArgumentNullException("mat");
if (mat != null)
mat.ThrowIfDisposed();
if (intPtr == IntPtr.Zero)
throw new ArgumentException("intPtr == IntPtr.Zero");
OpenCVForUnity_MatDataToByteArray(mat.nativeObj, intPtr);
}
/**
* Copies Pixel Data IntPtr to OpenCV Mat data.
*
*
This method copy the pixel data IntPtr to the OpenCV Mat data.
*
The Mat object must have the same byte size as the pixel data ([total() * elemSize()] byte).
*
Because this method doesn't check bounds, is faster than Mat.put().
*
* @param intPtr a pixel data IntPtr.
* @param mat the Mat object must have the same byte size as the pixel data ([total() * elemSize()] byte).
*/
public static void copyToMat(IntPtr intPtr, Mat mat)
{
if (intPtr == IntPtr.Zero)
throw new ArgumentException("intPtr == IntPtr.Zero");
if (mat == null)
throw new ArgumentNullException("mat");
if (mat != null)
mat.ThrowIfDisposed();
OpenCVForUnity_ByteArrayToMatData(intPtr, mat.nativeObj);
}
/**
* Copies OpenCV Mat data to Pixel Data Array.
*
*
*
*
*
This method copies the OpenCV Mat data to the pixel data Array.
*
The pixel data Array must have the same byte size as the Mat data ([total() * elemSize()] byte).
*
Because this method doesn't check bounds, is faster than Mat.get().
*
* @param mat a Mat object.
* @param array the pixel data Array must have the same byte size as the Mat data ([total() * elemSize()] byte).
*/
public static void copyFromMat
This method copies the pixel data Array to the OpenCV Mat data.
*
The Mat object must have the same byte size as the pixel data Array ([total() * elemSize()] byte).
*
Because this method doesn't check bounds, is faster than Mat.put().
*
* @param array a pixel data Array.
* @param mat the Mat object must have the same byte size as the pixel data Array ([total() * elemSize()] byte).
*/
public static void copyToMat
This method copies the OpenCV Mat data to the pixel data NativeArray.
*
The pixel data Array must have the same byte size as the Mat data ([total() * elemSize()] byte).
*
Because this method doesn't check bounds, is faster than Mat.get().
*
* @param mat a Mat object.
* @param array the pixel data Array must have the same byte size as the Mat data ([total() * elemSize()] byte).
*/
public static void copyFromMat
This method copies the pixel data NativeArray to the OpenCV Mat data.
*
The Mat object must have the same byte size as the pixel data Array ([total() * elemSize()] byte).
*
Because this method doesn't check bounds, is faster than Mat.put().
*
* @param array a pixel data Array.
* @param mat the Mat object must have the same byte size as the pixel data Array ([total() * elemSize()] byte).
*/
public static void copyToMat