pliers.extractors.FarnebackOpticalFlowExtractor

class pliers.extractors.FarnebackOpticalFlowExtractor(pyr_scale=0.5, levels=3, winsize=15, iterations=3, poly_n=5, poly_sigma=1.2, flags=0, show=False)[source]

Bases: VideoExtractor

Extracts total amount of dense optical flow between every pair of video frames.

Parameters
  • pyr_scale (float) – specifying the image scale (<1) to build pyramids for each image; pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous one.

  • levels (int) – number of pyramid layers including the initial image; levels=1 means that no extra layers are created and only the original images are used.

  • winsize (int) – averaging window size; larger values increase the algorithm robustness to image noise and give more chances for fast motion detection, but yield more blurred motion field.

  • iterations (int) – number of iterations the algorithm does at each pyramid level

  • poly_n (int) – size of the pixel neighborhood used to find polynomial expansion in each pixel; larger values mean that the image will be approximated with smoother surfaces, yielding more robust algorithm and more blurred motion field, typically poly_n =5 or 7.

  • poly_sigma (float) – standard deviation of the Gaussian that is used to smooth derivatives used as a basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a good value would be poly_sigma=1.5.

  • flags (int) – operation flags, usually OPTFLOW_USE_INITIAL_FLOW or OPTFLOW_FARNEBACK_GAUSSIAN

  • show (bool) – flag for displaying flow image during extraction

__init__(pyr_scale=0.5, levels=3, winsize=15, iterations=3, poly_n=5, poly_sigma=1.2, flags=0, show=False)[source]
transform(stim, *args, **kwargs)

Executes the transformation on the passed stim(s).

Parameters
  • stims (str, Stim, list) –

    One or more stimuli to process. Must be one of:

    • A string giving the path to a file that can be read in as a Stim (e.g., a .txt file, .jpg image, etc.)

    • A Stim instance of any type.

    • An iterable of stims, where each element is either a string or a Stim.

  • validation (str) –

    String specifying how validation errors should be handled. Must be one of:

    • ’strict’: Raise an exception on any validation error

    • ’warn’: Issue a warning for all validation errors

    • ’loose’: Silently ignore all validation errors

  • args – Optional positional arguments to pass onto the internal _transform call.

  • kwargs – Optional positional arguments to pass onto the internal _transform call.