movis.layer.media.ImageSequence#

class movis.layer.media.ImageSequence(start_times: Sequence[float], end_times: Sequence[float], img_files: Sequence[str | PathLike | Image | ndarray])[source]#

Image sequence layer to encapsulate various formats of images.

Args:
start_times:

a sequence of start times for each image.

end_times:

a sequence of end times for each image.

img_files:

a sequence of image data. Each element can be a file path (str or Path), a PIL.Image object, or a two or four-dimensional numpy.ndarray with a shape of (H, W, C).

Methods

classmethod from_dir(img_dir: str | PathLike, each_duration: float = 1.0) ImageSequence[source]#

Create an ImageSequence object from a directory of image files.

Args:
img_dir:

a directory containing image files.

each_duration:

the duration for which each image should be displayed. Default is 1.0.

Returns:

An ImageSequence object.

classmethod from_files(img_files: Sequence[str | PathLike | Image | ndarray], each_duration: float = 1.0) ImageSequence[source]#

Create an ImageSequence object from a sequence of image files.

Different from ImageSequence.__init__, this method does not require the start and end times, and the duration for each image is set to each_duration.

Args:
img_files:

a sequence of image data. Each element can be a file path (str or PathLike), a PIL.Image object, or a two or four-dimensional numpy.ndarray with a shape of (H, W, C).

each_duration:

the duration for which each image should be displayed. Default is 1.0.

Returns:

An ImageSequence object.

get_key(time: float) int[source]#

Get the state index for the given time.

get_state(time: float) int#

Returns the index of the state at the given time, or -1 if no state exists.

Attributes

duration

Returns the duration of the timeline.