From 30c6c8499d0df03ce429244649508d03d4baa0b1 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Tue, 30 May 2023 16:09:56 +0200 Subject: [PATCH] try sending image as binary data --- .../api_communication/api_listener.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/api_communication/api_communication/api_listener.py b/src/api_communication/api_communication/api_listener.py index 0d3d4a80..ab2259cb 100644 --- a/src/api_communication/api_communication/api_listener.py +++ b/src/api_communication/api_communication/api_listener.py @@ -133,9 +133,13 @@ class ApiListener(Node): self.get_logger().info("Received result filename: " + result_filename) with open(result_filename, 'rb') as f: self.get_logger().info('Reading image') - base64_img = base64.b64encode(f.read()) - self.message_queue.append(json.dumps( - {'type': ResponseMessage.IMAGE.name, 'image': base64_img.decode('utf-8')})) + read_file = f.read() + # base64_img = base64.b64encode(read_file) + # self.message_queue.append(json.dumps( + # {'type': ResponseMessage.IMAGE.name, 'image': base64_img.decode('utf-8')})) + + # send image as binary file + self.message_queue.append(read_file) except Exception as e: self.get_logger().error('Something went wrong while sending a take picture request and waiting for the response: %r' % (e))