Image and PointCloud sources#

The toolbox provides a variety of sources for these objects. They can be obtained from files, from cameras, from ROS topics and bag files, from the web, and from other sources. The toolbox provides a convenient interface to these sources, and the objects they produce are instances of the Image and PointCloud classes, which have a large number of methods for processing and displaying them.

All provide an iterator interface, so they can be used in a for loop to process a sequence of images or point clouds. For example, to read a video file and display each frame:

from machinevisiontoolbox import VideoFile

for im in VideoFile("myvideo.mp4"):
    im.disp()

All sources also have a read method that returns the next image or point cloud. For example, to read a video file and display each frame:

from machinevisiontoolbox import VideoFile

video = VideoFile("myvideo.mp4")
while True:
    im = video.read()
    if im is None:
        break
    im.disp()

Some sources also have a __getitem__ method that allows you to index into the source to get a specific image or point cloud. For example, to read the 10th frame of a video file:

from machinevisiontoolbox import VideoFile

video = VideoFile("myvideo.mp4")
im = video[9]  # index starts at 0
im.disp()

All sources serve as a context manager, so they can be used in a with statement to ensure that resources are properly released. For example, to read a video file and display each frame:

from machinevisiontoolbox import VideoFile

with VideoFile("myvideo.mp4") as video:
    for im in video:
        im.disp()

All sources have a disp method that displays the image or point cloud using Matplotlib. For example, to read a video file and display each frame:

from machinevisiontoolbox import VideoFile

with VideoFile("myvideo.mp4") as video:
    for im in video:
        im.disp()

All sources have a close method that releases any resources associated with the source. For example, to read a video file and display each frame:

from machinevisiontoolbox import VideoFile

video = VideoFile("myvideo.mp4")
for im in video:
    im.disp()
video.close()

All sources have a tensor method that returns the image or point cloud as a PyTorch tensor. For example, to read a video file and display each frame:

from machinevisiontoolbox import VideoFile

with VideoFile("myvideo.mp4") as video:
    for im in video:
        tensor = im.tensor()
        # do something with the tensor

Image sources#

Image objects can be conveniently obtained from a variety of sources:

ImageSequence

An in-memory sequence of Image objects with interactive display.

FileCollection

Iterate images from a collection of files

FileArchive

Iterate images from a compressed archive

VideoFile

Iterate images from a video file

VideoCamera

Iterate images from a local video camera

WebCam

Iterate images from an internet web camera

EarthView

Iterate images from GoogleEarth

ROSBag

Iterate images and point clouds from a ROS 1 bag file.

ROSTopic

Iterate images from a live ROS topic via a rosbridge WebSocket.

TensorStack

Lazy image source from a PyTorch batch tensor.

LabelMeReader

Read annotations from a LabelMe JSON file.

Deprecated aliases#

These names are kept for backward compatibility and will emit a deprecation warning.

ImageCollection

Deprecated alias for FileCollection.

ZipArchive

Deprecated alias for FileArchive.

PointCloud sources#

PointCloud objects can be conveniently obtained from a variety of sources:

PointCloudSequence

An in-memory sequence of PointCloud objects with interactive display.

ROSBag

Iterate images and point clouds from a ROS 1 bag file.

ROSTopic

Iterate images from a live ROS topic via a rosbridge WebSocket.