Skip to content

Commit c8f5e12

Browse files
author
SzabolcsGergely
committed
Merge remote-tracking branch 'origin/main' into HEAD
2 parents 8a64a2a + e511f96 commit c8f5e12

File tree

16 files changed

+539
-203
lines changed

16 files changed

+539
-203
lines changed
40.4 KB
Loading

docs/source/components/device.rst

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
Device
44
======
55

6-
Device is a DepthAI `module <https://docs.luxonis.com/en/latest/pages/products/>`__. After the :ref:`Pipeline` is defined, it can be uploaded to the device.
7-
When you create the device in the code, firmware is uploaded together with the pipeline.
6+
Device represents an `OAK camera <https://docs.luxonis.com/projects/hardware/en/latest/>`__. On all of our devices there's a powerful vision processing unit
7+
(**VPU**), called `Myriad X <https://www.intel.com/content/www/us/en/products/details/processors/movidius-vpu.html>`__.
8+
The VPU is optimized for performing AI inference algorithms and for processing sensory inputs (eg. calculating stereo disparity from two cameras).
9+
10+
Device API
11+
##########
12+
13+
:code:`Device` object represents an OAK device. When starting the device, you have to upload a :ref:`Pipeline` to it, which will get executed on the VPU.
14+
When you create the device in the code, firmware is uploaded together with the pipeline and other assets (such as NN blobs).
815

