chore(cameras): remove compressed files + filename better managed in opencv camera tests + add camera artefacts in lfs

This commit is contained in:
Steven Palma
2025-05-14 11:20:10 +02:00
parent 95ae56827d
commit e790ad737f
11 changed files with 43 additions and 44 deletions

2
.gitattributes vendored
View File

@@ -11,10 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
*.memmap filter=lfs diff=lfs merge=lfs -text *.memmap filter=lfs diff=lfs merge=lfs -text
*.stl filter=lfs diff=lfs merge=lfs -text *.stl filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text *.safetensors filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text *.mp4 filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text *.arrow filter=lfs diff=lfs merge=lfs -text
*.json !text !filter !merge !diff *.json !text !filter !merge !diff
tests/artifacts/cameras/*.{png,bag} filter=lfs diff=lfs merge=lfs -text

6
.gitignore vendored
View File

@@ -171,9 +171,3 @@ dmypy.json
# Cython debug symbols # Cython debug symbols
cython_debug/ cython_debug/
# realsense data-recording format
*.bag
# opencv test images
fakecam*

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f79d14daafb1c0cf2fec5d46ee8029a73fe357402fdd31a7cd4a4794d7319a7c
size 260367

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b8840fb643afe903191248703b1f95a57faf5812ecd9978ac502ee939646fdb2
size 121115

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7e11af87616b83c1cdb30330e951b91e86b51c64a1326e1ba5b4a3fbcdec1a11
size 55698

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9dc9df05797dc0e7b92edc845caab2e4c37c3cfcabb4ee6339c67212b5baba3b
size 38023

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a8d6e64d6cb0e02c94ae125630ee758055bd2e695772c0463a30d63ddc6c5e17
size 3520862

View File

@@ -29,6 +29,14 @@ from lerobot.common.cameras.opencv import OpenCVCamera, OpenCVCameraConfig
from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError
# NOTE(Steven): Consider improving the assert coverage # NOTE(Steven): Consider improving the assert coverage
TEST_ARTIFACTS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "artifacts", "cameras")
DEFAULT_PNG_FILE_PATH = os.path.join(TEST_ARTIFACTS_DIR, "fakecam_sd_160x120.png")
TEST_IMAGE_PATHS = [
os.path.join(TEST_ARTIFACTS_DIR, "fakecam_sd_160x120.png"),
os.path.join(TEST_ARTIFACTS_DIR, "fakecam_hd_320x180.png"),
os.path.join(TEST_ARTIFACTS_DIR, "fakecam_fullhd_480x270.png"),
os.path.join(TEST_ARTIFACTS_DIR, "fakecam_square_128x128.png"),
]
def test_base_class_implementation(): def test_base_class_implementation():
@@ -38,7 +46,7 @@ def test_base_class_implementation():
def test_connect(): def test_connect():
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png") config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
camera.connect(do_warmup_read=False) camera.connect(do_warmup_read=False)
@@ -47,7 +55,7 @@ def test_connect():
def test_connect_already_connected(): def test_connect_already_connected():
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png") config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
camera.connect(do_warmup_read=False) camera.connect(do_warmup_read=False)
@@ -65,7 +73,7 @@ def test_connect_invalid_camera_path():
def test_invalid_width_connect(): def test_invalid_width_connect():
config = OpenCVCameraConfig( config = OpenCVCameraConfig(
index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png", index_or_path=DEFAULT_PNG_FILE_PATH,
width=99999, # Invalid width to trigger error width=99999, # Invalid width to trigger error
height=480, height=480,
) )
@@ -75,15 +83,7 @@ def test_invalid_width_connect():
camera.connect(do_warmup_read=False) camera.connect(do_warmup_read=False)
@pytest.mark.parametrize( @pytest.mark.parametrize("index_or_path", TEST_IMAGE_PATHS)
"index_or_path",
[
"tests/artifacts/cameras/fakecam_sd_640x480.png",
"tests/artifacts/cameras/fakecam_hd_1280x720.png",
"tests/artifacts/cameras/fakecam_fullhd_1920x1080.png",
"tests/artifacts/cameras/fakecam_square_512x512.png",
],
)
def test_read(index_or_path): def test_read(index_or_path):
config = OpenCVCameraConfig(index_or_path=index_or_path) config = OpenCVCameraConfig(index_or_path=index_or_path)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
@@ -95,7 +95,7 @@ def test_read(index_or_path):
def test_read_before_connect(): def test_read_before_connect():
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png") config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
with pytest.raises(DeviceNotConnectedError): with pytest.raises(DeviceNotConnectedError):
@@ -103,7 +103,7 @@ def test_read_before_connect():
def test_disconnect(): def test_disconnect():
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png") config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
camera.connect(do_warmup_read=False) camera.connect(do_warmup_read=False)
@@ -113,22 +113,14 @@ def test_disconnect():
def test_disconnect_before_connect(): def test_disconnect_before_connect():
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png") config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
with pytest.raises(DeviceNotConnectedError): with pytest.raises(DeviceNotConnectedError):
_ = camera.disconnect() _ = camera.disconnect()
@pytest.mark.parametrize( @pytest.mark.parametrize("index_or_path", TEST_IMAGE_PATHS)
"index_or_path",
[
"tests/artifacts/cameras/fakecam_sd_640x480.png",
"tests/artifacts/cameras/fakecam_hd_1280x720.png",
"tests/artifacts/cameras/fakecam_fullhd_1920x1080.png",
"tests/artifacts/cameras/fakecam_square_512x512.png",
],
)
def test_async_read(index_or_path): def test_async_read(index_or_path):
config = OpenCVCameraConfig(index_or_path=index_or_path) config = OpenCVCameraConfig(index_or_path=index_or_path)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
@@ -143,7 +135,7 @@ def test_async_read(index_or_path):
def test_async_read_timeout(): def test_async_read_timeout():
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png") config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
camera.connect(do_warmup_read=False) camera.connect(do_warmup_read=False)
@@ -154,22 +146,14 @@ def test_async_read_timeout():
def test_async_read_before_connect(): def test_async_read_before_connect():
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png") config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
camera = OpenCVCamera(config) camera = OpenCVCamera(config)
with pytest.raises(DeviceNotConnectedError): with pytest.raises(DeviceNotConnectedError):
_ = camera.async_read() _ = camera.async_read()
@pytest.mark.parametrize( @pytest.mark.parametrize("index_or_path", TEST_IMAGE_PATHS)
"index_or_path",
[
"tests/artifacts/cameras/fakecam_sd_640x480.png",
"tests/artifacts/cameras/fakecam_hd_1280x720.png",
"tests/artifacts/cameras/fakecam_fullhd_1920x1080.png",
"tests/artifacts/cameras/fakecam_square_512x512.png",
],
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"rotation", "rotation",
[ [

View File

@@ -26,11 +26,17 @@ import numpy as np
import pytest import pytest
from lerobot.common.cameras.configs import Cv2Rotation from lerobot.common.cameras.configs import Cv2Rotation
from lerobot.common.cameras.intel import RealSenseCamera, RealSenseCameraConfig
from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError
try:
import pyrealsense2 as rs # noqa: F401
from lerobot.common.cameras.intel import RealSenseCamera, RealSenseCameraConfig
except (ImportError, ModuleNotFoundError):
pytest.skip("pyrealsense2 not available", allow_module_level=True)
TEST_ARTIFACTS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "artifacts", "cameras") TEST_ARTIFACTS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "artifacts", "cameras")
BAG_FILE_PATH = os.path.join(TEST_ARTIFACTS_DIR, "test.bag") BAG_FILE_PATH = os.path.join(TEST_ARTIFACTS_DIR, "test_rs.bag")
if not os.path.exists(BAG_FILE_PATH): if not os.path.exists(BAG_FILE_PATH):