AutoCalibration 是一个主机节点,它在管道中运行自动立体校准工作流,并在运行时提供校准质量结果。区分两个层面很重要:AutoCalibration是您添加到管道中的主机节点。- 在内部,它在后台控制并使用
DynamicCalibration。 DEPTHAI_AUTOCALIBRATION是自动校准的全局部署开关。
启用自动校准的三种方式
- 全局变量 (
DEPTHAI_AUTOCALIBRATION) 最适合已部署的管道,您希望在不更改代码的情况下启用自动行为。 - AutoCalibration 主机节点 最适合您希望对模式、重试、验证、刷写和结果处理进行显式管道级控制的情况。
- 管道设置器 (
pipeline.setAutoCalibrationMode(...)) 最适合您希望进行轻量级代码级控制而无需添加AutoCalibration主机节点的情况。
通过全局变量进行自动校准
Command Line
1DEPTHAI_AUTOCALIBRATION=ON_START
2DEPTHAI_AUTOCALIBRATION=CONTINUOUS
3DEPTHAI_AUTOCALIBRATION=OFF从
DepthAI 3.6 开始,自动校准默认以 ON_START 模式启用。使用 DEPTHAI_AUTOCALIBRATION=OFF 或 pipeline.setAutoCalibrationMode(...OFF) 禁用它。行为说明
- 适用于立体
1280x800和640x400管道。 - 将校准刷写为用户校准。
- 出厂校准保持不变。
- 如果您的管道已包含
DynamicCalibration节点或AutoCalibration节点,则不会初始化基于AutoCalibrationMode的自动过程。
在
ON_START 和 CONTINUOUS 过程中,新的校准都将刷写为用户校准。这会覆盖设备上当前存储的现有用户校准。ON_START 过程
示例
Command Line
1DEPTHAI_AUTOCALIBRATION=ON_START python3 examples/Stereo/stereo.pyCommand Line
1DEPTHAI_LEVEL=info DEPTHAI_AUTOCALIBRATION=ON_START python3 examples/Stereo/stereo.py- 快速路径:约
2.5s。 - 常见重试路径:约
6s。 - 最坏情况重试 (
maxIterations = 10):最多约25s。
CONTINUOUS 过程
示例
Command Line
1DEPTHAI_AUTOCALIBRATION=CONTINUOUS python3 examples/Stereo/stereo.pyCommand Line
1DEPTHAI_LEVEL=info DEPTHAI_AUTOCALIBRATION=CONTINUOUS python3 examples/Stereo/stereo.pyON_START 不同,此模式会增加持续的处理开销。通过管道设置器进行自动校准
AutoCalibration 主机节点时,请使用 pipeline.setAutoCalibrationMode(...)。Python
Python
1pipeline = dai.Pipeline()
2pipeline.setAutoCalibrationMode(dai.Pipeline.AutoCalibrationMode.ON_START)
3# 或者持续运行:
4# pipeline.setAutoCalibrationMode(dai.Pipeline.AutoCalibrationMode.CONTINUOUS)
5
6# 禁用自动校准
7pipeline.setAutoCalibrationMode(dai.Pipeline.AutoCalibrationMode.OFF)如果同时设置了
DEPTHAI_AUTOCALIBRATION 和 pipeline.setAutoCalibrationMode(...),则代码中设置的管道本地模式将覆盖环境变量。管道中的 AutoCalibration 主机节点
示例
1280x800 立体输入,但相同的 AutoCalibration 工作流也支持 640x400。Python
Python
1import cv2 as cv
2import numpy as np
3import depthai as dai
4
5# 创建管道
6with dai.Pipeline() as pipeline:
7 device = pipeline.getDefaultDevice()
8 botchCalibration(device)
9
10 camLeft = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
11 camRight = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
12 stereo = pipeline.create(dai.node.StereoDepth)
13
14 dcWorker = pipeline.create(dai.node.AutoCalibration).build(camLeft, camRight)
15 dcWorker.initialConfig.maxIterations = 2
16 dcWorker.initialConfig.sleepingTime = 10
17 dcWorker.initialConfig.flashCalibration = False
18 dcWorker.initialConfig.mode = dai.AutoCalibrationConfig.CONTINUOUS # ON_START
19 dcWorker.initialConfig.validationSetSize = 5
20 dcWorker.initialConfig.dataConfidenceThreshold = 0.7
21 workerOutputQueue = dcWorker.output.createOutputQueue()
22
23 videoQueueLeft = camLeft.requestOutput((1280, 800), fps=30)
24 videoQueueRight = camRight.requestOutput((1280, 800), fps=30)
25
26 videoQueueLeft.link(stereo.left)
27 videoQueueRight.link(stereo.right)
28
29 stereoOut = stereo.depth.createOutputQueue()
30 pipeline.start()
31
32 while pipeline.isRunning():
33 workerOutput = workerOutputQueue.tryGet()
34 if workerOutput is not None:
35 if workerOutput.passed:
36 print("Passed")
37 print(f"dataConfidence = {workerOutput.dataConfidence}")
38 print(f"calibrationConfidence = {workerOutput.calibrationConfidence}")
39 else:
40 print("Did not pass")
41
42 depth = stereoOut.get()
43 cv.imshow("Depth", depth)
44
45 if cv.waitKey(1) == ord("q"):
46 break
47
48 pipeline.stop()配置参数
auto_calib.initialConfig 配置行为:mode选择自动校准过程(ON_START或CONTINUOUS)。flashCalibration如果为true,则在成功验证后将校准刷写为用户校准。maxIterations最大校准尝试次数。sleepingTime校准尝试/迭代之间的延迟。validationSetSize接受校准前使用的验证样本数量。
节点输出(结果)
AutoCalibrationResult 消息。常见字段:passed校准/验证是否成功。dataQuality收集到的校准数据的质量指标。calibrationConfidence结果校准的置信度分数。
可用性和推出状态
DepthAI 3.5.0通过DEPTHAI_AUTOCALIBRATION提供启动自动校准作为可选测试版。- 从
DepthAI 3.6开始,自动校准默认以ON_START模式启用。 - 使用
DEPTHAI_AUTOCALIBRATION=OFF或pipeline.setAutoCalibrationMode(...OFF)禁用它。
Command Line
1python3 -m pip install depthai==3.5.0反馈
AutoCalibration 是一个积极发展的功能。如果您想帮助塑造它,请在实际部署中使用该节点,并在 GitHub 上与我们分享反馈:哪些方面运行良好,哪些方面失败了,以及您希望改进哪些参数或输出。我们根据用户反馈优先改进 API。- 论坛:discuss.luxonis.com
- GitHub:luxonis/depthai-core
- 在调试期间收集校准数据时,请使用 立体调谐辅助 并附加捕获的 zip 文件夹。
参考
class
dai::node::AutoCalibration
using
variable
std::shared_ptr< AutoCalibrationConfig > initialConfig
variable
Output output
function
std::shared_ptr< AutoCalibration > build(const std::shared_ptr< Camera > & cameraLeft, const std::shared_ptr< Camera > & cameraRight)function
~AutoCalibration()function
void run()function
void setRunOnHost(bool runOnHost)function
bool runOnHost()Returns true or false whether the node should be run on host or not.
function
void buildInternal()Function called from within the create function to build the node. This function is useful for initialization, setting up inputs and outputs = stuff that cannot be perform in the constuctor.
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)需要帮助?
请访问讨论论坛以获取技术支持或您可能有的任何其他问题。