Skip to content

[OAK-D Lite] Stereo depth code cannot start the camera after the first run #1248

Description

@LivingWithHippos

I have a strange problem, I'm using a python script to get the stereo depth, which is a slightly modified version of the one in the examples, and while it always works after boot, it fails to start on successive tests, with these errors:

[2026-07-15 13:10:14.856] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_2_0' (X_LINK_ERROR)'
[2026-07-15 13:10:14.856] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_7__output' (X_LINK_ERROR)'
[2026-07-15 13:10:14.856] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_3_depth' (X_LINK_ERROR)'
[2026-07-15 13:10:14.856] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_0_0' (X_LINK_ERROR)'
[194430107173DD5900] [5.1] [1784113816.224] [host] [warning] Closed connection

[194430107173DD5900] [5.1] [1784113816.224] [host] [warning] Attempting to reconnect. Timeout is 10000ms

[2026-07-15 13:10:19.523] [depthai] [error] Device with id 1944... has crashed. Crash dump logs are stored in: crash_dump_2026-07-15_13_10_19.tar.gz - please report to developers.
[194430107173DD5900] [5.1] [1784113821.532] [host] [warning] Reconnection successful
# keeps on crashing and restarting

crash_dump_2026-07-15_13_10_19.tar.gz

script:

import depthai as dai
import cv2
import numpy as np


def draw_rotated_rectangle(frame, center, size, angle, color, thickness=2):
    # Create a rotated rectangle
    rect = ((center[0], center[1]), (size[0], size[1]), angle)

    # Get the four vertices of the rotated rectangle
    box = cv2.boxPoints(rect)
    box = np.intp(box)  # Convert to integer coordinates

    # Draw the rectangle on the frame
    cv2.polylines(frame, [box], isClosed=True, color=color, thickness=thickness)


def processDepthFrame(depthFrame):
    depth_downscaled = depthFrame[::4]
    if np.all(depth_downscaled == 0):
        min_depth = 0
    else:
        min_depth = np.percentile(depth_downscaled[depth_downscaled != 0], 1)
    max_depth = np.percentile(depth_downscaled, 99)
    depthFrameColor = np.interp(depthFrame, (min_depth, max_depth), (0, 255)).astype(
        np.uint8
    )
    return cv2.applyColorMap(depthFrameColor, cv2.COLORMAP_HOT)


def getRectangleDistance(depthFrame, rectangle: dai.RotatedRect) -> float:
    center = (rectangle.center.x, rectangle.center.y)
    size = (rectangle.size.width, rectangle.size.height)
    x, y = int(center[0] - size[0] / 2), int(center[1] - size[1] / 2)
    values = depthFrame[y : y + int(size[1]), x : x + int(size[0])]
    # average them skipping zeroes (invalid)
    valid_values = values[values != 0]
    if valid_values.size == 0:
        return 0.0
    mm_distance = float(np.mean(valid_values))
    return mm_distance / 1000


with dai.Pipeline() as pipeline:
    color = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_A)
    monoLeft = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
    monoRight = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
    stereo = pipeline.create(dai.node.StereoDepth)

    stereo.setDefaultProfilePreset(dai.node.StereoDepth.PresetMode.DEFAULT)

    colorCamOut = color.requestOutput((640, 480))

    monoLeftOut = monoLeft.requestOutput((640, 480))
    monoRightOut = monoRight.requestOutput((640, 480))

    monoLeftOut.link(stereo.left)
    monoRightOut.link(stereo.right)

    colorOut = colorCamOut.createOutputQueue()
    rightOut = monoRightOut.createOutputQueue()
    stereoOut = stereo.depth.createOutputQueue()

    counter = 0

    rectangle_center = (640 / 2, 480 / 2)
    rectangle_sizes = (50, 50)
    rectangle_angle = 0

    rect = dai.RotatedRect(
        dai.Point2f(rectangle_center[0], rectangle_center[1]),
        dai.Size2f(rectangle_sizes[0], rectangle_sizes[1]),
        rectangle_angle,
    )

    pipeline.start()
    while pipeline.isRunning():
        counter += 1
        colorFrame: dai.ImgFrame = colorOut.get()
        stereoFrame: dai.ImgFrame = stereoOut.get()

        assert colorFrame.validateTransformations()
        assert stereoFrame.validateTransformations()

        clr = colorFrame.getCvFrame()
        depth = processDepthFrame(stereoFrame.getCvFrame())

        remappedRect = colorFrame.getTransformation().remapRectTo(
            stereoFrame.getTransformation(), rect
        )

        depth_frame = stereoFrame.getFrame()
        rect_distance = getRectangleDistance(depth_frame, remappedRect)

        draw_rotated_rectangle(
            clr,
            (rect.center.x, rect.center.y),
            (rect.size.width, rect.size.height),
            rect.angle,
            (255, 0, 0),
        )
        draw_rotated_rectangle(
            depth,
            (remappedRect.center.x, remappedRect.center.y),
            (remappedRect.size.width, remappedRect.size.height),
            remappedRect.angle,
            (255, 0, 0),
        )

        cv2.putText(
            clr,
            f"{rect_distance:.3f} m",
            (10, 30),
            cv2.FONT_HERSHEY_SIMPLEX,
            1,
            (255, 255, 255),
            2,
        )
        cv2.imshow("color", clr)
        cv2.imshow("depth", depth)

        if cv2.waitKey(1) == ord("q"):
            break
    if pipeline.isRunning():
        pipeline.stop()

