AutoCalibration is a host node that runs automatic stereo calibration workflows in a pipeline and provides calibration quality results during runtime.It is important to separate the two layers:AutoCalibrationis a host node that you add to your pipeline.- Internally, it controls and uses
DynamicCalibrationin the background. DEPTHAI_AUTOCALIBRATIONis a global deployment switch for automatic calibration.
Three ways to enable automatic calibration
- Global variable (
DEPTHAI_AUTOCALIBRATION) Best for deployed pipelines where you want to enable automatic behavior without changing code. - AutoCalibration host node Best when you want explicit pipeline-level control over mode, retries, validation, flashing, and result handling.
- Pipeline setter (
pipeline.setAutoCalibrationMode(...)) Best when you want lightweight code-level control without adding theAutoCalibrationhost node.
Automatic calibration via global variable
Command Line
1DEPTHAI_AUTOCALIBRATION=ON_START
2DEPTHAI_AUTOCALIBRATION=CONTINUOUS
3DEPTHAI_AUTOCALIBRATION=OFFFrom
DepthAI 3.6, automatic calibration is enabled by default in ON_START mode.Use DEPTHAI_AUTOCALIBRATION=OFF or pipeline.setAutoCalibrationMode(...OFF) to disable it.Behavior notes
- Applies to stereo
1280x800and640x400pipelines. - Flashes calibration as user calibration.
- Factory calibration remains untouched.
- If your pipeline already includes a
DynamicCalibrationnode or anAutoCalibrationnode,AutoCalibrationMode- based automatic procedure is not initialized.
In both
ON_START and CONTINUOUS procedures, the new calibration is flashed as user calibration. This overwrites the existing user calibration currently stored on the device.ON_START procedure
Example
Command Line
1DEPTHAI_AUTOCALIBRATION=ON_START python3 examples/Stereo/stereo.pyCommand Line
1DEPTHAI_LEVEL=info DEPTHAI_AUTOCALIBRATION=ON_START python3 examples/Stereo/stereo.py- Fast path: about
2.5s. - Common retry path: about
6s. - Worst-case retries (
maxIterations = 10): up to about25s.
CONTINUOUS procedure
Example
Command Line
1DEPTHAI_AUTOCALIBRATION=CONTINUOUS python3 examples/Stereo/stereo.pyCommand Line
1DEPTHAI_LEVEL=info DEPTHAI_AUTOCALIBRATION=CONTINUOUS python3 examples/Stereo/stereo.pyON_START.Automatic calibration via pipeline setter
pipeline.setAutoCalibrationMode(...) when you want explicit mode control in code without adding the AutoCalibration host node.Python
Python
1pipeline = dai.Pipeline()
2pipeline.setAutoCalibrationMode(dai.Pipeline.AutoCalibrationMode.ON_START)
3# Or run continuously:
4# pipeline.setAutoCalibrationMode(dai.Pipeline.AutoCalibrationMode.CONTINUOUS)
5
6# Disable automatic calibration
7pipeline.setAutoCalibrationMode(dai.Pipeline.AutoCalibrationMode.OFF)If both
DEPTHAI_AUTOCALIBRATION and pipeline.setAutoCalibrationMode(...) are set, the pipeline-local mode set in code overrides the environment variable.AutoCalibration host node in your pipeline
Example
1280x800 stereo inputs, but the same AutoCalibration workflow also supports 640x400.Python
Python
1import cv2 as cv
2import numpy as np
3import depthai as dai
4
5# Create pipeline
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()Configuration Parameters
auto_calib.initialConfig:modeSelects the automatic calibration procedure (ON_STARTorCONTINUOUS).flashCalibrationIftrue, calibration is flashed as user calibration after successful validation.maxIterationsMaximum number of calibration attempts.sleepingTimeDelay between calibration attempts/iterations.validationSetSizeNumber of validation samples used before accepting calibration.
Node Output (Result)
AutoCalibrationResult messages. Common fields:passedWhether calibration/validation succeeded.dataQualityQuality indicator of the collected calibration data.calibrationConfidenceConfidence score for the resulting calibration.
Availability and rollout status
DepthAI 3.5.0provides startup automatic calibration as an opt-in beta throughDEPTHAI_AUTOCALIBRATION.- From
DepthAI 3.6, automatic calibration is enabled by default inON_STARTmode. - Use
DEPTHAI_AUTOCALIBRATION=OFForpipeline.setAutoCalibrationMode(...OFF)to disable it.
Command Line
1python3 -m pip install depthai==3.5.0Feedback
AutoCalibration is an actively evolving feature. If you want to help shape it, use the node in real deployments and share feedback with us on GitHub: what worked well, what failed, and what parameters or outputs you want to see improved. We prioritize API improvements based on user feedback.- Forum: discuss.luxonis.com
- GitHub: luxonis/depthai-core
- For calibration data collection during debugging, use Stereo Tuning Assistance and attach the captured zip folder.
Reference
class
dai::node::AutoCalibration
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()function
void buildInternal()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)enum
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.