machinevisiontoolbox.Sources.VideoFile

class machinevisiontoolbox.Sources.VideoFile(filename, **kwargs)[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
References:
  • Robotics, Vision & Control for Python, Section 11.1.4, P. Corke, Springer 2023.

Seealso:

convert opencv.VideoCapture

__init__(filename, **kwargs)[source]

Methods

__init__