Software Stack
DepthAI

Cookie-cutter template app

Quickest way to get started with Luxonis ecosystem is to use the template app. This app is a starting point for your own applications and includes all the necessary components to get you up and running. Apps range from very simple pipelines (e.g. camera stream) to complex and wide-encompassing (e.g using custom AI models and nodes).
1

Install

Get up and running in under 5 minutes:
Command Line
1# Install core packages
2pip install --pre depthai --force-reinstall
3# Clone the template app
4git clone https://github.com/luxonis/oak-template.git
5# Change directory to the template app
6cd oak-template
This will download the template / cookie-cutter app to your current directory.
Text
1template-app/
2├── main.py
3├── oakapp.toml
4├── requirements.txt
5├── media/ # Optional media files
6└── utils/ # Optional helper functions
2

main.py

This is where your main logic resides. The downloaded script will use "Camera + NN + Hub" as a default pipeline. Feel free to swap it with any of the other examples below if you don't need the NN or Hub functionality.
Camera + NN + HUB (default)
Camera stream
Depth
Python
1import os
2from pathlib import Path
3
4import depthai as dai
5from utils.snaps_producer import SnapsProducer
6from depthai_nodes.node.parsing_neural_network import ParsingNeuralNetwork
7
8
9model = "luxonis/yolov6-nano:r2-coco-512x288"
10
11visualizer = dai.RemoteConnection(httpPort=8082)
12device = dai.Device()
13
14api_key = "<your_api_key>"
15
16
17with dai.Pipeline(device) as pipeline:
18    print("Creating pipeline...")
19
20    model_description = dai.NNModelDescription(model)
21    platform = device.getPlatformAsString()
22    model_description.platform = platform
23    nn_archive = dai.NNArchive(
24        dai.getModelFromZoo(
25            model_description,
26            apiKey=api_key,
27        )
28    )
29
30    input_node = pipeline.create(dai.node.Camera).build()
31
32    nn_with_parser = pipeline.create(ParsingNeuralNetwork).build(
33        input_node, nn_archive
34    )
35
36    visualizer.addTopic("Video", nn_with_parser.passthrough, "images")
37    visualizer.addTopic("Visualizations", nn_with_parser.out, "images")
38
39    snaps_producer = pipeline.create(SnapsProducer).build(
40        nn_with_parser.passthrough,
41        nn_with_parser.out,
42        label_map=nn_archive.getConfigV1().model.heads[0].metadata.classes,
43    )
44
45    print("Pipeline created.")
46
47    pipeline.start()
48    visualizer.registerPipeline(pipeline)
49
50    while pipeline.isRunning():
51        key = visualizer.waitKey(1)
52        if key == ord("q"):
53            print("Got q key from the remote connection!")
54            break

DepthAI Examples

If you wish to use a different pipeline, you can find a list of available nodes and their examples

3

oakapp.toml

This is where you define the build process for your container. For the purposes of this example, it can remain unchanged. You can find more information here.
Toml
1identifier = "custom.oakapp"
2app_version = "1.0.0"
3
4prepare_container = [
5    { type = "RUN", command = "apt-get update" },
6    { type = "RUN", command = "apt-get install -y python3 python3-pip wget git" },
7]
8
9prepare_build_container = []
10
11build_steps = ["pip3 install -r /app/requirements.txt --break-system-packages"]
12
13entrypoint = ["bash", "-c", "python3 /app/main.py"]
4

Deploy

Now that you have your main.py and oakapp.toml, you can deploy your application to the OAK device. You have two options:
  • Standalone: This is the simplest option. Just run the following command in the same directory as your main.py and oakapp.toml files:
Command Line
1oakctl app run .
This will containerize your application and deploy it to the OAK device. Results can be viewed with the visualizer webapp at http://<device-ip>:8082.
  • Peripheral: This option is for when you want to run your application from your host machine. No containerization is needed in this mode, but you need a steady connection to the device. To run your application in peripheral mode, run the following command:
Command Line
1python3 main.py
Results can be viewed with the visualizer webapp at http://<host-ip>:8082.