916
.. code-block:: python
1017
@@ -14,8 +21,10 @@ When you create the device in the code, firmware is uploaded together with the p
1421
1522
# Upload the pipeline to the device
1623
with depthai.Device(pipeline) as device:
17-
# Start the pipeline that is now on the device
18-
device.startPipeline()
24+
# Print Myriad X Id (MxID), USB speed, and available cameras on the device
25+
print('MxId:',device.getDeviceInfo().getMxId())
26+
print('USB speed:',device.getUsbSpeed())
27+
print('Connected cameras:',device.getConnectedCameras())
1928
2029
# Input queue, to send message from the host to the device (you can recieve the message on the device with XLinkIn)
2130
input_q = device.getInputQueue("input_name", maxSize=4, blocking=False)
@@ -24,7 +33,7 @@ When you create the device in the code, firmware is uploaded together with the p
2433
output_q = device.getOutputQueue("output_name", maxSize=4, blocking=False)
2534
2635
while True:
27-
# Get the message from the queue
36+
# Get a message that came from the queue
2837
output_q.get() # Or output_q.tryGet() for non-blocking
2938
3039
# Send a message to the device
@@ -40,7 +49,7 @@ If you want to use multiple devices on a host, check :ref:`Multiple DepthAI per
4049
Device queues
4150
#############
4251

43-
After initializing the device, one has to initialize the input/output queues as well.
52+
After initializing the device, one has to initialize the input/output queues as well. These queues will be located on the host computer (in RAM).
4453

4554
.. code-block:: python
4655
@@ -62,6 +71,40 @@ flags determine the behavior of the queue in this case. You can set these flags
6271
queue.setMaxSize(10)
6372
queue.setBlocking(True)
6473
74+
Specifying arguments for :code:`getOutputQueue` method
75+
######################################################
76+
77+
When obtaining the output queue (example code below), the :code:`maxSize` and :code:`blocking` arguments should be set depending on how
78+
the messages are intended to be used, where :code:`name` is the name of the outputting stream.
79+
80+
Since queues are on the host computer, memory (RAM) usually isn't that scarce. But if you are using a small SBC like RPI Zero, where there's only 0.5GB RAM,
81+
you might need to specify max queue size as well.
82+
83+
.. code-block:: python
84+
85+
with dai.Device(pipeline) as device:
86+
queueLeft = device.getOutputQueue(name="manip_left", maxSize=8, blocking=False)
87+
88+
If only the latest results are relevant and previous do not matter, one can set :code:`maxSize = 1` and :code:`blocking = False`.
89+
That way only latest message will be kept (:code:`maxSize = 1`) and it might also be overwritten in order to avoid waiting for
90+
the host to process every frame, thus providing only the latest data (:code:`blocking = False`).
91+
However, if there are a lot of dropped/overwritten frames, because the host isn't able to process them fast enough
92+
(eg. one-threaded environment which does some heavy computing), the :code:`maxSize` could be set to a higher
93+
number, which would increase the queue size and reduce the number of dropped frames.
94+
Specifically, at 30 FPS, a new frame is recieved every ~33ms, so if your host is able to process a frame in that time, the :code:`maxSize`
95+
could be set to :code:`1`, otherwise to :code:`2` for processing times up to 66ms and so on.
96+
97+
If, however, there is a need to have some intervals of wait between retrieving messages, one could specify that differently.
98+
An example would be checking the results of :code:`DetectionNetwork` for the last 1 second based on some other event,
99+
in which case one could set :code:`maxSize = 30` and :code:`blocking = False`
100+
(assuming :code:`DetectionNetwork` produces messages at ~30FPS).
101+
102+
The :code:`blocking = True` option is mostly used when correct order of messages is needed.
103+
Two examples would be:
104+
105+
- matching passthrough frames and their original frames (eg. full 4K frames and smaller preview frames that went into NN),
106+
- encoding (most prominently H264/H265 as frame drops can lead to artifacts).
107+
65108
Blocking behaviour
66109
******************
67110

docs/source/components/messages.rst

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,54 @@
33
Messages
44
========
55

6-
Messages are sent between linked :ref:`Nodes`. The only way nodes communicate with each other is by sending messages from one to another.
6+
Messages are sent between linked :ref:`Nodes`. The only way nodes communicate with each other is by sending messages from one to another. On the
7+
table of contents (left side of the page) **all DepthAI messages are listed** under the :code:`Messages` entry. You can click on them to find out more.
78

8-
If we have :code:`Node1` whose output is linked with :code:`Node2`'s input, a **message** is created in the :code:`Node1`,
9-
sent out of the :code:`Node1`'s output and to the :code:`Node2`'s input.
9+
.. rubric:: Creating a message in Script node
1010

11-
On the table of contents (left side of the page) all messages are listed under the :code:`Messages` entry. You can click on them to find out more.
11+
A DepthAI message can be created either on the device, by a node automatically or manually inside the :ref:`Script` node. In below example,
12+
the code is taken from the :ref:`Script camera control` example, where :ref:`CameraControl` is created inside the Script node every second
13+
and sent to the :ref:`ColorCamera`'s input (:code:`cam.inputControl`).
14+
15+
.. code-block:: python
16+
17+
script = pipeline.create(dai.node.Script)
18+
script.setScript("""
19+
# Create a message
20+
ctrl = CameraControl()
21+
# Configure the message
22+
ctrl.setCaptureStill(True)
23+
# Send the message from the Script node
24+
node.io['out'].send(ctrl)
25+
""")
26+
27+
.. rubric:: Creating a message on a Host
28+
29+
It can also be created on a host computer and sent to the device via :ref:`XLinkIn` node. :ref:`RGB Camera Control`, :ref:`Video & MobilenetSSD`
30+
and :ref:`Stereo Depth from host` code examples demonstrate this functionality perfectly. In the example below, we have removed all the code
31+
that isn't relevant to showcase how a message can be created on the host and sent to the device via XLink.
32+
33+
.. code-block:: python
34+
35+
# Create XLinkIn node and configure it
36+
xin = pipeline.create(dai.node.XLinkIn)
37+
xin.setStreamName("frameIn")
38+
xin.out.link(nn.input) # Connect it to NeuralNetwork's input
39+
40+
with dai.Device(pipeline) as device:
41+
# Create input queue, which allows you to send messages to the device
42+
qIn = device.getInputQueue("frameIn")
43+
# Create ImgFrame message
44+
img = dai.ImgFrame()
45+
img.setData(frame)
46+
img.setWidth(300)
47+
img.setHeight(300)
48+
qIn.send(img) # Send the message to the device
49+
50+
.. rubric:: Creating a message on an external MCU
51+
52+
A message can also be created on an external MCU and sent to the device via :ref:`SPIIn` node. An demo of such functionality is the
53+
`spi_in_landmark <https://github.com/luxonis/esp32-spi-message-demo/tree/main/spi_in_landmark>`__ example.
1254

1355
.. toctree::
1456
:maxdepth: 0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
StereoDepthConfig
2+
=================
3+
4+
This message is used to configure the :ref:`StereoDepth` node.
5+
With this message you can set filters, confidences, thresholds and mode of the :ref:`StereoDepth` node.
6+
7+
Examples of functionality
8+
#########################
9+
10+
- :ref:`Stereo Depth from host`
11+
12+
Reference
13+
#########
14+
15+
.. tabs::
16+
17+
.. tab:: Python
18+
19+
.. autoclass:: depthai.StereoDepthConfig
20+
:members:
21+
:inherited-members:
22+
:noindex:
23+
24+
.. tab:: C++
25+
26+
.. doxygenclass:: dai::StereoDepthConfig
27+
:project: depthai-core
28+
:members:
29+
:private-members:
30+
:undoc-members:
31+
32+
.. include:: ../../includes/footer-short.rst

