Giter VIP home page Giter VIP logo

pcaflow's Introduction

PCA-Flow: Fast, approximate optical flow computation

UPDATE (05/29/2022): Due to the legacy character of this codebase, please make sure to use Python2.

This software package contains two algorithms for the computation of optical flow, as described in Wulff & Black, "Efficient Sparse-to-Dense Optical Flow Estimation using a Learned Basis and Layers" (CVPR 2015).

PCA-Flow computes approximate optical flow extremely fast, by making the assumption that optical flow lies on a low-dimensional subspace.

PCA-Layers extends this to a layered model to increase accuracy, especially at boundaries.

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

  • Python2
  • OpenCV >= 3.0-rc1 with Python bindings
  • OpenBlas
  • Scientific Python stack with NumPy, SciPy, Scikit-Learn, Cython, and Matplotlib.

The easiest way to get the required scientific Python stack is to install a distribution such as Anaconda.

A note about libviso2

In order to obtain the best results, we recommend using the libviso2 features as described in

@INPROCEEDINGS{Geiger2011IV,
  author = {Andreas Geiger and Julius Ziegler and Christoph Stiller},
  title = {StereoScan: Dense 3D Reconstruction in Real-time},
  booktitle = {Intelligent Vehicles Symposium (IV)},
  year = {2011}
} 

These features can be downloaded from http://cvlibs.net/software/libviso. Simply place the file libviso2.zip in the root directory (where the readme.md is). The build.sh script will then build the necessary extension.

