Skip to content

Commit 6581557

Browse files
authored
Merge pull request #486 from luxonis/depth_filters
Depth filters
2 parents 9dac225 + ddd6bd0 commit 6581557

File tree

7 files changed

+127
-6
lines changed

7 files changed

+127
-6
lines changed
-91.2 KB
Binary file not shown.
110 KB
Loading
583 KB
Loading

docs/source/components/nodes/stereo_depth.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Inputs and Outputs
7373
Internal block diagram of StereoDepth node
7474
##########################################
7575

76-
.. image:: /_static/images/components/depth_diagram.jpeg
76+
.. image:: /_static/images/components/depth_diagram.png
7777
:target: https://whimsical.com/stereo-node-EKcfcXGjGpNL6cwRPV6NPv
7878

7979
On the diagram, red rectangle are firmware settings that are configurable via the API. Gray rectangles are settings that that are not yet
@@ -126,9 +126,15 @@ Currently configurable blocks
126126

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

129-
.. tab:: Mesh file / Homography matrix
129+
.. tab:: Depth Filters
130130

131-
Mesh files are generated using the camera intrinsics, distortion coeffs, and rectification rotations.
131+
**Depth Filtering** / **Depth Post-Processing** is performed at the end of the depth pipeline. It helps with noise reduction and overall depth quality.
132+
133+
.. include:: ../../includes/depth-filters.rst
134+
135+
.. tab:: Mesh files
136+
137+
Mesh files (homography matrix) are generated using the camera intrinsics, distortion coeffs, and rectification rotations.
132138
These files helps in overcoming the distortions in the camera increasing the accuracy and also help in when `wide FOV <https://docs.luxonis.com/projects/hardware/en/latest/pages/arducam.html#arducam-compatible-cameras>`__ lens are used.
133139

134140
.. note::
@@ -148,7 +154,7 @@ Currently configurable blocks
148154

149155
.. tab:: Confidence Threshold
150156

151-
- **Confidence threshold**: Stereo depth algorithm searches for the matching feature from right camera point to the left image (along the 96 disparity levels). During this process it computes the cost for each disparity level and choses the minimal cost between two disparities and uses it to compute the confidence at each pixel. Stereo node will output disparity/depth pixels only where depth confidence is below the **confidence threshold** (lower the confidence value means better depth accuracy). Note: This threshold only applies to Normal stereo mode as of now.
157+
- **Confidence threshold**: Stereo depth algorithm searches for the matching feature from right camera point to the left image (along the 96 disparity levels). During this process it computes the cost for each disparity level and chooses the minimal cost between two disparities and uses it to compute the confidence at each pixel. Stereo node will output disparity/depth pixels only where depth confidence is below the **confidence threshold** (lower the confidence value means better depth accuracy).
152158
- **LR check threshold**: Disparity is considered for the output when the difference between LR and RL disparities is smaller than the LR check threshold.
153159

154160
.. doxygenfunction:: dai::StereoDepthConfig::setConfidenceThreshold
@@ -159,8 +165,8 @@ Currently configurable blocks
159165
:project: depthai-core
160166
:no-link:
161167

162-
Current limitations
163-
###################
168+
Limitations
169+
###########
164170

