Giter VIP home page Giter VIP logo

mrflow's Introduction

MR-FLOW: Optical Flow for Mostly Rigid Scenes

This software package contains the MR-Flow optical flow algorithm, as described in Wulff, Sevilla, and Black, "Optical Flow for Mostly Rigid Scenes" (CVPR 2017).

MR-Flow splits the scene into moving objects and the static scene, uses general optical flow for the moving parts, and strong geometric constraints in the static scene.

Note that due to some small bugfixes and changes in the codebase, the results can differ slightly from those given in the paper.

We hope this software is useful to you. If you have any questions, comments, or issues, please do not hesitate to contact us.

Installation

Requirements

Except OpenCV, all other packages can be installed via PIP.

Installation

To use MR-Flow, please set the $MRFLOW_HOME environment variable to the root directory (where this file is located).

MR-Flow uses Karteek Alahari's Efficient TRWS code, which is included in this package. To compile the Cython extension, simply run build_trws.sh in the main directory.

After that, you can test MR-Flow as

python mrflow.py --no_init example/frame1.png example/frame2.png example/frame3.png

Usage

The recommended way to call MR-Flow as

python mrflow.py \
  --rigidity RIGIDITYMAP.png \
  --flow_fwd FLOW_FWD.flo \
  --flow_bwd FLOW_BWD.flo \
  --backflow_fwd BACKFLOW_FWD.flo \
  --backflow_bwd BACKFLOW_BWD.flo \
  IMAGE1 IMAGE2 IMAGE3

This will compute the optical flow from IMAGE2 to IMAGE3. MR-Flow will save the resulting optical flow, the structure, and some visualizations to the current directory.

Some important flags are

  • --rigidity RIGIDITYMAP : Use pre-computed rigidity, for example given by a semantic segmentation CNN. RIGIDITYMAP has to be a monochrome PNG, where black denotes a moving object and white denotes the static scene. Note that the rigiditymap does not have to be binary; values between 0 and 1 are interpreted as probabilties for a pixel to be part of the static scene.
  • --flow_fwd FLOW_FWD : Initial flow from IMAGE2 to IMAGE3. Note that if not all initial flow fields are given, the initial flow is computed using DiscreteFlow.
  • --flow_bwd FLOW_BWD : Initial flow from IMAGE2 to IMAGE1.
  • --backflow_fwd BFLOW_FWD : Initial flow from IMAGE3 to IMAGE2.
  • --backflow_bwd BFLOW_BWD : Initial flow from IMAGE1 to IMAGE2.
  • --no_init : Omit the initializations that are not given. Instead, use DiscreteFlow to compute the initial optical flow maps, and use a uniform prior for the rigidity estimate. If you omit the initialization, do not expect comparable performance to the paper. If both --no_init is given and some initialization is provided (e.g. by calling python mrflow.py --no_init --rigidity RIGIDITMAP.png ...), the initialization that is given is still used.
  • --tempdir TDIR : Alternative output directory
  • --override_optimization 1 : Do not perform variational structure refinement. Often this gives sufficient accuracy, at a much lower computational cost.

For further flags and parameters, please see the file parameter.py.

Rigidity maps

The CNNs to estimate the rigidity maps in the paper are available here.

Citation

If you use MR-Flow, please cite the following paper:

@inproceedings{Wulff:CVPR:2017,
title = {Optical Flow in Mostly Rigid Scenes},
author = {Wulff, Jonas and Sevilla-Lara, Laura and Black, Michael J.},
booktitle = {IEEE Conf. on Computer Vision and Pattern Recognition (CVPR)},
month = jul,
year = {2017},
month_numeric = {7}
}

License

See LICENSE.md for licensing issues and details.

This packages contains code from the paper

"Reduce, Reuse & Recycle: Efficiently Solving Multi-Label MRFs"
Karteek Alahari, Pushmeet Kohli, Philip H. S. Torr
In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2008. 

The code is contained in the directory extern/eff_trws. For licensing details regarding this code, please see extern/eff_trws/eff_mlabel_ver1/README.txt.

Contact

If you run into any issues with MR-Flow, please do not hesitate to contact us at [email protected].

mrflow's People

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

mrflow's Issues

Exception when computing structure

I got this error when trying to run the program on my own frames. I ran with the --no_init option and provided three frames as specified. My images basically have a more or less still background with moving human subject (essentially the first few seconds of this video from Ellen Degeneres as a test for our later use cases)

==== EXCEPTION ====
Traceback (most recent call last):
  File "mrflow.py", line 111, in compute_mrflow
    params)
  File "/Users/jg/repositories/mrflow/pipeline/compute_structure.py", line 429, in compute_structure
    raise Exception('TooFewStructureMatches')
Exception: TooFewStructureMatches

CNN Rigidity estimation

Hi, I want to run mrflow.py for my frames. It is written that initialization with flows and rigidity image gives more accurate estimate. I want to ask if I give parameter --no_init, mrflow.py would still use CNN for estimating rigidity or not.

RuntimeWarning: invalid value encountered in sqrt

Thank you so much for sharing code.
When I run the demo code:
python mrflow.py --no_init example/frame1.png example/frame2.png example/frame3.png

It raised this error:

mrflow.py:189: RuntimeWarning: invalid value encountered in sqrt
flowdiff = np.sqrt((u-uinit)**2 + (v-vinit)**2)

sqrt returns this error when we square root a negative number. (u-uinit)**2 + (v-vinit)**2 is always possitive, I don't know why it returns the error.

Code modification issue

Can I use this code to calculate optical flow for a video recorded from a camera fixed on the dashboard of a car?
Also. can I modify the code to calculate the optical flow between 2 images only or this modification will affect the accuracy greatly?

rigidity maps ?

hello and thanks for the code!
are you planning to publish your code to generate the rigidity maps ?
or are there existing projects to do that already available .. ?
thanks in advance
luc

How to get good results

I struggle to get some decent results on real life pictures/videos.
Blur looks like a significant issue bt maybe I a not using the algo properly. I am just usin the test syntax line from the readme so far.
Can you give some tweaks/advices to get better results if possible?

I attach the best test I got so far but I did expect some better rigidity map given the video you published a day ago.
img2
img1
img3
comparison
structure

Missing avg_train_image.npy?

I was following the instruction in the README.txt inside semantic_rigidity_cvpr2017. When I tried running python do_deeplab_segmentation.py TEST deeplab_deploy.prototxt deeplab_adam_0.0001_iter_1400.caffemodel . it gives me the following error

FileNotFoundError: [Errno 2] No such file or directory: avg_train_image.npy

Can not run example

Hi, first thanks for your work ad for sharing it.

I am trying to execute your example but I have the following error message. It seems it may relate to the env variable but I think I did export it properly. Can you help?below the shell outputs when executing:

tets:~/mrflow-master$ sudo python mrflow.py --no_init example/frame1.png example/frame2.png example/frame3.png
Traceback (most recent call last):
  File "mrflow.py", line 11, in <module>
    MRFLOW_HOME = os.environ['MRFLOW_HOME']
  File "/usr/lib/python2.7/UserDict.py", line 40, in __getitem__
    raise KeyError(key)
KeyError: 'MRFLOW_HOME'
tets:~/mrflow-master$ $MRFLOW_HOME/
bash: /home/tets/mrflow-master/: Is a directory

Tets

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.