Skip to content

Commit 4af5933

Browse files
author
SzabolcsGergely
committed
Merge remote-tracking branch 'origin/main' into HEAD
2 parents 568cf1c + 7950bdc commit 4af5933

15 files changed

+305
-89
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,47 @@ See: [depthai-core dependencies](https://github.com/luxonis/depthai-core#depende
3131

3232
### Building
3333

34+
The first time you build, the repository submodules need be initialized:
35+
```
36+
git submodule update --init --recursive
37+
38+
# Tip: You can ask Git to do that automatically:
39+
git config submodule.recurse true
40+
```
41+
42+
Later submodules also need to be updated.
43+
44+
#### Local build with pip
3445
To build and install using pip:
3546
```
3647
python3 -m pip install .
3748
```
3849
Add parameter `-v` to see the output of the building process.
3950

40-
51+
#### Wheel with pip
4152
To build a wheel, execute the following
4253
```
4354
python3 -m pip wheel . -w wheelhouse
4455
```
4556

57+
#### Shared library
4658
To build a shared library from source perform the following:
4759

4860
> ℹ️ To speed up build times, use `cmake --build build --parallel [num CPU cores]` (CMake >= 3.12).
4961
For older versions use: Linux/macOS: `cmake --build build -- -j[num CPU cores]`, MSVC: `cmake --build build -- /MP[num CPU cores]`
5062

5163
```
52-
git submodule update --init --recursive
5364
cmake -H. -Bbuild
5465
cmake --build build
5566
```
5667
To specify custom Python executable to build for, use `cmake -H. -Bbuild -D PYTHON_EXECUTABLE=/full/path/to/python`.
5768

69+
#### Common issues
70+
71+
* Many build fails due to missing dependencies. This also happens when submodules are missing or outdated (`git submodule update --recursive`).
72+
* If libraries and headers are not in standard places, or not on the search paths, CMake reports it cannot find what it needs (e.g. `libusb`). CMake can be hinted at where to look, for exmpale: `CMAKE_LIBRARY_PATH=/opt/local/lib CMAKE_INCLUDE_PATH=/opt/local/include pip install .`
73+
* Some distribution installers may not get the desired library. For example, an install on a RaspberryPi failed, missing `libusb`, as the default installation with APT led to v0.1.3 at the time, whereas the library here required v1.0.
74+
5875

5976
## Running tests
6077

docs/source/components/device.rst

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,58 @@ If you want to use multiple devices on a host, check :ref:`Multiple DepthAI per
4040
Device queues
4141
#############
4242

43-
After initializing the device, one has to initialize the input/output queues as well. You can create an input queue with
44-
:code:`device.getInputQueue("input_name")` and output queue with :code:`device.getOutputQueue("output_name")`.
45-
46-
47-
When you define an output queue, the device can write to it at any point in time, and the host can read from it at any point in time.
48-
There might be a cases when the host is reading very fast from the queue, and the queue, no matter its size, will stay empty most of
49-
the time. But as we add things on the host side (additional processing, analysis etc), it may happen that the device will be writing to
50-
the queue faster than the host can read from it. And then the packets in the queue will start to add up - and both maxSize and blocking
51-
flags determine the behavior of the queue in this case.
52-
53-
By default, the queue is blocking and its size is 30, so the device will put
54-
30 packets at most, and when the limit is reached, it will hang on queue put call and wait until it can successfully complete this
55-
call (so, waits for the host to consume the packet before putting a new one). Making the queue non-blocking will change its behavior
56-
in this situation - instead of waiting, it will discard the oldest packet and add the new one, and then continue it's processing
57-
loop (so it won't get blocked). maxSize determines the size of the queue and also
58-
helps to control the memory usage - if the packet have 5MB of data, and the queue size is 30, this queue effectively stores
59-
150MB of data in memory (the packets can also get really big, for instance a single 4K NV12 encoded frame takes about ~12MB).
60-
Decreasing the queue size to 1 and setting non-blocking behavior will effectively mean "I only want the latest packet from the queue".
61-
62-
The size and behavior of the queue can be modified after the initialization by calling :code:`queue.setBlocking()` and :code:`queue.setMaxSize()`.
43+
After initializing the device, one has to initialize the input/output queues as well.
44+
45+
.. code-block:: python
46+
47+
outputQueue = device.getOutputQueue("output_name")
48+
inputQueue = device.getInputQueue("input_name")
49+
50+
When you define an output queue, the device can push new messages to it at any point in time, and the host can read from it at any point in time.
51+
Usually, when the host is reading very fast from the queue, the queue (regardless of its size) will stay empty most of
52+
the time. But as we add things on the host side (additional processing, analysis, etc), it may happen that the device will be writing to
53+
the queue faster than the host can read from it. And then the messages in the queue will start to add up - and both maxSize and blocking
54+
flags determine the behavior of the queue in this case. You can set these flags with:
55+
56+
.. code-block:: python
57+
58+
# When initializing the queue
59+
queue = device.getOutputQueue(name="name", maxSize=5, blocking=False)
60+
61+
# Or afterwards
62+
queue.setMaxSize(10)
63+
queue.setBlocking(True)
64+
65+
Blocking behaviour
66+
******************
67+
68+
By default, queues are **blocking** and their size is **30**, so when the device fills up a queue and when the limit is
69+
reached, any additional messages from the device will be blocked and the library will wait until it can add new messages to the queue.
70+
It will wait for the host to consume (eg. :code:`queue.get()`) a message before putting a new one into the queue.
71+
72+
.. note::
73+
After the host queue gets filled up, the XLinkOut.input queue on the device will start filling up. If that queue is
74+
set to blocking, other nodes that are sending messages to it will have to wait as well. This is a usual cause for a
75+
blocked pipeline, where one of the queues isn't emptied in timely manner and the rest of the pipeline waits for it
76+
to be empty again.
77+
78+
Non-Blocking behaviour
79+
**********************
80+
Making the queue non-blocking will change the behavior in the situation described above - instead of waiting, the library will discard
81+
the oldest message and add the new one to the queue, and then continue its processing loop (so it won't get blocked).
82+
:code:`maxSize` determines the size of the queue and it also helps to control memory usage.
83+
84+
For example, if a message has 5MB of data, and the queue size is 30, this queue can effectively store
85+
up to 150MB of data in the memory on the host (the messages can also get really big, for instance, a single 4K NV12 encoded frame takes about ~12MB).
86+
87+
Some additional information
88+
***************************
89+
90+
- Decreasing the queue size to 1 and setting non-blocking behavior will effectively mean "I only want the latest packet from the queue".
91+
- Queues are thread-safe - they can be accessed from any thread.
92+
- Queues are created such that each queue is its own thread which takes care of receiving, serializing/deserializing, and sending the messages forward (same for input/output queues).
93+
- The :code:`Device` object isn't fully thread-safe. Some RPC calls (eg. :code:`getLogLevel`, :code:`setLogLevel`, :code:`getDdrMemoryUsage`) will get thread-safe once the mutex is set in place (right now there could be races).
94+
6395

6496
Reference
6597
#########
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
@@ -60,4 +60,8 @@ Code samples are used for automated testing. They are also a great starting poin
6060
- :ref:`System information` - Displays device system information (memory/cpu usage, temperature)
6161
- :ref:`OpenCV support` - Demonstrates how to retrieve an image frame as an OpenCV frame
6262
- :ref:`Device Queue Event` - Demonstrates how to use device queue events
63-
- :ref:`Queue add callback` - Demonstrates how to use queue callbacks
63+
- :ref:`Queue add callback` - Demonstrates how to use queue callbacks
64+
- :ref:`Calibration Flash v5` - Demonstrates how to flash calibration data of version 5 (gen1 calibration data) to the device
65+
- :ref:`Calibration Flash` - Demonstrates how to flash calibration data of version 6 (gen2 calibration data) to the device
66+
- :ref:`Calibration Reader` - Demonstrates how to read calibration data stored on device over XLink
67+
- :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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,5 @@ 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)
126126
add_python_example(imu_rotation_vector imu_rotation_vector.py)
127+
add_python_example(rgb_depth_aligned rgb_depth_aligned.py)
127128
add_python_example(edge_detector edge_detector.py)

0 commit comments

Comments
 (0)