If you can or do not want to use libviso2, PCA-flow will fall back onto A-AKAZE features (see http://www.robesafe.com/personal/pablo.alcantarilla/kaze.html for details), which are included in OpenCV.

Installation

If all the requirements are satisfied, run build.sh to check dependencies, and build the necessary local libraries.

After that, you can test PCA-Flow with

python demo.py

The file demo.py contains further details on how to use PCA-Flow and PCA-Layers.

Examples

demo.py

demo.py can be run without any parameters, and shows how to use PCA-Flow in a Python program.

compute_flow.py

compute_flow.py [PARAMETER] IMAGE1 IMAGE2 OUTFILE can be used to compute the flow between two arbitrary frames IMAGE1 and IMAGE2 and write the output flow to OUTFILE. PARAMETER can be a combination of the following settings:

  • -kitti/-sintel: Use optimized parameters for specific dataset.
  • -pcaflow/-pcalayers: Compute flow using PCA-Flow or PCA-Layers.
  • If no parameters are given, the settings -sintel -pcalayers are used.

Example: python compute_flow.py -kitti -pcaflow image1.png image2.png output.flo.

compute_flow_directory.py

compute_flow_directory.py [PARAMETER] INDIR OUTDIR can be used to compute the flow for all files in directory INDIR and write the output flow files to OUTDIR. PARAMETER can be a combination of the following settings:

  • -kitti/-sintel: Use optimized parameters for specific dataset.
  • -pcaflow/-pcalayers: Compute flow using PCA-Flow or PCA-Layers.
  • If no parameters are given, the settings -sintel -pcalayers are used.

Example: python compute_flow_directory.py -kitti -pcaflow ~/sintel/training/final/alley_1 ~/sintel_flow/alley_1/

Citation

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

@inproceedings{Wulff:CVPR:2015,
  title = {Efficient Sparse-to-Dense Optical Flow Estimation using a Learned Basis and Layers},
  author = {Wulff, Jonas and Black, Michael J.},
  booktitle = { IEEE Conf. on Computer Vision and Pattern Recognition (CVPR) 2015},
  month = jun,
  year = {2015}
}

License

See LICENSE.md for licensing issues and details.

Contact

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

pcaflow's People

Contributors

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

Watchers

 avatar  avatar  avatar  avatar  avatar

pcaflow's Issues

IndexError: only integers, slices (`:`)

Hello,

Your code looks awesome! I'm trying to get it running on my machine, and I'm bumping into this error: not sure what I'm doing wrong?

On a Linux Ubuntu 16.04 machine, ran the build.sh script, appear to have prerequisites installed.
Running
python compute_flow.py -kitti -pcaflow image1.png image2.png output.flo as shown:

(py2) anthony@aZ68MA-D2H-B3:/media/anthony/CA80455D8045515D/code-2tb/pcaflow$ python compute_flow.py -kitti -pcaflow image1.png image2.png output.flo
/media/anthony/CA80455D8045515D/code-2tb/pcaflow/pcaflow
*** LOADING PRESET pcaflow_kitti ***

[PARAMETERS MAIN]

	NC: 	500
	SUBLAYER_NC: 	200
	SUBLAYER_lambda: 	0.02
	SUBLAYER_sigma: 	0.95
	debug: 	0
	em_additional_remove_outliers: 	0
	em_init_loc_weight: 	0.4
	features: 	libviso
	features_clahe: 	1
	features_fast_limit: 	-1
	features_libviso_bucket_size: 	50
	features_libviso_buckets_x: 	8
	features_libviso_buckets_y: 	4
	features_libviso_half_resolution: 	0
	features_libviso_match_binsize: 	50
	features_libviso_match_disp_tolerance: 	1
	features_libviso_match_radius: 	200
	features_libviso_multi_stage: 	1
	features_libviso_multiscale: 	0
	features_libviso_n_scales: 	2
	features_libviso_nms_n: 	5
	features_libviso_nms_tau: 	25
	features_libviso_outlier_disp_tolerance: 	5
	features_libviso_outlier_flow_tolerance: 	7
	features_libviso_refinement: 	1
	features_prune_border: 	0.05
	image_blur: 	5
	lambda: 	0.4
	model_color_n_mixtures: 	1
	model_factor_dist_to_median: 	0.008
	model_gamma: 	350.0
	model_gamma_c: 	5.0
	model_gamma_l: 	6.5
	model_gamma_warp: 	1.0
	model_sigma_w: 	300.0
	n_models: 	1
	remove_homography: 	0
	sigma: 	0.55
Initializing matcher...
NC: 
500
NC_MAX_PER: 
250
WARNING: Image changed size. (0,0 => 435,1024).
Re-allocating matcher...
Traceback (most recent call last):
  File "compute_flow.py", line 67, in <module>
    main()
  File "compute_flow.py", line 59, in main
    u,v = P.compute_flow()
  File "/media/anthony/CA80455D8045515D/code-2tb/pcaflow/pcaflow/PCAFlow.py", line 315, in compute_flow
    kp1_,kp2_ = self.feature_matcher.get_features()
  File "/media/anthony/CA80455D8045515D/code-2tb/pcaflow/pcaflow/features/FeatureMatcherLibviso.py", line 175, in get_features
    feats_I1,feats_I2 = self.prune_second_stage(feats_I1.copy(),feats_I2.copy(),self.w,self.h) 
  File "/media/anthony/CA80455D8045515D/code-2tb/pcaflow/pcaflow/features/FeatureMatcherLibviso.py", line 198, in prune_second_stage
    if not bin_occupied[b]:
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Import RobustQuadraticSolverCython Error

Hi, Thank you for all your work !
I had ran the ./build.sh file and it turned out many warings. I choose to ignore this warnings and run the demo.py ,then it didn't work with the error below , can you give me some suggestion?Thank you !

root@desktop:/home/hh/pca# python demo.py /home/hh/pca/pcaflow Traceback (most recent call last): File "demo.py", line 3, in <module> from pcaflow import PCAFlow File "/home/hh/pca/pcaflow/PCAFlow.py", line 35, in <module> from solver.RobustQuadraticSolverCython import RobustQuadraticSolverCython as RobustQuadraticSolver ImportError: /home/hh/pca/pcaflow/solver/RobustQuadraticSolverCython.so: undefined symbol: dgetri_

Warnings affect the result?

Thank you so much for sharing your code.

When I run PCA_Layers, it returns 2 warnings:

~/anaconda3/envs/pca/lib/python2.7/site-packages/sklearn/utils/deprecation.py:77: DeprecationWarning: Function log_multivariate_normal_density is deprecated; The function log_multivariate_normal_density is deprecated in 0.18 and will be removed in 0.20.

warnings.warn(msg, category=DeprecationWarning)

~/anaconda3/envs/pca/lib/python2.7/site-packages/sklearn/utils/deprecation.py:58:
DeprecationWarning: Class GMM is deprecated; The class GMM is deprecated in 0.18 and will be removed in 0.20. Use class GaussianMixture instead.

warnings.warn(msg, category=DeprecationWarning)

Do these warning affect the output?
Thank you.

Unable to run demo.py

Hi,

I am able to normally compile with build.sh. However, when running demo.py I am getting the following python error

Re-allocating matcher...
Traceback (most recent call last):
  File "demo.py", line 46, in <module>
    u,v = P.compute_flow()
  File "/home/gustavo/pcaflow/pcaflow/PCAFlow.py", line 380, in compute_flow
    **kwargs)
  File "/home/gustavo/pcaflow/pcaflow/solver/EMSolver.py", line 364, in solve
    inliers,H,shape_I_orig)
  File "/home/gustavo/pcaflow/pcaflow/solver/EMSolver.py", line 493, in get_flow_GC
    point_models)
  File "/home/gustavo/pcaflow/pcaflow/solver/EMSolver.py", line 639, in _compute_unaries_color
    G = mixture.GMM(n_components=nc,covariance_type='full').fit(P)
AttributeError: 'module' object has no attribute 'GMM'

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.