Skip to main content

Optical Flow video tools

Project description

Logo

Toolkit to generate customized visualizations related to optical flow (beta 0.3.0)
PyPI page · Installation · Examples · Presets

color_flow result color_epe result flow_arrows result

Table of contents

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:

  • Presets can be listed using python3 -m flowvid -h
$ python3 -m flowvid -h

usage: flowvid [-h] preset

Generate an optical flow visualization using the available presets.

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
  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

positional arguments:
  preset      Video preset, see above.

optional arguments:
  -h, --help  show this help message and exit
  • Example: converting flow files to rgb and saving into a video
$ python3 -m flowvid color_flow

Flow files directory (default: flo): path/to/flo/dir 
Vector normalize type (video, [frame], none): video
Normalization clamp percentage (default: 1.0): 0.8
Normalization gamma curve exponent (default: 1.0): 1.5
Video framerate (default: 24): 12
Output video name (default: output_color_flow.mp4): flowcolors.mp4 

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

# 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)

Acknowledgements

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flowvid, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size flowvid-0.3.0-py3-none-any.whl (54.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flowvid-0.3.0.tar.gz (25.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page