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 coordinates 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
Python
C++
Python
Python
1pipeline = dai.Pipeline()
2spatialCalc = pipeline.create(dai.node.SpatialLocationCalculator)Inputs and Outputs
Usage
Python
C++
Python
Python
1pipeline = dai.Pipeline()
2spatialCalc = pipeline.create(dai.node.SpatialLocationCalculator)
3spatialCalc.setWaitForConfigInput(False)
4
5# Set initial config
6config = dai.SpatialLocationCalculatorConfigData()
7config.depthThresholds.lowerThreshold = 100
8config.depthThresholds.upperThreshold = 10000
9
10topLeft = dai.Point2f(0.4, 0.4)
11bottomRight = dai.Point2f(0.6, 0.6)
12config.roi = dai.Rect(topLeft, bottomRight)
13
14spatial_calc.initialConfig.addROI(config)
15
16# You can later send configs from the host (XLinkIn) / Script node to the InputConfigExamples of functionality
Spatial coordinate system
Middle of the frame is 0,0 in terms of X,Y coordinates. If you go down, Y will increase, and if you go right, X will increase.Reference
class
dai::node::SpatialLocationCalculator
variable
std::shared_ptr< SpatialLocationCalculatorConfig > initialConfig
Initial config to use when calculating spatial location data.
variable
Input inputConfig
Input SpatialLocationCalculatorConfig message with ability to modify parameters in runtime. Default queue is non-blocking with size 4.
variable
Input inputDetections
Input messages on which spatial location will be calculated. Possible datatypes are ImgDetections or Keypoints.
variable
Input inputDepth
Input message with depth data used to retrieve spatial information about detected object. Default queue is non-blocking with size 4.
variable
Output out
Outputs SpatialLocationCalculatorData message that carries spatial locations for each additional ROI that is specified in the config.
variable
Output outputDetections
variable
Output passthroughDepth
Passthrough message on which the calculation was performed. Suitable for when input queue is set to non-blocking behavior.
function
SpatialLocationCalculator()inline function
SpatialLocationCalculator(std::unique_ptr< Properties > props)function
void setRunOnHost(bool runOnHost)Specify whether to run on host or device By default, the node will run on device.
function
bool runOnHost()Check if the node is set to run on host
function
void run()inline function
DeviceNodeCRTP()inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device)inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props)inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.