• DepthAI-v2
  • Warning: "Align depth map to socket 'RGB' using setDepthAlign"

Can someone tell me the correct:

???.setDepthAlign(???)

to align to the RGB camera and get rid of this warning:

[SpatialDetectionNetwork(1)] [warning] Neural network inference was performed on socket 'RGB', depth frame is aligned to socket 'RIGHT'. Bounding box mapping will not be correct, and will lead to erroneus spatial values. Align depth map to socket 'RGB' using 'setDepthAlign'.

My Setup:

# Create pipeline
pipeline = dai.Pipeline()

# Define sources and outputs
camRgb = pipeline.create(dai.node.ColorCamera)
spatialDetectionNetwork = pipeline.create(dai.node.YoloSpatialDetectionNetwork)
monoLeft = pipeline.create(dai.node.MonoCamera)
monoRight = pipeline.create(dai.node.MonoCamera)
stereo = pipeline.create(dai.node.StereoDepth)

xoutNN = pipeline.create(dai.node.XLinkOut)
xoutNN.setStreamName("detections")

# Properties

camRgb.setPreviewSize(416, 416)
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
camRgb.setInterleaved(False)
camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.BGR)
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT)
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
monoRight.setBoardSocket(dai.CameraBoardSocket.RIGHT)

# setting node configs

# to eliminate error msg 2024-01-17 alan
"""
[184430101175A41200] [3.1] [147.531] [SpatialDetectionNetwork(1)] [warning] Neural network inference was performed on socket 'RGB', depth frame is aligned to socket 'RIGHT'. Bounding box mapping will not be correct, and will lead to erroneus spatial values. Align depth map to socket 'RGB' using 'setDepthAlign'.
"""

# ???.setDepthAlign(???)

spatialDetectionNetwork.setBlobPath(nnBlobPath)
spatialDetectionNetwork.setConfidenceThreshold(0.5)
spatialDetectionNetwork.input.setBlocking(False)
spatialDetectionNetwork.setBoundingBoxScaleFactor(0.5)
spatialDetectionNetwork.setDepthLowerThreshold(100)
spatialDetectionNetwork.setDepthUpperThreshold(5000)

# Yolo specific parameters

spatialDetectionNetwork.setNumClasses(80)
spatialDetectionNetwork.setCoordinateSize(4)
spatialDetectionNetwork.setAnchors(np.array([10,14, 23,27, 37,58, 81,82, 135,169, 344,319]))
spatialDetectionNetwork.setAnchorMasks({ "side26": np.array([1,2,3]), "side13": np.array([3,4,5]) })
spatialDetectionNetwork.setIouThreshold(0.5)

# Linking
monoLeft.out.link(stereo.left)
monoRight.out.link(stereo.right)
camRgb.preview.link(spatialDetectionNetwork.input)
spatialDetectionNetwork.out.link(xoutNN.input)
stereo.depth.link(spatialDetectionNetwork.inputDepth)

    Hi cycob
    stereo.setDepthAlign(dai.CameraBoardSocket.CAM_A) # cam_a should be your color camera

    Thanks,
    Jaka

      jakaskerl Thank you - that works perfect.

      (vdepthai) pi@WaLiPi5:~/wali_pi5/systests/Oak-D-Lite/vdepthai/spatial_tiny_yolo $ ./console_spatial_tiny_yolo.py

      NN fps: 27.7
      person X:21 Y:280 Z:1131 mm

      NN fps: 27.7
      person X:23 Y:280 Z:1131 mm

      NN fps: 27.7
      person X:23 Y:268 Z:1094 mm