SpatialLocationCalculator¶
SpatialLocationCalculator node calculates the spatial coordinates of the ROI (region-of-interest) based on the
depth
map from the inputDepth
. It will average the depth values in the ROI and remove the ones out of range.
You can also calculate spatial coordiantes on host side, demo here.
The demo also has the same logic that’s performed on the device (calc.py
file).
How to place it¶
pipeline = dai.Pipeline()
spatialCalc = pipeline.create(dai.node.SpatialLocationCalculator)
dai::Pipeline pipeline;
auto spatialCalc = pipeline.create<dai::node::SpatialLocationCalculator>();
Inputs and Outputs¶
┌───────────────────┐
│ │
inputConfig │ │ out
──────────────►│ Spatial ├───────────►
│ location │
│ calculator │
inputDepth │ │passthroughDepth
──────────────►│-------------------├───────────►
└───────────────────┘
Message types
inputConfig
- SpatialLocationCalculatorConfiginputDepth
- ImgFramepassthroughDepth
- ImgFrame
Usage¶
pipeline = dai.Pipeline()
spatialCalc = pipeline.create(dai.node.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) / Script 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¶
Spatial coordinate system¶
OAK camera uses left-handed (Cartesian) coordinate system for all spatial coordiantes.
Middle of the frame is 0,0 in terms of X,Y coordinates. If you go up, Y will increase, and if you go right, X will increase.
Reference¶
-
class
depthai.node.
SpatialLocationCalculator
-
class
Id
Node identificator. Unique for every node on a single Pipeline
-
getAssetManager
(*args, **kwargs) Overloaded function.
getAssetManager(self: depthai.Node) -> depthai.AssetManager
getAssetManager(self: depthai.Node) -> depthai.AssetManager
-
getInputRefs
(*args, **kwargs) Overloaded function.
getInputRefs(self: depthai.Node) -> list[depthai.Node.Input]
getInputRefs(self: depthai.Node) -> list[depthai.Node.Input]
-
getInputs
(self: depthai.Node) → list[depthai.Node.Input]
-
getName
(self: depthai.Node) → str
-
getOutputRefs
(*args, **kwargs) Overloaded function.
getOutputRefs(self: depthai.Node) -> list[depthai.Node.Output]
getOutputRefs(self: depthai.Node) -> list[depthai.Node.Output]
-
getOutputs
(self: depthai.Node) → list[depthai.Node.Output]
-
getParentPipeline
(*args, **kwargs) Overloaded function.
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
-
getWaitForConfigInput
(self: depthai.node.SpatialLocationCalculator) → bool
-
setWaitForConfigInput
(self: depthai.node.SpatialLocationCalculator, wait: bool) → None
-
class
-
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
-
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
- 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
-
static constexpr const char *
NAME
= "SpatialLocationCalculator"¶
Private Members
-
std::shared_ptr<RawSpatialLocationCalculatorConfig>
rawConfig
¶
-
void