sleap.io.asyncvideo#

Support for loading video frames (by chunk) in background process.

class sleap.io.asyncvideo.AsyncVideo(base_port: int = 9010)[source]#

Supports fetching chunks from video in background process.

property chunks: Iterator[Tuple[List[int], numpy.ndarray]]#

Generator for fetching chunks of frames.

When all chunks are loaded, closes the server and communication ports.

Yields

Tuple with (list of frame indices, ndarray of frames)

close()[source]#

Close the async video server and communication ports.

classmethod from_video(video: sleap.io.video.Video, frame_idxs: Optional[Iterable[int]] = None, frames_per_chunk: int = 64) sleap.io.asyncvideo.AsyncVideo[source]#

Create object and start loading frames in background process.

load_by_chunk(video: sleap.io.video.Video, frame_idxs: Optional[Iterable[int]] = None, frames_per_chunk: int = 64)[source]#

Sends request for loading video in background process.

Parameters
  • video – The Video to load

  • frame_idxs – Frame indices we want to load; if None, then full video is loaded.

  • frames_per_chunk – How many frames to load per chunk.

Returns

None, data should be accessed via :py:method:`chunks`.

class sleap.io.asyncvideo.AsyncVideoServer(base_port: int)[source]#

Class which loads video frames in background on request.

All interactions with video server should go through AsyncVideo which runs in local thread.

run()[source]#

Method to be run in sub-process; can be overridden in sub-class