Skip to content

Commit a12c8bc

Browse files
authored
Merge pull request #672 from luxonis/disparity_shift
Added disparity shift docs
2 parents cdbbc95 + b83bd0d commit a12c8bc

File tree

1 file changed

+51
-18
lines changed

1 file changed

+51
-18
lines changed

docs/source/components/nodes/stereo_depth.rst

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
StereoDepth
2-
===========
2+
###########
33

4-
Stereo depth node calculates the disparity/depth from two :ref:`mono cameras <MonoCamera>`.
4+
StereoDepth node calculates the disparity/depth from the stereo camera pair (2x :ref:`MonoCamera <MonoCamera>`).
55

66
How to place it
7-
###############
7+
===============
88

99
.. tabs::
1010

@@ -20,7 +20,7 @@ How to place it
2020

2121

2222
Inputs and Outputs
23-
##################
23+
==================
2424

2525
.. code-block::
2626
@@ -71,7 +71,7 @@ Inputs and Outputs
7171
- :code:`debugDispCostDump` - :ref:`ImgFrame`
7272

7373
Internal block diagram of StereoDepth node
74-
##########################################
74+
==========================================
7575

7676
.. image:: /_static/images/components/depth_diagram.png
7777
:target: https://whimsical.com/stereo-node-EKcfcXGjGpNL6cwRPV6NPv
@@ -83,7 +83,7 @@ configurable sooner.
8383
If you click on the image, you will be redirected to the webapp. Some blocks have notes that provide additional technical information.
8484

8585
Currently configurable blocks
86-
*****************************
86+
-----------------------------
8787

8888
.. tabs::
8989

@@ -165,12 +165,12 @@ Currently configurable blocks
165165
:no-link:
166166

167167
Limitations
168-
###########
168+
===========
169169

170170
- Median filtering is disabled when subpixel mode is set to 4 or 5 bits.
171171

172172
Stereo depth FPS
173-
################
173+
================
174174

175175
.. list-table::
176176
:header-rows: 1
@@ -201,7 +201,7 @@ All stereo modes were measured for :code:`depth` output with **5x5 median filter
201201
to **60 FPS** and for 400P mono cameras were set to **110 FPS**.
202202

203203
Usage
204-
#####
204+
=====
205205

206206
.. tabs::
207207

@@ -238,15 +238,15 @@ Usage
238238
right->out.link(stereo->right);
239239

240240
Examples of functionality
241-
#########################
241+
=========================
242242

243243
- :ref:`Depth Preview`
244244
- :ref:`RGB Depth alignment`
245245
- :ref:`Mono & MobilenetSSD & Depth`
246246
- :ref:`RGB & MobilenetSSD with spatial data`
247247

248248
Reference
249-
#########
249+
=========
250250

251251
.. tabs::
252252

@@ -266,7 +266,7 @@ Reference
266266
:undoc-members:
267267

268268
Disparity
269-
#########
269+
=========
270270

271271
Disparity refers to the distance between two corresponding points in the left and right image of a stereo pair.
272272
By looking at the image below, it can be seen that point :code:`X` gets projected to :code:`XL = (u, v)` in the :code:`Left view` and :code:`XR = (p, q)` in the :code:`Right view`.
@@ -290,7 +290,7 @@ For the final disparity map, a filtering is applied based on the confidence thre
290290
the threshold get invalidated, i.e. their disparity value is set to zero. You can set the confidence threshold with :code:`stereo.initialConfig.setConfidenceThreshold()`.
291291

292292
Calculate depth using disparity map
293-
###################################
293+
===================================
294294

295295
Disparity and depth are inversely related. As disparity decreases, depth increases exponentially depending on baseline and focal length. Meaning, if the disparity value is close to zero, then a small change in disparity generates a large change in depth. Similarly, if the disparity value is big, then large changes in disparity do not lead to a large change in depth.
296296

@@ -339,7 +339,7 @@ Examples for calculating the depth value, using the OAK-D (7.5cm baseline):
339339
Note the value of disparity depth data is stored in :code:`uint16`, where 0 is a special value, meaning that distance is unknown.
340340

341341
Min stereo depth distance
342-
#########################
342+
=========================
343343

344344
If the depth results for close-in objects look weird, this is likely because they are below the minimum depth-perception distance of the device.
345345

@@ -375,8 +375,41 @@ or roughly 35cm.
375375

