Commit de378a72 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #729 from vbystricky:dis_flow

parents 986a2837 5a1fd4c8
...@@ -302,6 +302,25 @@ public: ...@@ -302,6 +302,25 @@ public:
/** @copybrief getGradientDescentIterations @see getGradientDescentIterations */ /** @copybrief getGradientDescentIterations @see getGradientDescentIterations */
CV_WRAP virtual void setVariationalRefinementIterations(int val) = 0; CV_WRAP virtual void setVariationalRefinementIterations(int val) = 0;
/** @brief Weight of the smoothness term
@see setVariationalRefinementAlpha */
CV_WRAP virtual float getVariationalRefinementAlpha() const = 0;
/** @copybrief getVariationalRefinementAlpha @see getVariationalRefinementAlpha */
CV_WRAP virtual void setVariationalRefinementAlpha(float val) = 0;
/** @brief Weight of the color constancy term
@see setVariationalRefinementDelta */
CV_WRAP virtual float getVariationalRefinementDelta() const = 0;
/** @copybrief getVariationalRefinementDelta @see getVariationalRefinementDelta */
CV_WRAP virtual void setVariationalRefinementDelta(float val) = 0;
/** @brief Weight of the gradient constancy term
@see setVariationalRefinementGamma */
CV_WRAP virtual float getVariationalRefinementGamma() const = 0;
/** @copybrief getVariationalRefinementGamma @see getVariationalRefinementGamma */
CV_WRAP virtual void setVariationalRefinementGamma(float val) = 0;
/** @brief Whether to use mean-normalization of patches when computing patch distance. It is turned on /** @brief Whether to use mean-normalization of patches when computing patch distance. It is turned on
by default as it typically provides a noticeable quality boost because of increased robustness to by default as it typically provides a noticeable quality boost because of increased robustness to
illumanition variations. Turn it off if you are certain that your sequence does't contain any changes illumanition variations. Turn it off if you are certain that your sequence does't contain any changes
......
...@@ -65,6 +65,9 @@ class DISOpticalFlowImpl : public DISOpticalFlow ...@@ -65,6 +65,9 @@ class DISOpticalFlowImpl : public DISOpticalFlow
int patch_stride; int patch_stride;
int grad_descent_iter; int grad_descent_iter;
int variational_refinement_iter; int variational_refinement_iter;
float variational_refinement_alpha;
float variational_refinement_gamma;
float variational_refinement_delta;
bool use_mean_normalization; bool use_mean_normalization;
bool use_spatial_propagation; bool use_spatial_propagation;
...@@ -84,6 +87,13 @@ class DISOpticalFlowImpl : public DISOpticalFlow ...@@ -84,6 +87,13 @@ class DISOpticalFlowImpl : public DISOpticalFlow
void setGradientDescentIterations(int val) { grad_descent_iter = val; } void setGradientDescentIterations(int val) { grad_descent_iter = val; }
int getVariationalRefinementIterations() const { return variational_refinement_iter; } int getVariationalRefinementIterations() const { return variational_refinement_iter; }
void setVariationalRefinementIterations(int val) { variational_refinement_iter = val; } void setVariationalRefinementIterations(int val) { variational_refinement_iter = val; }
float getVariationalRefinementAlpha() const { return variational_refinement_alpha; }
void setVariationalRefinementAlpha(float val) { variational_refinement_alpha = val; }
float getVariationalRefinementDelta() const { return variational_refinement_delta; }
void setVariationalRefinementDelta(float val) { variational_refinement_delta = val; }
float getVariationalRefinementGamma() const { return variational_refinement_gamma; }
void setVariationalRefinementGamma(float val) { variational_refinement_gamma = val; }
bool getUseMeanNormalization() const { return use_mean_normalization; } bool getUseMeanNormalization() const { return use_mean_normalization; }
void setUseMeanNormalization(bool val) { use_mean_normalization = val; } void setUseMeanNormalization(bool val) { use_mean_normalization = val; }
bool getUseSpatialPropagation() const { return use_spatial_propagation; } bool getUseSpatialPropagation() const { return use_spatial_propagation; }
...@@ -161,6 +171,10 @@ DISOpticalFlowImpl::DISOpticalFlowImpl() ...@@ -161,6 +171,10 @@ DISOpticalFlowImpl::DISOpticalFlowImpl()
patch_stride = 4; patch_stride = 4;
grad_descent_iter = 16; grad_descent_iter = 16;
variational_refinement_iter = 5; variational_refinement_iter = 5;
variational_refinement_alpha = 20.f;
variational_refinement_gamma = 10.f;
variational_refinement_delta = 5.f;
border_size = 16; border_size = 16;
use_mean_normalization = true; use_mean_normalization = true;
use_spatial_propagation = true; use_spatial_propagation = true;
...@@ -234,9 +248,9 @@ void DISOpticalFlowImpl::prepareBuffers(Mat &I0, Mat &I1) ...@@ -234,9 +248,9 @@ void DISOpticalFlowImpl::prepareBuffers(Mat &I0, Mat &I1)
spatialGradient(I0s[i], I0xs[i], I0ys[i]); spatialGradient(I0s[i], I0xs[i], I0ys[i]);
Ux[i].create(cur_rows, cur_cols); Ux[i].create(cur_rows, cur_cols);
Uy[i].create(cur_rows, cur_cols); Uy[i].create(cur_rows, cur_cols);
variational_refinement_processors[i]->setAlpha(20.0f); variational_refinement_processors[i]->setAlpha(variational_refinement_alpha);
variational_refinement_processors[i]->setDelta(5.0f); variational_refinement_processors[i]->setDelta(variational_refinement_delta);
variational_refinement_processors[i]->setGamma(10.0f); variational_refinement_processors[i]->setGamma(variational_refinement_gamma);
variational_refinement_processors[i]->setSorIterations(5); variational_refinement_processors[i]->setSorIterations(5);
variational_refinement_processors[i]->setFixedPointIterations(variational_refinement_iter); variational_refinement_processors[i]->setFixedPointIterations(variational_refinement_iter);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment