Skip to content

Commit 6441db6

Browse files
Merge pull request #286 from luxonis/synch_calibration
Synchonize calibration examples w/ c++; add documentation
2 parents 2691b7b + dfe7492 commit 6441db6

12 files changed

+236
-66
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Calibration Flash
2+
=================
3+
4+
This example shows how to flash calibration data of version 6 (gen2 calibration data) to the device.
5+
6+
.. rubric:: Similiar samples:
7+
8+
- :ref:`Calibration Flash v5`
9+
- :ref:`Calibration Reader`
10+
- :ref:`Calibration Load`
11+
12+
Setup
13+
#####
14+
15+
.. include:: /includes/install_from_pypi.rst
16+
17+
Source code
18+
###########
19+
20+
.. tabs::
21+
22+
.. tab:: Python
23+
24+
Also `available on GitHub <https://github.com/luxonis/depthai-python/blob/main/examples/calibration_flash.py>`__
25+
26+
.. literalinclude:: ../../../examples/calibration_flash.py
27+
:language: python
28+
:linenos:
29+
30+
.. tab:: C++
31+
32+
Also `available on GitHub <https://github.com/luxonis/depthai-core/blob/main/examples/src/calibration_flash.cpp>`__
33+
34+
.. literalinclude:: ../../../depthai-core/examples/src/calibration_flash.cpp
35+
:language: cpp
36+
:linenos:
37+
38+
.. include:: /includes/footer-short.rst
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Calibration Flash v5
2+
====================
3+
4+
This example shows how to flash calibration data of version 5 (gen1 calibration data) to the device.
5+
6+
.. rubric:: Similiar samples:
7+
8+
- :ref:`Calibration Flash`
9+
- :ref:`Calibration Reader`
10+
- :ref:`Calibration Load`
11+
12+
Setup
13+
#####
14+
15+
.. include:: /includes/install_from_pypi.rst
16+
17+
Source code
18+
###########
19+
20+
.. tabs::
21+
22+
.. tab:: Python
23+
24+
Also `available on GitHub <https://github.com/luxonis/depthai-python/blob/main/examples/calibration_flash_v5.py>`__
25+
26+
.. literalinclude:: ../../../examples/calibration_flash_v5.py
27+
:language: python
28+
:linenos:
29+
30+
.. tab:: C++
31+
32+
Also `available on GitHub <https://github.com/luxonis/depthai-core/blob/main/examples/src/calibration_flash_v5.cpp>`__
33+
34+
.. literalinclude:: ../../../depthai-core/examples/src/calibration_flash_v5.cpp
35+
:language: cpp
36+
:linenos:
37+
38+
.. include:: /includes/footer-short.rst
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Calibration Load
2+
================
3+
4+
This example shows how to load and use calibration data of version6 (gen2 calibration data) in a pipeline.
5+
6+
.. rubric:: Similiar samples:
7+
8+
- :ref:`Calibration Flash v5`
9+
- :ref:`Calibration Flash`
10+
- :ref:`Calibration Reader`
11+
12+
Setup
13+
#####
14+
15+
.. include:: /includes/install_from_pypi.rst
16+
17+
Source code
18+
###########
19+
20+
.. tabs::
21+
22+
.. tab:: Python
23+
24+
Also `available on GitHub <https://github.com/luxonis/depthai-python/blob/main/examples/calibration_load.py>`__
25+
26+
.. literalinclude:: ../../../examples/calibration_load.py
27+
:language: python
28+
:linenos:
29+
30+
.. tab:: C++
31+
32+
Also `available on GitHub <https://github.com/luxonis/depthai-core/blob/main/examples/src/calibration_load.cpp>`__
33+
34+
.. literalinclude:: ../../../depthai-core/examples/src/calibration_load.cpp
35+
:language: cpp
36+
:linenos:
37+
38+
.. include:: /includes/footer-short.rst
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Calibration Reader
2+
==================
3+
4+
This example shows how to read calibration data stored on device over XLink.
5+
6+
.. rubric:: Similiar samples:
7+
8+
- :ref:`Calibration Flash v5`
9+
- :ref:`Calibration Flash`
10+
- :ref:`Calibration Load`
11+
12+
Setup
13+
#####
14+
15+
.. include:: /includes/install_from_pypi.rst
16+
17+
Source code
18+
###########
19+
20+
.. tabs::
21+
22+
.. tab:: Python
23+
24+
Also `available on GitHub <https://github.com/luxonis/depthai-python/blob/main/examples/calibration_reader.py>`__
25+
26+
.. literalinclude:: ../../../examples/calibration_reader.py
27+
:language: python
28+
:linenos:
29+
30+
.. tab:: C++
31+
32+
Also `available on GitHub <https://github.com/luxonis/depthai-core/blob/main/examples/src/calibration_reader.cpp>`__
33+
34+
.. literalinclude:: ../../../depthai-core/examples/src/calibration_reader.cpp
35+
:language: cpp
36+
:linenos:
37+
38+
.. include:: /includes/footer-short.rst

docs/source/tutorials/code_samples.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,8 @@ Code samples are used for automated testing. They are also a great starting poin
5959
- :ref:`System information` - Displays device system information (memory/cpu usage, temperature)
6060
- :ref:`OpenCV support` - Demonstrates how to retrieve an image frame as an OpenCV frame
6161
- :ref:`Device Queue Event` - Demonstrates how to use device queue events
62-
- :ref:`Queue add callback` - Demonstrates how to use queue callbacks
62+
- :ref:`Queue add callback` - Demonstrates how to use queue callbacks
63+
- :ref:`Calibration Flash v5` - Demonstrates how to flash calibration data of version 5 (gen1 calibration data) to the device
64+
- :ref:`Calibration Flash` - Demonstrates how to flash calibration data of version 6 (gen2 calibration data) to the device
65+
- :ref:`Calibration Reader` - Demonstrates how to read calibration data stored on device over XLink
66+
- :ref:`Calibration Load` - Demonstrates how to load and use calibration data of version6 (gen2 calibration data) in a pipeline

docs/source/tutorials/mixed_samples.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ Mixed
1010
../samples/opencv_support.rst
1111
../samples/device_queue_event.rst
1212
../samples/queue_add_callback.rst
13+
../samples/calibration_flash_v5.rst
14+
../samples/calibration_flash.rst
15+
../samples/calibration_reader.rst
16+
../samples/calibration_load.rst
1317

1418
- :ref:`System information` - Displays device system information (memory/cpu usage, temperature)
1519
- :ref:`OpenCV support` - Demonstrates how to retrieve an image frame as an OpenCV frame
1620
- :ref:`Device Queue Event` - Demonstrates how to use device queue events
17-
- :ref:`Queue add callback` - Demonstrates how to use queue callbacks
21+
- :ref:`Queue add callback` - Demonstrates how to use queue callbacks
22+
- :ref:`Calibration Flash v5` - Demonstrates how to flash calibration data of version 5 (gen1 calibration data) to the device
23+
- :ref:`Calibration Flash` - Demonstrates how to flash calibration data of version 6 (gen2 calibration data) to the device
24+
- :ref:`Calibration Reader` - Demonstrates how to read calibration data stored on device over XLink
25+
- :ref:`Calibration Load` - Demonstrates how to load and use calibration data of version6 (gen2 calibration data) in a pipeline

examples/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,8 @@ add_python_example(object_tracker_video object_tracker_video.py)
123123
add_python_example(stereo_depth_from_host stereo_depth_from_host.py)
124124
add_python_example(stereo_depth_video stereo_depth_video.py)
125125
add_python_example(imu_gyroscope_accelerometer imu_gyroscope_accelerometer.py)
126-
add_python_example(imu_rotation_vector imu_rotation_vector.py)
126+
add_python_example(imu_rotation_vector imu_rotation_vector.py)
127+
add_python_example(calibration_flash_v5 calibration_flash_v5.py)
128+
add_python_example(calibration_flash calibration_flash.py)
129+
add_python_example(calibration_load calibration_load.py)
130+
add_python_example(calibration_reader calibration_reader.py)

examples/calibration_flash.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@
55
import depthai as dai
66
import argparse
77

8-
9-
# Connect Device
108
calibJsonFile = str((Path(__file__).parent / Path('models/depthai_calib.json')).resolve().absolute())
11-
calibBackupfile = str((Path(__file__).parent / Path('depthai_calib_backup.json')).resolve().absolute())
9+
calibBackUpFile = str((Path(__file__).parent / Path('depthai_calib_backup.json')).resolve().absolute())
1210

1311
parser = argparse.ArgumentParser()
1412
parser.add_argument('calibJsonFile', nargs='?', help="Path to V6 calibration file in json", default=calibJsonFile)
1513
args = parser.parse_args()
1614

15+
# Connect device
1716
with dai.Device() as device:
17+
1818
deviceCalib = device.readCalibration()
19-
deviceCalib.eepromToJsonFile(calibBackupfile)
19+
deviceCalib.eepromToJsonFile(calibBackUpFile)
2020
print("Calibration Data on the device is backed up at:")
21-
print(calibBackupfile)
22-
calibData = dai.CalibrationHandler(args.calibJsonFile);
21+
print(calibBackUpFile)
22+
calibData = dai.CalibrationHandler(args.calibJsonFile)
23+
2324
status = device.flashCalibration(calibData)
2425
if status:
25-
print('Calibration write succesfull')
26+
print('Calibration Flash Successful')
2627
else:
27-
print('Calibration Flash Failed!!')
28+
print('Calibration Flash Failed!!!')

examples/calibration_flash_v5.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,26 @@
55
import depthai as dai
66
import argparse
77

8-
9-
# Connect Device
108
boardConfigFile = str((Path(__file__).parent / Path('models/BW1098OBC.json')).resolve().absolute())
119
calibBinaryFile = str((Path(__file__).parent / Path('models/depthai_v5.calib')).resolve().absolute())
12-
calibBackupfile = str((Path(__file__).parent / Path('depthai_calib_backup.json')).resolve().absolute())
10+
calibBackUpFile = str((Path(__file__).parent / Path('depthai_calib_backup.json')).resolve().absolute())
1311

1412
parser = argparse.ArgumentParser()
1513
parser.add_argument('boardConfigFile', nargs='?', help="Path to board config file", default=boardConfigFile)
1614
parser.add_argument('calibBinaryFile', nargs='?', help="Path to version 5 .calib file", default=calibBinaryFile)
1715
args = parser.parse_args()
1816

17+
# Connect device
1918
with dai.Device() as device:
19+
2020
deviceCalib = device.readCalibration()
21-
deviceCalib.eepromToJsonFile(calibBackupfile)
21+
deviceCalib.eepromToJsonFile(calibBackUpFile)
2222
print("Calibration Data on the device is backed up at:")
23-
print(calibBackupfile)
24-
calibData = dai.CalibrationHandler(args.calibBinaryFile, args.boardConfigFile);
23+
print(calibBackUpFile)
24+
calibData = dai.CalibrationHandler(args.calibBinaryFile, args.boardConfigFile)
25+
2526
status = device.flashCalibration(calibData)
2627
if status:
27-
print('Calibration write succesful')
28+
print('Calibration Flash Successful')
2829
else:
29-
print('Calibration Flash Failed!!')
30+
print('Calibration Flash Failed!!!')

0 commit comments

Comments
 (0)