165171
- Median filtering is disabled when subpixel mode is set to 4 or 5 bits.
166172

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.. tabs::
2+
3+
.. tab:: Median
4+
5+
This is a non-edge preserving `Median filter <https://en.wikipedia.org/wiki/Median_filter>`__, which can be used
6+
to reduce noise and smoothen the depth map. Median filter is implemented in hardware, so it's the fastest filter.
7+
8+
.. doxygenenum:: dai::MedianFilter
9+
:project: depthai-core
10+
:no-link:
11+
12+
.. tab:: Speckle
13+
14+
**Speckle Filter** is used to reduce the speckle noise. Speckle noise is a region with huge
15+
variance between neighboring disparity/depth pixels, and speckle filter tries to filter this region.
16+
17+
.. doxygenstruct:: dai::RawStereoDepthConfig::PostProcessing::SpeckleFilter
18+
:project: depthai-core
19+
:no-link:
20+
:members:
21+
22+
.. tab:: Temporal
23+
24+
**Temporal Filter** is intended to improve the depth data persistency by manipulating per-pixel
25+
values based on previous frames. The filter performs a single pass on the data, adjusting the depth
26+
values while also updating the tracking history. In cases where the pixel data is missing or invalid,
27+
the filter uses a user-defined persistency mode to decide whether the missing value should be
28+
rectified with stored data. Note that due to its reliance on historic data the filter may introduce
29+
visible blurring/smearing artifacts, and therefore is best-suited for static scenes.
30+
31+
.. doxygenstruct:: dai::RawStereoDepthConfig::PostProcessing::TemporalFilter
32+
:project: depthai-core
33+
:no-link:
34+
:members:
35+
36+
.. tab:: Spatial
37+
38+
**Spatial Edge-Preserving Filter** will fill invalid depth pixels with valid neighboring depth pixels.
39+
It performs a series of 1D horizontal and vertical passes or iterations, to enhance the smoothness of
40+
the reconstructed data. It is based on `this research paper <https://www.inf.ufrgs.br/~eslgastal/DomainTransform/>`__.
41+
42+
.. doxygenstruct:: dai::RawStereoDepthConfig::PostProcessing::SpatialFilter
43+
:project: depthai-core
44+
:no-link:
45+
:members:
46+
47+
.. tab:: Threshold
48+
49+
**Threshold Filter** filters out all disparity/depth pixels outside the configured min/max
50+
threshold values.
51+
52+
.. autoclass:: depthai.RawStereoDepthConfig.PostProcessing.ThresholdFilter
53+
:members:
54+
:inherited-members:
55+
:noindex:
56+
57+
.. tab:: Decimation
58+
59+
**Decimation Filter** will sub-samples the depth map, which means it reduces the depth scene complexity and allows
60+
other filters to run faster. Setting :code:`decimationFactor` to 2 will downscale 1280x800 depth map to 640x400.
61+
62+
.. doxygenstruct:: dai::RawStereoDepthConfig::PostProcessing::DecimationFilter
63+
:members:
64+
:project: depthai-core
65+
:no-link:
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Depth Post-Processing
2+
=====================
3+
4+
This example shows how you can run depth post-processing filters on the device itself to reduce noise,
5+
smooth the depth map and overall improve the depth map quality. Post-processing can be added to :ref:`StereoDepth` node.
6+
7+
8+
Demo
9+
####
10+
11+
.. image:: /_static/images/examples/depth_comparison.png
12+
13+
Depth filters
14+
#############
15+
16+
.. include:: /includes/depth-filters.rst
17+
18+
.. rubric:: Similar samples:
19+
20+
- :ref:`Depth Preview`
21+
- :ref:`Stereo Depth from host`
22+
23+
Setup
24+
#####
25+
26+
.. include:: /includes/install_from_pypi.rst
27+
28+
Source code
29+
###########
30+
31+
.. tabs::
32+
33+
.. tab:: Python
34+
35+
Also `available on GitHub <https://github.com/luxonis/depthai-python/blob/main/examples/StereoDepth/depth_post_processing.py>`__
36+
37+
.. literalinclude:: ../../../../examples/StereoDepth/depth_post_processing.py
38+
:language: python
39+
:linenos:
40+
41+
.. tab:: C++
42+
43+
Also `available on GitHub <https://github.com/luxonis/depthai-core/blob/main/examples/StereoDepth/depth_post_processing.cpp>`__
44+
45+
.. literalinclude:: ../../../../depthai-core/examples/StereoDepth/depth_post_processing.cpp
46+
:language: cpp
47+
:linenos:
48+
49+
.. include:: /includes/footer-short.rst

docs/source/tutorials/code_samples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ are presented with code.
122122
.. rubric:: StereoDepth
123123

124124
- :ref:`Depth Crop Control` - Demonstrates how to control cropping of depth frames from the host
125+
- :ref:`Depth Post-Processing` - Depth post-processing filters
125126
- :ref:`Depth Preview` - Displays colorized stereo disparity
126127
- :ref:`Stereo Depth from host` - Generates stereo depth frame from a set of mono images from the host
127128
- :ref:`Stereo Depth Video` - An extended version of **Depth Preview**

0 commit comments

Comments
 (0)