Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds test for camera to check that different image sizes work #964

Merged
merged 12 commits into from
Sep 19, 2024
33 changes: 33 additions & 0 deletions source/extensions/omni.isaac.lab/test/sensors/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,39 @@ def test_multi_camera_init(self):
for im_data in cam.data.output.to_dict().values():
self.assertEqual(im_data.shape, (1, self.camera_cfg.height, self.camera_cfg.width))

def test_multi_camera_with_different_resolution(self):
"""Test multi-camera initialization with cameras having different image resolutions."""
# create two cameras with different prim paths
# -- camera 1
cam_cfg_1 = copy.deepcopy(self.camera_cfg)
cam_cfg_1.prim_path = "/World/Camera_1"
cam_1 = Camera(cam_cfg_1)
# -- camera 2
cam_cfg_2 = copy.deepcopy(self.camera_cfg)
cam_cfg_2.prim_path = "/World/Camera_2"
cam_cfg_2.height = 240
cam_cfg_2.width = 320
cam_2 = Camera(cam_cfg_2)

# play sim
self.sim.reset()

# Simulate for a few steps
# note: This is a workaround to ensure that the textures are loaded.
# Check "Known Issues" section in the documentation for more details.
for _ in range(5):
self.sim.step()
# perform rendering
self.sim.step()
# update camera
cam_1.update(self.dt)
cam_2.update(self.dt)
# check image sizes
self.assertEqual(
cam_1.data.output["distance_to_image_plane"].shape, (1, self.camera_cfg.height, self.camera_cfg.width)
)
self.assertEqual(cam_2.data.output["distance_to_image_plane"].shape, (1, cam_cfg_2.height, cam_cfg_2.width))

def test_camera_init_intrinsic_matrix(self):
"""Test camera initialization from intrinsic matrix."""
# get the first camera
Expand Down
Loading