Luxonis
LuxonisApplications
Software
Support
About UsBlog
Store
Applications
DocumentationGuides, specifications and datasheets
GitHubSource code of our libraries
RobotHubDiscover our cloud platform
About UsBlogStore
Nov 18, 2022

DepthAI SDK Library Release

Create powerful applications with minimal code
DepthAI
Applications/Experiments
Development

The DepthAI SDK Library is now available, and makes it significantly faster and easier to develop applications for OAK cameras. In many cases, complex tasks that would otherwise take hundreds of lines of code can be done in a fraction of the time and space.

Take a look at the following person detection application, which was created from only 8 lines of code.

And here's the code!

And for those who are curious, here’s how we made it happen from start to finish.

First, make sure to clone the DepthAI repository, which you can do using the following:

git clone https://github.com/luxonis/depthai.git

Next, install DepthAI and DepthAI SDK:

cd depthai
  • Windows
py -3 install_requirements.py
  • Linux/MacOS
python install_requirements.py

Now we can use DepthAI SDK to reproduce the result shown above. The steps are as follows:

  1. First, we need to create an OakCamera object. If we want to use video as an input to the detector, we should pass an optional replay argument. In this example we use the people-tracking-above-04 video that will be automatically downloaded from Luxonis’ servers.
from depthai_sdk import OakCamera, BboxStylewith OakCamera(replay='people-tracking-above-04') as oak: ...
  1. Next, we need to define the input frames for our detector.
camera = oak.create_camera('color', encode='h264')
  1. Next, it's time to create our detector - neural network. In this example we use the person-detection-retail-0013 detector, which belongs to SDK supported models. Additionally, we set the confidence threshold to 0.1.
nn = oak.create_nn('person-detection-retail-0013', camera) nn.config_nn(confThreshold=0.1)
  1. Once we have a detector, we need to visualize the output. DepthAI SDK supports automatic visualization of the detections.
visualizer = oak.visualize(nn) visualizer.detections(bbox_style=BboxStyle.CORNERS, color=(232, 36, 87), hide_label=True)
  1. The last remaining item is starting the script:
oak.start(blocking=True)

Finally, we can assemble all the parts and get the final script:

from depthai_sdk import OakCamera, BboxStyle with OakCamera(replay='people-tracking-above-04') as oak: camera = oak.create_camera('color', fps=30, encode='h264') nn = oak.create_nn('person-detection-retail-0013', camera) nn.config_nn(confThreshold=0.1) visualizer = oak.visualize(nn) visualizer.detections(bbox_style=BboxStyle.CORNERS, color=(232, 36, 87), hide_label=True) oak.start(blocking=True)

There you have it!

To learn more about how DepthAI SDK works and to start using it yourself, visit our documentation page.

And if you have any questions or need support we’re always there for you on Discord.


Erik Kokalj
Erik KokaljDirector of Applications Engineering