Skip to content

Commit

Permalink
Fixed depth->disparity conversion for visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Erol444 committed May 17, 2023
1 parent 1337d30 commit 53fa9cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 5 additions & 2 deletions depthai_sdk/src/depthai_sdk/components/stereo_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions depthai_sdk/src/depthai_sdk/oak_outputs/xout/xout_depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'

Expand Down

0 comments on commit 53fa9cf

Please sign in to comment.