From 53fa9cfa3b03e5040db31f262c8994771a59f11f Mon Sep 17 00:00:00 2001 From: Erol444 Date: Fri, 5 May 2023 16:21:37 +0200 Subject: [PATCH] Fixed depth->disparity conversion for visualization --- depthai_sdk/src/depthai_sdk/components/stereo_component.py | 7 +++++-- depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_depth.py | 3 +-- .../src/depthai_sdk/oak_outputs/xout/xout_disparity.py | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/depthai_sdk/src/depthai_sdk/components/stereo_component.py b/depthai_sdk/src/depthai_sdk/components/stereo_component.py index 3f8d3cbc7..697f26daa 100644 --- a/depthai_sdk/src/depthai_sdk/components/stereo_component.py +++ b/depthai_sdk/src/depthai_sdk/components/stereo_component.py @@ -369,8 +369,11 @@ def __init__(self, stereo_component: 'StereoComponent'): self._comp = stereo_component def _mono_frames(self): + """ + Create mono frames output if WLS filter is enabled or colorize is set to RGBD + """ mono_frames = None - if self._comp.wls_enabled: + if self._comp.wls_enabled or self._comp._colorize == StereoColor.RGBD: mono_frames = StreamXout(self._comp.node.id, self._comp._right_stream, name=self._comp.name) return mono_frames @@ -383,7 +386,7 @@ def disparity(self, pipeline: dai.Pipeline, device: dai.Device) -> XoutBase: out = XoutDisparity( frames=StreamXout(self._comp.node.id, self._comp.disparity, name=self._comp.name), - max_disp=self._comp.node.getMaxDisparity(), + max_disp=self._comp.node, fps=fps, mono_frames=self._mono_frames(), colorize=self._comp._colorize, diff --git a/depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_depth.py b/depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_depth.py index 0693f2be9..1d4b36c58 100644 --- a/depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_depth.py +++ b/depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_depth.py @@ -36,7 +36,7 @@ def __init__(self, self.name = 'Depth' super().__init__( frames=frames, - max_disp=95, + stereo=stereo, fps=fps, mono_frames=mono_frames, colorize=colorize, @@ -66,4 +66,3 @@ def visualize(self, packet: DepthPacket): disp[disp==np.inf] = 0 packet.frame = np.round(disp).astype(np.uint8) super().visualize(packet) - diff --git a/depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_disparity.py b/depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_disparity.py index 4aba4523d..781733a42 100644 --- a/depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_disparity.py +++ b/depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_disparity.py @@ -20,7 +20,7 @@ class XoutDisparity(XoutFrames, Clickable): def __init__(self, frames: StreamXout, - max_disp: float, + stereo: dai.node.StereoDepth, fps: float, mono_frames: Optional[StreamXout], colorize: StereoColor = None, @@ -30,7 +30,7 @@ def __init__(self, wls_lambda: float = None, wls_sigma: float = None): self.mono_frames = mono_frames - self.multiplier = 255.0 / max_disp + self.multiplier = 255.0 / stereo.getMaxDisparity() self.fps = fps self.name = 'Disparity'