//======= Copyright (c) Stereolabs Corporation, All rights reserved. =============== using System; using System.Runtime.InteropServices; /// /// This file holds the ZEDMat class along with low-level structures used for passing data between /// the C# ZEDMat and its equivalent in the SDK. /// namespace sl { /// /// Represents a 2D vector of uchars for use on both the CPU and GPU. /// [StructLayout(LayoutKind.Sequential)] public struct char2 { public byte r; public byte g; } /// /// Represents a 3D vector of uchars for use on both the CPU and GPU. /// [StructLayout(LayoutKind.Sequential)] public struct char3 { public byte r; public byte g; public byte b; } /// /// Represents a 4D vector of uchars for use on both the CPU and GPU. /// [StructLayout(LayoutKind.Sequential)] public struct char4 { [MarshalAs(UnmanagedType.U1)] public byte r; [MarshalAs(UnmanagedType.U1)] public byte g; [MarshalAs(UnmanagedType.U1)] public byte b; [MarshalAs(UnmanagedType.U1)] public byte a; } /// /// Represents a 2D vector of floats for use on both the CPU and GPU. /// [StructLayout(LayoutKind.Sequential)] public struct float2 { public float r; public float g; } /// /// Represents a 3D vector of floats for use on both the CPU and GPU. /// [StructLayout(LayoutKind.Sequential)] public struct float3 { public float r; public float g; public float b; } /// /// Represents a 4D vector of floats for use on both the CPU and GPU. /// [StructLayout(LayoutKind.Sequential)] public struct float4 { public float r; public float g; public float b; public float a; } /// /// Mirrors the sl::Mat class used in the ZED C++ SDK to store images. /// Can be used to retrieve individual images from GPU or CPU memory: see ZEDCamera.RetrieveImage() /// and ZEDCamera.RetrieveMeasure(). /// /// For more information on the Mat class it mirrors, see: /// https://www.stereolabs.com/developers/documentation/API/v2.5.1/classsl_1_1Mat.html /// public class ZEDMat { /// /// Type of mat, indicating the data type and the number of channels it holds. /// Proper mat type depends on the image type. See sl.VIEW and sl.MEASURE (in ZEDCommon.cs) /// public enum MAT_TYPE { /// /// Float, one channel. Used for depth and disparity Measure-type textures. /// MAT_32F_C1, /// /// Float, two channels. /// MAT_32F_C2, /// /// Float, three channels. /// MAT_32F_C3, /*!< float 3 channels.*/ /// /// Float, four channels. Used for normals and XYZ (point cloud) measure-type textures /// MAT_32F_C4, /// /// Unsigned char, one channel. Used for greyscale image-type textures like depth and confidence displays. /// MAT_8U_C1, /// /// Unsigned char, two channels. /// MAT_8U_C2, /// /// Unsigned char, three channels. /// MAT_8U_C3, /// /// Unsigned char, four channels. Used for color images, like the main RGB image from each sensor. /// MAT_8U_C4 }; /// /// Categories for copying data within or between the CPU (processor) memory and GPU (graphics card) memory. /// public enum COPY_TYPE { /// /// Copies data from one place in CPU memory to another. /// COPY_TYPE_CPU_CPU, /*!< copy data from CPU to CPU.*/ /// /// Copies data from CPU memory to GPU memory. /// COPY_TYPE_CPU_GPU, /*!< copy data from CPU to GPU.*/ /// /// Copies data from one place in GPU memory to another. /// COPY_TYPE_GPU_GPU, /*!< copy data from GPU to GPU.*/ /// /// Copies data from GPU memory to CPU memory. /// COPY_TYPE_GPU_CPU /*!< copy data from GPU to CPU.*/ }; /// /// Which memory to store an image/mat: CPU/processor memory or GPU (graphics card) memory. /// public enum MEM { /// /// Store on memory accessible by the CPU. /// MEM_CPU = 1, /// /// Store on memory accessible by the GPU. /// MEM_GPU = 2 }; #region DLL Calls const string nameDll = "sl_unitywrapper"; [DllImport(nameDll, EntryPoint = "dllz_mat_create_new")] private static extern IntPtr dllz_mat_create_new(sl.Resolution resolution, int type, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_create_new_empty")] private static extern IntPtr dllz_mat_create_new_empty(); [DllImport(nameDll, EntryPoint = "dllz_mat_is_init")] private static extern bool dllz_mat_is_init(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_free")] private static extern bool dllz_mat_free(System.IntPtr ptr, int type); [DllImport(nameDll, EntryPoint = "dllz_mat_get_infos")] private static extern bool dllz_mat_get_infos(System.IntPtr ptr, byte[] buffer); [DllImport(nameDll, EntryPoint = "dllz_mat_get_value_float")] private static extern int dllz_mat_get_value_float(System.IntPtr ptr, int x, int y, out float value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_get_value_float2")] private static extern int dllz_mat_get_value_float2(System.IntPtr ptr, int x, int y, out float2 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_get_value_float3")] private static extern int dllz_mat_get_value_float3(System.IntPtr ptr, int x, int y, out float3 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_get_value_float4")] private static extern int dllz_mat_get_value_float4(System.IntPtr ptr, int x, int y, out float4 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_get_value_uchar")] private static extern int dllz_mat_get_value_uchar(System.IntPtr ptr, int x, int y, out byte value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_get_value_uchar2")] private static extern int dllz_mat_get_value_uchar2(System.IntPtr ptr, int x, int y, out char2 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_get_value_uchar3")] private static extern int dllz_mat_get_value_uchar3(System.IntPtr ptr, int x, int y, out char3 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_get_value_uchar4")] private static extern int dllz_mat_get_value_uchar4(System.IntPtr ptr, int x, int y, out char4 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_value_float")] private static extern int dllz_mat_set_value_float(System.IntPtr ptr, int x, int y, ref float value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_value_float2")] private static extern int dllz_mat_set_value_float2(System.IntPtr ptr, int x, int y, ref float2 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_value_float3")] private static extern int dllz_mat_set_value_float3(System.IntPtr ptr, int x, int y, ref float3 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_value_float4")] private static extern int dllz_mat_set_value_float4(System.IntPtr ptr, int x, int y, ref float4 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_value_uchar")] private static extern int dllz_mat_set_value_uchar(System.IntPtr ptr, int x, int y, ref byte value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_value_uchar2")] private static extern int dllz_mat_set_value_uchar2(System.IntPtr ptr, int x, int y, ref char2 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_value_uchar3")] private static extern int dllz_mat_set_value_uchar3(System.IntPtr ptr, int x, int y, ref char3 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_value_uchar4")] private static extern int dllz_mat_set_value_uchar4(System.IntPtr ptr, int x, int y, ref char4 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_to_float")] private static extern int dllz_mat_set_to_float(System.IntPtr ptr, ref float value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_to_float2")] private static extern int dllz_mat_set_to_float2(System.IntPtr ptr, ref float2 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_to_float3")] private static extern int dllz_mat_set_to_float3(System.IntPtr ptr, ref float3 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_to_float4")] private static extern int dllz_mat_set_to_float4(System.IntPtr ptr, ref float4 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_to_uchar")] private static extern int dllz_mat_set_to_uchar(System.IntPtr ptr, ref byte value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_to_uchar2")] private static extern int dllz_mat_set_to_uchar2(System.IntPtr ptr, ref char2 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_to_uchar3")] private static extern int dllz_mat_set_to_uchar3(System.IntPtr ptr, ref char3 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_to_uchar4")] private static extern int dllz_mat_set_to_uchar4(System.IntPtr ptr, ref char4 value, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_update_cpu_from_gpu")] private static extern int dllz_mat_update_cpu_from_gpu(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_update_gpu_from_cpu")] private static extern int dllz_mat_update_gpu_from_cpu(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_read")] private static extern int dllz_mat_read(System.IntPtr ptr, string filePath); [DllImport(nameDll, EntryPoint = "dllz_mat_write")] private static extern int dllz_mat_write(System.IntPtr ptr, string filePath); [DllImport(nameDll, EntryPoint = "dllz_mat_copy_to")] private static extern int dllz_mat_copy_to(System.IntPtr ptr, System.IntPtr dest, int cpyType); [DllImport(nameDll, EntryPoint = "dllz_mat_get_width")] private static extern int dllz_mat_get_width(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_get_height")] private static extern int dllz_mat_get_height(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_get_channels")] private static extern int dllz_mat_get_channels(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_get_memory_type")] private static extern int dllz_mat_get_memory_type(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_get_pixel_bytes")] private static extern int dllz_mat_get_pixel_bytes(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_get_step")] private static extern int dllz_mat_get_step(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_get_step_bytes")] private static extern int dllz_mat_get_step_bytes(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_get_width_bytes")] private static extern int dllz_mat_get_width_bytes(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_is_memory_owner")] private static extern bool dllz_mat_is_memory_owner(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_get_resolution")] private static extern sl.Resolution dllz_mat_get_resolution(System.IntPtr ptr); [DllImport(nameDll, EntryPoint = "dllz_mat_alloc")] private static extern void dllz_mat_alloc(System.IntPtr ptr, int width, int height, int type, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_set_from")] private static extern int dllz_mat_set_from(System.IntPtr ptr, System.IntPtr source, int copyType); [DllImport(nameDll, EntryPoint = "dllz_mat_get_ptr")] private static extern System.IntPtr dllz_mat_get_ptr(System.IntPtr ptr, int mem); [DllImport(nameDll, EntryPoint = "dllz_mat_clone")] private static extern void dllz_mat_clone(System.IntPtr ptr, System.IntPtr ptrSource); #endregion /// /// Returns the internal ptr of a Mat. /// private System.IntPtr _matInternalPtr; /// /// Returns the internal ptr of a Mat. /// public IntPtr MatPtr { get { return _matInternalPtr; } } /// /// Creates an empty Mat. /// public ZEDMat() { _matInternalPtr = dllz_mat_create_new_empty(); } /// /// Creates a mat from an existing internal ptr. /// /// IntPtr to create the material with. public ZEDMat(System.IntPtr ptr) { if(ptr == IntPtr.Zero) { throw new Exception("ZED Mat not initialized."); } _matInternalPtr = ptr; } /// /// Creates a Mat with a given resolution. /// /// Resolution for the new Mat. /// Data type and number of channels the Mat will hold. /// Depends on texture type: see sl.VIEW and sl.MEASURE in ZEDCommon.cs. /// Whether Mat should exist on CPU or GPU memory. /// Choose depending on where you'll need to access it from. public ZEDMat(sl.Resolution resolution, MAT_TYPE type, MEM mem = MEM.MEM_CPU) { _matInternalPtr = dllz_mat_create_new(resolution, (int)(type), (int)(mem)); } /// /// Creates a Mat with a given width and height. /// /// Width of the new Mat. /// Height of the new Mat. /// Data type and number of channels the Mat will hold. /// Depends on texture type: see sl.VIEW and sl.MEASURE in ZEDCommon.cs. /// Whether Mat should exist on CPU or GPU memory. /// Choose depending on where you'll need to access it from. public ZEDMat(uint width, uint height, MAT_TYPE type, MEM mem = MEM.MEM_CPU) { _matInternalPtr = dllz_mat_create_new(new sl.Resolution(width, height), (int)(type), (int)(mem)); } /// /// True if the Mat has been initialized. /// /// public bool IsInit() { return dllz_mat_is_init(_matInternalPtr); } /// /// Frees the memory of the Mat. /// /// Whether the Mat is on CPU or GPU memory. public void Free(MEM mem = (MEM.MEM_GPU | MEM.MEM_CPU)) { dllz_mat_free(_matInternalPtr, (int)mem); _matInternalPtr = System.IntPtr.Zero; } /// /// Copies data from the GPU to the CPU, if possible. /// /// public sl.ERROR_CODE UpdateCPUFromGPU() { return (sl.ERROR_CODE)dllz_mat_update_cpu_from_gpu(_matInternalPtr); } /// /// Copies data from the CPU to the GPU, if possible. /// /// public sl.ERROR_CODE UpdateGPUFromCPU() { return (sl.ERROR_CODE)dllz_mat_update_gpu_from_cpu(_matInternalPtr); } /// /// Returns information about the Mat. /// /// String providing Mat information. public string GetInfos() { byte[] buf = new byte[300]; dllz_mat_get_infos(_matInternalPtr, buf); return System.Text.Encoding.ASCII.GetString(buf); } /// /// Copies data from this Mat to another Mat (deep copy). /// /// Mat that the data will be copied to. /// The To and From memory types. /// Error code indicating if the copy was successful, or why it wasn't. public sl.ERROR_CODE CopyTo(sl.ZEDMat dest, sl.ZEDMat.COPY_TYPE copyType = COPY_TYPE.COPY_TYPE_CPU_CPU) { return (sl.ERROR_CODE)dllz_mat_copy_to(_matInternalPtr, dest._matInternalPtr, (int)(copyType)); } /// /// Reads an image from a file. Supports .png and .jpeg. Only works if Mat has access to MEM_CPU. /// /// File path, including file name and extension. /// Error code indicating if the read was successful, or why it wasn't. public sl.ERROR_CODE Read(string filePath) { return (sl.ERROR_CODE)dllz_mat_read(_matInternalPtr, filePath); } /// /// Writes the Mat into a file as an image. Only works if Mat has access to MEM_CPU. /// /// File path, including file name and extension. /// Error code indicating if the write was successful, or why it wasn't. public sl.ERROR_CODE Write(string filePath) { return (sl.ERROR_CODE)dllz_mat_write(_matInternalPtr, filePath); } /// /// Returns the width of the matrix. /// /// public int GetWidth() { return dllz_mat_get_width(_matInternalPtr); } /// /// Returns the height of the matrix. /// /// public int GetHeight() { return dllz_mat_get_height(_matInternalPtr); } /// /// Returns the number of values/channels stored in each pixel. /// /// Number of values/channels. public int GetChannels() { return dllz_mat_get_channels(_matInternalPtr); } /// /// Returns the size in bytes of one pixel. /// /// Size in bytes. public int GetPixelBytes() { return dllz_mat_get_pixel_bytes(_matInternalPtr); } /// /// Returns the memory 'step' in number/length of elements - how many values make up each row of pixels. /// /// Step length. public int GetStep() { return dllz_mat_get_step(_matInternalPtr); } /// /// Returns the memory 'step' in bytes - how many bytes make up each row of pixels. /// /// public int GetStepBytes() { return dllz_mat_get_step_bytes(_matInternalPtr); } /// /// Returns the size of each row in bytes. /// /// public int GetWidthBytes() { return dllz_mat_get_width_bytes(_matInternalPtr); } /// /// Returns the type of memory (CPU and/or GPU). /// /// public MEM GetMemoryType() { return (MEM)dllz_mat_get_memory_type(_matInternalPtr); } /// /// Returns whether the Mat is the owner of the memory it's accessing. /// /// public bool IsMemoryOwner() { return dllz_mat_is_memory_owner(_matInternalPtr); } /// /// Returns the resolution of the image that this Mat holds. /// /// public sl.Resolution GetResolution() { return dllz_mat_get_resolution(_matInternalPtr); } /// /// Allocates memory for the Mat. /// /// Width of the image/matrix in pixels. /// Height of the image/matrix in pixels. /// Type of matrix (data type and channels; see sl.MAT_TYPE) /// Where the buffer will be stored - CPU memory or GPU memory. public void Alloc(uint width, uint height, MAT_TYPE matType, MEM mem = MEM.MEM_CPU) { dllz_mat_alloc(_matInternalPtr, (int)width, (int)height, (int)matType, (int)mem); } /// /// Allocates memory for the Mat. /// /// Size of the image/matrix in pixels. /// Type of matrix (data type and channels; see sl.MAT_TYPE) /// Where the buffer will be stored - CPU memory or GPU memory. public void Alloc(sl.Resolution resolution, MAT_TYPE matType, MEM mem = MEM.MEM_CPU) { dllz_mat_alloc(_matInternalPtr, (int)resolution.width, (int)resolution.height, (int)matType, (int)mem); } /// /// Copies data from another Mat into this one(deep copy). /// /// Source Mat from which to copy. /// The To and From memory types. /// ERROR_CODE (as an int) indicating if the copy was successful, or why it wasn't. public int SetFrom(ZEDMat src, COPY_TYPE copyType = COPY_TYPE.COPY_TYPE_CPU_CPU) { return dllz_mat_set_from(_matInternalPtr, src._matInternalPtr, (int)copyType); } public System.IntPtr GetPtr(MEM mem = MEM.MEM_CPU) { return dllz_mat_get_ptr(_matInternalPtr, (int)mem); } /// /// Duplicates a Mat by copying all its data into a new one (deep copy). /// /// public void Clone(ZEDMat source) { dllz_mat_clone(_matInternalPtr, source._matInternalPtr); } /************ GET VALUES *********************/ //Cannot send values by template due to a covariant issue with an out needed. /// /// Returns the value of a specific point in the matrix. (MAT_32F_C1) /// /// Row the point is in. /// Column the point is in. /// Gets filled with the current value. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the get was successful, or why it wasn't. public sl.ERROR_CODE GetValue(int x, int y, out float value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_get_value_float(_matInternalPtr, x, y, out value, (int)(mem))); } /// /// Returns the value of a specific point in the matrix. (MAT_32F_C2) /// /// Row the point is in. /// Column the point is in. /// Gets filled with the current value. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the get was successful, or why it wasn't. public sl.ERROR_CODE GetValue(int x, int y, out float2 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_get_value_float2(_matInternalPtr, x, y, out value, (int)(mem))); } /// /// Returns the value of a specific point in the matrix. (MAT_32F_C3) /// /// Row the point is in. /// Column the point is in. /// Gets filled with the current value. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the get was successful, or why it wasn't. public sl.ERROR_CODE GetValue(int x, int y, out float3 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_get_value_float3(_matInternalPtr, x, y, out value, (int)(mem))); } /// /// Returns the value of a specific point in the matrix. (MAT_32F_C4) /// /// Row the point is in. /// Column the point is in. /// Gets filled with the current value. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the get was successful, or why it wasn't. public sl.ERROR_CODE GetValue(int x, int y, out float4 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_get_value_float4(_matInternalPtr, x, y, out value, (int)(mem))); } /// /// Returns the value of a specific point in the matrix. (MAT_TYPE_8U_C1) /// /// Row the point is in. /// Column the point is in. /// Gets filled with the current value. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the get was successful, or why it wasn't. public sl.ERROR_CODE GetValue(int x, int y, out byte value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_get_value_uchar(_matInternalPtr, x, y, out value, (int)(mem))); } /// /// Returns the value of a specific point in the matrix. (MAT_TYPE_8U_C2) /// /// Row the point is in. /// Column the point is in. /// Gets filled with the current value. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the get was successful, or why it wasn't. public sl.ERROR_CODE GetValue(int x, int y, out char2 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_get_value_uchar2(_matInternalPtr, x, y, out value, (int)(mem))); } /// /// Returns the value of a specific point in the matrix. (MAT_TYPE_8U_C3) /// /// Row the point is in. /// Column the point is in. /// Gets filled with the current value. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the get was successful, or why it wasn't. public sl.ERROR_CODE GetValue(int x, int y, out char3 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_get_value_uchar3(_matInternalPtr, x, y, out value, (int)(mem))); } /// /// Returns the value of a specific point in the matrix. (MAT_TYPE_8U_C4) /// /// Row the point is in. /// Column the point is in. /// Gets filled with the current value. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the get was successful, or why it wasn't. public sl.ERROR_CODE GetValue(int x, int y, out char4 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_get_value_uchar4(_matInternalPtr, x, y, out value, (int)(mem))); } /***************************************************************************************/ /************ SET VALUES *********************/ //Cannot send values by template due to a covariant issue with an out needed. /// /// Sets a value to a specific point in the matrix. (MAT_32F_C1) /// /// Row the point is in. /// Column the point is in. /// Value to which the point will be set. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the set was successful, or why it wasn't. public sl.ERROR_CODE SetValue(int x, int y, ref float value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_value_float(_matInternalPtr, x, y, ref value, (int)(mem))); } /// /// Sets a value to a specific point in the matrix. (MAT_32F_C2) /// /// Row the point is in. /// Column the point is in. /// Value to which the point will be set. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the set was successful, or why it wasn't. public sl.ERROR_CODE SetValue(int x, int y, ref float2 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_value_float2(_matInternalPtr, x, y, ref value, (int)(mem))); } /// /// Sets a value to a specific point in the matrix. (MAT_32F_C3) /// /// Row the point is in. /// Column the point is in. /// Value to which the point will be set. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the set was successful, or why it wasn't. public sl.ERROR_CODE SetValue(int x, int y, ref float3 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_value_float3(_matInternalPtr, x, y, ref value, (int)(mem))); } /// /// Sets a value to a specific point in the matrix. (MAT_32F_C4) /// /// Row the point is in. /// Column the point is in. /// Value to which the point will be set. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the set was successful, or why it wasn't. public sl.ERROR_CODE SetValue(int x, int y, float4 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_value_float4(_matInternalPtr, x, y, ref value, (int)(mem))); } /// /// Sets a value to a specific point in the matrix. (MAT_TYPE_8U_C1) /// /// Row the point is in. /// Column the point is in. /// Value to which the point will be set. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the set was successful, or why it wasn't. public sl.ERROR_CODE SetValue(int x, int y, ref byte value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_value_uchar(_matInternalPtr, x, y, ref value, (int)(mem))); } /// /// Sets a value to a specific point in the matrix. (MAT_TYPE_8U_C2) /// /// Row the point is in. /// Column the point is in. /// Value to which the point will be set. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the set was successful, or why it wasn't. public sl.ERROR_CODE SetValue(int x, int y, ref char2 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_value_uchar2(_matInternalPtr, x, y, ref value, (int)(mem))); } /// /// Sets a value to a specific point in the matrix. (MAT_TYPE_8U_C3) /// /// Row the point is in. /// Column the point is in. /// Value to which the point will be set. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the set was successful, or why it wasn't. public sl.ERROR_CODE SetValue(int x, int y, ref char3 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_value_uchar3(_matInternalPtr, x, y, ref value, (int)(mem))); } /// /// Sets a value to a specific point in the matrix. (MAT_TYPE_8U_C4) /// /// Row the point is in. /// Column the point is in. /// Value to which the point will be set. /// Whether point is on CPU memory or GPU memory. /// Error code indicating if the set was successful, or why it wasn't. public sl.ERROR_CODE SetValue(int x, int y, ref char4 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_value_uchar4(_matInternalPtr, x, y, ref value, (int)(mem))); } /***************************************************************************************/ /************ SET TO *********************/ //Cannot send values by template due to a covariant issue with an out needed. /// /// Fills the entire Mat with the given value. (MAT_32F_C1) /// /// Value with which to fill the Mat. /// Which buffer to fill - CPU or GPU memory. /// Whether the set was successful, or why it wasn't. public sl.ERROR_CODE SetTo(ref float value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_to_float(_matInternalPtr, ref value, (int)(mem))); } /// /// Fills the entire Mat with the given value. (MAT_32F_C2) /// /// Value with which to fill the Mat. /// Which buffer to fill - CPU or GPU memory. /// Whether the set was successful, or why it wasn't. public sl.ERROR_CODE SetTo(ref float2 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_to_float2(_matInternalPtr, ref value, (int)(mem))); } /// /// Fills the entire Mat with the given value. (MAT_32F_C3) /// /// Value with which to fill the Mat. /// Which buffer to fill - CPU or GPU memory. /// Whether the set was successful, or why it wasn't. public sl.ERROR_CODE SetTo(ref float3 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_to_float3(_matInternalPtr, ref value, (int)(mem))); } /// /// Fills the entire Mat with the given value. (MAT_32F_C4) /// /// Value with which to fill the Mat. /// Which buffer to fill - CPU or GPU memory. /// Whether the set was successful, or why it wasn't. public sl.ERROR_CODE SetTo(ref float4 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_to_float4(_matInternalPtr, ref value, (int)(mem))); } /// /// Fills the entire Mat with the given value. (MAT_TYPE_8U_C1) /// /// Value with which to fill the Mat. /// Which buffer to fill - CPU or GPU memory. /// Whether the set was successful, or why it wasn't. public sl.ERROR_CODE SetTo(ref byte value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_to_uchar(_matInternalPtr, ref value, (int)(mem))); } /// /// Fills the entire Mat with the given value. (MAT_TYPE_8U_C2) /// /// Value with which to fill the Mat. /// Which buffer to fill - CPU or GPU memory. /// Whether the set was successful, or why it wasn't. public sl.ERROR_CODE SetTo(ref char2 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_to_uchar2(_matInternalPtr, ref value, (int)(mem))); } /// /// Fills the entire Mat with the given value. (MAT_TYPE_8U_C3) /// /// Value with which to fill the Mat. /// Which buffer to fill - CPU or GPU memory. /// Whether the set was successful, or why it wasn't. public sl.ERROR_CODE SetTo(ref char3 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_to_uchar3(_matInternalPtr, ref value, (int)(mem))); } /// /// Fills the entire Mat with the given value. (MAT_TYPE_8U_C4) /// /// Value with which to fill the Mat. /// Which buffer to fill - CPU or GPU memory. /// Whether the set was successful, or why it wasn't. public sl.ERROR_CODE SetTo( ref char4 value, sl.ZEDMat.MEM mem) { return (sl.ERROR_CODE)(dllz_mat_set_to_uchar4(_matInternalPtr, ref value, (int)(mem))); } /***************************************************************************************/ } }