Class SpatialLocationCalculatorConfig

Inheritance Relationships

Base Type

Class Documentation

class SpatialLocationCalculatorConfig : public dai::Buffer

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 config. ROI settings override the corresponding global values where specified.

Public Functions

SpatialLocationCalculatorConfig() = default

Construct SpatialLocationCalculatorConfig message.

virtual ~SpatialLocationCalculatorConfig()
void setROIs(std::vector<SpatialLocationCalculatorConfigData> ROIs)

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)

Add a new region of interest (ROI) to configuration data.

Parameters:

roi – Configuration parameters for ROI

void setDepthThresholds(uint32_t lowerThreshold = MIN_LOWER_THRESHOLD, uint32_t upperThreshold = MAX_UPPER_THRESHOLD)

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)

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)

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)

Set radius around keypoints to calculate spatial coordinates.

Warning

Only applicable to Keypoints or ImgDetections with keypoints.

Parameters:

radius – Radius in pixels.

void setCalculateSpatialKeypoints(bool calculateSpatialKeypoints)

If false, spatial coordinates of keypoints will not be calculated.

Warning

Only applicable to ImgDetections with keypoints.

Parameters:

calculateSpatialKeypoints

void setUseSegmentation(bool useSegmentation)

Specify whether to consider only segmented pixels within a detection bounding box for spatial calculations.

Warning

Only applicable to ImgDetections with segmentation masks.

Parameters:

useSegmentation

void setSegmentationPassthrough(bool passthroughSegmentation)

Specify whether to passthrough segmentation mask along with spatial detections.

Warning

Only applicable to ImgDetections with segmentation masks.

Parameters:

passthroughSegmentation

void setBoundingBoxScaleFactor(float scaleFactor)

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() const

Retrieve configuration data for SpatialLocationCalculator

Returns:

Vector of configuration parameters for ROIs (region of interests)

std::pair<int32_t, int32_t> getDepthThresholds() const
SpatialLocationCalculatorAlgorithm getCalculationAlgorithm() const
int32_t getStepSize() const
int32_t getKeypointRadius() const

Retrieve radius around keypoints used to calculate spatial coordinates.

bool getCalculateSpatialKeypoints() const

Retrieve whether keypoints are used for spatial location calculation.

Warning

Only applicable to ImgDetections with keypoints.

bool getUseSegmentation() const

Retrieve whether segmentation is used for spatial location calculation.

Warning

Only applicable to ImgDetections with segmentation masks.

bool getSegmentationPassthrough() const

Retrieve whether segmentation is passed through along with spatial detections.

Warning

Only applicable to ImgDetections with segmentation masks.

float getBoundingBoxScaleFactor() const

Retrieve scale factor for bounding boxes used in spatial calculations.

virtual void serialize(std::vector<std::uint8_t> &metadata, DatatypeEnum &datatype) const override
inline virtual DatatypeEnum getDatatype() const override

Get the datatype of this specific message.

Returns:

DatatypeEnum

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

Public Members

int32_t globalStepSize = AUTO
uint32_t globalLowerThreshold = MIN_LOWER_THRESHOLD
uint32_t globalUpperThreshold = MAX_UPPER_THRESHOLD
SpatialLocationCalculatorAlgorithm globalCalculationAlgorithm = SpatialLocationCalculatorAlgorithm::MEDIAN
int32_t globalKeypointRadius = 10
bool calculateSpatialKeypoints = true
bool useSegmentation = true
bool segmentationPassthrough = true
float bBoxScaleFactor = 1.0
std::vector<SpatialLocationCalculatorConfigData> config