vuba.FramesGUI

class vuba.FramesGUI(frames, indices=(None, None), *args, **kwargs)[source]

Class for creating interfaces for manipulating a sequence of frames.

Parameters
  • frames (list or ndarray) – Images to manipulate within the interface.

  • indices (tuple) – Frame indices to limit GUI to, especially useful when analysing long sequences of footage. First index will always be interpreted as the minimum index and the second as the maximum index. If None is specified to either limit, then that limit will be ignored. Default is for no limits, i.e. (None, None).

  • title (str) – Title of the interface window.

Returns

gui – Class object for creating the interactive window.

Return type

FramesGUI

Notes

Any gui created with this class will by default have a frame trackbar and corresponding callback for retrieving frames from the sequence provided at initiation (see FramesGUI.read).

Examples

Since the API for creating an interface is the same regardless of footage format, we will demonstrate a basic frame viewer here.

First, let’s create a sequence of binary images that gradually increase in their grayscale value:

>>> import numpy as np
>>> frames = [np.full((500, 500), i, dtype=np.uint8) for i in range(1, 255)]

Now let’s pass these to our basic frame viewer to view the result:

>>> import vuba
>>> import cv2
>>> gui = vuba.FramesGUI(frames, 'Frame viewer')
>>> @gui.method
>>> def blank(gui):
...     # Here we are not doing any image processing as we simply
...     # want to view the individual frames
...     frame = gui.frame.copy()
...     return frame
>>> gui.run()
__init__(frames, indices=(None, None), *args, **kwargs)[source]

Methods

__init__(frames[, indices])

method(func)

Add a main processing function to be executed on every trackbar call.

read(gui, val)

Callback for reading and displaying a frame from the provided frames.

run()

Launch the interface.

trackbar(name, id, min, max)

Add a trackbar to the interactive window.

values()

Retrieve all current trackbar values from the interface.