VideoFile#

class VideoFile(filename: str, **kwargs: Any)[source]#

Iterate images from a video file

Parameters:
  • filename (str) – Path to video file

  • kwargs – options applied to image frames, see convert

The resulting object is an iterator over the frames of the video file. The iterator returns Image objects where:

  • the name attribute is the name of the video file

  • the id attribute is the frame number within the file

If the path is not absolute, the video file is first searched for relative to the current directory, and if not found, it is searched for in the images folder of the mvtb-data package, installed as a Toolbox dependency.

Example:

from machinevisiontoolbox import VideoFile
video = VideoFile("traffic_sequence.mpg")
len(video)
for im in video:
  # process image

or using a context manager to ensure the file handle is always released:

with VideoFile("traffic_sequence.mpg") as video:
    for im in video:
        # process image
References:
Seealso:

convert opencv.VideoCapture

Methods

disp

Display images from the source interactively.

tensor

Convert all images from this source into a single 4D PyTorch tensor.

Attributes