Skip to content

scene_flow_uncalibscene_flow_uncalibSceneFlowUncalibSceneFlowUncalibscene_flow_uncalibscene_flow_uncalibπŸ”—

Short descriptionπŸ”—

scene_flow_uncalibscene_flow_uncalibSceneFlowUncalibSceneFlowUncalibscene_flow_uncalibscene_flow_uncalib β€” Compute the uncalibrated scene flow between two stereo image pairs.

SignatureπŸ”—

scene_flow_uncalib( image ImageRect1T1, image ImageRect2T1, image ImageRect1T2, image ImageRect2T2, image Disparity, out image OpticalFlow, out image DisparityChange, number SmoothingFlow, number SmoothingDisparity, attribute.name GenParamName, attribute.value GenParamValue )scene_flow_uncalib( ImageRect1T1, ImageRect2T1, ImageRect1T2, ImageRect2T2, Disparity : OpticalFlow, DisparityChange : SmoothingFlow, SmoothingDisparity, GenParamName, GenParamValue : )void SceneFlowUncalib( const HObject& ImageRect1T1, const HObject& ImageRect2T1, const HObject& ImageRect1T2, const HObject& ImageRect2T2, const HObject& Disparity, HObject* OpticalFlow, HObject* DisparityChange, const HTuple& SmoothingFlow, const HTuple& SmoothingDisparity, const HTuple& GenParamName, const HTuple& GenParamValue )static void HOperatorSet.SceneFlowUncalib( HObject imageRect1T1, HObject imageRect2T1, HObject imageRect1T2, HObject imageRect2T2, HObject disparity, out HObject opticalFlow, out HObject disparityChange, HTuple smoothingFlow, HTuple smoothingDisparity, HTuple genParamName, HTuple genParamValue )def scene_flow_uncalib( image_rect_1t1: HObject, image_rect_2t1: HObject, image_rect_1t2: HObject, image_rect_2t2: HObject, disparity: HObject, smoothing_flow: Union[float, int], smoothing_disparity: Union[float, int], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> Tuple[HObject, HObject]

Herror scene_flow_uncalib( const Hobject ImageRect1T1, const Hobject ImageRect2T1, const Hobject ImageRect1T2, const Hobject ImageRect2T2, const Hobject Disparity, Hobject* OpticalFlow, Hobject* DisparityChange, double SmoothingFlow, double SmoothingDisparity, const char* GenParamName, const char* GenParamValue )

Herror T_scene_flow_uncalib( const Hobject ImageRect1T1, const Hobject ImageRect2T1, const Hobject ImageRect1T2, const Hobject ImageRect2T2, const Hobject Disparity, Hobject* OpticalFlow, Hobject* DisparityChange, const Htuple SmoothingFlow, const Htuple SmoothingDisparity, const Htuple GenParamName, const Htuple GenParamValue )

HImage HImage::SceneFlowUncalib( const HImage& ImageRect2T1, const HImage& ImageRect1T2, const HImage& ImageRect2T2, const HImage& Disparity, HImage* DisparityChange, const HTuple& SmoothingFlow, const HTuple& SmoothingDisparity, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HImage HImage::SceneFlowUncalib( const HImage& ImageRect2T1, const HImage& ImageRect1T2, const HImage& ImageRect2T2, const HImage& Disparity, HImage* DisparityChange, double SmoothingFlow, double SmoothingDisparity, const HString& GenParamName, const HString& GenParamValue ) const

HImage HImage::SceneFlowUncalib( const HImage& ImageRect2T1, const HImage& ImageRect1T2, const HImage& ImageRect2T2, const HImage& Disparity, HImage* DisparityChange, double SmoothingFlow, double SmoothingDisparity, const char* GenParamName, const char* GenParamValue ) const

HImage HImage::SceneFlowUncalib( const HImage& ImageRect2T1, const HImage& ImageRect1T2, const HImage& ImageRect2T2, const HImage& Disparity, HImage* DisparityChange, double SmoothingFlow, double SmoothingDisparity, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HImage HImage.SceneFlowUncalib( HImage imageRect2T1, HImage imageRect1T2, HImage imageRect2T2, HImage disparity, out HImage disparityChange, HTuple smoothingFlow, HTuple smoothingDisparity, HTuple genParamName, HTuple genParamValue )

HImage HImage.SceneFlowUncalib( HImage imageRect2T1, HImage imageRect1T2, HImage imageRect2T2, HImage disparity, out HImage disparityChange, double smoothingFlow, double smoothingDisparity, string genParamName, string genParamValue )

DescriptionπŸ”—

scene_flow_uncalibSceneFlowUncalib computes the uncalibrated scene flow between two consecutive rectified stereo image pairs. The scene flow is the three-dimensional position and motion of surface points in a dynamic scene. The movement in the images can be caused by objects that move in the world or by a movement of the camera (or both) between the acquisition of the two image pairs. To calculate the calibrated scene flow, scene_flow_calibSceneFlowCalib can be used.

The two consecutive stereo image pairs of the image sequence are passed in ImageRect1T1imageRect1T1image_rect_1t1, ImageRect2T1imageRect2T1image_rect_2t1, ImageRect1T2imageRect1T2image_rect_1t2, and ImageRect2T2imageRect2T2image_rect_2t2. Each stereo image pair must be rectified. Note that the images can be rectified by using the operators calibrate_camerasCalibrateCameras, gen_binocular_rectification_mapGenBinocularRectificationMap, and map_imageMapImage. Furthermore, a single-channel Disparitydisparitydisparity image is required, which specifies for each pixel \((r,c1)\) of the image ImageRect1T1imageRect1T1image_rect_1t1 a matching pixel \((r,c2)\) of ImageRect2T1imageRect2T1image_rect_2t1 according to the equation \(c2=c1+d(r,c1)\), where \(d(r,c)\) is the Disparitydisparitydisparity at pixel \((r,c)\). The disparity image can be computed using binocular_disparityBinocularDisparity or binocular_disparity_mgBinocularDisparityMg.

The computed uncalibrated scene flow is returned in OpticalFlowopticalFlowoptical_flow and DisparityChangedisparityChangedisparity_change. The vectors in the vector field OpticalFlowopticalFlowoptical_flow represent the movement in the image plane between ImageRect1T1imageRect1T1image_rect_1t1 and ImageRect1T2imageRect1T2image_rect_1t2. The single-channel image DisparityChangedisparityChangedisparity_change describes the change in disparity between ImageRect2T1imageRect2T1image_rect_2t1 and ImageRect2T2imageRect2T2image_rect_2t2. A world point is projected into ImageRect1T1imageRect1T1image_rect_1t1 at position \((r,c)\). The same point is projected into

where \(u(r,c)\) and \(v(r,c)\) denote the values of the row and column components of the vector field image OpticalFlowopticalFlowoptical_flow, \(d(r,c)\) denotes the Disparitydisparitydisparity, and \(dc(r,c)\) the DisparityChangedisparityChangedisparity_change at the pixel \((r,c)\).

Relations between the four images and the optical flow as well as the disparities in the disparity images.

Parameter DescriptionπŸ”—

The rectified input images are passed in ImageRect1T1imageRect1T1image_rect_1t1, ImageRect2T1imageRect2T1image_rect_2t1, ImageRect1T2imageRect1T2image_rect_1t2, and ImageRect2T2imageRect2T2image_rect_2t2. The computation of the scene flow is performed on the domain of ImageRect1T1imageRect1T1image_rect_1t1, which is also the domain of the scene flow in OpticalFlowopticalFlowoptical_flow and DisparityChangedisparityChangedisparity_change. Disparitydisparitydisparity describes the disparity between the rectified images ImageRect1T1imageRect1T1image_rect_1t1 and ImageRect2T1imageRect2T1image_rect_2t1.

SmoothingFlowsmoothingFlowsmoothing_flow and SmoothingDisparitysmoothingDisparitysmoothing_disparity specify the regularization weights \(\lambda\) and \(\gamma\) with respect to the data term. The larger the value of these parameters, the smoother the computed scene flow is. For byte images with a gray value range of \([0,255]\), values around 40 typically yield good results.

The parameters of the iteration scheme and for the coarse-to-fine warping strategy can be specified with the generic parameters GenParamNamegenParamNamegen_param_name and GenParamValuegenParamValuegen_param_value.

Usually, it is sufficient to use one of the default parameter sets for the parameters by using GenParamNamegenParamNamegen_param_name = 'default_parameters'"default_parameters" and GenParamValuegenParamValuegen_param_value = 'very_accurate'"very_accurate", 'accurate'"accurate", 'fast'"fast", or 'very_fast'"very_fast". If necessary, individual parameters can be modified after the default parameter set has been chosen by specifying a subset of the parameters and corresponding values after 'default_parameters'"default_parameters" in GenParamNamegenParamNamegen_param_name and GenParamValuegenParamValuegen_param_value (e.g., GenParamNamegenParamNamegen_param_name = ['default_parameters', 'warp_zoom_factor']["default_parameters", "warp_zoom_factor"] and GenParamValuegenParamValuegen_param_value = ['accurate', 0.6]["accurate", 0.6]). The meaning of the individual parameters is described in detail below. The default parameter sets are given by:

'default_parameters'"default_parameters" 'very_accurate'"very_accurate" 'accurate'"accurate" 'fast'"fast" 'very_fast'"very_fast"
'warp_zoom_factor'"warp_zoom_factor" 0.75 0.5 0.5 0.5
'warp_levels'"warp_levels" 0 0 0 0
'warp_last_level'"warp_last_level" 1 1 1 2
'outer_iter'"outer_iter" 10 7 5 4
'inner_iter'"inner_iter" 2 2 2 2
'sor_iter'"sor_iter" 3 3 3 3
'omega'"omega" 1.9 1.9 1.9 1.9

If the parameters should be specified individually, GenParamNamegenParamNamegen_param_name and GenParamValuegenParamValuegen_param_value must be set to tuples of the same length. The values corresponding to the parameters specified in GenParamNamegenParamNamegen_param_name must be specified at the corresponding position in GenParamValuegenParamValuegen_param_value. For a deeper understanding of the following parameters, please refer to the section Algorithm below.

  • GenParamNamegenParamNamegen_param_name = 'warp_zoom_factor'"warp_zoom_factor" can be used to specify the resolution ratio between two consecutive warping levels in the coarse-to-fine warping hierarchy. 'warp_zoom_factor'"warp_zoom_factor" must be selected from the open interval \((0,1)\). For performance reasons, 'warp_zoom_factor'"warp_zoom_factor" is typically set to 0.5, i.e., the number of pixels is halved in each direction for each coarser warping level. Values for 'warp_zoom_factor'"warp_zoom_factor" close to 1 can lead to slightly better results. However, they require a disproportionately larger computation time.

  • GenParamNamegenParamNamegen_param_name = 'warp_levels'"warp_levels" can be used to restrict the warping hierarchy to a maximum number of levels. For 'warp_levels'"warp_levels" = 0, the largest possible number of levels is used. If the image size does not allow to use the specified number of levels (taking the resolution ratio 'warp_zoom_factor'"warp_zoom_factor" into account), the largest possible number of levels is used. Usually, 'warp_levels'"warp_levels" should be set to 0.

  • GenParamNamegenParamNamegen_param_name = 'warp_last_level'"warp_last_level" can be used to specify the number of warping levels for which the flow increment should no longer be computed. Usually, 'warp_last_level'"warp_last_level" is set to 1 or 2, i.e., a flow increment is computed for each warping level, or the finest warping level is skipped in the computation. In the latter case, the computation is performed on an image of half the resolution of the original image and then interpolated to the full resolution.

  • GenParamNamegenParamNamegen_param_name = 'outer_iter'"outer_iter" can be used to specify the number of outer iterations in the minimization scheme. Typically, the larger 'outer_iter'"outer_iter", the more accurate the numerical results are. Higher values for this parameter lead to an increase in the computation time. Typically, 'outer_iter'"outer_iter" is set to values between 5 and 10.

  • GenParamNamegenParamNamegen_param_name = 'inner_iter'"inner_iter" can be used to specify the number of inner iterations in the minimization scheme. Typically, the larger 'inner_iter'"inner_iter", the more accurate the numerical results are. Higher values for this parameter lead to an increase in the computation time. Usually, two inner iterations are sufficient.

  • GenParamNamegenParamNamegen_param_name = 'sor_iter'"sor_iter" can be used to specify the number of SOR iterations for solving the linear system of equations. Typically, the larger 'sor_iter'"sor_iter", the more accurate the numerical results are. Higher values for this parameter lead to an increase in the computation time. Usually, three SOR iterations are sufficient.

  • GenParamNamegenParamNamegen_param_name = 'omega'"omega" can be used to specify the relaxation factor \(\omega\) of the SOR method. 'omega'"omega" must be selected from the open interval \((1,2)\). Typically, 'omega'"omega" is set to 1.9.

AlgorithmπŸ”—

The scene flow is estimated by minimizing a suitable energy functional:

\[\begin{eqnarray*} E(f)=\int E_{D}(f)+E_{S}(f)\, \mathrm{d}r \mathrm{d}c \end{eqnarray*}\]

where \(f=(u,v,dc)\) is the optical flow field and the disparity change. \(E_{D}(f)\) denotes the data term and \(E_{S}(f)\) the smoothness (regularization) term. The algorithm is based on the following assumptions, which lead to the data and smoothness terms:

  • Brightness Constancy It is assumed that the gray value of a point remains constant in all four input images, resulting in the following four constraints:

    \[\begin{eqnarray*} C_{D1} & = & I_{1,t1}(r,c) - I_{2,t1}(r,c+d(r,c)) = 0 \\ C_{F1} & = & I_{1,t2}(r+u(r,c),c+v(r,c)) - I_{1,t1}(r,c) = 0 \\ C_{F2} & = & I_{2,t2}(r+u(r,c),c+v(r,c)+d(r,c)+dc(r,c)) - I_{2,t1}(r,c+d(r,c)) = 0 \\ C_{D2} & = & I_{2,t2}(r+u(r,c),c+v(r,c)+d(r,c)+dc(r,c)) - I_{1,t2}(r+u(r,c),c+v(r,c)) = 0 \end{eqnarray*}\]

    Here, \(I_{1,t1}\), \(I_{2,t1}\), \(I_{1,t2}\), and \(I_{2,t2}\) denote ImageRect1T1imageRect1T1image_rect_1t1, ImageRect2T1imageRect2T1image_rect_2t1, ImageRect1T2imageRect1T2image_rect_1t2, and ImageRect2T2imageRect2T2image_rect_2t2, respectively.

  • Piecewise smoothness of the scene flow The solution is assumed to be piecewise smooth. This smoothness is achieved by penalizing the first derivatives of the flow \(\nabla(u)^2, \nabla(v)^2, \nabla(dc)^2\). The use of a statistically robust (linear) penalty function \(\Psi(s) = \sqrt{s^2+\varepsilon}\) with \(\varepsilon = 0.001\) provides the desired preservation of edges in the movement in the scene flow to be determined.

Because the disparity image \(d\) is given, the first constraint \(C_{D1}\) can be omitted. Taking into account all of the above assumptions, the energy functional can be written as

\[\begin{eqnarray*} E(f) = \int \Psi(C_{F1}^2) + \Psi(C_{F2}^2) + \Psi(C_{D2}^2) + \Psi(\lambda(\nabla(u)^2+\nabla(v)^2) + \gamma\nabla(dc)^2)\, \mathrm{d}r \mathrm{d}c \end{eqnarray*}\]

where \(\lambda\) and \(\gamma\) are the regularization parameters passed in SmoothingFlowsmoothingFlowsmoothing_flow and SmoothingDisparitysmoothingDisparitysmoothing_disparity.

To calculate large displacements, coarse-to-fine warping strategies use two concepts that are closely interlocked: The successive refinement of the problem (coarse-to-fine) and the successive compensation of the current image pair by already computed displacements (warping). Algorithmically, such coarse-to-fine warping strategies can be described as follows:

  1. First, all images are zoomed down to a very coarse resolution level.

  2. Then, the scene flow is computed on this coarse resolution.

  3. The scene flow is required on the next resolution level: It is applied there to the second image pair of the image sequence, i.e., the problem on the finer resolution level is compensated by the already computed scene flow. This step is also known as warping.

  4. The modified problem (difference problem) is now solved on the finer resolution level, i.e., the scene scene flow is computed there.

  5. The steps 3-4 are repeated until the finest resolution level is reached.

  6. The final result is computed by adding up the scene flow from all resolution levels.

This incremental computation of the scene flow has the following advantage: While the coarse-to-fine strategy ensures that the displacements on the finest resolution level are very small, the warping strategy ensures that the displacements remain small for the incremental displacements (scene flow of the difference problems). Since small displacements can be computed much more accurately than larger displacements, the accuracy of the results typically increases significantly by using such a coarse-to-fine warping strategy. However, instead of having to solve a single correspondence problem, an entire hierarchy of these problems must be solved.

The minimization of functionals is mathematically very closely related to the minimization of functions: Like the fact that the zero crossing of the first derivative is a necessary condition for the minimum of a function, the fulfillment of the so called Euler-Lagrange equations is a necessary condition for the minimizing function of a functional (the minimizing function corresponds to the desired scene flow in this case). The Euler-Lagrange equations are partial differential equations. By discretizing these Euler-Lagrange equations using finite differences, large sparse nonlinear equation systems have to be solved in this algorithm.

For each warping level a single equation system must be solved. The algorithm uses an iteration scheme consisting of two nested iterations (called the outer and inner iteration) and the SOR (Successive Over-Relaxation) method. The outer loop contains the linearization of the nonlinear terms resulting from the data constraints. The nonlinearity of \(\Psi'\) is removed by the inner fixed point iteration scheme. The resulting linear system of equations can be solved efficiently by the SOR method.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on internal data level.

ParametersπŸ”—

ImageRect1T1imageRect1T1image_rect_1t1 (input_object) singlechannelimage(-array) β†’ object (byte / uint2 / real)object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject (byte / uint2 / real)

Input image 1 at time \(t_{1}\).

ImageRect2T1imageRect2T1image_rect_2t1 (input_object) singlechannelimage(-array) β†’ object (byte / uint2 / real)object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject (byte / uint2 / real)

Input image 2 at time \(t_{1}\).

ImageRect1T2imageRect1T2image_rect_1t2 (input_object) singlechannelimage(-array) β†’ object (byte / uint2 / real)object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject (byte / uint2 / real)

Input image 1 at time \(t_{2}\).

ImageRect2T2imageRect2T2image_rect_2t2 (input_object) singlechannelimage(-array) β†’ object (byte / uint2 / real)object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject (byte / uint2 / real)

Input image 2 at time \(t_{2}\).

Disparitydisparitydisparity (input_object) singlechannelimage(-array) β†’ object (real)object (real)HObject (real)HImage (real)HObject (real)Hobject (real)

Disparity between input images 1 and 2 at time \(t_{1}\).

OpticalFlowopticalFlowoptical_flow (output_object) singlechannelimage(-array) β†’ object (vector_field)object (vector_field)HObject (vector_field)HImage (vector_field)HObject (vector_field)Hobject * (vector_field)

Estimated optical flow.

DisparityChangedisparityChangedisparity_change (output_object) singlechannelimage(-array) β†’ object (real)object (real)HObject (real)HImage (real)HObject (real)Hobject * (real)

Estimated change in disparity.

SmoothingFlowsmoothingFlowsmoothing_flow (input_control) number β†’ (real / integer)(real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[float, int]Htuple (double / Hlong)

Weight of the regularization term relative to the data term (derivatives of the optical flow).

Default: 40.040.0
Suggested values: 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.010.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0
Restriction: SmoothingFlow > 0.0

SmoothingDisparitysmoothingDisparitysmoothing_disparity (input_control) number β†’ (real / integer)(real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[float, int]Htuple (double / Hlong)

Weight of the regularization term relative to the data term (derivatives of the disparity change).

Default: 40.040.0
Suggested values: 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.010.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0
Restriction: SmoothingDisparity > 0.0

GenParamNamegenParamNamegen_param_name (input_control) attribute.name(-array) β†’ (string)(string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Parameter name(s) for the algorithm.

Default: 'default_parameters'"default_parameters"
Suggested values: 'default_parameters', 'warp_levels', 'warp_zoom_factor', 'warp_last_level', 'outer_iter', 'inner_iter', 'sor_iter', 'omega'"default_parameters", "warp_levels", "warp_zoom_factor", "warp_last_level", "outer_iter", "inner_iter", "sor_iter", "omega"

GenParamValuegenParamValuegen_param_value (input_control) attribute.value(-array) β†’ (string / integer / real)(string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)MaybeSequence[Union[int, float, str]]Htuple (char* / Hlong / double)

Parameter value(s) for the algorithm.

Default: 'accurate'"accurate"
Suggested values: 'very_accurate', 'accurate', 'fast', 'very_fast', 0, 1, 2, 3, 4, 5, 6, 0.5, 0.6, 0.7, 0.75, 3, 5, 7, 2, 3, 1.9"very_accurate", "accurate", "fast", "very_fast", 0, 1, 2, 3, 4, 5, 6, 0.5, 0.6, 0.7, 0.75, 3, 5, 7, 2, 3, 1.9

ResultπŸ”—

If the parameter values are correct, the operator scene_flow_uncalibSceneFlowUncalib returns the value 2 (H_MSG_TRUE). If the input is empty (no input images are available) the behavior can be set via set_system('no_object_result',<Result>). If necessary, an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

binocular_disparityBinocularDisparity, binocular_disparity_mgBinocularDisparityMg

Possible successors

thresholdThreshold, vector_field_lengthVectorFieldLength

Alternatives

scene_flow_calibSceneFlowCalib, optical_flow_mgOpticalFlowMg

ReferencesπŸ”—

A. Wedel, C. Rabe, T. Vaudrey, T. Brox, U. Franke and D. Cremers: β€œEfficient dense scene flow from sparse or dense stereo data”; In: Proceedings of the 10th European Conference on Computer Vision: Part I, pages 739-751. Springer-Verlag, 2008.

ModuleπŸ”—

Foundation