diplomat.utils.extract_frames.extract_n_pack

diplomat.utils.extract_frames.extract_n_pack(dlfs_in: BinaryIO, frames: Sequence[int], threshold: float = 1e-06, compression_lvl: int = 6, on_frames: Optional[Callable[[TrackingData], None]] = None) bytes[source]

Extract frames from a DLC Frame Store file and pack them into a base64 encoded byte string.

Parameters
  • dlfs_in – A binary file, the input DeepLabCut frame store file. Frames will be extracted from this file.

  • frames – A sequence of integers, the indexes of the frames to extract, in order of extraction.

  • threshold – A float between 0 and 1, inclusive. The frame sparsification threshold, any probabilities below the threshold are ignored. If set to 0, sparsification of frames is disabled. Default is 1e6.

  • compression_lvl – An integer between 0 and 9, inclusive. The compression level if using the .dlfs format. Default is 6.

  • on_frames – A function that accepts a TrackingData for each frame. Useful for pretty printing/doing something with the data during rewrite. Defaults to None, meaning it is not called.

Returns

A bytes object, being a base64 encoded DLFS or HDF5 frame store file.