Skip to content

Commit

Permalink
Merge pull request #1110 from luxonis/develop
Browse files Browse the repository at this point in the history
DepthAI SDK v1.13.0
  • Loading branch information
daniilpastukhov authored Sep 4, 2023
2 parents f319764 + 69b6f97 commit 67365b7
Show file tree
Hide file tree
Showing 111 changed files with 3,494 additions and 3,347 deletions.
2 changes: 1 addition & 1 deletion depthai_sdk/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Luxonis'

# The full version, including alpha/beta/rc tags
release = '1.12.1'
release = '1.13.0'


# -- General configuration ---------------------------------------------------
Expand Down
32 changes: 22 additions & 10 deletions depthai_sdk/docs/source/features/ai_models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,53 @@ The following table lists all the models supported by the SDK. The model name is
* - ``face-detection-retail-0004``
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_face_detection_retail_0004.html>`__
- 33
* - ``facemesh_192x192``
- `DMZ <https://github.com/luxonis/depthai-model-zoo/tree/main/models/facemesh_192x192>`__
- 32
* - ``facial_landmarks_68_160x160``
- 32
- `DMZ <https://github.com/luxonis/depthai-model-zoo/blob/main/models/facial_landmarks_68_160x160>`__
* - ``human-pose-estimation-0001``
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_human_pose_estimation_0001.html>`__
- 8
* - ``mobilenet-ssd``
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_mobilenet_ssd.html>`__
- 31
* - ``mobilenetv2_imagenet_embedder_224x224``
- `DMZ <https://github.com/luxonis/depthai-model-zoo/tree/main/models/mobilenetv2_imagenet_embedder_224x224>`__
- /
* - ``pedestrian-detection-adas-0002``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_pedestrian_detection_adas_0002.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_pedestrian_detection_adas_0002.html>`__
- 19
* - ``person-detection-0200``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_person_detection_0200.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_person_detection_0200.html>`__
- 14
* - ``person-detection-retail-0013``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_person_detection_retail_0013.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_person_detection_retail_0013.html>`__
- 15
* - ``person-reidentification-retail-0288``
- `OMZ <https://docs.openvino.ai/cn/latest/omz_models_model_person_reidentification_retail_0288.html>`__
- `OMZ <https://docs.openvino.ai/cn/2021.4/omz_models_model_person_reidentification_retail_0288.html>`__
- 33
* - ``person-vehicle-bike-detection-crossroad-1016``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_person_vehicle_bike_detection_crossroad_1016.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_person_vehicle_bike_detection_crossroad_1016.html>`__
- 12
* - ``sbd_mask_classification_224x224``
- `DMZ <https://github.com/luxonis/depthai-model-zoo/tree/main/models/sbd_mask_classification_224x224>`__
- 64+
* - ``vehicle-detection-0202``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_vehicle_detection_0202.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_vehicle_detection_0202.html>`__
- 14
* - ``vehicle-detection-adas-0002``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_vehicle_detection_adas_0002.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_vehicle_detection_adas_0002.html>`__
- 14
* - ``vehicle-license-plate-detection-barrier-0106``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_vehicle_license_plate_detection_barrier_0106.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_vehicle_license_plate_detection_barrier_0106.html>`__
- 29
* - ``yolo-v3-tf``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_yolo_v3_tf.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_yolo_v3_tf.html>`__
- 3.5
* - ``yolo-v3-tiny-tf``
- `OMZ <https://docs.openvino.ai/latest/omz_models_model_yolo_v3_tiny_tf.html>`__
- `OMZ <https://docs.openvino.ai/2022.1/omz_models_model_yolo_v3_tiny_tf.html>`__
- 33
* - ``yolov4_coco_608x608``
- `DMZ <https://github.com/luxonis/depthai-model-zoo/tree/main/models/yolov4_coco_608x608>`__
Expand Down
4 changes: 0 additions & 4 deletions depthai_sdk/docs/source/fundamentals/visualizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,6 @@ Visualizer
:members:
:undoc-members:

.. autoclass:: depthai_sdk.visualize.visualizer.Platform
:members:
:undoc-members:

Objects
-------

Expand Down
4 changes: 2 additions & 2 deletions depthai_sdk/docs/source/oak-camera.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Interoperability with DepthAI API
---------------------------------

DepthAI SDK was developed with `DepthAI API <https://docs.luxonis.com/projects/api/en/latest/>`__ interoperability in mind.
Users can access all depthai API nodes inside components, and after ``oak.build()`` also the `dai.Pipeline <https://docs.luxonis.com/projects/api/en/latest/components/pipeline/>`__
and `dai.Device <https://docs.luxonis.com/projects/api/en/latest/components/device/>`__ objects.
Users can access all depthai API nodes inside components, along with the `dai.Pipeline <https://docs.luxonis.com/projects/api/en/latest/components/pipeline/>`__ (``oak.pipeline``)
and `dai.Device <https://docs.luxonis.com/projects/api/en/latest/components/device/>`__ (``oak.device``) objects.

