Skip to content

Commit

Permalink
fix checks
Browse files Browse the repository at this point in the history
  • Loading branch information
NishanthJKumar committed Jul 18, 2023
1 parent b6c8d4c commit 8a0ae52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
7 changes: 2 additions & 5 deletions predicators/spot_utils/perception_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,8 @@ def query_detic_sam(image_in: np.ndarray, classes: List[str],
# return np.vstack((x, y, z)).T, valid_inds


def process_image_response(
image_response: bosdyn.api.image_pb2.ImageResponse,
to_rgb: bool = False
) -> np.ndarray:
def process_image_response(image_response: bosdyn.api.image_pb2.ImageResponse,
to_rgb: bool = False) -> np.ndarray:
"""Given a Boston Dynamics SDK image response, extract the correct np array
corresponding to the image."""
# pylint: disable=no-member
Expand Down Expand Up @@ -272,7 +270,6 @@ def process_image_response(
else:
img = cv2.imdecode(img, -1)

# TODO also add here; to check duplicate
# Convert to RGB color, as some perception models assume RGB format
# By default, still use BGR to keep backward compability
if to_rgb:
Expand Down
24 changes: 8 additions & 16 deletions predicators/spot_utils/spot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,9 @@ def get_single_camera_image(self,
img_req = build_image_request(
source_name,
quality_percent=100,
pixel_format=(
None if
('hand' in source_name or 'depth' in source_name) else
image_pb2.Image.PIXEL_FORMAT_RGB_U8
)
)
pixel_format=(None if
('hand' in source_name or 'depth' in source_name)
else image_pb2.Image.PIXEL_FORMAT_RGB_U8))
image_response = self.image_client.get_image([img_req])

# Format image before detecting apriltags.
Expand Down Expand Up @@ -493,15 +490,11 @@ def get_sam_object_loc_from_camera(
"""
_, rgb_img_response = self.get_single_camera_image(source_rgb, True)
_, depth_img_response = self.get_single_camera_image(
source_depth, True)
# TODO fix - to rgb in processing response
source_depth, False)
image = {
'rgb': process_image_response(
rgb_img_response[0], to_rgb=True
),
'depth': process_image_response(
depth_img_response[0], to_rgb=True
),
'rgb': process_image_response(rgb_img_response[0], to_rgb=True),
'depth': process_image_response(depth_img_response[0],
to_rgb=False),
}
image_responses = {
'rgb': rgb_img_response[0],
Expand Down Expand Up @@ -970,8 +963,7 @@ def arm_object_grasp(self, obj: Object) -> None:
results = get_pixel_locations_with_detic_sam(
classes=[obj_name_to_vision_prompt['brush']],
in_res_image=image_for_sam,
plot=CFG.spot_visualize_vision_model_outputs
)
plot=CFG.spot_visualize_vision_model_outputs)

if len(results) > 0:
# We only want the most likely sample (for now).
Expand Down

0 comments on commit 8a0ae52

Please sign in to comment.