Git Product home page Git Product logo

pyoptflow's Introduction

Optical Flow: Horn-Schunck

image Actions Status PyPi Download stats

Python implementation of optical flow estimation using only the Scipy stack for:

  • Horn Schunck

Lucas-Kanade is also possible in the future, let us know if you're interested in Lucas Kanade.

Install

python -m pip install -e .

optionally, to run self-tests:

python -m pip install -e .[tests]

pytest -v

Examples

The program scripts expect directory glob pattern

imageio loads a wide varity of images and video.

Box:

python HornSchunck.py src/pyoptflow/data/tests/box box*.bmp

Office: all time steps:

python HornSchunck.py src/pyoptflow/data/tests/office office*.bmp

or just the first 2 time steps:

python HornSchunck.py src/pyoptflow/data/tests/office office.[0-2].bmp

Rubic:

python HornSchunck.py src/pyoptflow/data/tests/rubic rubic*.bmp

Sphere

python HornSchunck.py src/pyoptflow/data/tests/sphere sphere*.bmp

Compare: Matlab Computer Vision toolbox: in matlab, similar method in Octave and a comparison plot using Matlab Computer Vision toolbox.

Reference:Inspiration

pyoptflow's People

Contributors

ilya-muromets avatar scivision avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyoptflow's Issues

Partial time derivative in Horn Schunck method

Hi,

I have a question regarding the HornSchunck method and the partial time derivative:

ft = im2 - im1

ft = filter2(im1, kernelT) + filter2(im2, -kernelT)

with kernelT = np.ones((2, 2))*.25

If my understanding is correct, you substract the values from the second image from the ones in the first image.
In the Horn und Schunck paper I understood that you are supposed to do it the other way around.

Could you maybe tell me, if I understood it wrong or what the reasoning is to put this the other way around?

I also tried implementing the method myself, and exactly this issue seems to be my problem. If I implemented this with the minus sign in the im2 kernel, my directions are correct. I just donot understand why that is the case.

Thank you and greetings!

Flipped output

Hey,

Nice code!

The output is flipped. You probably have noticed. I fixed that with a simple np.flip.

im1 = np.flip(im1, 0)
im2 = np.flip(im2, 0)

Random question: Would this be suitable for real-time state estimation tasks?

Basically, I'm wondering if you could combine optical flow data from a camera with other sensor data using something like a KF or UKF. The application would be model aircraft, drones or stabilized model rockets. So the optic flow should be due primarily to rotations, translations and perspective effects. The camera would be aligned with one of the vehicles axes and could look at just rotation about that axis, for example.

Basically I'm wondering how fast it is, and if there is a way that you could feed it live data from a camera.

Obviously, I could hunt through the code, so answers that are equally as lazy as my question are welcome, haha!

Couldn't run the script

  File "HornSchunck.py", line 22
    fn1 = f'{stem}.{i}{ext}'
                           ^
SyntaxError: invalid syntax

Above error appears when python HornSchunck.py data/box/box. Tested in Windows and Ubuntu, python 2.7

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.