Skip to content

Commit e790ad7

Browse files
chore(cameras): remove compressed files + filename better managed in opencv camera tests + add camera artefacts in lfs
1 parent 95ae568 commit e790ad7

File tree

11 files changed

+43
-44
lines changed

11 files changed

+43
-44
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
1514
*.memmap filter=lfs diff=lfs merge=lfs -text
1615
*.stl filter=lfs diff=lfs merge=lfs -text
1716
*.safetensors filter=lfs diff=lfs merge=lfs -text
1817
*.mp4 filter=lfs diff=lfs merge=lfs -text
1918
*.arrow filter=lfs diff=lfs merge=lfs -text
2019
*.json !text !filter !merge !diff
20+
tests/artifacts/cameras/*.{png,bag} filter=lfs diff=lfs merge=lfs -text

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,3 @@ dmypy.json
171171

172172
# Cython debug symbols
173173
cython_debug/
174-
175-
# realsense data-recording format
176-
*.bag
177-
178-
# opencv test images
179-
fakecam*
-2.28 MB
Binary file not shown.
-6.27 MB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:a8d6e64d6cb0e02c94ae125630ee758055bd2e695772c0463a30d63ddc6c5e17
3+
size 3520862

tests/cameras/test_opencv.py

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError
3030

3131
# NOTE(Steven): Consider improving the assert coverage
32+
TEST_ARTIFACTS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "artifacts", "cameras")
33+
DEFAULT_PNG_FILE_PATH = os.path.join(TEST_ARTIFACTS_DIR, "fakecam_sd_160x120.png")
34+
TEST_IMAGE_PATHS = [
35+
os.path.join(TEST_ARTIFACTS_DIR, "fakecam_sd_160x120.png"),
36+
os.path.join(TEST_ARTIFACTS_DIR, "fakecam_hd_320x180.png"),
37+
os.path.join(TEST_ARTIFACTS_DIR, "fakecam_fullhd_480x270.png"),
38+
os.path.join(TEST_ARTIFACTS_DIR, "fakecam_square_128x128.png"),
39+
]
3240

3341

3442
def test_base_class_implementation():
@@ -38,7 +46,7 @@ def test_base_class_implementation():
3846

3947

4048
def test_connect():
41-
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png")
49+
config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
4250
camera = OpenCVCamera(config)
4351

4452
camera.connect(do_warmup_read=False)
@@ -47,7 +55,7 @@ def test_connect():
4755

4856

4957
def test_connect_already_connected():
50-
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png")
58+
config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
5159
camera = OpenCVCamera(config)
5260
camera.connect(do_warmup_read=False)
5361

@@ -65,7 +73,7 @@ def test_connect_invalid_camera_path():
6573

6674
def test_invalid_width_connect():
6775
config = OpenCVCameraConfig(
68-
index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png",
76+
index_or_path=DEFAULT_PNG_FILE_PATH,
6977
width=99999, # Invalid width to trigger error
7078
height=480,
7179
)
@@ -75,15 +83,7 @@ def test_invalid_width_connect():
7583
camera.connect(do_warmup_read=False)
7684

7785

78-
@pytest.mark.parametrize(
79-
"index_or_path",
80-
[
81-
"tests/artifacts/cameras/fakecam_sd_640x480.png",
82-
"tests/artifacts/cameras/fakecam_hd_1280x720.png",
83-
"tests/artifacts/cameras/fakecam_fullhd_1920x1080.png",
84-
"tests/artifacts/cameras/fakecam_square_512x512.png",
85-
],
86-
)
86+
@pytest.mark.parametrize("index_or_path", TEST_IMAGE_PATHS)
8787
def test_read(index_or_path):
8888
config = OpenCVCameraConfig(index_or_path=index_or_path)
8989
camera = OpenCVCamera(config)
@@ -95,15 +95,15 @@ def test_read(index_or_path):
9595

9696

9797
def test_read_before_connect():
98-
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png")
98+
config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
9999
camera = OpenCVCamera(config)
100100

101101
with pytest.raises(DeviceNotConnectedError):
102102
_ = camera.read()
103103

104104

105105
def test_disconnect():
106-
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png")
106+
config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
107107
camera = OpenCVCamera(config)
108108
camera.connect(do_warmup_read=False)
109109

@@ -113,22 +113,14 @@ def test_disconnect():
113113

114114

115115
def test_disconnect_before_connect():
116-
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png")
116+
config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
117117
camera = OpenCVCamera(config)
118118

119119
with pytest.raises(DeviceNotConnectedError):
120120
_ = camera.disconnect()
121121

122122

123-
@pytest.mark.parametrize(
124-
"index_or_path",
125-
[
126-
"tests/artifacts/cameras/fakecam_sd_640x480.png",
127-
"tests/artifacts/cameras/fakecam_hd_1280x720.png",
128-
"tests/artifacts/cameras/fakecam_fullhd_1920x1080.png",
129-
"tests/artifacts/cameras/fakecam_square_512x512.png",
130-
],
131-
)
123+
@pytest.mark.parametrize("index_or_path", TEST_IMAGE_PATHS)
132124
def test_async_read(index_or_path):
133125
config = OpenCVCameraConfig(index_or_path=index_or_path)
134126
camera = OpenCVCamera(config)
@@ -143,7 +135,7 @@ def test_async_read(index_or_path):
143135

144136

145137
def test_async_read_timeout():
146-
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png")
138+
config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
147139
camera = OpenCVCamera(config)
148140
camera.connect(do_warmup_read=False)
149141

@@ -154,22 +146,14 @@ def test_async_read_timeout():
154146

155147

156148
def test_async_read_before_connect():
157-
config = OpenCVCameraConfig(index_or_path="tests/artifacts/cameras/fakecam_sd_640x480.png")
149+
config = OpenCVCameraConfig(index_or_path=DEFAULT_PNG_FILE_PATH)
158150
camera = OpenCVCamera(config)
159151

160152
with pytest.raises(DeviceNotConnectedError):
161153
_ = camera.async_read()
162154

163155

164-
@pytest.mark.parametrize(
165-
"index_or_path",
166-
[
167-
"tests/artifacts/cameras/fakecam_sd_640x480.png",
168-
"tests/artifacts/cameras/fakecam_hd_1280x720.png",
169-
"tests/artifacts/cameras/fakecam_fullhd_1920x1080.png",
170-
"tests/artifacts/cameras/fakecam_square_512x512.png",
171-
],
172-
)
156+
@pytest.mark.parametrize("index_or_path", TEST_IMAGE_PATHS)
173157
@pytest.mark.parametrize(
174158
"rotation",
175159
[

0 commit comments

Comments
 (0)