Python API

This section includes information for using the pure Python API of bob.ip.optflow.liu.

Root module functions

bob.ip.optflow.liu.get_config()[source]

Returns a string containing the configuration information.

Conjugate-Gradient (CG) based Implementation

Ce Liu’s Optical Flow implementations using CG

bob.ip.optflow.liu.cg.flow(i1, i2, [alpha=0.02, [ratio=0.75, [min_width=30, [n_outer_fp_iterations=20, [n_inner_fp_iterations=1, [n_cg_iterations=50]]]]]]) -> (u, v, w2)

This method computes the dense optical flow field using a coarse-to-fine approach. C++ code running under this call is extracted from the old version (pre Aug 1, 2011) of Ce Liu’s homepage and should give the exact same output as the Matlab equivalent.

Note

This variant does not use the Successive Over-Relaxation (SOR) that was implemented on August 1st., 2011 by C. Liu, but the old version based on Conjugate-Gradient (CG).

Parameters:

i1
First input frame (grayscale/double image)
i2
Second input frame (same dimension and type of the first frame)
alpha
[optional] Regularization weight
ratio
[optional] Downsample ratio
min_width
[optional] Width of the coarsest level
n_outer_fp_iterations
[optional] The number of outer fixed point iterations
n_inner_fp_iterations
[optional] The number of inner fixed point iterations
n_cg_iterations
[optional] The number of conjugate-gradient (CG) iterations

Returns a tuple containing three 2D double arrays with the same dimensions as the input images:

u
Output velocities in x (horizontal axis).
v
Output velocities in y (vertical axis).
warped_i2
i2 as estimated by the optical flow field from i1

Successive-Over-Relaxation (SOR) based Implementation

Ce Liu’s Optical Flow implementations using SOR

bob.ip.optflow.liu.sor.flow(i1, i2, [alpha=1.0, [ratio=0.5, [min_width=40, [n_outer_fp_iterations=4, [n_inner_fp_iterations=1, [n_sor_iterations=20]]]]]]) -> (u, v, w2)

This method computes the dense optical flow field using a coarse-to-fine approach. C++ code running under this call is extracted from the old version (pre Aug 1, 2011) of Ce Liu’s homepage and should give the exact same output as the Matlab equivalent.

Note

This variant uses the Successive Over-Relaxation (SOR) that was implemented on August 1st., 2011 by C. Liu.

Parameters:

i1
First input frame (grayscale/double image)
i2
Second input frame (same dimension and type of the first frame)
alpha
[optional] Regularization weight
ratio
[optional] Downsample ratio
min_width
[optional] Width of the coarsest level
n_outer_fp_iterations
[optional] The number of outer fixed point iterations
n_inner_fp_iterations
[optional] The number of inner fixed point iterations
n_sor_iterations
[optional] The number of successive-over-relaxation (SOR) iterations

Returns a tuple containing three 2D double arrays with the same dimensions as the input images:

u
Output velocities in x (horizontal axis).
v
Output velocities in y (vertical axis).
warped_i2
i2 as estimated by the optical flow field from i1