SpatialLocationCalculator

SpatialLocationCalculator will calculate the depth based on the depth map from the inputDepth and ROI (region-of-interest) provided from the inputConfig. It will average the depth values in the ROI and remove the ones out of range.

How to place it

pipeline = dai.Pipeline()
spatialCalc = pipeline.SpatialLocationCalculator()
dai::Pipeline pipeline;
auto spatialCalc = pipeline.create<dai::node::SpatialLocationCalculator>();

Inputs and Outputs

               ┌───────────────────┐
               │                   │
inputConfig    │                   │       out
──────────────►│     Spatial       ├───────────►
               │     location      │
               │     calculator    │
inputDepth     │                   │passthroughDepth
──────────────►│-------------------├───────────►
               └───────────────────┘

Message types

Usage

pipeline = dai.Pipeline()
spatialCalc = pipeline.SpatialLocationCalculator()
spatialCalc.setWaitForConfigInput(False)

# Set initial config
config = dai.SpatialLocationCalculatorConfigData()
config.depthThresholds.lowerThreshold = 100
config.depthThresholds.upperThreshold = 10000

topLeft = dai.Point2f(0.4, 0.4)
bottomRight = dai.Point2f(0.6, 0.6)
config.roi = dai.Rect(topLeft, bottomRight)

spatial_calc.initialConfig.addROI(config)

# You can later send configs from the host (XLinkIn) / scripting node to the InputConfig
dai::Pipeline pipeline;
auto spatialCalc = pipeline.create<dai::node::SpatialLocationCalculator>();
spatialCalc->setWaitForConfigInput(false);

// Set initial config
dai::SpatialLocationCalculatorConfigData config;
config.depthThresholds.lowerThreshold = 100;
config.depthThresholds.upperThreshold = 10000;

dai::Point2f topLeft(0.4f, 0.4f);
dai::Point2f bottomRight(0.6f, 0.6f);
config.roi = dai::Rect(topLeft, bottomRight);

spatialCalc->initialConfig.addROI(config);

// You can later send configs from the host (XLinkIn) / scripting node to the InputConfig

Examples of functionality

Reference

class depthai.node.SpatialLocationCalculator

SpatialLocationCalculator node. Calculates spatial location data on a set of ROIs on depth map.

class Connection

Connection between an Input and Output

class Id

Node identificator. Unique for every node on a single Pipeline

Properties

alias of depthai.SpatialLocationCalculatorProperties

getAssetManager(*args, **kwargs)

Overloaded function.

  1. getAssetManager(self: depthai.Node) -> depthai.AssetManager

Get node AssetManager as a const reference

  1. getAssetManager(self: depthai.Node) -> depthai.AssetManager

Get node AssetManager as a const reference

getInputRefs(*args, **kwargs)

Overloaded function.

  1. getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]

Retrieves reference to node inputs

  1. getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]

Retrieves reference to node inputs

getInputs(self: depthai.Node) → List[depthai.Node.Input]

Retrieves all nodes inputs

getName(self: depthai.Node)str

Retrieves nodes name

getOutputRefs(*args, **kwargs)

Overloaded function.

  1. getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]

Retrieves reference to node outputs

  1. getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]

Retrieves reference to node outputs

getOutputs(self: depthai.Node) → List[depthai.Node.Output]

Retrieves all nodes outputs

getParentPipeline(*args, **kwargs)

Overloaded function.

  1. getParentPipeline(self: depthai.Node) -> depthai.Pipeline

  2. getParentPipeline(self: depthai.Node) -> depthai.Pipeline

getWaitForConfigInput(self: depthai.node.SpatialLocationCalculator)bool

See also

setWaitForConfigInput

Returns

True if wait for inputConfig message, false otherwise

property id

Id of node

property initialConfig

Initial config to use when calculating spatial location data.

property inputConfig

Input SpatialLocationCalculatorConfig message with ability to modify parameters in runtime. Default queue is non-blocking with size 4.

property inputDepth

Input message with depth data used to retrieve spatial information about detected object. Default queue is non-blocking with size 4.

property out

Outputs SpatialLocationCalculatorData message that carries spatial location results.

property passthroughDepth

Passthrough message on which the calculation was performed. Suitable for when input queue is set to non-blocking behavior.

setWaitForConfigInput(self: depthai.node.SpatialLocationCalculator, wait: bool)None

Specify whether or not wait until configuration message arrives to inputConfig Input.

Parameter wait:

True to wait for configuration message, false otherwise.

class dai::node::SpatialLocationCalculator : public dai::NodeCRTP<Node, SpatialLocationCalculator, SpatialLocationCalculatorProperties>

SpatialLocationCalculator node. Calculates spatial location data on a set of ROIs on depth map.

Public Functions

SpatialLocationCalculator(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId)
SpatialLocationCalculator(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId, std::unique_ptr<Properties> props)
void setWaitForConfigInput(bool wait)

Specify whether or not wait until configuration message arrives to inputConfig Input.

Parameters
  • wait: True to wait for configuration message, false otherwise.

bool getWaitForConfigInput() const

See

setWaitForConfigInput

Return

True if wait for inputConfig message, false otherwise

Public Members

SpatialLocationCalculatorConfig initialConfig

Initial config to use when calculating spatial location data.

Input inputConfig = {*this, "inputConfig", Input::Type::SReceiver, false, 4, {{DatatypeEnum::SpatialLocationCalculatorConfig, false}}}

Input SpatialLocationCalculatorConfig message with ability to modify parameters in runtime. Default queue is non-blocking with size 4.

Input inputDepth = {*this, "inputDepth", Input::Type::SReceiver, false, 4, true, {{DatatypeEnum::ImgFrame, false}}}

Input message with depth data used to retrieve spatial information about detected object. Default queue is non-blocking with size 4.

Output out = {*this, "out", Output::Type::MSender, {{DatatypeEnum::SpatialLocationCalculatorData, false}}}

Outputs SpatialLocationCalculatorData message that carries spatial location results.

Output passthroughDepth = {*this, "passthroughDepth", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}}

Passthrough message on which the calculation was performed. Suitable for when input queue is set to non-blocking behavior.

Public Static Attributes

constexpr const char *NAME = "SpatialLocationCalculator"

Private Members

std::shared_ptr<RawSpatialLocationCalculatorConfig> rawConfig

Got questions?

We’re always happy to help with code or other questions you might have.