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 (
strorPath), a PIL.Image object, or a two or four-dimensionalnumpy.ndarraywith a shape of(H, W, C).
Methods
- classmethod from_dir(img_dir: str | PathLike, each_duration: float = 1.0) ImageSequence[source]#
Create an
ImageSequenceobject 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
ImageSequenceobject.
- classmethod from_files(img_files: Sequence[str | PathLike | Image | ndarray], each_duration: float = 1.0) ImageSequence[source]#
Create an
ImageSequenceobject 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 toeach_duration.- Args:
- img_files:
a sequence of image data. Each element can be a file path (
strorPathLike), a PIL.Image object, or a two or four-dimensionalnumpy.ndarraywith a shape of(H, W, C).- each_duration:
the duration for which each image should be displayed. Default is
1.0.
- Returns:
An
ImageSequenceobject.
- get_state(time: float) int#
Returns the index of the state at the given time, or
-1if no state exists.
Attributes
durationReturns the duration of the timeline.