Capture Object

By default, all image and video capture data are stored to instances of openflexure_microscope.captures.CaptureObject. This class mostly wraps up complexity associated with moving data between disk and memory.

The class also includes some convenience features such as handling metadata tags and file names, and generating image thumbnails. Additionally, the class handles storing capture metadata to Exif tags in supported formats.

Below are details of available methods and attributes.

class openflexure_microscope.captures.capture.CaptureObject(filepath: str)[source]

File-like object used to store and process on-disk capture data, and metadata. Serves to simplify modifying properties of on-disk capture data.

id = None

Unique capture ID

Type:str
split_file_path(filepath: str)[source]

Take a full file path, and split it into separated class properties.

Parameters:filepath (str) – String of the full file path, including file format extension
exists

Check if capture data file exists on disk.

put_tags(tags: List[str])[source]

Add a new tag to the tags list attribute.

Parameters:tags (list) – List of tags to be added
delete_tag(tag: str)[source]

Remove a tag from the tags list attribute, if it exists.

Parameters:tag (str) – Tag to be removed
put_annotations(data: Dict[str, str])[source]

Merge annotations from a passed dictionary into the capture metadata, and saves.

Parameters:data (dict) – Dictionary of metadata to be added
put_metadata(data: dict)[source]

Merge root metadata from a passed dictionary into the capture metadata, and saves.

Parameters:data (dict) – Dictionary of metadata to be added
put_and_save(tags: Optional[List[str]] = None, annotations: Optional[Dict[str, str]] = None, dataset: Optional[Dict[str, str]] = None, metadata: Optional[dict] = None)[source]

Batch-write tags, metadata, and annotations in a single disk operation

metadata

Create basic metadata dictionary from basic capture data, and any added custom metadata and tags.

data

Return a BytesIO object of the capture data.

binary

Return a byte string of the capture data.

thumbnail

Returns a thumbnail of the capture data, for supported image formats.

save()[source]

Write stream to file, and save/update metadata file

delete() → bool[source]

If the StreamObject has been saved, delete the file.