SpatialMappingParameters Class Reference

Sets the spatial mapping parameters. 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
 

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)
 Default constructor. Sets all parameters to their default and optimized values. More...
 
void set (MAPPING_RESOLUTION mapping_resolution=MAPPING_RESOLUTION::MEDIUM)
 Sets the resolution corresponding to the given MAPPING_RESOLUTION preset. More...
 
void set (MAPPING_RANGE mapping_range=MAPPING_RANGE::MEDIUM)
 Sets the maximum value of the depth corresponding to the given MAPPING_RANGE preset. More...
 
bool save (String filename)
 Saves the current set of parameters into a file. More...
 
bool load (String filename)
 Loads the values of the parameters contained in a 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 resolution corresponding to the given MAPPING_RESOLUTION preset. More...
 
static float get (MAPPING_RANGE mapping_range=MAPPING_RANGE::MEDIUM)
 Returns the maximum value of depth corresponding to the given MAPPING_RANGE presets. More...
 
static float getRecommendedRange (MAPPING_RESOLUTION mapping_resolution, Camera &camera)
 Returns the recommended maximum depth value for the given 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. Should fit allowed_resolution. More...
 
float range_meter = 0.f
 Depth range in meters. Can be different from the value set by sl::InitParameters::depth_maximum_distance.
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. More...
 
bool save_texture = false
 Set to true if you want to be able to apply the texture to your mesh after its creation. More...
 
bool use_chunk_only = false
 Set to false if you want to ensure consistency between the mesh and its inner chunk data. More...
 
int max_memory_usage = 2048
 The maximum CPU memory (in MB) allocated for the meshing process. More...
 
bool reverse_vertex_order = false
 Specify if the order of the vertices of the triangles needs to be inverted. If your display process does not handle front and back face culling, you can use this to correct it. More...
 
SPATIAL_MAP_TYPE map_type = SPATIAL_MAP_TYPE::MESH
 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 SPATIAL_MAP_TYPE. More...
 

Static Attributes

static const interval allowed_resolution
 The resolution allowed by the spatial mapping.
allowed_resolution.first is the minimum value allowed.
allowed_resolution.second is the maximum value allowed. More...
 
static const interval allowed_range
 Range of the maximum depth value allowed by spatial mapping.
allowed_range.first is the minimum value allowed.
allowed_range.second is the maximum value allowed. More...
 

Detailed Description

Sets the spatial mapping parameters.

Instantiating with the default constructor will set all parameters to their default values.
You can customize these values to fit your application, and then save them to a preset to be loaded in future executions.

Note
Users can adjust these parameters as they see fit.

Member Typedef Documentation

◆ interval

typedef std::pair<float, float> 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 
)

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 resolution corresponding to the given MAPPING_RESOLUTION preset.

Parameters
mapping_resolutionThe desired MAPPING_RESOLUTION. Default: MAPPING_RESOLUTION::MEDIUM.
Returns
The resolution in meters.

◆ set() [1/2]

void set ( MAPPING_RESOLUTION  mapping_resolution = MAPPING_RESOLUTION::MEDIUM)

Sets the resolution corresponding to the given 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 maximum value of depth corresponding to the given MAPPING_RANGE presets.

Parameters
mapping_rangeThe desired MAPPING_RANGE. Default: MAPPING_RANGE::MEDIUM.
Returns
The maximum value of the depth.

◆ set() [2/2]

void set ( MAPPING_RANGE  mapping_range = MAPPING_RANGE::MEDIUM)

Sets the maximum value of the depth corresponding to the given 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 for the given 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.

Parameters
filename: the 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. False otherwise.
Warning
For security reason, the file must not exist. In case a file already exists, Function will return false and existing file will not be updated.

◆ load()

bool load ( String  filename)

Loads the values of the parameters contained in a file.

Parameters
filenamethe path to the file from which the parameters will be loaded.
Returns
true if the file was successfully loaded. false otherwise.

◆ 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. 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.
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

Range of the maximum depth value 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

Set to true if you want to be able to apply the texture to your mesh after its creation.

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

◆ use_chunk_only

bool use_chunk_only = false

Set to false if you want to 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

Specify if the order of the vertices of the triangles needs to be inverted. 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 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 SPATIAL_MAP_TYPE.