Registry / ai-ml / depthai

depthai

JSON →
library3.7.1pypypi✓ verified 90d ago

The `depthai` Python library provides an API to interact with Luxonis OAK (OpenCV AI Kit) devices, enabling users to build sophisticated computer vision and AI applications with on-device processing. It supports various nodes for camera input, neural inference, depth estimation, and data output. The current version is 3.5.0, with a rapid release cadence introducing new features and improvements, often alongside firmware updates.

pip install depthai
INSTALL
IMPORT
SIG · DEPTHAI
D
depthai
ai-mlpythonv3.7.1
Install
5.5s avg
Import
371ms
Disk
295MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.940 runs
build_error
glibc
py 3.10–3.940 runs
installs and imports cleanly · install 5.5s · import 0.371s · 293MB
295MB installed
● package 295MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dai
✓ import depthai as dai
✗ import depthai
The standard convention is to import `depthai` as `dai` for brevity and consistency with examples.
Pipeline
✓ pipeline = dai.Pipeline()
Device
✓ with dai.Device(pipeline) as device:
ColorCamera
✓ camRgb = pipeline.create(dai.node.ColorCamera)
XLinkOut
✓ xoutRgb = pipeline.create(dai.node.XLinkOut)

This quickstart code initializes a DepthAI pipeline to capture a 1080p color stream from the OAK-D's RGB camera, resizes it to 300x300 for preview, and displays it using OpenCV. Ensure `opencv-python` is installed (`pip install opencv-python`).

import depthai as dai import cv2 # Create pipeline pipeline = dai.Pipeline() # Define source and output nodes camRgb = pipeline.create(dai.node.ColorCamera) xoutRgb = pipeline.create(dai.node.XLinkOut) xoutRgb.setStreamName("rgb") # Properties for ColorCamera camRgb.setPreviewSize(300, 300) # Output resolution for preview stream camRgb.setBoardSocket(dai.CameraBoardSocket.RGB) camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P) camRgb.setInterleaved(False) # Non-interleaved (separate R, G, B planes) # Link nodes: camera preview output to XLinkOut input camRgb.preview.link(xoutRgb.input) # Connect to device and start pipeline with dai.Device(pipeline) as device: print(f"Connected to OAK-D with MxId: {device.get=}") # Get output queue for the RGB stream qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False) while True: inRgb = qRgb.tryGet() if inRgb is not None: # Get a NumPy array from the image frame and display it frame = inRgb.getCvFrame() cv2.imshow("rgb", frame) # Wait for 'q' key to exit if cv2.waitKey(1) == ord('q'): break
Debug
Known issues
breakingMajor API changes occurred between v2.x and v3.x, impacting pipeline creation, node configuration, and data access. Code written for v2.x is generally not compatible with v3.x.
fix
Refer to the official DepthAI v2 to v3 migration guide on Luxonis documentation. Key changes include using `pipeline.create(dai.node.NodeName)` for node instantiation and updated setters for node properties (e.g., `setResolution` instead of `setPreviewSize`).
affects: >=3.0.0
gotchaDevice firmware must be compatible with the installed `depthai` library version. Mismatched firmware can lead to connection issues, unexpected behavior, or errors.
fix
Ensure your OAK device firmware is updated to a compatible version using `python3 -m depthai.auto_update`. Check the release notes for your `depthai` version for recommended firmware.
affects: All
gotchaOAK devices have limited processing capabilities and USB bandwidth. Running multiple high-resolution/high-framerate streams or complex neural networks can hit performance limits.
fix
Optimize pipeline design by using lower resolutions/framerate where possible, offloading processing to the host, or leveraging the device's hardware accelerators efficiently. Monitor CPU/memory usage on the device if available.
affects: All
gotchaThe `AutoCalibration` feature (introduced in v3.5.0) can be implicitly enabled via the `DEPTHAI_AUTOCALIBRATION` environment variable (`ON_START` or `CONTINUOUS`), potentially altering device behavior without explicit code.
fix
Be aware of this environment variable. If unexpected calibration behavior occurs, check if `DEPTHAI_AUTOCALIBRATION` is set in your environment. For explicit control, use the `dai.node.AutoCalibration` node in your pipeline.
affects: >=3.5.0
Errors
Common errors & fixes
RuntimeError: No device found
The OAK device is not connected, not powered, or there are USB/permissions issues.
fix
Ensure the OAK device is properly connected to a USB 3.0 port and powered. Check USB cable integrity. On Linux, ensure correct udev rules are installed (e.g., `curl -fL https://docs.luxonis.com/install_dependencies.sh | bash`).
AttributeError: 'ColorCamera' object has no attribute 'setPreviewSize'
This error often indicates using v2.x API calls with a v3.x library, or vice-versa, or an incorrect method name.
fix
If upgrading from v2 to v3, consult the migration guide. For v3.x, instead of `setPreviewSize` for output, use `camRgb.setVideoSize(width, height)` for video stream or `camRgb.setStillSize(width, height)` for still images, or link `camRgb.preview` to an `ImageManip` node for custom scaling.
ValueError: Camera resolution not supported by device
The selected camera resolution or framerate is not supported by the specific OAK device model or its sensor.
fix
Refer to your OAK device's specifications for supported resolutions and framerates for each camera sensor. Adjust `camRgb.setResolution()` or `camMono.setResolution()` accordingly. Sometimes, lower framerates might enable higher resolutions.
dai.XLinkError: X_LINK_ERROR
A general XLink communication error, often due to exceeding USB bandwidth, firmware issues, or a malformed pipeline causing a crash on the device.
fix
Reduce bandwidth (lower resolution, framerate, or fewer streams). Update device firmware (`python3 -m depthai.auto_update`). Simplify the pipeline to isolate the problematic node or connection. Check logs for more specific errors if available.
Upgrade
Version history
3.7.1latest on PyPI · released Jun 7, 2026
Audit
Dependencies
opencv-pythonoptionalCommonly used for displaying frames and image processing. Included with `depthai[full]`.
blobconverteroptionalUsed for converting models to MyriadX blob format for on-device inference. Included with `depthai[full]`.
Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources