Skip to main content

Logo

PyPI version PyPI monthly downloads GitHub issues
Toolkit to generate customized visualizations related to optical flow
PyPI page · Installation · Examples · Presets

color_flow result color_epe result flow_arrows result

Table of contents

flowvid is a toolkit for all things related to optical flow. It comes with many visualization presets you can generate with no effort (see below), but it also allows for more complex data manipulation that doesn't have to imply generating a visualization (see examples).

Installation

flowvid is available as a PyPI package:

pip3 install flowvid

Or you can install it directly from Github:

pip3 install git+https://github.com/diegoroyo/flowvid/

or you can clone the repo:

git clone https://github.com/diegoroyo/flowvid.git
cd flowvid
scripts/local_install.sh

You might need to install the following dependencies:

pip3 install imageio imageio-ffmpeg numpy matplotlib Pillow
# or if you use the provided requirements.txt
pip3 install -r requirements.txt

Quick start

Flowvid is a python library for video generation, but it also contains several video presets with an user-friendly assistant:

  • Usage: python3 -m flowvid <preset> [ <config-params> | --config <config-file> ]
  • Presets can be listed using python3 -m flowvid -h
Preset can be one of:
  color_flow: Convert flow data to RGB using the Middlebury representation
  color_epe: Calculate endpoint error and generate a video representation
  flow_arrows: Draw arrows representing optical flow over a video
  plot_epe: Generate a pyplot plot with the EPE distribution in all frames
  track_points: Place points in a image and see how flow moves them
  track_side_by_side: Place points in a image and see how flow can track them
  • Example: converting flow files to rgb and saving into a video
$ python3 -m flowvid color_flow

# \/ option names are shown here
[--flo-dir] Flow files directory (default: flo): path/to/flo/dir
[--norm-type] Vector normalization type (video, [frame], none): video
[--norm-clamp] Normalization clamp percentage (default: 1.0): 0.8
[--norm-gamma] Normalization gamma curve exponent (default: 1.0): 1.5
[--output-type] Output type ([video], pyplot): pyplot
[--output-framerate] Video framerate (default: 10): 10

You can specify its parameters via the command line. The following is equivalent:

# Option names can be listed with python3 -m flowvid --help
$ python3 -m flowvid color_flow
    --flo-dir path/to/flo/dir
    --norm-type video
    --norm-clamp 0.8
    --norm-gamma 1.5
    --output-type pyplot
    --output-framerate 10

Configuration can also be saved in a file so you don't have to type it always:

# Store configuration after use
$ python3 -m flowvid color_flow --flo-dir path/to/flo/dir (...)

Save configuration in a file? (y, [n]): y
Output configuration filename (default: preset_color_flow.yaml): path/to/config.yaml

Saved configuration file in path/to/config.yaml

(...)

# Load from a file
$ python3 -m flowvid color_flow --config path/to/config.yaml

color_flow result

Here are some examples illustrating the other presets' results:

color_epe plot_epe
color_epe result plot_epe result
track_points track_side_by_side
track_points result track_side_by_side result
flow_arrows (1) flow_arrows (2)
flow_arrows result flow_arrows result

Python library

If you want to generate more complex or customized videos, you can easily use flowvid's tools:

import flowvid as fv

# Convert multiple optical flow files to their color representation,
# and save them to a video (.mp4) file.
# Similar to `color_flow` preset, without the extra options

# Read flow files data
flo_data = fv.input.flo('path/to/flo/dir')

# Normalize each file (so max flow's module is 1),
# necessary to convert to RGB
flo_data = fv.normalize_frame(flo_data)
rgb_data = fv.flow_to_rgb(flo_data)

# Output as video
out = fv.output.video(filename='output.mp4', framerate=24)
out.add_all(rgb_data)

The given code's structure and information flows (flo/rgb data) can be represented with the following nodes:

color_flow code representation using nodes

Acknowledgements

C. Liu. Beyond Pixels: Exploring New Representations and Applications for Motion Analysis. Doctoral Thesis. Massachusetts Institute of Technology. May 2009.

Release files for flowvid 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flowvid 0.4.1
File Size Uploaded
flowvid-0.4.1.tar.gz 30.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flowvid 0.4.1
File Interpreter ABI Platform
flowvid-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 90.5 kB

Release files / flowvid-0.4.1.tar.gz

Download URL flowvid-0.4.1.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
36cdd48e4b4419366e37a7e2b43df1e8725283db84f91a3c4632ced7e428c996
BLAKE2b-256 checksum
How to use checksums
74d5b943f34da46d82040757c8d6bbec0ba1b2b66f6760cab39bd9f71e572e9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

Release files / flowvid-0.4.1-py3-none-any.whl

Download URL flowvid-0.4.1-py3-none-any.whl
Size 59.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
851db8705337fca1b973198fa925bff8dcb01e88d6e28eba9d0523edcd264396
BLAKE2b-256 checksum
How to use checksums
98ea84859d29601e5eb322e893044ffbd733b78d83397d11258a6b11620165f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page