Skip to content

Commit

Permalink
Fix pointcloud component
Browse files Browse the repository at this point in the history
  • Loading branch information
Erol444 committed Jun 27, 2024
1 parent 29ca479 commit 7c91da6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion depthai_sdk/examples/PointcloudComponent/pointcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
color = oak.camera('color')
stereo = oak.create_stereo()
stereo.config_stereo(align=color)
pcl = oak.create_pointcloud(stereo=stereo, colorize=color)
pcl = oak.create_pointcloud(depth_input=stereo, colorize=color)
oak.visualize(pcl, visualizer='depthai-viewer')
oak.start(blocking=True)
4 changes: 3 additions & 1 deletion depthai_sdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"visualize": ['PySide2',
'Qt.py>=1.3.0',
'matplotlib==3.5.3; python_version <= "3.7"',
'matplotlib==3.6.1; python_version > "3.7"'],
'matplotlib==3.6.1; python_version > "3.7"',
'depthai-viewer'
],
"replay": ['mcap>=0.0.10',
'mcap-ros1-support==0.0.8',
'rosbags==0.9.11'],
Expand Down
2 changes: 1 addition & 1 deletion depthai_sdk/src/depthai_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from depthai_sdk.utils import _create_config, get_config_field, _sentry_before_send
from depthai_sdk.visualize import *

__version__ = '1.13.1'
__version__ = '1.15'


def __import_sentry(sentry_dsn: str) -> None:
Expand Down
14 changes: 7 additions & 7 deletions depthai_sdk/src/depthai_sdk/components/pointcloud_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def __init__(self,

# Depth aspect
if depth_input is None:
stereo = StereoComponent(device, pipeline, replay=replay, args=args)
stereo.config_stereo(lr_check=True, subpixel=True, subpixel_bits=3, confidence=230)
stereo.node.initialConfig.setNumInvalidateEdgePixels(20)
depth_input = StereoComponent(device, pipeline, replay=replay, args=args)
depth_input.config_stereo(lr_check=True, subpixel=True, subpixel_bits=3, confidence=230)
depth_input.node.initialConfig.setNumInvalidateEdgePixels(20)

config = stereo.node.initialConfig.get()
config = depth_input.node.initialConfig.get()
config.postProcessing.speckleFilter.enable = True
config.postProcessing.speckleFilter.speckleRange = 50
config.postProcessing.temporalFilter.enable = True
Expand All @@ -52,14 +52,14 @@ def __init__(self,
config.postProcessing.thresholdFilter.maxRange = 20000 # 20m
config.postProcessing.decimationFilter.decimationFactor = 2
config.postProcessing.decimationFilter.decimationMode = dai.RawStereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode.NON_ZERO_MEDIAN
stereo.node.initialConfig.set(config)
depth_input.node.initialConfig.set(config)

if self.colorize_comp is not None:
# Align to colorize node
stereo.config_stereo(align=self.colorize_comp)
depth_input.config_stereo(align=self.colorize_comp)

if isinstance(depth_input, StereoComponent):
depth_input = stereo.node
depth_input = depth_input.node
elif isinstance(depth_input, ToFComponent):
if depth_input._align is not None:
self.depth = depth_input._align.outputAligned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, scale, fps):

try:
# timeout is optional, but it might be good to prevent the script from hanging if the module is large.
process = subprocess.Popen([sys.executable, "-m", "depthai_viewer"], stdout=subprocess.PIPE,
process = subprocess.Popen([sys.executable, "-m", "depthai_viewer", "--viewer-mode"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = process.communicate(timeout=3)

Expand Down Expand Up @@ -65,10 +65,8 @@ def show(self, packet) -> None:
viewer.log_imu(*packet.get_imu_vals())
elif type(packet) == PointcloudPacket:
if packet.colorize_frame is not None:
bgr_frame = packet.colorize_frame
rgb_frame = bgr_frame[..., ::-1]
frame = np.dstack((rgb_frame, np.full(bgr_frame.shape[:2], 255, dtype=np.uint8)))
viewer.log_image(f'color', frame)
rgb_frame = packet.colorize_frame[..., ::-1]
viewer.log_image(f'color', rgb_frame)
viewer.log_points(packet.name, packet.points.reshape(-1, 3) / 1000, colors=rgb_frame.reshape(-1, 3))
else:
viewer.log_points(packet.name, packet.points.reshape(-1, 3) / 1000)
Expand Down

0 comments on commit 7c91da6

Please sign in to comment.