SpatialMappingParameters Class Reference

Structure containing a set of parameters for the spatial mapping module. More...

Types

enum class  SPATIAL_MAP_TYPE
 Lists the types of spatial maps that can be created. More...
 
enum class  MAPPING_RESOLUTION
 Lists the spatial mapping resolution presets. More...
 
enum class  MAPPING_RANGE
 Lists the spatial mapping depth range presets. More...
 
typedef std::pair< float, float > interval
 Float pair defining an interval. More...
 

Functions

 SpatialMappingParameters (MAPPING_RESOLUTION resolution=MAPPING_RESOLUTION::MEDIUM, MAPPING_RANGE range=MAPPING_RANGE::AUTO, int max_memory_usage_=2048, bool save_texture_=false, bool use_chunk_only_=false, bool reverse_vertex_order_=false, SPATIAL_MAP_TYPE map_type=SPATIAL_MAP_TYPE::MESH, int stability_counter=0)
 Default constructor. More...
 
void set (MAPPING_RESOLUTION mapping_resolution=MAPPING_RESOLUTION::MEDIUM)
 Sets the resolution to a sl::SpatialMappingParameters::MAPPING_RESOLUTION preset. More...
 
void set (MAPPING_RANGE mapping_range=MAPPING_RANGE::MEDIUM)
 Sets the range to a sl::SpatialMappingParameters::MAPPING_RANGE preset. More...
 
bool save (String filename)
 Saves the current set of parameters into a file to be reloaded with the load() method. More...
 
bool load (String filename)
 Loads a set of parameters from the values contained in a previously saved file. More...
 
bool operator== (const SpatialMappingParameters &param1) const
 
bool operator!= (const SpatialMappingParameters &param1) const
 

Static Functions

static float get (MAPPING_RESOLUTION mapping_resolution=MAPPING_RESOLUTION::MEDIUM)
 Returns the value corresponding to a sl::SpatialMappingParameters::MAPPING_RESOLUTION preset in meters. More...
 
static float get (MAPPING_RANGE mapping_range=MAPPING_RANGE::MEDIUM)
 Returns the value corresponding to a sl::SpatialMappingParameters::MAPPING_RANGE preset in meters. More...
 
static float getRecommendedRange (MAPPING_RESOLUTION mapping_resolution, Camera &camera)
 Returns the recommended maximum depth value corresponding to a sl::SpatialMappingParameters::MAPPING_RESOLUTION preset. More...
 
static float getRecommendedRange (float resolution_meters, Camera &camera)
 Returns the recommended maximum depth value for the given resolution in meters. More...
 

Attributes

float resolution_meter = 0.05f
 Spatial mapping resolution in meters. More...
 
float range_meter = 0.f
 Depth range in meters. More...
 
bool save_texture = false
 Whether to save the texture. More...
 
bool use_chunk_only = false
 Whether to only use chunks. More...
 
int max_memory_usage = 2048
 The maximum CPU memory (in MB) allocated for the meshing process. More...
 
bool reverse_vertex_order = false
 Whether to inverse the order of the vertices of the triangles. More...
 
SPATIAL_MAP_TYPE map_type = SPATIAL_MAP_TYPE::MESH
 The type of spatial map to be created. More...
 
int stability_counter = 0
 Control the integration rate of the current depth into the mapping process. More...
 

Static Attributes

static const interval allowed_resolution
 The resolution allowed by the spatial mapping: More...
 
static const interval allowed_range
 The maximum depth allowed by spatial mapping: More...
 

Detailed Description

Structure containing a set of parameters for the spatial mapping module.

The default constructor sets all parameters to their default settings.

Note
Parameters can be adjusted by the user.

Member Typedef Documentation

◆ interval

typedef std::pair<float, float> interval

Float pair defining an interval.

Constructor and Destructor

◆ SpatialMappingParameters()

SpatialMappingParameters ( MAPPING_RESOLUTION  resolution = MAPPING_RESOLUTION::MEDIUM,
MAPPING_RANGE  range = MAPPING_RANGE::AUTO,
int  max_memory_usage_ = 2048,
bool  save_texture_ = false,
bool  use_chunk_only_ = false,
bool  reverse_vertex_order_ = false,
SPATIAL_MAP_TYPE  map_type = SPATIAL_MAP_TYPE::MESH,
int  stability_counter = 0 
)

Default constructor.

Sets all parameters to their default and optimized values.

Functions

◆ get() [1/2]

static float get ( MAPPING_RESOLUTION  mapping_resolution = MAPPING_RESOLUTION::MEDIUM)
static

Returns the value corresponding to a sl::SpatialMappingParameters::MAPPING_RESOLUTION preset in meters.

Parameters
mapping_resolutionThe desired MAPPING_RESOLUTION. Default: MAPPING_RESOLUTION::MEDIUM
Returns
The value of mapping_resolution in meters.

◆ set() [1/2]

void set ( MAPPING_RESOLUTION  mapping_resolution = MAPPING_RESOLUTION::MEDIUM)

