Skip to content

Processors

Image processor

load_image(path, greyscale=False, scale=None)

Load an image file.

Parameters:

Name Type Description Default
path Path

The path to the image.

required
greyscale bool

If True, the image will be converted to greyscale.

False
scale float

Scale the image.

None

Returns:

Type Description
ndarray

The image as a NumPy array.

RGB video processor

VideoLoader

__init__(path, greyscale=True, scale=None, height=None, width=None, fps=30, codec='h264')

A convenience class for loading video files or directories of images as frames.

Parameters:

Name Type Description Default
path str | Path

Save path.

required
greyscale bool

Greyscale toggle

True
scale float | None

Scale of the frame.

None
height int | None

Frame height.

None
width int | None

Frame width.

None
fps int

The FPS of the video.

30
codec str

The video codec.

'h264'

preview(index=0)

Preview the first frame of the input.

Returns:

Type Description
figure

A frame as a NumPy array.

size property

Frame size.

Returns:

Type Description
tuple[int, ...]

The frame size as a tuple (height, width).

VideoRecorder

__init__(fpath, height, width, function, codec=None, fps=30)

Create an animation from a buffer of stored activations.

Parameters:

Name Type Description Default
fpath str | Path

Local file path.

required
height int

Frame height.

required
width int

Frame width.

required
function Callable

Frame factory function.

required
codec str | None

The codec to use.

None
fps int

FPS for the output video.

30

size property

Return the size of the frame.

Returns:

Type Description
tuple[int, int]

The size as a tuple (height, width)