Skip to content

Commit

Permalink
Merge pull request #1070 from jakaskerl/main
Browse files Browse the repository at this point in the history
Updating SDK docs with examples
  • Loading branch information
Erol444 committed Jul 4, 2023
2 parents bce814c + a469d8d commit 9db2903
Show file tree
Hide file tree
Showing 135 changed files with 2,197 additions and 2 deletions.
3 changes: 2 additions & 1 deletion depthai_sdk/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Sphinx==4.1.2
Sphinx==4.2.0
sphinx-rtd-theme==0.5.0
autodocsumm==0.2.10
sphinx-tabs==3.4.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions depthai_sdk/docs/source/components/camera_component.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CameraComponent
nodes and supports mocking the camera when recording is passed during OakCamera initialization. When using :ref:`Replaying` feature, this component will
mock the camera by sending frames from the host to the OAK device (via `XLinkIn <https://docs.luxonis.com/projects/api/en/latest/components/nodes/xlink_in/>`__ node).


Usage
#####

Expand Down
3 changes: 2 additions & 1 deletion depthai_sdk/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"sphinx_rtd_theme",
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'autodocsumm'
'autodocsumm',
'sphinx_tabs.tabs'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
3 changes: 3 additions & 0 deletions depthai_sdk/docs/source/includes/blocking_behavior.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. note::
Visualization in current example is done with blocking behavor. This means that the program will halt at ``oak.start()`` until the window is closed.
This is done to keep the example simple. For more advanced usage, see :ref:`Blocking behavior` section.
12 changes: 12 additions & 0 deletions depthai_sdk/docs/source/includes/install_from_pypi.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Please run the `install script <https://github.com/luxonis/depthai/blob/main/install_requirements.py>`__
to download all required dependencies. Please note that this script must be ran from git context, so you have to download the `depthai <https://github.com/luxonis/depthai>`__ repository first and then run the script


.. code-block:: python
git clone https://github.com/luxonis/depthai.git
cd depthai/
python3 install_requirements.py
For additional information, please follow our :ref:`installation guide <Installation>`.
10 changes: 10 additions & 0 deletions depthai_sdk/docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,20 @@ ease of use when developing apps for OAK devices**.

