From 0b8d125f0f9b77051dd6e6514da73d13c0186365 Mon Sep 17 00:00:00 2001 From: Ashay Athalye Date: Wed, 11 Sep 2024 17:40:49 -0400 Subject: [PATCH] Rotate spot camera images. --- predicators/perception/spot_perceiver.py | 1 - predicators/spot_utils/perception/spot_cameras.py | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/predicators/perception/spot_perceiver.py b/predicators/perception/spot_perceiver.py index 88d164f17..cf3cfa7dc 100644 --- a/predicators/perception/spot_perceiver.py +++ b/predicators/perception/spot_perceiver.py @@ -675,7 +675,6 @@ def step(self, observation: Observation) -> State: imgs = [v.rgb for _, v in imgs.items()] # import PIL # PIL.Image.fromarray(imgs[0]).show() - # import pdb; pdb.set_trace() self._gripper_open_percentage = observation.gripper_open_percentage self._curr_state = self._create_state() self._curr_state.simulator_state["images"] = imgs diff --git a/predicators/spot_utils/perception/spot_cameras.py b/predicators/spot_utils/perception/spot_cameras.py index f6ead0248..0c249a89f 100644 --- a/predicators/spot_utils/perception/spot_cameras.py +++ b/predicators/spot_utils/perception/spot_cameras.py @@ -2,6 +2,7 @@ from typing import Collection, Dict, Optional, Type import cv2 +from scipy import ndimage import numpy as np from bosdyn.api import image_pb2 from bosdyn.client.frame_helpers import BODY_FRAME_NAME, get_a_tform_b @@ -22,12 +23,12 @@ 'right_fisheye_image': 180 } RGB_TO_DEPTH_CAMERAS = { - # "hand_color_image": "hand_depth_in_hand_color_frame", - # "left_fisheye_image": "left_depth_in_visual_frame", - # "right_fisheye_image": "right_depth_in_visual_frame", + "hand_color_image": "hand_depth_in_hand_color_frame", + "left_fisheye_image": "left_depth_in_visual_frame", + "right_fisheye_image": "right_depth_in_visual_frame", "frontleft_fisheye_image": "frontleft_depth_in_visual_frame", - # "frontright_fisheye_image": "frontright_depth_in_visual_frame", - # "back_fisheye_image": "back_depth_in_visual_frame" + "frontright_fisheye_image": "frontright_depth_in_visual_frame", + "back_fisheye_image": "back_depth_in_visual_frame" } # Hack to avoid double image capturing when we want to (1) get object states @@ -173,6 +174,7 @@ def capture_images_without_context( rgb_img_resp = name_to_response[camera_name] depth_img_resp = name_to_response[RGB_TO_DEPTH_CAMERAS[camera_name]] rgb_img = _image_response_to_image(rgb_img_resp) + rgb_img = ndimage.rotate(rgb_img, ROTATION_ANGLE[camera_name]) depth_img = _image_response_to_image(depth_img_resp) # # Create transform. # camera_tform_body = get_a_tform_b(