docs/source/components/nodes/script.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Script
33

44
Script node allows users to run **custom Python scripts on the device**. Due to the computational resource constraints,
55
script node shouldn't be used for heavy computing (eg. image manipulation/CV), but for managing the flow
6-
of the pipeline. Example use cases would be controlling nodes like :ref:`ImageManip`, :ref:`ColorCamera`, :ref:`SpatialLocationCalculator`,
7-
decoding :ref:`NeuralNetwork` results, or interfacing with GPIOs.
6+
of the pipeline (business logic). Example use cases would be controlling nodes like :ref:`ImageManip`, :ref:`ColorCamera`, :ref:`SpatialLocationCalculator`,
7+
decoding :ref:`NeuralNetwork` results, or interfacing with GPIOs. For **debugging scripts**, we suggest :ref:`Script node logging <script_logging>`.
88

99
How to place it
1010
###############

docs/source/components/nodes/stereo_depth.rst

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,50 @@ Inputs and Outputs
2525
.. code-block::
2626
2727
┌───────────────────┐
28+
│ │ confidenceMap
29+
│ ├─────────────►
2830
│ │rectifiedLeft
2931
│ ├─────────────►
3032
left │ │ syncedLeft
31-
──────────────►│ ├─────────────►
33+
──────────────►│-------------------├─────────────►
3234
│ │ depth
3335
│ ├─────────────►
3436
│ StereoDepth │ disparity
3537
│ ├─────────────►
36-
right │ │rectifiedRight
37-
──────────────►│ ├─────────────►
38-
│ │ syncedRight
38+
right │ │ syncedRight
39+
──────────────►│-------------------├─────────────►
40+
│ │rectifiedRight
3941
│ ├─────────────►
42+
inputConfig │ | outConfig
43+
──────────────►│-------------------├─────────────►
4044
└───────────────────┘
4145
42-
**Message types**
46+
.. tabs::
47+
48+
.. tab:: **Inputs**
49+
50+
- :code:`left` - :ref:`ImgFrame` from the left :ref:`MonoCamera`
51+
- :code:`right` - :ref:`ImgFrame` from the right :ref:`MonoCamera`
52+
- :code:`inputConfig` - :ref:`StereoDepthConfig`
53+
54+
.. tab:: **Outputs**
55+
56+
- :code:`confidenceMap` - :ref:`ImgFrame`
57+
- :code:`rectifiedLeft` - :ref:`ImgFrame`
58+
- :code:`syncedLeft` - :ref:`ImgFrame`
59+
- :code:`depth` - :ref:`ImgFrame`
60+
- :code:`disparity` - :ref:`ImgFrame`
61+
- :code:`rectifiedRight` - :ref:`ImgFrame`
62+
- :code:`syncedRight` - :ref:`ImgFrame`
63+
- :code:`outConfig` - :ref:`StereoDepthConfig`
4364

44-
- :code:`left` - :ref:`ImgFrame` from the left :ref:`MonoCamera`
45-
- :code:`right` - :ref:`ImgFrame` from the right :ref:`MonoCamera`
46-
- :code:`rectifiedLeft` - :ref:`ImgFrame`
47-
- :code:`syncedLeft` - :ref:`ImgFrame`
48-
- :code:`depth` - :ref:`ImgFrame`
49-
- :code:`disparity` - :ref:`ImgFrame`
50-
- :code:`rectifiedRight` - :ref:`ImgFrame`
51-
- :code:`syncedRight` - :ref:`ImgFrame`
65+
.. tab:: **Debug outputs**
66+
67+
- :code:`debugDispLrCheckIt1` - :ref:`ImgFrame`
68+
- :code:`debugDispLrCheckIt2` - :ref:`ImgFrame`
69+
- :code:`debugExtDispLrCheckIt1` - :ref:`ImgFrame`
70+
- :code:`debugExtDispLrCheckIt2` - :ref:`ImgFrame`
71+
- :code:`debugDispCostDump` - :ref:`ImgFrame`
5272

5373
Internal block diagram of StereoDepth node
5474
##########################################
@@ -73,32 +93,36 @@ Currently configurable blocks
7393

