chore(cameras): remove compressed files + filename better managed in opencv camera tests + add camera artefacts in lfs
This commit is contained in:
@@ -29,6 +29,14 @@ from lerobot.common.cameras.opencv import OpenCVCamera, OpenCVCameraConfig
|
||||
from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError
|
||||
|
||||
# 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():
|
||||
@@ -38,7 +46,7 @@ def test_base_class_implementation():
|
||||
|
||||
|
||||
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.connect(do_warmup_read=False)
|
||||
@@ -47,7 +55,7 @@ def test_connect():
|
||||
|
||||
|
||||
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.connect(do_warmup_read=False)
|
||||
|
||||
@@ -65,7 +73,7 @@ def test_connect_invalid_camera_path():
|
||||
|
||||
def test_invalid_width_connect():
|
||||
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
|
||||
height=480,
|
||||
)
|
||||
@@ -75,15 +83,7 @@ def test_invalid_width_connect():
|
||||
camera.connect(do_warmup_read=False)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"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("index_or_path", TEST_IMAGE_PATHS)
|
||||
def test_read(index_or_path):
|
||||
config = OpenCVCameraConfig(index_or_path=index_or_path)
|
||||
camera = OpenCVCamera(config)
|
||||
@@ -95,7 +95,7 @@ def test_read(index_or_path):
|
||||
|
||||
|
||||
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)
|
||||
|
||||
with pytest.raises(DeviceNotConnectedError):
|
||||
@@ -103,7 +103,7 @@ def test_read_before_connect():
|
||||
|
||||
|
||||
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.connect(do_warmup_read=False)
|
||||
|
||||
@@ -113,22 +113,14 @@ def test_disconnect():
|
||||
|
||||
|
||||
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)
|
||||
|
||||
with pytest.raises(DeviceNotConnectedError):
|
||||
_ = camera.disconnect()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"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("index_or_path", TEST_IMAGE_PATHS)
|
||||
def test_async_read(index_or_path):
|
||||
config = OpenCVCameraConfig(index_or_path=index_or_path)
|
||||
camera = OpenCVCamera(config)
|
||||
@@ -143,7 +135,7 @@ def test_async_read(index_or_path):
|
||||
|
||||
|
||||
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.connect(do_warmup_read=False)
|
||||
|
||||
@@ -154,22 +146,14 @@ def test_async_read_timeout():
|
||||
|
||||
|
||||
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)
|
||||
|
||||
with pytest.raises(DeviceNotConnectedError):
|
||||
_ = camera.async_read()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"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("index_or_path", TEST_IMAGE_PATHS)
|
||||
@pytest.mark.parametrize(
|
||||
"rotation",
|
||||
[
|
||||
|
||||
@@ -26,11 +26,17 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
from lerobot.common.cameras.configs import Cv2Rotation
|
||||
from lerobot.common.cameras.intel import RealSenseCamera, RealSenseCameraConfig
|
||||
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")
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user