Calibration Load
This example shows how to load and use calibration data of version6 (gen2 calibration data) in a pipeline.Similar samples:
Setup
Please run the install script to download all required dependencies. Please note that this script must be ran from git context, so you have to download the depthai-python repository first and then run the scriptCommand Line
1git clone https://github.com/luxonis/depthai-python.git
2cd depthai-python/examples
3python3 install_requirements.py
Source code
Python
C++
PythonGitHub
1#!/usr/bin/env python3
2
3from pathlib import Path
4import cv2
5import depthai as dai
6import argparse
7import numpy as np
8import cv2
9
10calibJsonFile = str((Path(__file__).parent / Path('../models/depthai_calib.json')).resolve().absolute())
11
12parser = argparse.ArgumentParser()
13parser.add_argument('calibJsonFile', nargs='?', help="Path to calibration file in json", default=calibJsonFile)
14args = parser.parse_args()
15
16calibData = dai.CalibrationHandler(args.calibJsonFile)
17
18# Create pipeline
19pipeline = dai.Pipeline()
20pipeline.setCalibrationData(calibData)
21
22# Define sources and output
23monoLeft = pipeline.create(dai.node.MonoCamera)
24monoRight = pipeline.create(dai.node.MonoCamera)
25stereo = pipeline.create(dai.node.StereoDepth)
26xoutDepth = pipeline.create(dai.node.XLinkOut)
27xoutDepth.setStreamName("depth")
28
29# MonoCamera
30monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
31monoLeft.setCamera("left")
32# monoLeft.setFps(5.0)
33monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
34monoRight.setCamera("right")
35# monoRight.setFps(5.0)
36
37# Linking
38monoLeft.out.link(stereo.left)
39monoRight.out.link(stereo.right)
40stereo.depth.link(xoutDepth.input)
41
42# Connect to device and start pipeline
43with dai.Device(pipeline) as device:
44
45 depthQueue = device.getOutputQueue(name="depth", maxSize=4, blocking=False)
46
47 while True:
48 # blocking call, will wait until a new data has arrived
49 inDepth = depthQueue.get()
50 frame = inDepth.getFrame()
51
52 # frame is ready to be shown
53 cv2.imshow("depth", frame)
54
55 if cv2.waitKey(1) == ord('q'):
56 break
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.