.. literalinclude:: ../../examples/mixed/api_interop.py
:language: python
Expand Down
3 changes: 1 addition & 2 deletions depthai_sdk/docs/source/tutorials/code_samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ are presented with code.
.. rubric:: NN
- :ref:`Age-Gender Inference` - Demonstrates age-gender inference
- :ref:`Custom Decode Function` - Demonstrates custom decoding function
- :ref:`Deeplabv3 Person Segmentation` - Demonstrates Deeplabv3 person segmentation
- :ref:`Emotion Recognition` - Demonstrates emotion recognition
- :ref:`Emotion Recognition` - Demonstrates emotion recognition
- :ref:`Face Detection RGB` - Run face detection on RGB camera
- :ref:`Face Detection Mono` - Run face detection on mono camera
- :ref:`Human Pose Estimation` - Run human pose estimation inference
Expand Down
1 change: 0 additions & 1 deletion depthai_sdk/docs/source/visualizer_formats/example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"platform": "pc",
"frame_shape": [720, 1280],
"config": {
"output": {
Expand Down
7 changes: 0 additions & 7 deletions depthai_sdk/docs/source/visualizer_formats/format.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
{
"platform": {
"type": "string",
"enum": [
"pc",
"robothub"
]
},
"frame_shape": {
"type": "array",
"items": {
Expand Down
9 changes: 9 additions & 0 deletions depthai_sdk/examples/CameraComponent/camera_encode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from depthai_sdk import OakCamera

with OakCamera() as oak:
color = oak.create_camera('color', encode='h265')

oak.visualize(color.out.encoded, fps=True, scale=2/3)
# By default, it will stream non-encoded frames
oak.visualize(color, fps=True, scale=2/3)
oak.start(blocking=True)
4 changes: 2 additions & 2 deletions depthai_sdk/examples/CameraComponent/preview_all_cameras.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from depthai_sdk import OakCamera

with OakCamera() as oak:
cams = oak.create_all_cameras()
oak.visualize(cams)
cams = oak.create_all_cameras(resolution='max')
oak.visualize(cams, fps=True)
oak.start(blocking=True)
6 changes: 2 additions & 4 deletions depthai_sdk/examples/CameraComponent/rotated.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from depthai_sdk import OakCamera

with OakCamera(rotation=90) as oak:
color = oak.create_camera('color', resolution='1080p')
left = oak.create_camera('left', resolution='400p')
right = oak.create_camera('right', resolution='400p')
oak.visualize([color, left, right], fps=True)
all_cams = oak.create_all_cameras()
oak.visualize(all_cams, fps=True)
oak.start(blocking=True)
4 changes: 3 additions & 1 deletion depthai_sdk/examples/IMUComponent/imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
with OakCamera() as oak:
imu = oak.create_imu()
imu.config_imu(report_rate=400, batch_report_threshold=5)
oak.visualize(imu.out.main)
# DepthAI viewer should open, and IMU data can be viewed on the right-side panel,
# under "Stats" tab (right of the "Device Settings" tab).
oak.visualize(imu.out.main, visualizer='viewer')
oak.start(blocking=True)
30 changes: 0 additions & 30 deletions depthai_sdk/examples/IMUComponent/imu_rerun.py

This file was deleted.

2 changes: 1 addition & 1 deletion depthai_sdk/examples/NNComponent/age-gender.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def callback(packet: TwoStagePacket):
gender_str = "Woman" if gender[0] > gender[1] else "Man"

visualizer.add_text(f'{gender_str}\nAge: {age}',
bbox=(*det.top_left, *det.bottom_right),
bbox=packet.bbox.get_relative_bbox(det.bbox),
position=TextPosition.BOTTOM_RIGHT)

frame = visualizer.draw(packet.frame)
Expand Down
32 changes: 14 additions & 18 deletions depthai_sdk/examples/NNComponent/custom_decode.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import blobconverter
import cv2
import numpy as np
from depthai import NNData

import depthai as dai
from depthai_sdk import OakCamera
from depthai_sdk.classes import Detections, DetectionPacket
from depthai_sdk.classes import Detections


def decode(nn_data: NNData) -> Detections:
def decode(nn_data: dai.NNData) -> Detections:
"""
Custom decode function for the NN component. Decode function has to accept NNData argument.
The return type should preferably be a class that inherits from depthai_sdk.classes.GenericNNOutput,
Expand All @@ -18,29 +16,27 @@ def decode(nn_data: NNData) -> Detections:
layer = nn_data.getFirstLayerFp16()
results = np.array(layer).reshape((1, 1, -1, 7))
dets = Detections(nn_data)

for result in results[0][0]:
if result[2] > 0.5:
if result[2] > 0.3:
label = int(result[1])
conf = result[2]
bbox = result[3:]
dets.add(label, conf, bbox)
det = dai.ImgDetection()
det.confidence = conf
det.label = label
det.xmin = bbox[0]
det.ymin = bbox[1]
det.xmax = bbox[2]
det.ymax = bbox[3]
dets.detections.append(det)

return dets


def callback(packet: DetectionPacket):
visualizer = packet.visualizer
frame = packet.frame
frame = visualizer.draw(frame)
cv2.imshow('Custom decode function', frame)


with OakCamera() as oak:
color = oak.create_camera('color')

nn_path = blobconverter.from_zoo(name='person-detection-0200', version='2021.4')
nn_path = blobconverter.from_zoo(name='person-detection-0200', version='2021.4', shaves=6)
nn = oak.create_nn(nn_path, color, decode_fn=decode)

oak.visualize(nn, callback=callback)
oak.visualize(nn)
oak.start(blocking=True)
11 changes: 0 additions & 11 deletions depthai_sdk/examples/NNComponent/deeplabv3_person.py

This file was deleted.

2 changes: 1 addition & 1 deletion depthai_sdk/examples/NNComponent/emotion-recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def callback(packet: TwoStagePacket):
emotion_name = emotions[np.argmax(emotion_results)]

visualizer.add_text(emotion_name,
bbox=(*det.top_left, *det.bottom_right),
bbox=packet.bbox.get_relative_bbox(det.bbox),
position=TextPosition.BOTTOM_RIGHT)

visualizer.draw(packet.frame)
Expand Down
3 changes: 2 additions & 1 deletion depthai_sdk/examples/NNComponent/nn_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
color = oak.create_camera('color')
# List of models that are supported out-of-the-box by the SDK:
# https://docs.luxonis.com/projects/sdk/en/latest/features/ai_models/#sdk-supported-models
nn = oak.create_nn('yolov7tiny_coco_640x352', color)
nn = oak.create_nn('yolov5n_coco_416x416', color)
nn.config_nn(resize_mode='stretch')
oak.visualize([nn.out.main], fps=True)
oak.visualize(nn.out.passthrough)
oak.start(blocking=True)
4 changes: 2 additions & 2 deletions depthai_sdk/examples/NNComponent/spatial_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
calc_algo=dai.SpatialLocationCalculatorAlgorithm.AVERAGE
)

oak.visualize([nn.out.main], fps=True)
oak.visualize(nn.out.passthrough)
oak.visualize(nn.out.main, fps=True)
oak.visualize([nn.out.passthrough, nn.out.spatials])
oak.start(blocking=True)
24 changes: 5 additions & 19 deletions depthai_sdk/examples/PointcloudComponent/pointcloud.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
import cv2
from depthai_sdk import OakCamera
from depthai_sdk.classes.packets import PointcloudPacket, FramePacket
import rerun as rr
import subprocess
import time

subprocess.Popen(["rerun", "--memory-limit", "200MB"])
time.sleep(1) # Wait til rerun spins up
rr.init("Rerun ", spawn=False)
rr.connect()

def callback(packet: PointcloudPacket):
colors = packet.color_frame.getCvFrame()[..., ::-1] # BGR to RGB
rr.log_image('Color Image', colors)
points = packet.points.reshape(-1, 3)
rr.log_points("Pointcloud", points, colors=colors.reshape(-1, 3))


with OakCamera() as oak:
pcl = oak.create_pointcloud()
oak.callback(pcl, callback=callback)
color = oak.camera('color')
stereo = oak.create_stereo()
stereo.config_stereo(align=color)
pcl = oak.create_pointcloud(stereo=stereo, colorize=color)
oak.visualize(pcl, visualizer='depthai-viewer')
oak.start(blocking=True)
7 changes: 2 additions & 5 deletions depthai_sdk/examples/mixed/api_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
nn = oak.create_nn('mobilenet-ssd', color)
oak.visualize([nn.out.passthrough, nn], fps=True)

# Build the pipeline, connect to the oak, update components. Place interop logic AFTER oak.build()
pipeline = oak.build()

nn.node.setNumInferenceThreads(2) # Configure components' nodes

features = pipeline.create(dai.node.FeatureTracker) # Create new pipeline nodes
features = oak.pipeline.create(dai.node.FeatureTracker) # Create new pipeline nodes
color.node.video.link(features.inputImage)

out = pipeline.create(dai.node.XLinkOut)
out = oak.pipeline.create(dai.node.XLinkOut)
out.setStreamName('features')
features.outputFeatures.link(out.input)

Expand Down
6 changes: 2 additions & 4 deletions depthai_sdk/examples/mixed/collision_avoidance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from depthai_sdk import OakCamera
from depthai_sdk.visualize.configs import StereoColor
from depthai_sdk.classes.packets import DepthPacket
from depthai_sdk.classes.packets import DisparityDepthPacket
import math
import depthai as dai
import cv2
Expand All @@ -11,7 +11,7 @@

slc_data = []

def cb(packet: DepthPacket):
def cb(packet: DisparityDepthPacket):
global slc_data
fontType = cv2.FONT_HERSHEY_TRIPLEX

Expand Down Expand Up @@ -56,8 +56,6 @@ def cb(packet: DepthPacket):

oak.visualize([stereo], fps=True, callback=cb)

oak.build()

slc = oak.pipeline.create(dai.node.SpatialLocationCalculator)
for x in range(15):
for y in range(9):
Expand Down
Loading

0 comments on commit 67365b7

Please sign in to comment.