7494
.. tab:: Left-Right Check
7595

76-
Left-Right Check or LR-Check is used to remove incorrectly calculated disparity pixels due to occlusions at object borders (Left and Right camera views
96+
**Left-Right Check** or LR-Check is used to remove incorrectly calculated disparity pixels due to occlusions at object borders (Left and Right camera views
7797
are slightly different).
7898

7999
#. Computes disparity by matching in R->L direction
80100
#. Computes disparity by matching in L->R direction
81101
#. Combines results from 1 and 2, running on Shave: each pixel d = disparity_LR(x,y) is compared with disparity_RL(x-d,y). If the difference is above a threshold, the pixel at (x,y) in the final disparity map is invalidated.
82102

103+
You can use :code:`debugDispLrCheckIt1` and :code:`debugDispLrCheckIt2` debug outputs for debugging/fine-tuning purposes.
104+
83105
.. tab:: Extended Disparity
84106

85-
The :code:`extended disparity` allows detecting closer distance objects for the given baseline. This increases the maximum disparity search from 96 to 191, meaning the range is now: **[0..190]**.
107+
**Extended disparity mode** allows detecting closer distance objects for the given baseline. This increases the maximum disparity search from 96 to 191, meaning the range is now: **[0..190]**.
86108
So this cuts the minimum perceivable distance in half, given that the minimum distance is now :code:`focal_length * base_line_dist / 190` instead
87109
of :code:`focal_length * base_line_dist / 95`.
88110

89111
#. Computes disparity on the original size images (e.g. 1280x720)
90112
#. Computes disparity on 2x downscaled images (e.g. 640x360)
91113
#. Combines the two level disparities on Shave, effectively covering a total disparity range of 191 pixels (in relation to the original resolution).
92114

115+
You can use :code:`debugExtDispLrCheckIt1` and :code:`debugExtDispLrCheckIt2` debug outputs for debugging/fine-tuning purposes.
116+
93117
.. tab:: Subpixel Disparity
94118

95-
Subpixel improves the precision and is especially useful for long range measurements. It also helps for better estimating surface normals.
119+
**Subpixel mode** improves the precision and is especially useful for long range measurements. It also helps for better estimating surface normals.
96120

97121
Besides the integer disparity output, the Stereo engine is programmed to dump to memory the cost volume, that is 96 levels (disparities) per pixel,
98-
then software interpolation is done on Shave, resulting a final disparity with 5 fractional bits, resulting in significantly more granular depth
99-
steps (32 additional steps between the integer-pixel depth steps), and also theoretically, longer-distance depth viewing - as the maximum depth
100-
is no longer limited by a feature being a full integer pixel-step apart, but rather 1/32 of a pixel. In this mode, stereo cameras perform: :code:`96 depth steps * 32 subpixel depth steps = 3,072 depth steps.`
101-
Note that Subpixel and Extended Disparity are not yet supported simultaneously (which would result in :code:`191 * 32 = 6,112 depth steps`), but should be available in the near future (`Pull Request <https://github.com/luxonis/depthai-python/pull/347>`__).
122+
then software interpolation is done on Shave, resulting a final disparity with 3 fractional bits, resulting in significantly more granular depth
123+
steps (8 additional steps between the integer-pixel depth steps), and also theoretically, longer-distance depth viewing - as the maximum depth
124+
is no longer limited by a feature being a full integer pixel-step apart, but rather 1/8 of a pixel. In this mode, stereo cameras perform: :code:`94 depth steps * 8 subpixel depth steps + 2 (min/max values) = 754 depth steps`
125+
Note that Subpixel and Extended Disparity are not yet supported simultaneously.
102126

103127
For comparison of normal disparity vs. subpixel disparity images, click `here <https://github.com/luxonis/depthai/issues/184>`__.
104128

@@ -138,12 +162,7 @@ Currently configurable blocks
138162
Current limitations
139163
###################
140164

141-
If one or more of the additional depth modes (:code:`lrcheck`, :code:`extended`, :code:`subpixel`) are enabled, then:
142-
143-
- median filtering is disabled on device
144-
- with subpixel, if both :code:`depth` and :code:`disparity` are used, only :code:`depth` will have valid output
145-
146-
Otherwise, :code:`depth` output is **U16** (in millimeters) and median is functional.
165+
- Median filtering is disabled when subpixel mode is set to 4 or 5 bits.
147166

148167
Stereo depth FPS
149168
################

0 commit comments

Comments
 (0)