features/*


.. toctree::
:maxdepth: 1
:hidden:
:caption: Examples

tutorials/code_samples.rst


.. toctree::
:maxdepth: 2
:hidden:
:glob:
:caption: References

api_reference.rst

32 changes: 32 additions & 0 deletions depthai_sdk/docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,38 @@ This class simplifies the creation of pipelines that capture video from the OAK
With :class:`OakCamera <depthai_sdk.OakCamera>`, you can easily create color and depth streams using the :meth:`create_camera() <depthai_sdk.OakCamera.create_camera>` and :meth:`create_stereo() <depthai_sdk.OakCamera.create_stereo>` methods respectively, and add pre-trained neural networks using the :meth:`create_nn() <depthai_sdk.OakCamera.create_nn>` method.
Additionally, you can add custom callbacks to the pipeline using the :meth:`callback() <depthai_sdk.OakCamera.callback>` method and record the outputs using the :meth:`record() <depthai_sdk.OakCamera.record>` method.

Blocking behavior
^^^^^^^^^^^^^^^^^

When starting the :class:`OakCamera <depthai_sdk.OakCamera>` object, you can specify whether the :meth:`start() <depthai_sdk.OakCamera.start>` method should block the main thread or not. By default, the :meth:`start() <depthai_sdk.OakCamera.start>` method does not block the main thread, which means you will need to manually poll the camera using the :meth:`oak.poll() <depthai_sdk.OakCamera.poll>` method.

.. code-block:: python
from depthai_sdk import OakCamera
with OakCamera() as oak:
color = oak.create_camera('color', resolution='1080p')
oak.visualize([color])
oak.start(blocking=False)
while oak.running():
oak.poll()
# this code is executed while the pipeline is running
Alternatively, setting the ``blocking`` argument to ``True`` will loop and continuously poll the camera, blocking the rest of the code.


.. code-block:: python
from depthai_sdk import OakCamera
with OakCamera() as oak:
color = oak.create_camera('color', resolution='1080p')
oak.visualize([color])
oak.start(blocking=True)
# this code doesn't execute until the pipeline is stopped
Creating color and depth streams
---------------------

Expand Down
37 changes: 37 additions & 0 deletions depthai_sdk/docs/source/samples/CameraComponent/sdk_cam_ffc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FFC Camera Visualization
========================

This example shows how to use the `Camera` component to display the camera feed from the FFC camera.

For FFC, the camera board socket must be specified. In our case the cameras are connected to socket A, B and C. After setting the resolution to 1200p
and downscaling using ISP to 800p, the camera feed is displayed in a window.

.. include:: /includes/blocking_behavior.rst


Setup
#####

.. include:: /includes/install_from_pypi.rst

Pipeline
########

.. image:: /_static/images/pipelines/cam_ffc.png
:alt: Pipeline graph


Source Code
###########

.. tabs::

.. tab:: Python

Also `available on GitHub <https://github.com/luxonis/depthai/depthai_sdk/examples/CameraComponent/cam_ffc.py>`__

.. literalinclude:: ../../../../examples/CameraComponent/cam_ffc.py
:language: python
:linenos:

.. include:: /includes/footer-short.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Camera Control
==============

This example shows how to use DepthAI SDK to control the color camera parameters.

.. code-block::
Control: key[dec/inc] min..max
exposure time: I O 1..33000 [us]
sensitivity iso: K L 100..1600
To go back to auto controls:
'E' - autoexposure
Demo
####

.. image:: /_static/images/demos/sdk_camera_control.gif
:alt: Camera Control Demo


Setup
#####

.. include:: /includes/install_from_pypi.rst

Pipeline
########

.. image:: /_static/images/pipelines/camera_control.png
:alt: Pipeline graph



Source Code
###########

.. tabs::

.. tab:: Python

Also `available on GitHub <https://github.com/luxonis/depthai/depthai_sdk/examples/CameraComponent/camera_control.py>`__

.. literalinclude:: ../../../../examples/CameraComponent/camera_control.py
:language: python
:linenos:

.. include:: /includes/footer-short.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Camera Control with NN
=====================

This example shows how to set up control of color camera (focus and exposure) to be controlled by NN. The NN is a face detection model which passes detected face
bounding box to camera component run auto focus and auto exposure algorithms on.

.. include:: /includes/blocking_behavior.rst

Demo
####

.. image:: /_static/images/demos/sdk_camera_control_with_NN.png
:alt: Control with NN Demo


Setup
#####

.. include:: /includes/install_from_pypi.rst

Pipeline
########

.. image:: /_static/images/pipelines/camera_control_with_NN.png
:alt: Pipeline graph


Source Code
###########

.. tabs::

.. tab:: Python

Also `available on GitHub <https://github.com/luxonis/depthai/depthai_sdk/examples/CameraComponent/camera_control_with_NN.py>`__

.. literalinclude:: ../../../../examples/CameraComponent/camera_control_with_NN.py
:language: python
:linenos:

.. include:: /includes/footer-short.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Camera Preview
==============

This example shows how to set up a pipeline that outputs a a preview for color camera, both mono cameras and their stereo depth. Each frame is displayed using OpenCV in blocking behavour.

.. include:: /includes/blocking_behavior.rst



Demo
####

.. image:: /_static/images/demos/sdk_camera_preview.png
:alt: Camera Preview Demo


Setup
#####

.. include:: /includes/install_from_pypi.rst

Pipeline
########

.. image:: /_static/images/pipelines/camera_preview.png
:alt: Pipeline graph



Source Code
###########

.. tabs::

.. tab:: Python

Also `available on GitHub <https://github.com/luxonis/depthai/depthai_sdk/examples/CameraComponent/camera_preview.py>`__

.. literalinclude:: ../../../../examples/CameraComponent/camera_preview.py
:language: python
:linenos:

.. include:: /includes/footer-short.rst
40 changes: 40 additions & 0 deletions depthai_sdk/docs/source/samples/CameraComponent/sdk_mono_400p.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Mono Camera Preview
===================

This example shows how to set up a pipeline that outputs a video feed for both mono cameras and sets the resolution to 400p (640x400) and the frame rate to 60 fps.

.. include:: /includes/blocking_behavior.rst

Demo
####

.. image:: /_static/images/demos/sdk_mono_400p.png
:alt: Mono Demo


Setup
#####

.. include:: /includes/install_from_pypi.rst

Pipeline
########

.. image:: /_static/images/pipelines/mono_400p.png
:alt: Pipeline graph


Source Code
###########

.. tabs::

.. tab:: Python

Also `available on GitHub <https://github.com/luxonis/depthai/depthai_sdk/examples/CameraComponent/mono_400p.py>`__

.. literalinclude:: ../../../../examples/CameraComponent/mono_400p.py
:language: python
:linenos:

.. include:: /includes/footer-short.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Preview All Cameras
===================

This example shows how to set up a pipeline that outputs a a preview for each camera currently connected (and available) to the device. The preview is displayed in a window on the host machine.
If run on OAK-D devices, this example does the same thing as the ``sdk_camera_preview`` example.

.. include:: /includes/blocking_behavior.rst

Demo
####

.. image:: /_static/images/demos/sdk_preview_all_cameras.png
:alt: Camera Preview Demo


Setup
#####

.. include:: /includes/install_from_pypi.rst

Pipeline
########

.. image:: /_static/images/pipelines/preview_all_cameras.png
:alt: Pipeline graph


Source Code
###########

.. tabs::

.. tab:: Python

Also `available on GitHub <https://github.com/luxonis/depthai/depthai_sdk/examples/CameraComponent/preview_all_cameras.py>`__

.. literalinclude:: ../../../../examples/CameraComponent/preview_all_cameras.py
:language: python
:linenos:

.. include:: /includes/footer-short.rst
Loading

0 comments on commit 9db2903

Please sign in to comment.