diplomat.utils.frame_store_api.FrameReader

class diplomat.utils.frame_store_api.FrameReader(file: BinaryIO)[source]

Bases: ABC

The frame reader API. Allows for reading frames from a diplomat frame store format to TrackingData object.

abstract __init__(file: BinaryIO)[source]

Construct a frame read frame reader.

Parameters:

file – The file to read frames from.

Methods

__init__(file)

Construct a frame read frame reader.

close()

Close this frame reader.

get_header()

Get the header of this frame store.

has_next([num_frames])

Checks to see if there are more frames available for reading.

read_frames([num_frames])

Read frames from the frame store.

seek_frame(frame_idx)

Seek to the specified frame in the frame store object.

tell_frame()

Get the current frame this frame reader is on.

abstract close()[source]

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

abstract get_header() DLFSHeader[source]

Get the header of this frame store.

Returns:

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

abstract has_next(num_frames: int = 1) bool[source]

Checks to see if there are more frames available for reading.

Parameters:

num_frames – An integer, the number of frames to check for. Defaults to 1 frame.

Returns:

A boolean, True if there are at least num_frames frames available for reading from the file. Otherwise, this method returns False.

abstract read_frames(num_frames: int = 1) TrackingData[source]

Read frames from the frame store.

Parameters:

num_frames – The number of frames to read from the frame store, and integer. Defaults to 1.

Returns:

A DeepLabCut TrackingData object, which will contain all of the probability frames for num_frames frames.

Throws:

ValueError if the frame reader reaches the end of the file and the number of frames requested is greater than the number of frames available in the frame store.

seek_frame(frame_idx: int)[source]

Seek to the specified frame in the frame store object. Implementors of the FrameReader class are not required to support this method, and the default implementation of this method throws a NotImplementedError.

Parameters:

frame_idx – The frame index that the frame reader will move to, an integer.

abstract tell_frame() int[source]

Get the current frame this frame reader is on.

Returns:

An integer, being the index of the frame that the frame reader will be reading next.