Giter VIP home page Giter VIP logo

optical-flow's Introduction

optical-flow

Pure python implementation of Gunnar Farneback's optical flow algorithm

The flow_iterative function is the implementation of the algorithm. The poly_exp function fits each window of an image to a 2nd order 2D polynomial. Both functions make use of a gaussian applicability window in order to use separable normalized convolution. This also allows for certainty to be included as an input to the algorithm.

The optical flow method implements an optional affine or projective regularization as described by Farneback. Without the regularization, pixels with low certainty (especially those near edges) tend to have large errors, but the regularization may negatively impact the ability to model local optical flow in the images.

Comparing to OpenCV

OpenCV implements a similar algorithm described by Farneback. The included script calculates the optical flow on frames from the "Yosemite" sequence using opencv and this algorithm. To install an environment for running this script, use pipenv or conda:

# Run "pipenv lock --dev" or delete Pipfile.lock first if you 
# want to solve your own environment
pipenv install --dev
pipenv run pre-commit install  # optionally install pre-commit hooks
pipenv run python compare_to_opencv.py
conda env create
conda activate optical-flow

python compare_to_opencv.py

In the script, there are two different options for running the algorithm. The first does not regularize the output with a warp parametrization, and the second uses a projective warp regularization. By switching between the options, you can see the differences in the quality of the warp at the edges and at certain interior points with local flow fields.

No Regularization

no regularization

Projective Regularization

projective regularization

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.