other info:

  • I'm testing on a Linux laptop with arch on kernel 7.1.3
  • depthai 3.8.0 (it crashed the same on 3.7.1)
  • opencv-python 4.10.0.84
  • depthai nodes 0.5.2 (not used in this script)
  • python 3.13 in a virtual environment
  • decent usb 3 cable

what doesn't work:

  • changing USB port does not work
  • changing USB cable does not work (tried a USB A 2.0)
  • the original example behaviour is similar to this one
  • the new example has the same behaviour, it fails at depthFrame = depthQueue.get()

I can also replicate this with the health check script

Device: DeviceInfo(name=5.1, deviceId=1944, X_LINK_UNBOOTED, X_LINK_USB_VSC, X_LINK_MYRIAD_X, X_LINK_SUCCESS)
Power supply check duration: 20000 ms
Running health check...

Health check completed in 30853 ms
HealthCheckMetrics(
  usbGeneration=USB 3.0,
  bandwidthMbps=2108.67,
  cameraFunctionality=pass,
  cameraCalibration=pass,
  imuFunctionality=pass,
  imuCalibration=pass,
  powerSupplyFunctionality=pass,
  deviceInUse=false,
  deviceInSetupMode=false,
  missingUdevRules=false,
  issues=[{type=warning, stage=powerSupply, message="No IR drivers detected; power supply check ran without IR load."}]
)

# becomes

Running health check...
[2026-07-15 14:08:34.030] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_2_0' (X_LINK_ERROR)'
[2026-07-15 14:08:34.030] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_3_out' (X_LINK_ERROR)'
[2026-07-15 14:08:34.030] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_7__output' (X_LINK_ERROR)'
[2026-07-15 14:08:34.030] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_0_0' (X_LINK_ERROR)'
[2026-07-15 14:08:34.030] [depthai] [error] Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: '__x_1_0' (X_LINK_ERROR)'
[194430107173DD5900] [5.1] [1784117316.147] [host] [warning] Closed connection

[194430107173DD5900] [5.1] [1784117316.147] [host] [warning] Attempting to reconnect. Timeout is 10000ms

what does work:

  • rebooting does work (once)
  • disconnecting the camera from the camera/cable and waiting a bit after reconnecting and retrying DOES work, but again, only for the first time
  • if I run another script which has a "normal" object detection pipeline, with no stereo, it always works (same device, same pc, same venv)

dmesg of a broken loop

# camera connected
lug 15 13:21:55 kernel: usb 5-1: new high-speed USB device number 21 using xhci_hcd
lug 15 13:21:55 kernel: usb 5-1: New USB device found, idVendor=03e7, idProduct=2485, bcdDevice= 0.01
lug 15 13:21:55 kernel: usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
lug 15 13:21:55 kernel: usb 5-1: Product: Movidius MyriadX
lug 15 13:21:55 kernel: usb 5-1: Manufacturer: Movidius Ltd.
lug 15 13:21:55 kernel: usb 5-1: SerialNumber: 03e7
# script started
lug 15 13:22:08 kernel: usb 5-1: USB disconnect, device number 21
lug 15 13:22:10 kernel: usb 6-1: new SuperSpeed USB device number 19 using xhci_hcd
lug 15 13:22:10 kernel: usb 6-1: New USB device found, idVendor=03e7, idProduct=f63b, bcdDevice= 1.00
lug 15 13:22:10 kernel: usb 6-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
lug 15 13:22:10 kernel: usb 6-1: Product: Luxonis Device
lug 15 13:22:10 kernel: usb 6-1: Manufacturer: Intel Corporation
lug 15 13:22:10 kernel: usb 6-1: SerialNumber: 1944
lug 15 13:22:12 kernel: usb 6-1: USB disconnect, device number 19
lug 15 13:22:12 kernel: usb 5-1: new high-speed USB device number 22 using xhci_hcd
lug 15 13:22:13 kernel: usb 5-1: New USB device found, idVendor=03e7, idProduct=2485, bcdDevice= 0.01
lug 15 13:22:13 kernel: usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
lug 15 13:22:13 kernel: usb 5-1: Product: Movidius MyriadX
lug 15 13:22:13 kernel: usb 5-1: Manufacturer: Movidius Ltd.
lug 15 13:22:13 kernel: usb 5-1: SerialNumber: 03e7
lug 15 13:22:15 kernel: usb 5-1: USB disconnect, device number 22
# loops from "new SuperSpeed USB device..."
cat /etc/udev/rules.d/99-prolific.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="067b", ATTR{idProduct}=="2303", GROUP="libvirt", MODE="0660"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions