# DepthAI V3

DepthAI v3 API docs for OAK and OAK4 cameras: install, examples, and Python/C++ reference.

This is the documentation for DepthAI v3, which supports both OAK and OAK4 cameras. If you want to use DepthAI v2 (which supports
only RVC2 devices), please switch to [Depthai V2 documentation](https://docs.luxonis.com/software.md).

### Depthai V2 vs V3

See key differences between V2 and V3 API.

[V2 vs V3](https://docs.luxonis.com/software-v3/depthai/tutorials/v2-vs-v3.md)

### API Reference

 * [C++](https://docs.luxonis.com/software-v3/depthai/api/cpp.md)
 * [Python](https://docs.luxonis.com/software-v3/depthai/api/python.md)
 * [API Examples](https://docs.luxonis.com/software-v3/depthai/examples.md)

### Examples

For practical, real-world DepthAI usage, explore the [v3 OAK Examples](https://github.com/luxonis/oak-examples/tree/main/)
repository. These examples show complete pipelines and application patterns you can reuse for your own projects.

[Explore DepthAI examples](https://github.com/luxonis/oak-examples/tree/main/)

### Installation

#### Linux / MacOS

### 1. Install DepthAI v3

```bash
git clone https://github.com/luxonis/depthai-core.git && cd depthai-core
python3 -m venv venv
source venv/bin/activate
# Installs library and requirements
python3 examples/python/install_requirements.py
```

or via pip:

```bash
pip install depthai --force-reinstall
```

### 2. Run an example

After installing the library, you can run an example, eg. [Detection Network
example](https://docs.luxonis.com/software-v3/depthai/examples/detection_network/detection_network.md) or [Display all
cameras](https://docs.luxonis.com/software-v3/depthai/examples/camera/camera_all.md):

```bash
cd examples/python
# Run YoloV6 detection example
python3 DetectionNetwork/detection_network.py
# Display all camera streams
python3 Camera/camera_all.py
```

#### Windows

### 1. Install DepthAI v3

```bash
git clone https://github.com/luxonis/depthai-core.git
cd depthai-core
# Create and source venv
python -m venv venv
.\venv\Scripts\Activate.ps1 # OR .\venv\Scripts\Activate.bat if you are using CMD
# Install requirements
python examples\python\install_requirements.py
```

or via pip:

```bash
pip install depthai --force-reinstall
```

### 2. Run an example

After installing the library, you can run an example, eg. [Detection Network
example](https://docs.luxonis.com/software-v3/depthai/examples/detection_network/detection_network.md) or [Display all
cameras](https://docs.luxonis.com/software-v3/depthai/examples/camera/camera_all.md):

```bash
cd examples\python
# Run YoloV6 detection example
python DetectionNetwork\detection_network.py
# Display all camera streams
python Camera\camera_all.py
```

### Components

### DepthAI Components

 * [Nodes](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes.md) represent a sensor, accelerated hardware, or
   some compute function
 * [Pipeline](https://docs.luxonis.com/software-v3/depthai/depthai-components/pipeline.md) consists of linked nodes and gets
   deployed to the device where it runs on accelerated hardware blocks
 * [Messages](https://docs.luxonis.com/software-v3/depthai/depthai-components/messages.md) are used for communication between
   nodes. They hold data and metadata
 * [Device](https://docs.luxonis.com/software-v3/depthai/depthai-components/device.md) represents Luxonis' device - OAK or OAK4
   camera. It handles connectivity and communication
 * [Bootloader](https://docs.luxonis.com/software-v3/depthai/depthai-components/bootloader.md) handles logic when booting
   [RVC2](https://docs.luxonis.com/hardware/platform/rvc/rvc2.md) devices and makes them accessible for connection
 * [Luxonis OS](https://docs.luxonis.com/software-v3/sw-stack/luxonis-os.md) is a custom Linux distro for
   [RVC4](https://docs.luxonis.com/hardware/platform/rvc/rvc4.md) devices (OAK4)

### Deploying AI models

#### Pretrained models

[HubAI model zoo](https://models.luxonis.com/) has many pre-trained models that can be deployed to the OAK4 device directly.
Besides examples, we also have some NN examples/apps at
[oak-examples](https://github.com/luxonis/oak-examples/tree/main/neural-networks).

#### Custom models

You can convert your custom model either:

 * (Recommended) [Online via HubAI](https://docs.luxonis.com/cloud/hubai/model-registry/detailed-conversion.md)
 * [Offline via
   ModelConverter](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter.md)
   (nn_archive.tar.xz) - HubAI uses this tool, but it's more user-friendly
 * Using [SNPE tool directly](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/snpe.md) (.dlc)
   - ModelConverter uses SNPE under the hood for RVC4 platform

If you're using .dlc, you can deploy it to OAK4 by editing [NeuralNetwork
example](https://docs.luxonis.com/software-v3/depthai/examples/neural_network/neural_network.md) with the following snippet:

```python
nn = pipeline.create(dai.node.NeuralNetwork)
nn.setModelPath('my_model.dlc')
nn.setBackend("snpe") # Specify SNPE NN backend. This usually gets set under the hood
# Specify SNPE (RVC4) specific settings, like DSP runtime and NN performance profile
nn.setBackendProperties({"runtime": "dsp", "performance_profile": "default"})
```

Or, if you're using archive.tar.xz, you can edit that example with this snippet:

```python
cam = pipeline.create(dai.node.Camera).build(socket)
# If your nn model requires 640x640 input size (BGR):
cam_out = cam.requestOutput((640, 640), dai.ImgFrame.Type.BGR888p)

nn_archive = dai.NNArchive('./my_nn_archive.tar.xz')
nn = pipeline.create(dai.node.NeuralNetwork).build(cam_out, nn_archive)
```
