此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 如何放置
  • 输入和输出
  • 用法
  • 功能示例
  • 参考
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

SpatialLocationCalculator

最后更新
Supported on:RVC2RVC4
SpatialLocationCalculator 节点根据 inputDepth 中的 depth 图计算 ROI(感兴趣区域)的空间坐标。它将平均 ROI 中的深度值并移除超出范围的值。您也可以在主机端计算空间坐标,此处有演示。该演示还包含在设备上执行的相同逻辑(calc.py 文件)。
https://user-images.githubusercontent.com/18037362/146296930-9e7071f5-33b9-45f9-af21-cace7ffffc0f.gif

如何放置

Python

Python
1pipeline = dai.Pipeline()
2spatialCalc = pipeline.create(dai.node.SpatialLocationCalculator)

C++

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

输入和输出

用法

Python

Python
1pipeline = dai.Pipeline()
2spatialCalc = pipeline.create(dai.node.SpatialLocationCalculator)
3spatialCalc.setWaitForConfigInput(False)
4
5# 设置初始配置
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# 您可以稍后从主机 (XLinkIn) / Script 节点向 InputConfig 发送配置

C++

C++
1dai::Pipeline pipeline;
2auto spatialCalc = pipeline.create<dai::node::SpatialLocationCalculator>();
3spatialCalc->setWaitForConfigInput(false);
4
5// 设置初始配置
6dai::SpatialLocationCalculatorConfigData config;
7config.depthThresholds.lowerThreshold = 100;
8config.depthThresholds.upperThreshold = 10000;
9
10dai::Point2f topLeft(0.4f, 0.4f);
11dai::Point2f bottomRight(0.6f, 0.6f);
12config.roi = dai::Rect(topLeft, bottomRight);
13
14spatialCalc->initialConfig.addROI(config);
15
16// 您可以稍后从主机 (XLinkIn) / 脚本节点向 InputConfig 发送配置

功能示例

空间坐标系

OAK 摄像头对所有空间坐标都使用 RDF(右-下-前)坐标系。
帧的中心在 X、Y 坐标上是 0,0。如果向下移动,Y 会增加;如果向右移动,X 会增加。

参考

class

dai::node::SpatialLocationCalculator

#include SpatialLocationCalculator.hpp
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
Outputs SpatialImgDetections message that carries spatial locations along with original input data.
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)

需要帮助?

请访问讨论论坛以获取技术支持或您可能有的任何其他问题。