Image

For clients to use the image service.

exception bosdyn.client.image.ImageResponseError(response, error_message=None)[source]

Bases: bosdyn.client.exceptions.ResponseError

General class of errors for Image service.

exception bosdyn.client.image.UnknownImageSourceError(response, error_message=None)[source]

Bases: bosdyn.client.image.ImageResponseError

System cannot find the requested image source name.

exception bosdyn.client.image.SourceDataError(response, error_message=None)[source]

Bases: bosdyn.client.image.ImageResponseError

System cannot generate the ImageSource at this time.

exception bosdyn.client.image.ImageDataError(response, error_message=None)[source]

Bases: bosdyn.client.image.ImageResponseError

System cannot generate image data for the ImageCapture at this time.

exception bosdyn.client.image.UnsupportedImageFormatRequestedError(response, error_message=None)[source]

Bases: bosdyn.client.image.ImageResponseError

The image service cannot return data in the requested format.

class bosdyn.client.image.ImageClient[source]

Bases: bosdyn.client.common.BaseClient

Client for the image service.

default_service_name = 'image'
service_type = 'bosdyn.api.ImageService'
list_image_sources(**kwargs)[source]

Obtain the list of ImageSources.

Returns

A list of the different image sources as strings.

Raises

RpcError – Problem communicating with the robot.

list_image_sources_async(**kwargs)[source]

Async version of list_image_sources()

get_image_from_sources(image_sources, **kwargs)[source]

Obtain images from sources using default parameters.

Parameters

image_sources (list of strings) – The different image sources to request images from.

Returns

A list of image responses for each of the requested sources.

Raises
get_image_from_sources_async(image_sources, **kwargs)[source]

Obtain images from sources using default parameters.

get_image(image_requests, **kwargs)[source]

Obtain the set of images from the robot.

Parameters

image_requests (list of ImageRequest) – A list of the ImageRequest protobuf messages which specify which images to collect.

Returns

A list of image responses for each of the requested sources.

Raises
get_image_async(image_requests, **kwargs)[source]

Async version of get_image()

bosdyn.client.image.build_image_request(image_source_name, quality_percent=75, image_format=None)[source]

Helper function which builds an ImageRequest from an image source name.

By default the robot will choose an appropriate format when no image format is provided. For example, it will choose JPEG for visual images, or RAW for depth images. Clients can provide an image_format for other cases.

Parameters
  • image_source_name (string) – The image source to query.

  • quality_percent (int) – The image quality from [0,100] (percent-value).

  • image_format (image_pb2.Image.Format) – The type of format for the image data, such as JPEG, RAW, or RLE.

Returns

The ImageRequest protobuf message for the given parameters.

bosdyn.client.image.write_pgm_or_ppm(image_response, filename='', filepath='.')[source]

Write raw data from image_response to a PGM file.

Parameters
  • image_response (image_pb2.ImageResponse) – The ImageResponse proto to parse.

  • filename (string) – Name of the output file, if None is passed, then “image-{SOURCENAME}.pgm” is used.

  • filepath (string) – The directory to save the image.

bosdyn.client.image.write_image_data(image_response, filename='', filepath='.')[source]

Write image data from image_response to a file.

Parameters
  • image_response (image_pb2.ImageResponse) – The ImageResponse proto to parse.

  • filename (string) – Name of the output file (including the file extension), if None is passed, then “image-{SOURCENAME}.jpg” is used.

  • filepath (string) – The directory to save the image.

bosdyn.client.image.save_images_as_files(image_responses, filename='', filepath='.')[source]

Write image responses to files.

Parameters
  • image_responses (List[image_pb2.ImageResponse]) – The list of image responses to save.

  • filename (string) – Name prefix of the output files (made unique by an integer suffix), if None is passed the image source name is used.

  • filepath (string) – The directory to save the image files.