Video frame views.
Class |
|
A fiftyone.core.view.DatasetView of frames from a video fiftyone.core.dataset.Dataset . |
Class |
|
A frame in a FramesView . |
Function | make |
Creates a dataset that contains one sample per frame in the video collection. |
Variable | fouv |
Undocumented |
Variable | logger |
Undocumented |
Function | _get |
Undocumented |
Function | _init |
Undocumented |
Function | _insert |
Undocumented |
Function | _make |
Undocumented |
Function | _parse |
Undocumented |
Creates a dataset that contains one sample per frame in the video collection.
The returned dataset will contain all frame-level fields and the tags of each video as sample-level fields, as well as a sample_id field that records the IDs of the parent sample for each frame.
By default, sample_frames is False and this method assumes that the frames of the input collection have filepath fields populated pointing to each frame image. Any frames without a filepath populated will be omitted from the frames dataset.
When sample_frames is True, this method samples each video in the collection into a directory of per-frame images and stores the filepaths in the filepath frame field of the source dataset. By default, each folder of images is written using the same basename as the input video. For example, if frames_patt = "%%06d.jpg", then videos with the following paths:
/path/to/video1.mp4 /path/to/video2.mp4 ...
would be sampled as follows:
/path/to/video1/ 000001.jpg 000002.jpg ... /path/to/video2/ 000001.jpg 000002.jpg ...
However, you can use the optional output_dir and rel_dir parameters to customize the location and shape of the sampled frame folders. For example, if output_dir = "/tmp" and rel_dir = "/path/to", then videos with the following paths:
/path/to/folderA/video1.mp4 /path/to/folderA/video2.mp4 /path/to/folderB/video3.mp4 ...
would be sampled as follows:
/tmp/folderA/ video1/ 000001.jpg 000002.jpg ... video2/ 000001.jpg 000002.jpg ... /tmp/folderB/ video3/ 000001.jpg 000002.jpg ...
By default, samples will be generated for every video frame at full resolution, but this method provides a variety of parameters that can be used to customize the sampling behavior.
Note
If this method is run multiple times with sample_frames set to True, existing frames will not be resampled unless you set force_sample to True.
Parameters | |
sample | a
fiftyone.core.collections.SampleCollection |
sampleFalse | whether to assume that the frame images have already been sampled at locations stored in the filepath field of each frame (False), or whether to sample the video frames now according to the specified parameters (True) |
fps:None | an optional frame rate at which to sample each video's frames |
maxNone | an optional maximum frame rate at which to sample. Videos with frame rate exceeding this value are downsampled |
size:None | an optional (width, height) at which to sample frames. A dimension can be -1, in which case the aspect ratio is preserved. Only applicable when sample_frames=True |
minNone | an optional minimum (width, height) for each frame. A dimension can be -1 if no constraint should be applied. The frames are resized (aspect-preserving) if necessary to meet this constraint. Only applicable when sample_frames=True |
maxNone | an optional maximum (width, height) for each frame. A dimension can be -1 if no constraint should be applied. The frames are resized (aspect-preserving) if necessary to meet this constraint. Only applicable when sample_frames=True |
sparse:False | whether to only sample frame images for frame numbers
for which fiftyone.core.frame.Frame instances exist in the
input collection. This parameter has no effect when
sample_frames==False since frames must always exist in order to
have filepath information used |
outputNone | an optional output directory in which to write the sampled frames. By default, the frames are written in folders with the same basename of each video |
relNone | a relative directory to remove from the filepath of
each video, if possible. The path is converted to an absolute path
(if necessary) via fiftyone.core.storage.normalize_path .
This argument can be used in conjunction with output_dir to
cause the sampled frames to be written in a nested directory
structure within output_dir matching the shape of the input
video's folder structure |
framesNone | a pattern specifying the filename/format to use to write or check or existing sampled frames, e.g., "%%06d.jpg". The default value is fiftyone.config.default_sequence_idx + fiftyone.config.default_image_ext |
forceFalse | whether to resample videos whose sampled frames already exist. Only applicable when sample_frames=True |
skipTrue | whether to gracefully continue without raising an error if a video cannot be sampled |
verbose:False | whether to log information about the frames that will be sampled, if any |
name:None | a name for the dataset |
persistent:False | whether the dataset should persist in the database after the session terminates |
_generated | Undocumented |
Returns | |
a fiftyone.core.dataset.Dataset |