Skip to content

Commit 8ec6326

Browse files
committed
fix: send the image index along with time and metadata when saving image
1 parent 595df27 commit 8ec6326

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/crappy/blocks/camera.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ class Camera(Block):
2828
can accept input Links is when an ``image_generator`` is defined, or when
2929
defining a ``software_trig_label``. If ``save_images`` is set to :obj:`True`,
3030
and if an output Link is present, a message is sent to downstream Blocks at
31-
each saved image, containing the timestamp and the metadata of the image.
32-
They are respectively carried by the `'t(s)'` and `'meta'` labels. This is
33-
useful for performing an action conditionally at each new saved image.
31+
each saved image, containing the timestamp, the index, and the metadata of
32+
the image. They are respectively carried by the `'t(s)'`, `'img_index'` and
33+
`'meta'` labels. This is useful for performing an action conditionally at
34+
each new saved image.
3435
3536
Most of the time, this Block is used for recording to the desired location
3637
the images it acquires. Optionally, the images can also be displayed in a

src/crappy/blocks/camera_processes/record.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def __init__(self,
7171
backend ``'npy'``, that saves the images as raw numpy arrays.
7272
send_msg: In case no processing is performed, and if output Links are
7373
present, this argument is set to :obj:`True`. In that case, a message
74-
containing the timestamp and the metadata of the image is sent to
75-
downstream Blocks each time an image is saved.
74+
containing the timestamp, the index, and the metadata of the image is
75+
sent to downstream Blocks each time an image is saved.
7676
7777
.. versionadded:: 2.0.5
7878
"""
@@ -241,4 +241,6 @@ def loop(self) -> None:
241241

242242
# Sending the results to the downstream Blocks
243243
if self._send_msg:
244-
self.send({'t(s)': self.metadata['t(s)'], 'meta': self.metadata})
244+
self.send({'t(s)': self.metadata['t(s)'],
245+
'img_index': self.metadata['ImageUniqueID'],
246+
'meta': self.metadata})

0 commit comments

Comments
 (0)