class documentation
class VideoDataSet(AbstractDataSet[
VideoDataSet loads / save video data from a given filepath as sequence of PIL.Image.Image using OpenCV.
Example usage for the YAML API:
cars: type: video.VideoDataSet filepath: data/01_raw/cars.mp4 motorbikes: type: video.VideoDataSet filepath: s3://your_bucket/data/02_intermediate/company/motorbikes.mp4 credentials: dev_s3
Example usage for the Python API:
>>> from kedro.extras.datasets.video import VideoDataSet >>> import numpy as np >>> >>> video = VideoDataSet(filepath='/video/file/path.mp4').load() >>> frame = video[0] >>> np.sum(np.asarray(frame))
Example creating a video from numpy frames using Python API:
>>> from kedro.extras.datasets.video.video_dataset import VideoDataSet, SequenceVideo >>> import numpy as np >>> from PIL import Image >>> >>> frame = np.ones((640,480,3), dtype=np.uint8) * 255 >>> imgs = [] >>> for i in range(255): >>> imgs.append(Image.fromarray(frame)) >>> frame -= 1 >>> >>> video = VideoDataSet("my_video.mp4") >>> video.save(SequenceVideo(imgs, fps=25))
Example creating a video from numpy frames using a generator and the Python API:
>>> from kedro.extras.datasets.video.video_dataset import VideoDataSet, GeneratorVideo >>> import numpy as np >>> from PIL import Image >>> >>> def gen(): >>> frame = np.ones((640,480,3), dtype=np.uint8) * 255 >>> for i in range(255): >>> yield Image.fromarray(frame) >>> frame -= 1 >>> >>> video = VideoDataSet("my_video.mp4") >>> video.save(GeneratorVideo(gen(), fps=25, length=None))
Method | __init__ |
Creates a new instance of VideoDataSet to load / save video data for given filepath. |
Method | _describe |
Undocumented |
Method | _exists |
Undocumented |
Method | _load |
Loads data from the video file. |
Method | _save |
Saves video data to the specified filepath. |
Method | _write |
Undocumented |
Instance Variable | _filepath |
Undocumented |
Instance Variable | _fourcc |
Undocumented |
Instance Variable | _fs |
Undocumented |
Instance Variable | _protocol |
Undocumented |
Instance Variable | _storage |
Undocumented |
Inherited from AbstractDataSet
:
Class Method | from |
Create a data set instance using the configuration provided. |
Method | __str__ |
Undocumented |
Method | exists |
Checks whether a data set's output already exists by calling the provided _exists() method. |
Method | load |
Loads data by delegation to the provided load method. |
Method | release |
Release any cached data. |
Method | save |
Saves data by delegation to the provided save method. |
Method | _copy |
Undocumented |
Method | _release |
Undocumented |
Property | _logger |
Undocumented |
def __init__(self, filepath:
str
, fourcc: Optional[ str]
= 'mp4v', credentials: Dict[ str, Any]
= None, fs_args: Dict[ str, Any]
= None):
(source)
¶
Creates a new instance of VideoDataSet to load / save video data for given filepath.
Parameters | |
filepath:str | The location of the video file to load / save data. |
fourcc:Optional[ | The codec to use when writing video, note that depending on how opencv is installed there might be more or less codecs avaiable. If set to None, the fourcc from the video object will be used. |
credentials:Dict[ | Credentials required to get access to the underlying filesystem.
E.g. for GCSFileSystem it should look like {"token": None} . |
fsDict[ | Extra arguments to pass into underlying filesystem class constructor
(e.g. {"project": "my-project"} for GCSFileSystem). |
overrides
kedro.io.AbstractDataSet._load
Loads data from the video file.
Returns | |
AbstractVideo | Data from the video file as a AbstractVideo object |