TensorParameters Struct Reference

Structure to define the input options for deep learning inference. More...

Types

enum class  COLOR_FORMAT
 Lists available color formats for the Tensor. More...
 
enum class  LAYOUT
 Lists available memory layouts for the Tensor. More...
 
enum class  PIXEL_TYPE : int
 Lists available pixel data types for the Tensor elements. More...
 

Functions

size_t getPixelSize () const
 Returns the size in bytes of a single pixel element based on pixel_type. More...
 
int getRequestedChannels () const
 Returns the number of channels associated with the color_format. More...
 

Attributes

sl::Resolution target_size = sl::Resolution(640, 640)
 Target size for the input image (Width, Height). More...
 
PIXEL_TYPE pixel_type = PIXEL_TYPE::FLOAT
 Pixel data type for the Tensor elements. More...
 
sl::float3 mean = {0.485f, 0.456f, 0.406f}
 Normalization parameter: Mean. More...
 
sl::float3 std = {0.229f, 0.224f, 0.225f}
 Normalization parameter: Standard Deviation. More...
 
bool stretch = false
 If true, stretches the image to target_size. If false, keeps aspect ratio and applies letterboxing (padding). More...
 
sl::float3 scale = {1.f / 255.f, 1.f / 255.f, 1.f / 255.f}
 Scale factor applied to the pixel values before normalization. More...
 
COLOR_FORMAT color_format = COLOR_FORMAT::BGR
 Desired color format for the output Tensor. More...
 
LAYOUT layout = LAYOUT::NCHW
 Desired memory layout for the output Tensor. More...
 
size_t batch_size = 1
 Number of images in the batch. More...
 
MEM memory_type = MEM::GPU
 Where the Tensor should be stored (CPU or GPU). More...
 

Detailed Description

Structure to define the input options for deep learning inference.

Enumeration

◆ COLOR_FORMAT

enum COLOR_FORMAT
strong

Lists available color formats for the Tensor.

Enumerator
GRAY 

1-channel Grayscale.

1-channel Y (Luminance) from YUV.

RGB 

3-channel RGB.

BGR 

3-channel BGR.

RGBA 

4-channel RGBA.

BGRA 

4-channel BGRA.

◆ LAYOUT

enum LAYOUT
strong

Lists available memory layouts for the Tensor.

Enumerator
NCHW 

Batch, Channels, Height, Width (Planar). Common for PyTorch models.

NHWC 

Batch, Height, Width, Channels (Interleaved). Common for TensorFlow models.

◆ PIXEL_TYPE

enum PIXEL_TYPE : int
strong

Lists available pixel data types for the Tensor elements.

Enumerator
FLOAT 

32-bit floating point.

HALF 

16-bit floating point (half precision).

UCHAR 

Unsigned char (8-bit).

Functions

◆ getPixelSize()

size_t getPixelSize ( ) const
inline

Returns the size in bytes of a single pixel element based on pixel_type.

Returns
The size in bytes (1 for UCHAR, 2 for HALF, 4 for FLOAT).

◆ getRequestedChannels()

int getRequestedChannels ( ) const
inline

Returns the number of channels associated with the color_format.

Returns
The number of channels.

Variables

◆ target_size

sl::Resolution target_size = sl::Resolution(640, 640)

Target size for the input image (Width, Height).

◆ pixel_type

Pixel data type for the Tensor elements.

Note
Specifies the underlying data type: UCHAR (8-bit), FLOAT (32-bit), or HALF (16-bit).

◆ mean

sl::float3 mean = {0.485f, 0.456f, 0.406f}

Normalization parameter: Mean.

Note
Pixel = (Pixel * Scale - Mean) / Std.
Default: ImageNet Standard {0.485, 0.456, 0.406}.

◆ std

sl::float3 std = {0.229f, 0.224f, 0.225f}

Normalization parameter: Standard Deviation.

Note
Pixel = (Pixel * Scale - Mean) / Std.
Default: ImageNet Standard {0.229, 0.224, 0.225}.

◆ stretch

bool stretch = false

If true, stretches the image to target_size. If false, keeps aspect ratio and applies letterboxing (padding).

◆ scale

sl::float3 scale = {1.f / 255.f, 1.f / 255.f, 1.f / 255.f}

Scale factor applied to the pixel values before normalization.

◆ color_format

Desired color format for the output Tensor.

◆ layout

LAYOUT layout = LAYOUT::NCHW

Desired memory layout for the output Tensor.

Note
NCHW (planar) is common for PyTorch models.
NHWC (interleaved) is common for TensorFlow models.

◆ batch_size

size_t batch_size = 1

Number of images in the batch.

◆ memory_type

MEM memory_type = MEM::GPU

Where the Tensor should be stored (CPU or GPU).