Class representing 1 to 4-channel matrix of float or uchar, stored on CPU and/or GPU side. More...
Functions | |
Mat | __cinit__ (self, width=0, height=0, mat_type=MAT_TYPE.F32_C1, memory_type=MEM.CPU) |
Default constructor. More... | |
None | init_mat_type (self, width, height, mat_type, memory_type=MEM.CPU) |
Initilizes a new sl.Mat and allocates the requested memory by calling alloc_size(). More... | |
None | init_mat_cpu (self, int width, int height, MAT_TYPE mat_type, ptr, step, memory_type=MEM.CPU) |
Initilizes a new sl.Mat from an existing data pointer. More... | |
None | init_mat_resolution (self, Resolution resolution, MAT_TYPE mat_type, memory_type=MEM.CPU) |
Initilizes a new sl.Mat and allocates the requested memory by calling alloc_size(). More... | |
None | init_mat_resolution_cpu (self, Resolution resolution, mat_type, ptr, step, memory_type=MEM.CPU) |
Initilizes a new sl.Mat from an existing data pointer. More... | |
None | init_mat (self, Mat matrix) |
Initilizes a new sl.Mat by copy (shallow copy). More... | |
None | alloc_size (self, width, height, mat_type, memory_type=MEM.CPU) |
Allocates the sl.Mat memory. More... | |
None | alloc_resolution (self, Resolution resolution, MAT_TYPE mat_type, memory_type=MEM.CPU) |
Allocates the sl.Mat memory. More... | |
None | free (self, memory_type=MEM.CPU) |
Free the owned memory. More... | |
ERROR_CODE | copy_to (self, Mat dst, cpy_type=COPY_TYPE.CPU_CPU) |
Copies data to another sl.Mat (deep copy). More... | |
ERROR_CODE | set_from (self, Mat src, cpy_type=COPY_TYPE.CPU_CPU) |
Copies data from an other sl.Mat (deep copy). More... | |
ERROR_CODE | read (self, str filepath) |
Reads an image from a file (only if sl.MEM.CPU is available on the current sl.Mat). More... | |
ERROR_CODE | write (self, str filepath, memory_type=MEM.CPU, compression_level=-1) |
Writes the sl.Mat (only if sl.MEM.CPU is available on the current sl.Mat) into a file as an image. More... | |
ERROR_CODE | set_to (self, value, memory_type=MEM.CPU) |
Fills the sl.Mat with the given value. More... | |
ERROR_CODE | set_value (self, int x, int y, value, memory_type=MEM.CPU) |
Sets a value to a specific point in the matrix. More... | |
ERROR_CODE | get_value (self, int x, int y, memory_type=MEM.CPU) |
Returns the value of a specific point in the matrix. More... | |
int | get_width (self) |
Returns the width of the matrix. More... | |
int | get_height (self) |
Returns the height of the matrix. More... | |
Resolution | get_resolution (self) |
Returns the resolution (width and height) of the matrix. More... | |
int | get_channels (self) |
Returns the number of values stored in one pixel. More... | |
MAT_TYPE | get_data_type (self) |
Returns the format of the matrix. More... | |
MEM | get_memory_type (self) |
Returns the type of memory (CPU and/or GPU). More... | |
np.array | numpy (self, force=False) |
Returns the sl.Mat as a NumPy array. More... | |
np.array | get_data (self, memory_type=MEM.CPU, deep_copy=False) |
Cast the data of the sl.Mat in a NumPy array (with or without copy). More... | |
int | get_step_bytes (self, memory_type=MEM.CPU) |
Returns the memory step in bytes (size of one pixel row). More... | |
int | get_step (self, memory_type=MEM.CPU) |
Returns the memory step in number of elements (size in one pixel row). More... | |
int | get_pixel_bytes (self) |
Returns the size of one pixel in bytes. More... | |
int | get_width_bytes (self) |
Returns the size of a row in bytes. More... | |
str | get_infos (self) |
Returns the information about the sl.Mat into a string. More... | |
bool | is_init (self) |
Returns whether the sl.Mat is initialized or not. More... | |
bool | is_memory_owner (self) |
Returns whether the sl.Mat is the owner of the memory it accesses. More... | |
ERROR_CODE | clone (self, Mat py_mat) |
Duplicates a sl.Mat by copy (deep copy). More... | |
ERROR_CODE | move (self, Mat py_mat) |
Moves the data of the sl.Mat to another sl.Mat. More... | |
int | get_pointer (self, memory_type=MEM.CPU) |
Gets the pointer of the content of the sl.Mat. More... | |
str | name (self) |
The name of the sl.Mat (optional). More... | |
int | timestamp (self) |
Timestamp of the last manipulation of the data of the matrix by a method/function. | |
bool | verbose (self) |
Whether the sl.Mat can display information. | |
Static Functions | |
None | swap (Mat mat1, Mat mat2) |
Swaps the content of the provided sl::Mat (only swaps the pointers, no data copy). 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.
Mat __cinit__ | ( | self, | |
width = 0 , |
|||
height = 0 , |
|||
mat_type = MAT_TYPE.F32_C1 , |
|||
memory_type = MEM.CPU |
|||
) |
Default constructor.
width | : Width of the matrix in pixels. Default: 0 |
height | : Height of the matrix in pixels. Default: 0 |
mat_type | : Type of the matrix (sl.MAT_TYPE.F32_C1, sl.MAT_TYPE.U8_C4, etc.). Default: sl.MAT_TYPE.F32_C1 |
memory_type | : Where the buffer will be stored. Default: sl.MEM.CPU (you cannot change this default value) |
None init_mat_type | ( | self, | |
width, | |||
height, | |||
mat_type, | |||
memory_type = MEM.CPU |
|||
) |
Initilizes a new sl.Mat and allocates the requested memory by calling alloc_size().
width | : Width of the matrix in pixels. Default: 0 |
height | : Height of the matrix in pixels. Default: 0 |
mat_type | : Type of the matrix (sl.MAT_TYPE.F32_C1, sl.MAT_TYPE.U8_C4, etc.). Default: sl.MAT_TYPE.F32_C1 |
memory_type | : Where the buffer will be stored. Default: sl.MEM.CPU (you cannot change this default value) |
None init_mat_cpu | ( | self, | |
int | width, | ||
int | height, | ||
MAT_TYPE | mat_type, | ||
ptr, | |||
step, | |||
memory_type = MEM.CPU |
|||
) |
Initilizes a new sl.Mat from an existing data pointer.
This method does not allocate the memory.
width | : Width of the matrix in pixels. |
height | : Height of the matrix in pixels. |
mat_type | : Type of the matrix (sl.MAT_TYPE.F32_C1, sl.MAT_TYPE.U8_C4, etc.). Default: sl.MAT_TYPE.F32_C1 |
ptr | : Pointer to the data array. |
step | : Step of the data array (bytes size of one pixel row). |
memory_type | : Where the buffer will be stored. Default: sl.MEM.CPU (you cannot change this default value) |
None init_mat_resolution | ( | self, | |
Resolution | resolution, | ||
MAT_TYPE | mat_type, | ||
memory_type = MEM.CPU |
|||
) |
Initilizes a new sl.Mat and allocates the requested memory by calling alloc_size().
resolution | : Size of the matrix in pixels. |
mat_type | : Type of the matrix (sl.MAT_TYPE.F32_C1, sl.MAT_TYPE.U8_C4, etc.). Default: sl.MAT_TYPE.F32_C1 |
memory_type | : Where the buffer will be stored. Default: sl.MEM.CPU (you cannot change this default value) |
None init_mat_resolution_cpu | ( | self, | |
Resolution | resolution, | ||
mat_type, | |||
ptr, | |||
step, | |||
memory_type = MEM.CPU |
|||
) |
Initilizes a new sl.Mat from an existing data pointer.
This method does not allocate the memory.
resolution | : the size of the matrix in pixels. |
mat_type | : Type of the matrix (sl.MAT_TYPE.F32_C1, sl.MAT_TYPE.U8_C4, etc.). Default: sl.MAT_TYPE.F32_C1 |
ptr | : Pointer to the data array (CPU or GPU). |
step | : Step of the data array (bytes size of one pixel row). |
memory_type | : Where the buffer will be stored. Default: sl.MEM.CPU (you cannot change this default value) |
None init_mat | ( | self, | |
Mat | matrix | ||
) |
None alloc_size | ( | self, | |
width, | |||
height, | |||
mat_type, | |||
memory_type = MEM.CPU |
|||
) |
Allocates the sl.Mat memory.
width | : Width of the matrix in pixels. |
height | : Height of the matrix in pixels. |
mat_type | : Type of the matrix (sl.MAT_TYPE.F32_C1, sl.MAT_TYPE.U8_C4, etc.). Default: sl.MAT_TYPE.F32_C1 |
memory_type | : Where the buffer will be stored. Default: sl.MEM.CPU (you cannot change this default value) |
None alloc_resolution | ( | self, | |
Resolution | resolution, | ||
MAT_TYPE | mat_type, | ||
memory_type = MEM.CPU |
|||
) |
Allocates the sl.Mat memory.
resolution | : Size of the matrix in pixels. |
mat_type | : Type of the matrix (sl.MAT_TYPE.F32_C1, sl.MAT_TYPE.U8_C4, etc.). Default: sl.MAT_TYPE.F32_C1 |
memory_type | : Where the buffer will be stored. Default: sl.MEM.CPU (you cannot change this default value) |
None free | ( | self, | |
memory_type = MEM.CPU |
|||
) |
Free the owned memory.
memory_type | : Specifies which memory you wish to free. Default: sl.MEM.CPU (you cannot change this default value) |
ERROR_CODE copy_to | ( | self, | |
Mat | dst, | ||
cpy_type = COPY_TYPE.CPU_CPU |
|||
) |
Copies data to another sl.Mat (deep copy).
dst | : sl.Mat where the data will be copied to. |
cpy_type | : Specifies the memory that will be used for the copy. Default: sl.COPY_TYPE.CPU_CPU (you cannot change this default value) |
ERROR_CODE set_from | ( | self, | |
Mat | src, | ||
cpy_type = COPY_TYPE.CPU_CPU |
|||
) |
Copies data from an other sl.Mat (deep copy).
src | : sl.Mat where the data will be copied from. |
cpy_type | : Specifies the memory that will be used for the copy. Default: sl.COPY_TYPE.CPU_CPU (you cannot change this default value) |
ERROR_CODE read | ( | self, | |
str | filepath | ||
) |
Reads an image from a file (only if sl.MEM.CPU is available on the current sl.Mat).
Supported input files format are PNG and JPEG.
filepath | : Path of the file to read from (including the name and extension). |
ERROR_CODE write | ( | self, | |
str | filepath, | ||
memory_type = MEM.CPU , |
|||
compression_level = -1 |
|||
) |
Writes the sl.Mat (only if sl.MEM.CPU is available on the current sl.Mat) into a file as an image.
Supported output files format are PNG and JPEG.
filepath | : Path of the file to write (including the name and extension). |
memory_type | : Memory type of the sl.Mat. Default: sl.MEM.CPU (you cannot change the default value) |
compression_level | : Level of compression between 0 (lowest compression == highest size == highest quality(jpg)) and 100 (highest compression == lowest size == lowest quality(jpg)). |
ERROR_CODE set_to | ( | self, | |
value, | |||
memory_type = MEM.CPU |
|||
) |
Fills the sl.Mat with the given value.
This method overwrites all the matrix.
value | : Value to be copied all over the matrix. |
memory_type | : Which buffer to fill. Default: sl.MEM.CPU (you cannot change the default value) |
ERROR_CODE set_value | ( | self, | |
int | x, | ||
int | y, | ||
value, | |||
memory_type = MEM.CPU |
|||
) |
Sets a value to a specific point in the matrix.
x | : Column of the point to change. |
y | : Row of the point to change. |
value | : Value to be set. |
memory_type | : Which memory will be updated. |
ERROR_CODE get_value | ( | self, | |
int | x, | ||
int | y, | ||
memory_type = MEM.CPU |
|||
) |
Returns the value of a specific point in the matrix.
x | : Column of the point to get the value from. |
y | : Row of the point to get the value from. |
memory_type | : Which memory should be read. |
int get_width | ( | self | ) |
Returns the width of the matrix.
int get_height | ( | self | ) |
Returns the height of the matrix.
Resolution get_resolution | ( | self | ) |
Returns the resolution (width and height) of the matrix.
int get_channels | ( | self | ) |
Returns the number of values stored in one pixel.
MAT_TYPE get_data_type | ( | self | ) |
Returns the format of the matrix.
Referenced by Mat.get_value(), Mat.set_to(), and Mat.set_value().
MEM get_memory_type | ( | self | ) |
Returns the type of memory (CPU and/or GPU).
np.array numpy | ( | self, | |
force = False |
|||
) |
Returns the sl.Mat as a NumPy array.
This is for convenience to mimic the PyTorch API.
This is like an alias of get_data() method.
force | : Whether the memory of the sl.Mat need to be duplicated. |
np.array get_data | ( | self, | |
memory_type = MEM.CPU , |
|||
deep_copy = False |
|||
) |
Cast the data of the sl.Mat in a NumPy array (with or without copy).
memory_type | : Which memory should be read. Default: MEM.CPU (you cannot change the default value) |
deep_copy | : Whether the memory of the sl.Mat need to be duplicated. |
Referenced by Mat.numpy().
int get_step_bytes | ( | self, | |
memory_type = MEM.CPU |
|||
) |
Returns the memory step in bytes (size of one pixel row).
memory_type | : Specifies whether you want sl.MEM.CPU or sl.MEM.GPU step. Default: sl.MEM.CPU (you cannot change the default value) |
int get_step | ( | self, | |
memory_type = MEM.CPU |
|||
) |
Returns the memory step in number of elements (size in one pixel row).
memory_type | : Specifies whether you want sl.MEM.CPU or sl.MEM.GPU step. Default: sl.MEM.CPU (you cannot change the default value) |
int get_pixel_bytes | ( | self | ) |
Returns the size of one pixel in bytes.
int get_width_bytes | ( | self | ) |
Returns the size of a row in bytes.
str get_infos | ( | self | ) |
Returns the information about the sl.Mat into a string.
Referenced by Matrix4f.m(), and Mat.verbose().
bool is_init | ( | self | ) |
bool is_memory_owner | ( | self | ) |
ERROR_CODE clone | ( | self, | |
Mat | py_mat | ||
) |
ERROR_CODE move | ( | self, | |
Mat | py_mat | ||
) |
Moves the data of the sl.Mat to another sl.Mat.
This method gives the attribute of the current s.Mat to the specified one. (No copy.)
py_mat | : sl.Mat to move to. |
Referenced by Mat.__cinit__(), Mat.init_mat(), Mat.init_mat_cpu(), Mat.init_mat_resolution(), Mat.init_mat_resolution_cpu(), and Mat.init_mat_type().
Swaps the content of the provided sl::Mat (only swaps the pointers, no data copy).
mat1 | : First matrix to swap. |
mat2 | : Second matrix to swap. |
int get_pointer | ( | self, | |
memory_type = MEM.CPU |
|||
) |
Gets the pointer of the content of the sl.Mat.
memory_type | : Which memory you want to get. Default: sl.MEM.CPU (you cannot change the default value) |