Class representing 1 to 4-channel matrix of float or uchar, stored on CPU and/or GPU side. More...
Functions | |
Mat () | |
Default constructor. More... | |
Mat (System.IntPtr ptr) | |
Constructor. More... | |
Mat (sl.Resolution resolution, MAT_TYPE type, MEM mem=MEM.CPU) | |
Constructor. More... | |
void | Create (sl.Resolution resolution, MAT_TYPE type, MEM mem=MEM.CPU) |
Creates a sl.Mat with a given sl.Resolution. More... | |
void | Create (uint width, uint height, MAT_TYPE type, MEM mem=MEM.CPU) |
Creates a Mat with a given width and height. More... | |
bool | IsInit () |
Whether the sl.Mat has been initialized. More... | |
void | Free (MEM mem=MEM.BOTH) |
Frees the memory of the sl.Mat. More... | |
sl.ERROR_CODE | UpdateCPUFromGPU () |
Copies data from the GPU to the CPU, if possible. More... | |
sl.ERROR_CODE | UpdateGPUFromCPU () |
Copies data from the CPU to the GPU, if possible. More... | |
string | GetInfos () |
Returns the information about the sl::Mat into a string. More... | |
sl.ERROR_CODE | CopyTo (sl.Mat dest, sl.COPY_TYPE copyType=COPY_TYPE.CPU_CPU) |
Copies data from this sl.Mat to another sl.Mat (deep copy). More... | |
sl.ERROR_CODE | Read (string filePath) |
Reads an image from a file. More... | |
sl.ERROR_CODE | Write (string filePath, int compressionLevel=-1) |
Writes the sl.Mat into a file as an image. More... | |
int | GetWidth () |
Returns the width of the matrix. More... | |
int | GetHeight () |
Returns the height of the matrix. More... | |
int | GetChannels () |
Returns the number of values stored in one pixel. More... | |
int | GetPixelBytes () |
Returns the size of one pixel in bytes. More... | |
int | GetStep (sl.MEM mem=sl.MEM.CPU) |
Returns the memory step in number of elements (size in one pixel row). More... | |
int | GetStepBytes (sl.MEM mem=sl.MEM.CPU) |
Returns the memory step in bytes (size of one pixel row). More... | |
int | GetWidthBytes () |
Returns the size of a row in bytes. More... | |
MEM | GetMemoryType () |
Returns the type of memory (CPU and/or GPU). More... | |
bool | IsMemoryOwner () |
Returns whether the sl.Mat is the owner of the memory it accesses. More... | |
sl.Resolution | GetResolution () |
Returns the resolution (width and height) of the matrix. More... | |
void | Alloc (uint width, uint height, MAT_TYPE matType, MEM mem=MEM.CPU) |
Allocates the sl.Mat memory. More... | |
void | Alloc (sl.Resolution resolution, MAT_TYPE matType, MEM mem=MEM.CPU) |
Allocates the sl.Mat memory. More... | |
int | SetFrom (Mat src, COPY_TYPE copyType=COPY_TYPE.CPU_CPU) |
Copies data from another sl.Mat into this one (deep copy). More... | |
System.IntPtr | GetPtr (MEM mem=MEM.CPU) |
Returns the CPU or GPU data pointer. More... | |
void | Clone (Mat source) |
Duplicates a sl.Mat by copying all its data into a new one (deep copy). More... | |
sl.ERROR_CODE | GetValue (int x, int y, out float value, sl.MEM mem=sl.MEM.CPU) |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C1. More... | |
sl.ERROR_CODE | GetValue (int x, int y, out float2 value, sl.MEM mem=sl.MEM.CPU) |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C2. More... | |
sl.ERROR_CODE | GetValue (int x, int y, out float3 value, sl.MEM mem=sl.MEM.CPU) |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C3. More... | |
sl.ERROR_CODE | GetValue (int x, int y, out float4 value, sl.MEM mem=sl.MEM.CPU) |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C4. More... | |
sl.ERROR_CODE | GetValue (int x, int y, out byte value, sl.MEM mem=sl.MEM.CPU) |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C1. More... | |
sl.ERROR_CODE | GetValue (int x, int y, out char2 value, sl.MEM mem=sl.MEM.CPU) |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C2. More... | |
sl.ERROR_CODE | GetValue (int x, int y, out char3 value, sl.MEM mem=sl.MEM.CPU) |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C3. More... | |
sl.ERROR_CODE | GetValue (int x, int y, out char4 value, sl.MEM mem=sl.MEM.CPU) |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C4. More... | |
sl.ERROR_CODE | SetValue (int x, int y, ref float value, sl.MEM mem=sl.MEM.CPU) |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C1. More... | |
sl.ERROR_CODE | SetValue (int x, int y, ref float2 value, sl.MEM mem=sl.MEM.CPU) |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C2. More... | |
sl.ERROR_CODE | SetValue (int x, int y, ref float3 value, sl.MEM mem=sl.MEM.CPU) |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C3. More... | |
sl.ERROR_CODE | SetValue (int x, int y, float4 value, sl.MEM mem=sl.MEM.CPU) |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C4. More... | |
sl.ERROR_CODE | SetValue (int x, int y, ref byte value, sl.MEM mem=sl.MEM.CPU) |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C1. More... | |
sl.ERROR_CODE | SetValue (int x, int y, ref char2 value, sl.MEM mem=sl.MEM.CPU) |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C2. More... | |
sl.ERROR_CODE | SetValue (int x, int y, ref char3 value, sl.MEM mem=sl.MEM.CPU) |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C3. More... | |
sl.ERROR_CODE | SetValue (int x, int y, ref char4 value, sl.MEM mem=sl.MEM.CPU) |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C4. More... | |
sl.ERROR_CODE | SetTo (ref float value, sl.MEM mem) |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_32F_C1 with the given value. More... | |
sl.ERROR_CODE | SetTo (ref float2 value, sl.MEM mem) |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_32F_C2 with the given value. More... | |
sl.ERROR_CODE | SetTo (ref float3 value, sl.MEM mem) |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_32F_C3 with the given value. More... | |
sl.ERROR_CODE | SetTo (ref float4 value, sl.MEM mem) |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_32F_C4 with the given value. More... | |
sl.ERROR_CODE | SetTo (ref byte value, sl.MEM mem) |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_8U_C1 with the given value. More... | |
sl.ERROR_CODE | SetTo (ref char2 value, sl.MEM mem) |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_8U_C2 with the given value. More... | |
sl.ERROR_CODE | SetTo (ref char3 value, sl.MEM mem) |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_8U_C3 with the given value. More... | |
sl.ERROR_CODE | SetTo (ref char4 value, sl.MEM mem) |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_8U_C4 with the given value. More... | |
sl.ERROR_CODE | ConvertColor (sl.MEM mem=sl.MEM.CPU, bool swapRBChannels=false) |
Convert the color channels of the Mat (RGB to BGR or RGBA to BGRA). This methods works only on 8U_C4 or 8U_C3. More... | |
Static Functions | |
static sl.ERROR_CODE | ConvertColor (sl.Mat src, sl.Mat dst, bool swapRBChannels=false, bool removeAlphaChannel=false, sl.MEM mem=sl.MEM.CPU) |
Convert the color channels of the Mat into another Mat This methods works only on 8U_C4 if removeAlphaChannel is enabled, or 8U_C4 and 8U_C3 if swapRBChannels is enabled More... | |
static sl.ERROR_CODE | BlobFromImage (sl.Mat image_in, sl.Mat tensor_out, sl.Resolution resolution, float scaleFactor, float3 mean, float3 stdDev, bool keepAspectRatio, bool swapRBChannels) |
Convert an image into a GPU Tensor in planar channel configuration (NCHW), ready to use for deep learning model More... | |
static sl.ERROR_CODE | BlobFromImages (sl.Mat[] images_in, sl.Mat tensor_out, sl.Resolution resolution, float scaleFactor, float3 mean, float3 stdDev, bool keepAspectRatio, bool swapRBChannels) |
Convert an image array into a GPU Tensor in planar channel configuration (NCHW), ready to use for deep learning model More... | |
Properties | |
IntPtr | MatPtr [get] |
Returns the internal ptr of a Mat. More... | |
Class representing 1 to 4-channel matrix of float or uchar, stored on CPU and/or GPU side.
This class is defined in a row-major order, meaning that for an image buffer, the rows are stored consecutively from top to bottom.
|
inline |
|
inline |
Constructor.
Creates a sl.Mat with a given sl.Resolution.
resolution | Size of the matrix in pixels. |
type | Type of the matrix. Depends on texture type (see sl.VIEW and sl.MEASURE). |
mem | Where the buffer will be stored (CPU or GPU memory). Choose depending on where you'll need to access it from. |
|
inline |
Creates a sl.Mat with a given sl.Resolution.
resolution | Size of the matrix in pixels. |
type | Type of the matrix. Depends on texture type (see sl.VIEW and sl.MEASURE). |
mem | Where the buffer will be stored (CPU or GPU memory). Choose depending on where you'll need to access it from. |
Creates a Mat with a given width and height.
width | Width of the matrix in pixels. |
height | Height of the matrix in pixels.. |
type | Type of the matrix. Depends on texture type (see sl.VIEW and sl.MEASURE). |
mem | Where the buffer will be stored (CPU or GPU memory). Choose depending on where you'll need to access it from. |
|
inline |
Whether the sl.Mat has been initialized.
|
inline |
Copies data from the GPU to the CPU, if possible.
|
inline |
Copies data from the CPU to the GPU, if possible.
|
inline |
|
inline |
Copies data from this sl.Mat to another sl.Mat (deep copy).
dest | sl.Mat that the data will be copied to. |
copyType | The to and from memory types. |
|
inline |
Reads an image from a file.
Supports .png and .jpeg.
filePath | Path of the file to read (including the name and extension). |
|
inline |
Writes the sl.Mat into a file as an image.
filePath | Path of the file to write in (including the name and extension). |
compression_level | Compression level used. Highest value means highest compression (smaller size). Range [0 - 100]. |
|
inline |
Returns the width of the matrix.
|
inline |
Returns the height of the matrix.
|
inline |
Returns the number of values stored in one pixel.
|
inline |
Returns the size of one pixel in bytes.
|
inline |
Returns the memory step in number of elements (size in one pixel row).
|
inline |
Returns the memory step in bytes (size of one pixel row).
|
inline |
Returns the size of a row in bytes.
|
inline |
Returns the type of memory (CPU and/or GPU).
|
inline |
Returns whether the sl.Mat is the owner of the memory it accesses.
|
inline |
Returns the resolution (width and height) of the matrix.
Allocates the sl.Mat memory.
width | Width of the image/matrix in pixels. |
height | Height of the image/matrix in pixels. |
matType | Type of matrix (data type and channels - see sl.MAT_TYPE) |
mem | Where the buffer will be stored - CPU memory or GPU memory. |
|
inline |
Allocates the sl.Mat memory.
resolution | Size of the image/matrix in pixels. |
matType | Type of matrix (data type and channels - see sl.MAT_TYPE) |
mem | Where the buffer will be stored - CPU memory or GPU memory. |
|
inline |
Copies data from another sl.Mat into this one (deep copy).
src | sl.Mat where the data will be copied from. |
copyType | Specifies the memory that will be used for the copy. |
Returns the CPU or GPU data pointer.
mem | Specifies whether you want sl.MEM.CPU or sl.MEM.GPU. |
|
inline |
|
inline |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C1.
x | Column of the point to get the value from. |
y | Row of the point to get the value from. |
value | Gets filled with the current value. |
mem | Which memory should be read. |
|
inline |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C2.
x | Column of the point to get the value from. |
y | Row of the point to get the value from. |
value | Gets filled with the current value. |
mem | Which memory should be read. |
|
inline |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C3.
x | Column of the point to get the value from. |
y | Row of the point to get the value from. |
value | Gets filled with the current value. |
mem | Which memory should be read. |
|
inline |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C4.
x | Column of the point to get the value from. |
y | Row of the point to get the value from. |
value | Gets filled with the current value. |
mem | Which memory should be read. |
|
inline |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C1.
x | Column of the point to get the value from. |
y | Row of the point to get the value from. |
value | Gets filled with the current value. |
mem | Which memory should be read. |
|
inline |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C2.
x | Column of the point to get the value from. |
y | Row of the point to get the value from. |
value | Gets filled with the current value. |
mem | Which memory should be read. |
|
inline |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C3.
x | Column of the point to get the value from. |
y | Row of the point to get the value from. |
value | Gets filled with the current value. |
mem | Which memory should be read. |
|
inline |
Returns the value of a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C4.
x | Column of the point to get the value from. |
y | Row of the point to get the value from. |
value | Gets filled with the current value. |
mem | Which memory should be read. |
|
inline |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C1.
x | Column of the point to set the value. |
y | Row of the point to set the value. |
value | Value to which the point will be set. |
mem | Which memory will be updated. |
|
inline |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C2.
x | Column of the point to set the value. |
y | Row of the point to set the value. |
value | Value to which the point will be set. |
mem | Which memory will be updated. |
|
inline |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C3.
x | Column of the point to set the value. |
y | Row of the point to set the value. |
value | Value to which the point will be set. |
mem | Which memory will be updated. |
|
inline |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_32F_C4.
x | Column of the point to set the value. |
y | Row of the point to set the value. |
value | Value to which the point will be set. |
mem | Which memory will be updated. |
|
inline |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C1.
x | Column of the point to set the value. |
y | Row of the point to set the value. |
value | Value to which the point will be set. |
mem | Which memory will be updated. |
|
inline |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C2.
x | Column of the point to set the value. |
y | Row of the point to set the value. |
value | Value to which the point will be set. |
mem | Which memory will be updated. |
|
inline |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C3.
x | Column of the point to set the value. |
y | Row of the point to set the value. |
value | Value to which the point will be set. |
mem | Which memory will be updated. |
|
inline |
Sets a value to a specific point in the matrix of type sl.MAT_TYPE.MAT_8U_C4.
x | Column of the point to set the value. |
y | Row of the point to set the value. |
value | Value to which the point will be set. |
mem | Which memory will be updated. |
|
inline |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_32F_C1 with the given value.
value | Value to be copied all over the matrix. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inline |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_32F_C2 with the given value.
value | Value to be copied all over the matrix. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inline |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_32F_C3 with the given value.
value | Value to be copied all over the matrix. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inline |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_32F_C4 with the given value.
value | Value to be copied all over the matrix. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inline |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_8U_C1 with the given value.
value | Value to be copied all over the matrix. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inline |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_8U_C2 with the given value.
value | Value to be copied all over the matrix. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inline |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_8U_C3 with the given value.
value | Value to be copied all over the matrix. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inline |
Fills the entire sl.Mat of type sl.MAT_TYPE.MAT_8U_C4 with the given value.
value | Value to be copied all over the matrix. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inline |
Convert the color channels of the Mat (RGB to BGR or RGBA to BGRA). This methods works only on 8U_C4 or 8U_C3.
mem | Which buffer to fill, CPU and/or GPU. |
swapRBChannels | Swap blue and red channels. |
|
inlinestatic |
Convert the color channels of the Mat into another Mat This methods works only on 8U_C4 if removeAlphaChannel is enabled, or 8U_C4 and 8U_C3 if swapRBChannels is enabled
src | Source image. |
dst | Destination image. |
swapRBChannels | Swap blue and red channels. |
removeAlphaChannel | Remove alpha channel. |
mem | Which buffer to fill, CPU and/or GPU. |
|
inlinestatic |
Convert an image into a GPU Tensor in planar channel configuration (NCHW), ready to use for deep learning model
image_in | input image to convert |
tensor_out | output GPU tensor |
resolution | resolution of the output image, generally square, although not mandatory |
scaleFactor | Scale factor applied to each pixel value, typically to convert the char value into [0-1] float |
mean | mean, statistic to normalized the pixel values, applied AFTER the scale. For instance for imagenet statistics the mean would be sl::float3(0.485, 0.456, 0.406) |
stdDev | standard deviation, statistic to normalized the pixel values, applied AFTER the scale. For instance for imagenet statistics the standard deviation would be sl::float3(0.229, 0.224, 0.225) |
keepAspectRatio | indicates if the original width and height ratio should be kept using padding (sometimes refer to as letterboxing) or if the image should be stretched |
swapRBChannels | indicates if the Red and Blue channels should be swapped (RGB-BGR or RGBA-BGRA) |
|
inlinestatic |
Convert an image array into a GPU Tensor in planar channel configuration (NCHW), ready to use for deep learning model
image_in | input images to convert |
tensor_out | output GPU tensor |
resolution | resolution of the output image, generally square, although not mandatory |
scaleFactor | Scale factor applied to each pixel value, typically to convert the char value into [0-1] float |
mean | mean, statistic to normalized the pixel values, applied AFTER the scale. For instance for imagenet statistics the mean would be sl::float3(0.485, 0.456, 0.406) |
stdDev | standard deviation, statistic to normalized the pixel values, applied AFTER the scale. For instance for imagenet statistics the standard deviation would be sl::float3(0.229, 0.224, 0.225) |
keepAspectRatio | indicates if the original width and height ratio should be kept using padding (sometimes refer to as letterboxing) or if the image should be stretched |
swapRBChannels | indicates if the Red and Blue channels should be swapped (RGB-BGR or RGBA-BGRA) |
|
get |
Returns the internal ptr of a Mat.
Referenced by Fusion.RetrieveImage(), and Fusion.RetrieveMeasure().