• DepthAI-v2
  • Stereo depth decimation filter not correctly setting data size

I noticed the following bug:
When turning on decimation filter on a stereo depth node the frame data buffer size is not decimated with the image. The output image is decimated as expected, however the size of the buffer is unchanged.

Here's my code:
I expect the print statement to print (640*360*2,) 640 360, but it prints (1843200,) 640 360. 1843200 = 720x1080x2, which is the undecimated size.

import depthai as dai

# Create pipeline
pipeline = dai.Pipeline()

# Define sources and outputs
monoLeft = pipeline.create(dai.node.MonoCamera)
monoRight = pipeline.create(dai.node.MonoCamera)
depth = pipeline.create(dai.node.StereoDepth)

xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName("depth")

# Properties
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT)
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoRight.setBoardSocket(dai.CameraBoardSocket.RIGHT)

# Comment these three lines to turn decimation on and off.
config = depth.initialConfig.get()
config.postProcessing.decimationFilter.decimationFactor = 2
depth.initialConfig.set(config)


# Linking
monoLeft.out.link(depth.left)
monoRight.out.link(depth.right)
depth.depth.link(xout.input)

with dai.Device(pipeline) as device:
    q = device.getOutputQueue(name="depth", maxSize=4, blocking=False)

    while True:
        in_depth = q.get()
        frame = in_depth.getFrame()
        print(in_depth.getData().shape, in_depth.getWidth(), in_depth.getHeight())
    a year later

    Hello @GergelySzabolcs, running into the same issue with release v2.24.0.

    I notice that the device-side firmware is controlled via the CMake variable DEPTHAI_DEVICE_SIDE_COMMIT. I see you updated it in this commit in the previous conversation to b3aeaf23ff5857fc8f79d412ceefc08da23e7aad, but as of v2.24.0 it is currently a95f582a61ec9bdbd0f72dec84822455872ffaf7

    Is there a chance that this was regressed to the previous behavior during development? Also, do you have a changelog of device firmware releases? The single hash is a bit opaque to debug the release history.

      Hi amusco-outrider
      Shouldn't be a problem, tested with 2.24.0.0 main branch, the output size was (460800,) 640 360. Any other info you could provide?

      Thanks,
      Jaka

      4 months later

      Hi following up here

      I can confirm I am no longer seeing this behavior on v2.25.1.0 with python however I am still seeing it with the c++ API

      Hi @jhaskel
      The python API are just bindings for the Cpp API, so they should behave the exact same way provided you are on the same version.

      12 days later

      Sorry about the delay on this one, I created a minimal example and could not reproduce the issue

      But then I tried setting all the configs to be the same in the full pipeline and the problem manifested again.

      After some digging it seems that using `stereo->setDepthAlign` is causing the issue, it seems to scale the resolution to the targeted socket (expected behavior) but ignores the reduction from the decimation filter

      Hi @jhaskel
      It doesn't ignore the decimation filter. The depth is decimated, but is upscaled to color resolution for alignment to work.

      Thanks,
      Jaka

      Interesting, I am aligning it to a depth camera frame (e.g. left mono)

      For reference these images show the difference in what is output with setting the depth align and not setting it

      Here is the depth image output with setDepthAlign used

      Here is the depth image output without setDepthAlign used

        jhaskel
        Ok, that is a bug. Thanks for reporting we'll fix it asap.

        Thanks,
        Jaka

        17 days later