376376
See `these examples <https://github.com/luxonis/depthai-experiments/tree/master/gen2-camera-demo#real-time-depth-from-depthai-stereo-pair>`__ for how to enable Extended Disparity.
377377

378+
Disparity shift to lower min depth perception
379+
---------------------------------------------
380+
381+
Another option to perceive closer depth range is to use disparity shift. Disparity shift will shift the starting point
382+
of the disparity search, which will significantly decrease max depth (MazZ) perception, but it will also decrease min depth (MinZ) perception.
383+
Disparity shift can be combined with extended/subpixel/LR-check modes.
384+
385+
.. image:: https://user-images.githubusercontent.com/18037362/189375017-2fa137d2-ad6b-46de-8899-6304bbc6c9d7.png
386+
387+
**Left graph** shows min and max disparity and depth for OAK-D (7.5cm baseline, 800P resolution, ~70° HFOV) by default (disparity shift=0). See :ref:`Calculate depth using disparity map`.
388+
Since hardware (stereo block) has a fixed 95 pixel disparity search, DepthAI will search from 0 pixels (depth=INF) to 95 pixels (depth=71cm).
389+
390+
**Right graph** shows the same, but at disparity shift set to 30 pixels. This means that disparity search will be from 30 pixels (depth=2.2m) to 125 pixels (depth=50cm).
391+
This also means that depth will be very accurate at the short range (**theoretically** below 5mm depth error).
392+
393+
**Limitations**:
394+
395+
- Because of the inverse relationship between disparity and depth, MaxZ will decrease much faster than MinZ as the disparity shift is increased. Therefore, it is **advised not to use a larger than necessary disparity shift**.
396+
- Tradeoff in reducing the MinZ this way is that objects at **distances farther away than MaxZ will not be seen**.
397+
- Because of the point above, **we only recommend using disparity shift when MaxZ is known**, such as having a depth camera mounted above a table pointing down at the table surface.
398+
- Output disparity map is not expanded, only the depth map. So if disparity shift is set to 50, and disparity value obtained is 90, the real disparity is 140.
399+
400+
**Compared to Extended disparity**, disparity shift:
401+
402+
- **(+)** Is faster, as it doesn't require an extra computation, which means there's also no extra latency
403+
- **(-)** Reduces the MaxZ (significantly), while extended disparity only reduces MinZ.
404+
405+
Disparity shift can be combined with extended disparity.
406+
407+
.. doxygenfunction:: dai::StereoDepthConfig::setDisparityShift
408+
:project: depthai-core
409+
:no-link:
410+
378411
Max stereo depth distance
379-
#########################
412+
=========================
380413

381414
The maximum depth perception distance depends on the :ref:`accuracy of the depth perception <Depth perception accuracy>`. The formula used to calculate this distance is an approximation, but is as follows:
382415

@@ -397,7 +430,7 @@ So using this formula for existing models the *theoretical* max distance is:
397430
If greater precision for long range measurements is required, consider enabling Subpixel Disparity or using a larger baseline distance between mono cameras. For a custom baseline, you could consider using `OAK-FFC <https://docs.luxonis.com/projects/hardware/en/latest/pages/DM1090.html>`__ device or design your own baseboard PCB with required baseline. For more information see Subpixel Disparity under the Stereo Mode tab in :ref:`this table <Currently configurable blocks>`.
398431

399432
Depth perception accuracy
400-
#########################
433+
=========================
401434

402435
Disparity depth works by matching features from one image to the other and its accuracy is based on multiple parameters:
403436

@@ -415,7 +448,7 @@ Lower baseline enables us to detect the depth at a closer distance as long as th
415448
So the common norm is to adjust the baseline according to how far/close we want to be able to detect objects.
416449

417450
Limitation
418-
##########
451+
==========
419452

420453
Since depth is calculated from disparity, which requires the pixels to overlap, there is inherently a vertical
421454
band on the left side of the left mono camera and on the right side of the right mono camera, where depth
@@ -472,7 +505,7 @@ forum post.
472505
`here <https://github.com/luxonis/depthai-hardware/issues/114>`__.
473506

474507
Measuring real-world object dimensions
475-
######################################
508+
======================================
476509

477510
Because the depth map contains the Z distance, objects in parallel with the camera are measured accurately standard. For objects not in parallel, the Euclidean distance calculation can be used. Please refer to the below:
478511

0 commit comments

Comments
 (0)