diff --git a/pycozmo/client.py b/pycozmo/client.py index 5e254a8..fc64d1e 100644 --- a/pycozmo/client.py +++ b/pycozmo/client.py @@ -47,7 +47,8 @@ def __init__(self, protocol_log_messages: Optional[list] = None, auto_initialize: bool = True, enable_animations: bool = True, - enable_procedural_face: bool = True) -> None: + enable_procedural_face: bool = True, + enable_jpeg_decoding: bool = True) -> None: super().__init__() # Whether to automatically initialize the robot when connection is established. self.auto_initialize = bool(auto_initialize) @@ -93,6 +94,7 @@ def __init__(self, self.client_drop_count = 0 # Camera state self.last_image_timestamp = None + self.enable_jpeg_decoding = enable_jpeg_decoding # Object state self.available_objects = dict() self.connected_objects = dict() @@ -272,12 +274,15 @@ def _process_completed_image(self): else: data = camera.minigray_to_jpeg(data, width, height) - image = Image.open(io.BytesIO(data)).convert('RGB') + if self.enable_jpeg_decoding: + image = Image.open(io.BytesIO(data)).convert('RGB') - # Color images need to be resized to the proper resolution - if is_color_image: - size = camera.RESOLUTIONS[self._partial_image_resolution] - image = image.resize(size) + # Color images need to be resized to the proper resolution + if is_color_image: + size = camera.RESOLUTIONS[self._partial_image_resolution] + image = image.resize(size) + else: + image = data self._latest_image = image self.last_image_timestamp = self._partial_image_timestamp diff --git a/pycozmo/run.py b/pycozmo/run.py index 29d1cef..f6764df 100644 --- a/pycozmo/run.py +++ b/pycozmo/run.py @@ -61,7 +61,8 @@ def connect( robot_log_level: Optional[str] = None, auto_initialize: bool = True, enable_animations: bool = True, - enable_procedural_face: bool = True) -> client.Client: + enable_procedural_face: bool = True, + *args, **kwargs) -> client.Client: setup_basic_logging(log_level=log_level, protocol_log_level=protocol_log_level, robot_log_level=robot_log_level) @@ -70,7 +71,8 @@ def connect( protocol_log_messages=protocol_log_messages, auto_initialize=auto_initialize, enable_animations=enable_animations, - enable_procedural_face=enable_procedural_face) + enable_procedural_face=enable_procedural_face, + *args, **kwargs) cli.start() cli.connect() cli.wait_for_robot()