Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
73991ab
FW: support for IMX283, at almost full resolution: 5312x3692, FPS max…
alex-luxonis Apr 6, 2023
334b7d3
Update FW: IMX283 exposure and ISO setting fixed,
alex-luxonis Apr 17, 2023
74c3fdf
Merge 'develop' into imx283. Update FW with IMX462 support
alex-luxonis May 21, 2023
ed15db5
Added out binding to VideoEncoder
asahtik Aug 24, 2023
5f655c6
Added python bindings on host side
asahtik Aug 25, 2023
eb7a6b0
Added unknown frame type
asahtik Aug 29, 2023
d8a7042
bindings for getConnectivity
AnielAlexa Sep 6, 2023
03d57d5
depthai-core dependiences
AnielAlexa Sep 7, 2023
6edcfb1
Merge branch 'develop' of github.com:luxonis/depthai-python into vide…
asahtik Sep 8, 2023
b9c95c4
Bump core
asahtik Sep 12, 2023
ddaa16a
Bump core
asahtik Sep 19, 2023
4b9c9e7
EncFrm fixes
asahtik Sep 19, 2023
cd7eb6c
Added bitrate to bindings
asahtik Sep 20, 2023
80fdedf
Bump core
asahtik Sep 21, 2023
3aedd8f
Bump core
asahtik Sep 21, 2023
635ea06
Bump core again
asahtik Sep 21, 2023
e5dedba
Merge resolution
asahtik Oct 6, 2023
cfad98f
Bump core
asahtik Oct 9, 2023
ba9497a
FW: OAK-D-SR-PoE R1 fixes for fsync detect and status LED (green when…
alex-luxonis Oct 9, 2023
bfa0026
Merge resolution
asahtik Oct 10, 2023
40e2c12
Added fields to encodedframe
asahtik Oct 10, 2023
37c05dd
Bump core
asahtik Oct 11, 2023
20a59d6
Implemented message groups and sync node
asahtik Oct 18, 2023
ed3dc76
Add more options to the stereo_from_host_example
Oct 18, 2023
fbd86e6
Merge pull request #910 from luxonis/stereo_from_host_example
moratom Oct 20, 2023
43f20e6
CameraControl: add `setControlMode`, `setCaptureIntent`
alex-luxonis Oct 23, 2023
aba784e
cam_test.py: add scene mode, control mode, capture intent (`\` `;` `'…
alex-luxonis Oct 23, 2023
b177b9d
WIP: fix add binding somehow
asahtik Oct 27, 2023
b613a5f
Merge 'origin/develop' into imx283
alex-luxonis Oct 27, 2023
e5581d0
Bump core
asahtik Oct 28, 2023
0eb95f1
Merge resolution
asahtik Oct 30, 2023
91d2e79
Fixed python bindings
asahtik Oct 30, 2023
3ae8ff9
FW: multiple tunings to fix image quality issues, OV9782 tuning, IMX4…
alex-luxonis Oct 31, 2023
0abab20
Merge 'origin/imx283' into develop
alex-luxonis Oct 31, 2023
11ede87
Implemented messagedemux
asahtik Nov 2, 2023
3aa11ba
Implemented messagedemux
asahtik Nov 2, 2023
1023445
Merge resolution
asahtik Nov 2, 2023
5190fde
Bump core
asahtik Nov 2, 2023
3258d8e
Bump core
asahtik Nov 2, 2023
b32d0af
Merge branch 'develop' of github.com:luxonis/depthai-python into vide…
asahtik Nov 3, 2023
5ef08c8
Bump core
asahtik Nov 3, 2023
de02c64
Bump core
asahtik Nov 3, 2023
784ed42
Bumo core
asahtik Nov 3, 2023
e146388
Bump core
asahtik Nov 3, 2023
1d0dee9
Merge branch 'video_encoder_frame' of github.com:luxonis/depthai-pyth…
asahtik Nov 3, 2023
1ea482a
Some changes WRT Android build
themarpe Nov 3, 2023
ef924c3
Fix multi stereo node race condition when depth output is enabled
Nov 4, 2023
576d3c6
Merge branch 'video_encoder_frame' of github.com:luxonis/depthai-pyth…
zrezke Nov 6, 2023
a1941bb
Ir brightness control based on normalized intensity, instead of current.
zrezke Nov 6, 2023
760b895
Bump core (rewrite msggrps)
asahtik Nov 6, 2023
6d9c841
fix: release gil on close()
hashb Nov 3, 2023
152bd06
Merge pull request #916 from hashb/dev/release_lock_for_data_queue_bi…
themarpe Nov 6, 2023
e7657e8
Added ability to only demux successfuly synced groups
asahtik Nov 6, 2023
68eb3cd
Merge branch 'develop' of github.com:luxonis/depthai-python into getC…
asahtik Nov 6, 2023
2423686
Added IR intensity API.
zrezke Nov 6, 2023
ce621ef
Bump core
asahtik Nov 7, 2023
b8eb42d
Merge branch 'develop' of github.com:luxonis/depthai-python into vide…
asahtik Nov 7, 2023
20f716a
Add tests/multithread.py, can replicate a few failures:
alex-luxonis Nov 8, 2023
628e4ce
Fix XLink linkId reuse, caused multi-threading failures
alex-luxonis Nov 8, 2023
684dd41
Bump core
asahtik Nov 8, 2023
e1122c3
Bump core
asahtik Nov 8, 2023
f2d30d0
Merge branch 'develop' of github.com:luxonis/depthai-python into mess…
asahtik Nov 8, 2023
be73c4f
Bump core
asahtik Nov 8, 2023
2007a99
Bump core
asahtik Nov 8, 2023
c750c68
Renamed getConnectivity
asahtik Nov 10, 2023
5d6e1d3
Update docstring. Point to correct device side commit.
zrezke Nov 10, 2023
613049e
Merge branch 'develop' of github.com:luxonis/depthai-python into ir-i…
zrezke Nov 10, 2023
bf02891
Bump core
zrezke Nov 10, 2023
0f37f1d
Use IR intensity API in cam_test.py
zrezke Nov 10, 2023
063a8b9
Renamed getAvailableInterfaces
asahtik Nov 13, 2023
83ead49
Added an example for encframe
asahtik Nov 13, 2023
f80ce27
Merge pull request #893 from luxonis/video_encoder_frame
asahtik Nov 13, 2023
c8ccafe
Deprecated ir brightness api, fixed mono_preview_alternate_pro.py exa…
zrezke Nov 13, 2023
f8869b7
Merge branch 'develop' of github.com:luxonis/depthai-python into ir-i…
zrezke Nov 13, 2023
c51148c
Merge branch 'develop' of github.com:luxonis/depthai-python into mess…
asahtik Nov 13, 2023
c022aec
cam test: use step 0.05 for both dot projector and flood light
zrezke Nov 13, 2023
d713940
Bugfixes, changes to sync, msggrp, demux
asahtik Nov 14, 2023
e01046b
Fix docstrings build -
asahtik Nov 14, 2023
3d03da7
Add CameraControl `setAutoExposureLimit`. FW: improve OV9282/OV9782 i…
alex-luxonis Nov 15, 2023
4308c3e
Changed the way sync is configured
asahtik Nov 15, 2023
901fd9b
Clangformat
asahtik Nov 15, 2023
850746a
Added examples
asahtik Nov 15, 2023
21da65a
Required for python linting
Erol444 Oct 12, 2023
b591040
Merge pull request #907 from luxonis/warp_node_bindings
themarpe Nov 16, 2023
cf64f2c
Added iterator for MsgGrp and an example
asahtik Nov 17, 2023
047fd6b
Bump core (fw)
asahtik Nov 17, 2023
6b2a792
Merge branch 'develop' of github.com:luxonis/depthai-python into auto…
asahtik Nov 20, 2023
e98a371
Bump core + build fixes
asahtik Nov 20, 2023
d8edfab
Changed example to use disparity instead of depth
asahtik Nov 20, 2023
275d8b7
Clangformat
asahtik Nov 20, 2023
1c817ce
Bump core
asahtik Nov 20, 2023
f708788
Merge branch 'develop' of github.com:luxonis/depthai-python into getC…
asahtik Nov 20, 2023
d32e049
Merge develop + build fixes
asahtik Nov 20, 2023
9c50aa6
Merge pull request #890 from luxonis/getConnectivity_bindings
asahtik Nov 20, 2023
dac3938
Bump core
asahtik Nov 20, 2023
6a1e986
Merge branch 'develop' of github.com:luxonis/depthai-python into mess…
asahtik Nov 20, 2023
7646e8a
Changed syncThreshold setter to use chrono duration (timedelta)
asahtik Nov 20, 2023
16f17b5
Bump core
asahtik Nov 22, 2023
f6049b8
Bump core
asahtik Nov 23, 2023
7661cbc
Bump core
asahtik Nov 23, 2023
bcac0df
Merge branch 'develop' of github.com:luxonis/depthai-python into auto…
asahtik Nov 23, 2023
5df2d49
Bump core
asahtik Nov 23, 2023
40ae8e4
Bump core
asahtik Nov 23, 2023
82713dc
Bump core
asahtik Nov 23, 2023
281c22f
IR intensity API (#920)
zrezke Nov 23, 2023
f662c44
Merge 'origin/develop' into ae_exp_limit. FW: fix large exposure limi…
alex-luxonis Nov 24, 2023
33c8f6b
Merge pull request #921 from luxonis/ae_exp_limit
alex-luxonis Nov 24, 2023
32c4730
Merge 'origin/develop' into xlink_linkid_race_fix
alex-luxonis Nov 24, 2023
bdd6db1
Merge pull request #918 from luxonis/xlink_linkid_race_fix
alex-luxonis Nov 24, 2023
1a57fa6
Merge branch 'develop' of github.com:luxonis/depthai-python into mess…
asahtik Nov 24, 2023
0a187eb
Bump core
asahtik Nov 24, 2023
0243799
Bump core
asahtik Nov 24, 2023
8a45644
Merge branch 'develop' of github.com:luxonis/depthai-python into auto…
asahtik Nov 27, 2023
62bcbf6
Bump core
asahtik Nov 27, 2023
0ee9893
Bump core
asahtik Nov 27, 2023
88f6501
Bump core
asahtik Nov 29, 2023
faa123c
Bump core
asahtik Nov 29, 2023
23c4f53
Merge pull request #914 from luxonis/message_groups
asahtik Nov 29, 2023
ecab5d5
Merge branch 'develop' of github.com:luxonis/depthai-python into auto…
asahtik Nov 29, 2023
0f64ce0
Changed crashdump timing
asahtik Nov 29, 2023
54d8702
Clangformat
asahtik Nov 29, 2023
78d6f17
Bump core
asahtik Nov 29, 2023
89ac2ea
Merge pull request #928 from luxonis/auto_crash_report
asahtik Nov 29, 2023
51b2990
Fix a sync example
moratom Nov 30, 2023
a5a1f4c
Merge pull request #929 from luxonis/fix_sync_example
moratom Nov 30, 2023
5c0a0ea
Bump core
asahtik Nov 30, 2023
1051dbf
Merge pull request #930 from luxonis/dmaMemcpy_fix
moratom Nov 30, 2023
2e7cd0a
Bump core
asahtik Dec 5, 2023
cfd8b18
Smoothe timesync with a running median
asahtik Dec 6, 2023
4da7acb
Bump core
asahtik Dec 6, 2023
56ef6d8
Add an example
Dec 7, 2023
0af0fc7
[RVC2 FW] Update FW with depthai-shared develop
Dec 7, 2023
dcb8feb
Bump core (stability fix 1)
asahtik Dec 7, 2023
aa7e8fb
Update core with stability fixes for timesyncing
Dec 7, 2023
a4c687e
Test of bl fix
asahtik Dec 8, 2023
1223d91
Merge branch 'xlinkin_timestamps' of github.com:luxonis/depthai-pytho…
asahtik Dec 8, 2023
4c49912
Revert XLink profiling to uint64_t change
Dec 11, 2023
aa4ec10
Update depthai-core to develop
Dec 11, 2023
204261d
Merge pull request #934 from luxonis/timesync_median
moratom Dec 11, 2023
0c00a67
Update core
Dec 11, 2023
e50e92a
Update core to develop
Dec 11, 2023
d7f356d
Merge remote-tracking branch 'origin/develop' into device_bl_init_loc…
Dec 11, 2023
d24c945
Merge pull request #919 from luxonis/device_bl_init_lock_bugfix
moratom Dec 11, 2023
24ad14e
Modified libclang usage for readthedocs
themarpe Dec 13, 2023
ead6377
Bump version to 2.24.0.0
themarpe Dec 13, 2023
9f21470
Update core to main
Dec 13, 2023
bbf4048
Merge remote-tracking branch 'origin/main' into release_v2.24.0.0
Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge 'develop' into imx283. Update FW with IMX462 support
  • Loading branch information
alex-luxonis committed May 21, 2023
commit 74c3fdfc7ad76268d0c306602c1d9da19a07b42e
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ pybind11_add_module(${TARGET_NAME}
src/pipeline/node/AprilTagBindings.cpp
src/pipeline/node/DetectionParserBindings.cpp
src/pipeline/node/WarpBindings.cpp
src/pipeline/node/UVCBindings.cpp
src/pipeline/node/ToFBindings.cpp

src/pipeline/datatype/ADatatypeBindings.cpp
src/pipeline/datatype/AprilTagConfigBindings.cpp
Expand All @@ -135,6 +137,7 @@ pybind11_add_module(${TARGET_NAME}
src/pipeline/datatype/CameraControlBindings.cpp
src/pipeline/datatype/EdgeDetectorConfigBindings.cpp
src/pipeline/datatype/FeatureTrackerConfigBindings.cpp
src/pipeline/datatype/ToFConfigBindings.cpp
src/pipeline/datatype/ImageManipConfigBindings.cpp
src/pipeline/datatype/ImgDetectionsBindings.cpp
src/pipeline/datatype/ImgFrameBindings.cpp
Expand Down
2 changes: 1 addition & 1 deletion depthai-core
Submodule depthai-core updated 102 files
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ sphinx-autopackagesummary==1.3
autodocsumm==0.2.2
pathlib==1.0.1
jinja2==3.0.3
urllib3==1.26.15 # New urllib version breaks sphinx
-r ./requirements_mkdoc.txt
2 changes: 1 addition & 1 deletion docs/requirements_mkdoc.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
git+https://github.com/luxonis/pybind11_mkdoc.git@47a353ae22a3ca2fe1ca47f47b38613dcfb1043b
git+https://github.com/luxonis/pybind11_mkdoc.git@59746f8d1645c9f00ebfb534186334d0154b5bd6
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/source/components/nodes/color_camera.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Usage
pipeline = dai.Pipeline()
cam = pipeline.create(dai.node.ColorCamera)
cam.setPreviewSize(300, 300)
cam.setBoardSocket(dai.CameraBoardSocket.RGB)
cam.setBoardSocket(dai.CameraBoardSocket.CAM_A)
cam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
cam.setInterleaved(False)
cam.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
Expand All @@ -97,7 +97,7 @@ Usage
dai::Pipeline pipeline;
auto cam = pipeline.create<dai::node::ColorCamera>();
cam->setPreviewSize(300, 300);
cam->setBoardSocket(dai::CameraBoardSocket::RGB);
cam->setBoardSocket(dai::CameraBoardSocket::CAM_A);
cam->setResolution(dai::ColorCameraProperties::SensorResolution::THE_1080_P);
cam->setInterleaved(false);
cam->setColorOrder(dai::ColorCameraProperties::ColorOrder::RGB);
Expand Down
4 changes: 2 additions & 2 deletions docs/source/components/nodes/mono_camera.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ Usage

pipeline = dai.Pipeline()
mono = pipeline.create(dai.node.MonoCamera)
mono.setBoardSocket(dai.CameraBoardSocket.RIGHT)
mono.setCamera("right")
mono.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)

.. code-tab:: c++

dai::Pipeline pipeline;
auto mono = pipeline.create<dai::node::MonoCamera>();
mono->setBoardSocket(dai::CameraBoardSocket::RIGHT);
mono->setCamera("right");
mono->setResolution(dai::MonoCameraProperties::SensorResolution::THE_720_P);

Examples of functionality
Expand Down
218 changes: 217 additions & 1 deletion docs/source/components/nodes/stereo_depth.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
StereoDepth
###########

StereoDepth node calculates the disparity/depth from the stereo camera pair (2x :ref:`MonoCamera <MonoCamera>`/:ref:`ColorCamera`).
StereoDepth node calculates the disparity and/or depth from the stereo camera pair (2x :ref:`MonoCamera <MonoCamera>`/:ref:`ColorCamera`).
We suggest following :ref:`Configuring Stereo Depth` tutorial to achieve the best depth results.

How to place it
===============
Expand Down Expand Up @@ -286,6 +287,221 @@ as:
For the final disparity map, a filtering is applied based on the confidence threshold value: the pixels that have their confidence score larger than
the threshold get invalidated, i.e. their disparity value is set to zero. You can set the confidence threshold with :code:`stereo.initialConfig.setConfidenceThreshold()`.

Calculate depth using disparity map
===================================

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.

By considering this fact, depth can be calculated using this formula:

.. code-block:: python

depth = focal_length_in_pixels * baseline / disparity_in_pixels

Where baseline is the distance between two mono cameras. Note the unit used for baseline and depth is the same.

To get focal length in pixels, you can :ref:`read camera calibration <Calibration Reader>`, as focal length in pixels is
written in camera intrinsics (``intrinsics[0][0]``):

.. code-block:: python

import depthai as dai

with dai.Device() as device:
calibData = device.readCalibration()
intrinsics = calibData.getCameraIntrinsics(dai.CameraBoardSocket.CAM_C)
print('Right mono camera focal length in pixels:', intrinsics[0][0])

Here's theoretical calculation of the focal length in pixels:

.. code-block:: python

focal_length_in_pixels = image_width_in_pixels * 0.5 / tan(HFOV * 0.5 * PI/180)

# With 400P mono camera resolution where HFOV=71.9 degrees
focal_length_in_pixels = 640 * 0.5 / tan(71.9 * 0.5 * PI / 180) = 441.25

# With 800P mono camera resolution where HFOV=71.9 degrees
focal_length_in_pixels = 1280 * 0.5 / tan(71.9 * 0.5 * PI / 180) = 882.5

Examples for calculating the depth value, using the OAK-D (7.5cm baseline):

.. code-block:: python

# For OAK-D @ 400P mono cameras and disparity of eg. 50 pixels
depth = 441.25 * 7.5 / 50 = 66.19 # cm

# For OAK-D @ 800P mono cameras and disparity of eg. 10 pixels
depth = 882.5 * 7.5 / 10 = 661.88 # cm

Note the value of disparity depth data is stored in :code:`uint16`, where 0 is a special value, meaning that distance is unknown.

Min stereo depth distance
=========================

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.

To calculate this minimum distance, use the :ref:`depth formula <Calculate depth using disparity map>` and choose the maximum value for disparity_in_pixels parameter (keep in mind it is inveresly related, so maximum value will yield the smallest result).

For example OAK-D has a baseline of **7.5cm**, focal_length_in_pixels of **882.5 pixels** and the default maximum value for disparity_in_pixels is **95**. By using the :ref:`depth formula <Calculate depth using disparity map>` we get:

.. code-block:: python

min_distance = focal_length_in_pixels * baseline / disparity_in_pixels = 882.5 * 7.5cm / 95 = 69.67cm

or roughly 70cm.

However this distance can be cut in 1/2 (to around 35cm for the OAK-D) with the following options:

1. Changing the resolution to 640x400, instead of the standard 1280x800.

2. Enabling Extended Disparity.

Extended Disparity mode increases the levels of disparity to 191 from the standard 96 pixels, thereby 1/2-ing the minimum depth. It does so by computing the 96-pixel disparities on the original 1280x720 and on the downscaled 640x360 image, which are then merged to a 191-level disparity. For more information see the Extended Disparity tab in :ref:`this table <Currently configurable blocks>`.

Using the previous OAK-D example, disparity_in_pixels now becomes **190** and the minimum distance is:

.. code-block:: python

min_distance = focal_length_in_pixels * baseline / disparity_in_pixels = 882.5 * 7.5cm / 190 = 34.84cm

or roughly 35cm.

.. note::

Applying both of those options is possible, which would set the minimum depth to 1/4 of the standard settings, but at such short distances the minimum depth is limited by focal length, which is 19.6cm, since OAK-D mono cameras have fixed focus distance: 19.6cm - infinity.

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.

Disparity shift to lower min depth perception
---------------------------------------------

Another option to perceive closer depth range is to use disparity shift. Disparity shift will shift the starting point
of the disparity search, which will significantly decrease max depth (MazZ) perception, but it will also decrease min depth (MinZ) perception.
Disparity shift can be combined with extended/subpixel/LR-check modes.

.. image:: https://user-images.githubusercontent.com/18037362/189375017-2fa137d2-ad6b-46de-8899-6304bbc6c9d7.png

**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`.
Since hardware (stereo block) has a fixed 95 pixel disparity search, DepthAI will search from 0 pixels (depth=INF) to 95 pixels (depth=71cm).

**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).
This also means that depth will be very accurate at the short range (**theoretically** below 5mm depth error).

**Limitations**:

- 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**.
- Tradeoff in reducing the MinZ this way is that objects at **distances farther away than MaxZ will not be seen**.
- 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.
- 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.

**Compared to Extended disparity**, disparity shift:

- **(+)** Is faster, as it doesn't require an extra computation, which means there's also no extra latency
- **(-)** Reduces the MaxZ (significantly), while extended disparity only reduces MinZ.

Disparity shift can be combined with extended disparity.

.. doxygenfunction:: dai::StereoDepthConfig::setDisparityShift
:project: depthai-core
:no-link:

Max stereo depth distance
=========================

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:

.. code-block:: python

Dm = (baseline/2) * tan((90 - HFOV / HPixels)*pi/180)

So using this formula for existing models the *theoretical* max distance is:

.. code-block:: python

# For OAK-D (7.5cm baseline)
Dm = (7.5/2) * tan((90 - 71.9/1280)*pi/180) = 3825.03cm = 38.25 meters

# For OAK-D-CM4 (9cm baseline)
Dm = (9/2) * tan((90 - 71.9/1280)*pi/180) = 4590.04cm = 45.9 meters

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>`.

Depth perception accuracy
=========================

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

* Texture of objects / backgrounds

Backgrounds may interfere with the object detection, since backgrounds are objects too, which will make depth perception less accurate. So disparity depth works very well outdoors as there are very rarely perfectly-clean/blank surfaces there - but these are relatively commonplace indoors (in clean buildings at least).

* Lighting

If the illumination is low, the diparity map will be of low confidence, which will result in a noisy depth map.

* Baseline / distance to objects

Lower baseline enables us to detect the depth at a closer distance as long as the object is visible in both the frames. However, this reduces the accuracy for large distances due to less pixels representing the object and disparity decreasing towards 0 much faster.
So the common norm is to adjust the baseline according to how far/close we want to be able to detect objects.

Limitation
==========

Since depth is calculated from disparity, which requires the pixels to overlap, there is inherently a vertical
band on the left side of the left mono camera and on the right side of the right mono camera, where depth
cannot be calculated, since it is seen by only 1 camera. That band is marked with :code:`B`
on the following picture.

.. image:: https://user-images.githubusercontent.com/59799831/135310921-67726c28-07e7-4ffa-bc8d-74861049517e.png

Meaning of variables on the picture:

- ``BL [cm]`` - Baseline of stereo cameras.
- ``Dv [cm]`` - Minimum distace where both cameras see an object (thus where depth can be calculated).
- ``B [pixels]`` - Width of the band where depth cannot be calculated.
- ``W [pixels]`` - Width of mono in pixels camera or amount of horizontal pixels, also noted as :code:`HPixels` in other formulas.
- ``D [cm]`` - Distance from the **camera plane** to an object (see image :ref:`here <Measuring real-world object dimensions>`).
- ``F [cm]`` - Width of image at the distance ``D``.

.. image:: https://user-images.githubusercontent.com/59799831/135310972-c37ba40b-20ad-4967-92a7-c71078bcef99.png

With the use of the :code:`tan` function, the following formulas can be obtained:

- :code:`F = 2 * D * tan(HFOV/2)`
- :code:`Dv = (BL/2) * tan(90 - HFOV/2)`

In order to obtain :code:`B`, we can use :code:`tan` function again (same as for :code:`F`), but this time
we must also multiply it by the ratio between :code:`W` and :code:`F` in order to convert units to pixels.
That gives the following formula:

.. code-block:: python

B = 2 * Dv * tan(HFOV/2) * W / F
B = 2 * Dv * tan(HFOV/2) * W / (2 * D * tan(HFOV/2))
B = W * Dv / D # pixels

Example: If we are using OAK-D, which has a :code:`HFOV` of 72°, a baseline (:code:`BL`) of 7.5 cm and
:code:`640x400 (400P)` resolution is used, therefore :code:`W = 640` and an object is :code:`D = 100` cm away, we can
calculate :code:`B` in the following way:

.. code-block::

Dv = 7.5 / 2 * tan(90 - 72/2) = 3.75 * tan(54°) = 5.16 cm
B = 640 * 5.16 / 100 = 33 # pixels

Credit for calculations and images goes to our community member gregflurry, which he made on
`this <https://discuss.luxonis.com/d/339-naive-question-regarding-stereodepth-disparity-and-depth-outputs/7>`__
forum post.

.. note::

OAK-D-PRO will include both IR dot projector and IR LED, which will enable operation in no light.
IR LED is used to illuminate the whole area (for mono/color frames), while IR dot projector is mostly
for accurate disparity matching - to have good quality depth maps on blank surfaces as well. For outdoors,
the IR laser dot projector is only relevant at night. For more information see the development progress
`here <https://github.com/luxonis/depthai-hardware/issues/114>`__.

Measuring real-world object dimensions
======================================

Expand Down
27 changes: 2 additions & 25 deletions docs/source/includes/footer-short.rst
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
.. raw:: html

<h2>Got questions?</h2>
<h2>Got questions?</h2>

We're always happy to help with code or other questions you might have.

.. raw:: html

<div class="cta-row cta-row-short">
<div class="cta-box">
<a href="https://discord.gg/luxonis">
<img src="https://docs.luxonis.com/en/latest/_images/discord.png" alt="Discord"/>
<h5 class="cta-title">Community Discord</h5>
</a>
</div>
<div class="cta-box">
<a href="https://discuss.luxonis.com/">
<img src="https://docs.luxonis.com/en/latest/_images/forum.png" alt="forum"/>
<h5 class="cta-title">Discussion Forum</h5>
</a>
</div>
<div class="cta-box">
<a href="mailto:support@luxonis.com">
<img src="https://docs.luxonis.com/en/latest/_images/email.png" alt="forum"/>
<h5 class="cta-title">Email Support</h5>
</a>
</div>
</div>
Head over to <a href="https://discuss.luxonis.com/"><strong>Discussion Forum</strong></a> for technical support or any other questions you might have.
49 changes: 49 additions & 0 deletions docs/source/samples/Script/script_uart.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Script UART communication
=========================

This example uses :ref:`Script` node for `UART communication <https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter>`__. Note that OAK
cameras don't have UART pins easily disposed, and we soldered wires on `OAK-FFC-4P <https://docs.luxonis.com/projects/hardware/en/latest/pages/DD2090.html>`__
to expose UART pins.

.. note::

This should only be run on OAK-FFC-4P, as other OAK cameras might have different GPIO configuration.

Demo
####

.. raw:: html

<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; height: auto;">
<iframe src="https://www.youtube.com/embed/nbS1BczO5sE" frameborder="0" allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
</div>


.. figure:: https://user-images.githubusercontent.com/18037362/232458809-a36dc418-6bb5-411f-9172-5130a926191d.jpg

Oscilloscope connected to the OAK-FFC-4P UART pins

Setup
#####

.. include:: /includes/install_from_pypi.rst

Source code
###########

.. tabs::

.. tab:: Python

Also `available on GitHub <https://github.com/luxonis/depthai-python/blob/main/examples/Script/script_uart.py>`__

.. literalinclude:: ../../../../examples/Script/script_uart.py
:language: python
:linenos:

.. tab:: C++

Not yet available


.. include:: /includes/footer-short.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ scanning camera for mobile robots.
Demo
####

.. image:: https://user-images.githubusercontent.com/18037362/190861621-b57fd1e3-5a3d-4d79-b1a7-d17a0b78c63e.gif
.. image:: https://user-images.githubusercontent.com/18037362/231822498-6e3699a0-039e-424b-acb2-b246575e91ee.png

Setup
#####
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.