Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions dimos/hardware/camera.py

This file was deleted.

55 changes: 55 additions & 0 deletions dimos/hardware/camera/zed/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2025 Dimensional Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""ZED camera hardware interfaces."""

from pathlib import Path
from dimos.msgs.sensor_msgs.CameraInfo import CalibrationProvider

# Check if ZED SDK is available
try:
import pyzed.sl as sl

HAS_ZED_SDK = True
except ImportError:
HAS_ZED_SDK = False

# Only import ZED classes if SDK is available
if HAS_ZED_SDK:
from dimos.hardware.camera.zed.camera import ZEDCamera, ZEDModule
else:
# Provide stub classes when SDK is not available
class ZEDCamera:
def __init__(self, *args, **kwargs):
raise ImportError(
"ZED SDK not installed. Please install pyzed package to use ZED camera functionality."
)

class ZEDModule:
def __init__(self, *args, **kwargs):
raise ImportError(
"ZED SDK not installed. Please install pyzed package to use ZED camera functionality."
)


# Set up camera calibration provider (always available)
CALIBRATION_DIR = Path(__file__).parent
CameraInfo = CalibrationProvider(CALIBRATION_DIR)

__all__ = [
"ZEDCamera",
"ZEDModule",
"HAS_ZED_SDK",
"CameraInfo",
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import numpy as np
from typing import Any, Dict, Optional, Tuple

import cv2
import numpy as np
import open3d as o3d
from typing import Optional, Tuple, Dict, Any
import logging
import time
import threading
import pyzed.sl as sl
from dimos_lcm.sensor_msgs import CameraInfo
from reactivex import interval
from reactivex import operators as ops

try:
import pyzed.sl as sl
except ImportError:
sl = None
logging.warning("ZED SDK not found. Please install pyzed to use ZED camera functionality.")

from dimos.hardware.stereo_camera import StereoCamera
from dimos.core import Module, Out, rpc
from dimos.utils.logging_config import setup_logger
from dimos.protocol.tf import TF
from dimos.msgs.geometry_msgs import Transform, Vector3, Quaternion
from dimos.msgs.geometry_msgs import PoseStamped, Quaternion, Transform, Vector3

# Import LCM message types
from dimos.msgs.sensor_msgs import Image, ImageFormat
from dimos_lcm.sensor_msgs import CameraInfo
from dimos.msgs.geometry_msgs import PoseStamped
from dimos.msgs.std_msgs import Header
from dimos.protocol.tf import TF
from dimos.utils.logging_config import setup_logger

logger = setup_logger(__name__)


class ZEDCamera(StereoCamera):
class ZEDCamera:
"""ZED Camera capture node with neural depth processing."""

def __init__(
Expand Down
27 changes: 27 additions & 0 deletions dimos/hardware/camera/zed/single_webcam.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# for cv2.VideoCapture and cutting only half of the frame
image_width: 640
image_height: 376
camera_name: zed_webcam_single
camera_matrix:
rows: 3
cols: 3
data: [379.45267, 0. , 302.43516,
0. , 380.67871, 228.00954,
0. , 0. , 1. ]
distortion_model: plumb_bob
distortion_coefficients:
rows: 1
cols: 5
data: [-0.309435, 0.092185, -0.009059, 0.003708, 0.000000]
rectification_matrix:
rows: 3
cols: 3
data: [1., 0., 0.,
0., 1., 0.,
0., 0., 1.]
projection_matrix:
rows: 3
cols: 4
data: [291.12888, 0. , 304.94086, 0. ,
0. , 347.95022, 231.8885 , 0. ,
0. , 0. , 1. , 0. ]
43 changes: 43 additions & 0 deletions dimos/hardware/camera/zed/test_zed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
# Copyright 2025 Dimensional Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dimos.msgs.sensor_msgs.CameraInfo import CameraInfo


def test_zed_import_and_calibration_access():
"""Test that zed module can be imported and calibrations accessed."""
# Import zed module from camera
from dimos.hardware.camera import zed

# Test that CameraInfo is accessible
assert hasattr(zed, "CameraInfo")

# Test snake_case access
camera_info_snake = zed.CameraInfo.single_webcam
assert isinstance(camera_info_snake, CameraInfo)
assert camera_info_snake.width == 640
assert camera_info_snake.height == 376
assert camera_info_snake.distortion_model == "plumb_bob"

# Test PascalCase access
camera_info_pascal = zed.CameraInfo.SingleWebcam
assert isinstance(camera_info_pascal, CameraInfo)
assert camera_info_pascal.width == 640
assert camera_info_pascal.height == 376

# Verify both access methods return the same cached object
assert camera_info_snake is camera_info_pascal

print("✓ ZED import and calibration access test passed!")
51 changes: 0 additions & 51 deletions dimos/hardware/interface.py

This file was deleted.

26 changes: 0 additions & 26 deletions dimos/hardware/stereo_camera.py

This file was deleted.

5 changes: 2 additions & 3 deletions dimos/hardware/webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from abc import ABC, abstractmethod, abstractproperty
from dataclasses import dataclass, field
from functools import cache
from typing import Any, Callable, Generic, Optional, Protocol, TypeVar, Literal
from typing import Any, Callable, Generic, Literal, Optional, Protocol, TypeVar

import cv2
import numpy as np
Expand Down Expand Up @@ -153,12 +153,11 @@ def capture_frame(self) -> Image:
image = Image.from_numpy(
frame_rgb,
format=ImageFormat.RGB, # We converted to RGB above
frame_id=self._frame("camera"), # Standard frame ID for camera images
frame_id=self._frame("camera_optical"), # Standard frame ID for camera images
ts=time.time(), # Current timestamp
)

if self.config.stereo_slice in ("left", "right"):
image.frame_id = self._frame(f"camera_stereo_{self.config.stereo_slice}")
half_width = image.width // 2
if self.config.stereo_slice == "left":
image = image.crop(0, 0, half_width, image.height)
Expand Down
Loading
Loading