Skip to content

Commit

Permalink
make images stored separatedly
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed May 16, 2024
1 parent 15cd2e2 commit 99e7ae9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions tutorial_workspace/fogros2_tutorial/sam_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,21 @@ def handle_response(self, future, camera_type):
# Save a copy of the image sent published
image_stream = BytesIO(msg.data)
image = Image.open(image_stream)
os.makedirs('saved_images', exist_ok=True)
image.save(f'saved_images/original_image_{self.counter}.png', format='PNG')
os.makedirs('base_images', exist_ok=True)
image.save(f'base_images/original_image.png', format='PNG')
image.save(f'base_images/original_image_{self.counter}.png', format='PNG')
self.counter += 1

elif camera_type == 'top':
msg = CompressedImage()
msg.format = 'png'
msg.data = np.array(cv2.imencode('.png', cv_image)[1]).tobytes()
self.publisher_top.publish(msg)
image_stream = BytesIO(msg.data)
image = Image.open(image_stream)
os.makedirs('top_images', exist_ok=True)
image.save(f'top_images/original_image.png', format='PNG')
image.save(f'top_images/original_image_{self.counter}.png', format='PNG')
self.get_logger().info('Top camera image published.')
else:
self.get_logger().info(f'Failed to receive image from {camera_type} camera: ' + response.message)
Expand Down
2 changes: 1 addition & 1 deletion tutorial_workspace/fogros2_tutorial/sam_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self):

self.subscription = self.create_subscription(
CompressedImage,
'/image/base',
'/image/top',
self.listener_callback,
2)

Expand Down

0 comments on commit 99e7ae9

Please sign in to comment.