diplomat.utils.frame_store_api.FrameWriter

class diplomat.utils.frame_store_api.FrameWriter(file: BinaryIO, header: DLFSHeader, threshold: float | None = 1e-06)[source]

Bases: ABC

The frame writer API. Allows for writing frames in the form of TrackingData objects to a diplomat frame store format.

abstractmethod __init__(file: BinaryIO, header: DLFSHeader, threshold: float | None = 1e-06)[source]

Create a new frame writer.

Parameters:
  • file – A binary frame object, the file to write the frames to.

  • header – The DLFSHeader for this frame store, contains important metadata.

  • threshold – The minimum threshold for keeping probabilities. If set to None, this indicates to the frame writer that the probability frames should be stored in a non-sparse way. Defaults to 1e-6.

Methods

__init__(file, header[, threshold])

Create a new frame writer.

close()

Close this frame writer.

get_header()

Get the header of this frame writer.

tell_frame()

Get the current frame this frame writer is on.

write_data(data)

Write data to the file using this frame writer.

abstractmethod close()[source]

Close this frame writer. This does not close the file handler that this frame writer is utilizing, simply the frame writer itself.

abstractmethod get_header() DLFSHeader[source]

Get the header of this frame writer.

Returns:

A DLFSHeader object, which contains important metadata for this frame writer.

abstractmethod tell_frame() int[source]

Get the current frame this frame writer is on.

Returns:

An integer, being the index of the frame that the frame writer will be writing next.

abstractmethod write_data(data: TrackingData)[source]

Write data to the file using this frame writer.

Parameters:

data – A TrackingData object, being the frames to write to the file.

Throws:

ValueError if there is an attempt to write more frames than the total number of frames specified in the DLFSHeader passed when this frame writer was created.