Sets the resolution to a sl::SpatialMappingParameters::MAPPING_RESOLUTION preset.

Parameters
mapping_resolutionThe desired MAPPING_RESOLUTION. Default: MAPPING_RESOLUTION::MEDIUM

◆ get() [2/2]

static float get ( MAPPING_RANGE  mapping_range = MAPPING_RANGE::MEDIUM)
static

Returns the value corresponding to a sl::SpatialMappingParameters::MAPPING_RANGE preset in meters.

Parameters
mapping_rangeThe desired MAPPING_RANGE. Default: MAPPING_RANGE::MEDIUM
Returns
The value of mapping_range in meters.

◆ set() [2/2]

void set ( MAPPING_RANGE  mapping_range = MAPPING_RANGE::MEDIUM)

Sets the range to a sl::SpatialMappingParameters::MAPPING_RANGE preset.

Parameters
mapping_rangeThe desired MAPPING_RANGE. Default: MAPPING_RANGE::MEDIUM

◆ getRecommendedRange() [1/2]

static float getRecommendedRange ( MAPPING_RESOLUTION  mapping_resolution,
Camera camera 
)
static

Returns the recommended maximum depth value corresponding to a sl::SpatialMappingParameters::MAPPING_RESOLUTION preset.

Parameters
mapping_resolutionThe desired MAPPING_RESOLUTION.
cameraThe Camera object that will run the spatial mapping.
Returns
The maximum value of the depth in meters.

◆ getRecommendedRange() [2/2]

static float getRecommendedRange ( float  resolution_meters,
Camera camera 
)
static

Returns the recommended maximum depth value for the given resolution in meters.

Parameters
resolution_metersThe desired resolution in meters.
cameraThe Camera object that will run the spatial mapping.
Returns
The maximum value of the depth in meters.

◆ save()

bool save ( String  filename)

Saves the current set of parameters into a file to be reloaded with the load() method.

Parameters
filename: Name of the file which will be created to store the parameters (extension '.yml' will be added if not set).
Returns
True if the file was successfully saved, otherwise false.
Warning
For security reasons, the file must not already exist.
In case a file already exists, the method will return false and existing file will not be updated.

◆ load()

bool load ( String  filename)

Loads a set of parameters from the values contained in a previously saved file.

Parameters
filename: Path to the file from which the parameters will be loaded (extension '.yml' will be added at the end of the filename if not detected).
Returns
True if the file was successfully loaded, otherwise false.

◆ operator==()

bool operator== ( const SpatialMappingParameters param1) const

Comparison operator ==

Parameters
SpatialMappingParametersto compare
Returns
true if the two struct are identical

◆ operator!=()

bool operator!= ( const SpatialMappingParameters param1) const

Comparison operator !=

Parameters
SpatialMappingParametersto compare
Returns
true if the two struct are different

Variables

◆ resolution_meter

float resolution_meter = 0.05f

Spatial mapping resolution in meters.

Note
It should fit allowed_resolution.

◆ allowed_resolution

const interval allowed_resolution
static

The resolution allowed by the spatial mapping:

  • allowed_resolution.first is the minimum value allowed
  • allowed_resolution.second is the maximum value allowed

◆ range_meter

float range_meter = 0.f

Depth range in meters.

Can be different from the value set by sl::InitParameters::depth_maximum_distance.

Note
Set to 0 by default. In this case, the range is computed from resolution_meter and from the current internal parameters to fit your application.

◆ allowed_range

const interval allowed_range
static

The maximum depth allowed by spatial mapping:

  • allowed_range.first is the minimum value allowed
  • allowed_range.second is the maximum value allowed

◆ save_texture

bool save_texture = false

Whether to save the texture.

If set to true, you will be able to apply the texture to your mesh after it is created.

Note
This option will consume more memory.
This option is only available for sl::SpatialMappingParameters::SPATIAL_MAP_TYPE::MESH.

◆ use_chunk_only

bool use_chunk_only = false

Whether to only use chunks.

If set to false, you will ensure consistency between the mesh and its inner chunk data.

Note
Updating the mesh is time-consuming.
Setting this to true results in better performance.

◆ max_memory_usage

int max_memory_usage = 2048

The maximum CPU memory (in MB) allocated for the meshing process.

◆ reverse_vertex_order

bool reverse_vertex_order = false

Whether to inverse the order of the vertices of the triangles.

If your display process does not handle front and back face culling, you can use this to correct it.

Note
This option is only available for sl::SpatialMappingParameters::SPATIAL_MAP_TYPE::MESH.

◆ map_type

The type of spatial map to be created.

This dictates the format that will be used for the mapping (e.g. mesh, point cloud).
See sl::SpatialMappingParameters::SPATIAL_MAP_TYPE.

◆ stability_counter

int stability_counter = 0

Control the integration rate of the current depth into the mapping process.

This parameter controls how many times a stable 3D points should be seen before it is integrated into the spatial mapping.
Default: 0 (this will define the stability counter based on the mesh resolution, the higher the resolution, the higher the stability counter)