machinevisiontoolbox.Sources.ImageCollection

class machinevisiontoolbox.Sources.ImageCollection(filename=None, loop=False, **kwargs)[source]

Iterate images from a collection of files

Parameters:
  • filename (str) – wildcard path to image files

  • loop (bool, optional) – Endlessly loop over the files, defaults to False

  • kwargs – options applied to image frames, see convert

The resulting object is an iterator over the image files that match the wildcard description. The iterator returns Image objects where the name attribute is the name of the image 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 FileColletion
>>> images = FileCollection('campus/*.png')
>>> len(images)
>>> for image in images:  # iterate over images
>>>   # process image

alternatively:

>>> img = files[i]  # load i'th file from the collection
References:
  • Robotics, Vision & Control for Python, Section 11.1.2, P. Corke, Springer 2023.

Seealso:

convert cv2.imread

__init__(filename=None, loop=False, **kwargs)[source]

Methods

__init__