Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
65d3a7c
refactor(cameras): init abc class + config
Apr 21, 2025
0003fa9
refactor(cameras): opencv camera init
Apr 21, 2025
656c382
refactor(cameras): realsense camera init
Apr 21, 2025
f705dd8
chore(dependencies): add pyrealsense2 for macos + cleanup init camera…
Apr 21, 2025
c452d84
refactor(cameras): improvements opencv cam v0.1
imstevenpmwork Apr 28, 2025
8a52a3a
test(cameras): add minimal opencv test
imstevenpmwork Apr 30, 2025
e426cce
refactor(cameras): improvements realsense cam v0.1
imstevenpmwork May 2, 2025
88b607d
test(cameras): add minimal realsense test
imstevenpmwork May 5, 2025
cf22e29
chore(cameras): delete unused files
imstevenpmwork May 6, 2025
a26cfe3
chore(cameras): set timeout to 0 in tests
imstevenpmwork May 6, 2025
06e02f6
refactor(cameras): improvements utils functionalities v0.1
imstevenpmwork May 7, 2025
f28086f
refactor(cameras): improvements utils functionalities v0.2
imstevenpmwork May 9, 2025
991786a
refactor(cameras): fps, width and height are optional at camera level…
imstevenpmwork May 12, 2025
c9cc544
refactor(cameras): homogeneous depth processing in realsense camera
imstevenpmwork May 12, 2025
7224807
refactor(cameras): add warm-up, fix defaul args, remove width and hei…
imstevenpmwork May 12, 2025
a66d0dc
[skip ci] refactor(cameras): add warmup read + images different size …
imstevenpmwork May 13, 2025
95d57cf
refactor(cameras): add read_depth() for realsense + new compressed bag
imstevenpmwork May 13, 2025
95ae568
refactor(cameras): width, fps and height is mandatory to have a value…
imstevenpmwork May 13, 2025
e790ad7
chore(cameras): remove compressed files + filename better managed in …
imstevenpmwork May 14, 2025
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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# 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.

*.memmap filter=lfs diff=lfs merge=lfs -text
*.stl filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.json !text !filter !merge !diff
tests/artifacts/cameras/*.{png,bag} filter=lfs diff=lfs merge=lfs -text
39 changes: 32 additions & 7 deletions lerobot/common/cameras/camera.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
#!/usr/bin/env python

# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# 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.

import abc

import numpy as np

from .configs import CameraConfig, ColorMode


# NOTE(Steven): Consider something like configure() if makes sense for both cameras
class Camera(abc.ABC):
def __init__(self, config: CameraConfig):
self.fps: int | None = config.fps
self.width: int | None = config.width
self.height: int | None = config.height

@property
@abc.abstractmethod
def connect(self):
def is_connected(self) -> bool:
pass

@abc.abstractmethod
def read(self, temporary_color: str | None = None) -> np.ndarray:
def connect(self, do_warmup_read: bool = True) -> None:
pass

@abc.abstractmethod
def async_read(self) -> np.ndarray:
def read(self, color_mode: ColorMode | None = None) -> np.ndarray:
pass

@abc.abstractmethod
def disconnect(self):
def async_read(self, timeout_ms: float = 2000) -> np.ndarray:
pass

def __del__(self):
if getattr(self, "is_connected", False):
self.disconnect()
@abc.abstractmethod
def disconnect(self) -> None:
pass
35 changes: 34 additions & 1 deletion lerobot/common/cameras/configs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
#!/usr/bin/env python

# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# 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.

import abc
from dataclasses import dataclass
from enum import Enum

import draccus


@dataclass
class ColorMode(Enum):
RGB = "rgb"
BGR = "bgr"


class Cv2Rotation(Enum):
NO_ROTATION = 0
ROTATE_90 = 90
ROTATE_180 = 180
ROTATE_270 = -90


@dataclass(kw_only=True)
class CameraConfig(draccus.ChoiceRegistry, abc.ABC):
fps: int | None = None
width: int | None = None
height: int | None = None

@property
def type(self) -> str:
return self.get_choice_name(self.__class__)
2 changes: 0 additions & 2 deletions lerobot/common/cameras/intel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
from .camera_realsense import RealSenseCamera
from .configuration_realsense import RealSenseCameraConfig

__all__ = ["RealSenseCamera", "RealSenseCameraConfig"]
Loading
Loading