# SpatialLocationCalculatorConfig

This message is used to configure the
[SpatialLocationCalculator](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/spatial_location_calculator.md)
node.

## Examples of functionality

 * [Spatial location
   calculator](https://docs.luxonis.com/software-v3/depthai/examples/spatial_location_calculator/spatial_location_calculator.md)

## Reference

### dai::SpatialLocationCalculatorConfig

Kind: class

Configuration for SpatialLocationCalculator. Holds global parameters and optional per-ROI entries used to compute 3D spatial
locations from a depth map. Global parameters (defaults): Lower depth threshold [mm]: 0; Upper depth threshold [mm]: 65535;
Calculation algorithm: MEDIAN; Step size: AUTO; Keypoint radius [px]: 10; Calculate spatial keypoints: true; Use segmentation for
ImgDetections : true; Segmentation passthrough: true; Bounding box scale factor: 1.0 An optional list of per-ROI configurations is
available via

#### int32_t globalStepSize

Kind: variable

#### uint32_t globalLowerThreshold

Kind: variable

#### uint32_t globalUpperThreshold

Kind: variable

#### SpatialLocationCalculatorAlgorithm globalCalculationAlgorithm

Kind: variable

#### int32_t globalKeypointRadius

Kind: variable

#### bool calculateSpatialKeypoints

Kind: variable

#### bool useSegmentation

Kind: variable

#### bool segmentationPassthrough

Kind: variable

#### float bBoxScaleFactor

Kind: variable

#### std::vector< SpatialLocationCalculatorConfigData > config

Kind: variable

#### SpatialLocationCalculatorConfig()

Kind: function

Construct SpatialLocationCalculatorConfig message.

#### ~SpatialLocationCalculatorConfig()

Kind: function

#### void setROIs(std::vector< SpatialLocationCalculatorConfigData > ROIs)

Kind: function

Specify additional regions of interest (ROI) to calculate their spatial coordinates. Results of ROI coordinates are available on
SpatialLocationCalculatorData output. parameters: ROIs: Vector of configuration parameters for ROIs (region of interests)

#### void addROI(SpatialLocationCalculatorConfigData & ROI)

Kind: function

Add a new region of interest (ROI) to configuration data. parameters: roi: Configuration parameters for ROI

#### void setDepthThresholds(uint32_t lowerThreshold, uint32_t upperThreshold)

Kind: function

Set the lower and upper depth value thresholds to be used in the spatial calculations. parameters: lowerThreshold: Lower threshold
in depth units (millimeter by default).; upperThreshold: Upper threshold in depth units (millimeter by default).

#### void setCalculationAlgorithm(SpatialLocationCalculatorAlgorithm calculationAlgorithm)

Kind: function

Set spatial location calculation algorithm. Possible values: MEDIAN: Median of all depth values in the ROI; AVERAGE: Average of
all depth values in the ROI; MIN: Minimum depth value in the ROI; MAX: Maximum depth value in the ROI; MODE: Most frequent depth
value in the ROI

#### void setStepSize(int32_t stepSize)

Kind: function

Set step size for spatial location calculation. Step size 1 means that every pixel is taken into calculation, size 2 means every
second etc. for AVERAGE, MIN, MAX step size is 1; for MODE/MEDIAN it's 2.

#### void setKeypointRadius(int32_t radius)

Kind: function

Set radius around keypoints to calculate spatial coordinates. parameters: radius: Radius in pixels. warning: Only applicable to
Keypoints or ImgDetections with keypoints.

#### void setCalculateSpatialKeypoints(bool calculateSpatialKeypoints)

Kind: function

If false, spatial coordinates of keypoints will not be calculated. parameters: calculateSpatialKeypoints: warning: Only applicable
to ImgDetections with keypoints.

#### void setUseSegmentation(bool useSegmentation)

Kind: function

Specify whether to consider only segmented pixels within a detection bounding box for spatial calculations. parameters:
useSegmentation: warning: Only applicable to ImgDetections with segmentation masks.

#### void setSegmentationPassthrough(bool passthroughSegmentation)

Kind: function

Specify whether to passthrough segmentation mask along with spatial detections. parameters: passthroughSegmentation: warning: Only
applicable to ImgDetections with segmentation masks.

#### void setBoundingBoxScaleFactor(float scaleFactor)

Kind: function

Set scale factor for bounding boxes used in spatial calculations. parameters: scaleFactor: Scale factor must be in the interval
(0,1].

#### std::vector< SpatialLocationCalculatorConfigData > getConfigData()

Kind: function

Retrieve configuration data for SpatialLocationCalculator return: Vector of configuration parameters for ROIs (region of
interests)

#### std::pair< int32_t, int32_t > getDepthThresholds()

Kind: function

#### SpatialLocationCalculatorAlgorithm getCalculationAlgorithm()

Kind: function

#### int32_t getStepSize()

Kind: function

#### int32_t getKeypointRadius()

Kind: function

Retrieve radius around keypoints used to calculate spatial coordinates.

#### bool getCalculateSpatialKeypoints()

Kind: function

Retrieve whether keypoints are used for spatial location calculation. warning: Only applicable to ImgDetections with keypoints.

#### bool getUseSegmentation()

Kind: function

Retrieve whether segmentation is used for spatial location calculation. warning: Only applicable to ImgDetections with
segmentation masks.

#### bool getSegmentationPassthrough()

Kind: function

Retrieve whether segmentation is passed through along with spatial detections. warning: Only applicable to ImgDetections with
segmentation masks.

#### float getBoundingBoxScaleFactor()

Kind: function

Retrieve scale factor for bounding boxes used in spatial calculations.

#### void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)

Kind: function

#### DatatypeEnum getDatatype()

Kind: function

Get the datatype of this specific message.

return: DatatypeEnum

#### DEPTHAI_SERIALIZE(SpatialLocationCalculatorConfig, globalStepSize, globalLowerThreshold, globalUpperThreshold,
globalCalculationAlgorithm, globalKeypointRadius, calculateSpatialKeypoints, useSegmentation, segmentationPassthrough,
bBoxScaleFactor, config)

Kind: function

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
