Merge pull request #24852 from Octopus136:4.x

Make \epsilon parameter accessible in VariationalRefinement #24852

Resolves #24847

I believe this is necessary to expose \epsilon parameter.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
pull/24875/head
_Burnside 10 months ago committed by GitHub
parent 84bb1cda4e
commit 6c39fbc33f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      modules/video/include/opencv2/video/tracking.hpp
  2. 6
      modules/video/src/dis_flow.cpp
  3. 2
      modules/video/src/variational_refinement.cpp

@ -564,6 +564,12 @@ public:
/** @copybrief getGamma @see getGamma */
CV_WRAP virtual void setGamma(float val) = 0;
/** @brief Norm value shift for robust penalizer
@see setEpsilon */
CV_WRAP virtual float getEpsilon() const = 0;
/** @copybrief getEpsilon @see getEpsilon */
CV_WRAP virtual void setEpsilon(float val) = 0;
/** @brief Creates an instance of VariationalRefinement
*/
CV_WRAP static Ptr<VariationalRefinement> create();
@ -645,6 +651,12 @@ public:
/** @copybrief getVariationalRefinementGamma @see getVariationalRefinementGamma */
CV_WRAP virtual void setVariationalRefinementGamma(float val) = 0;
/** @brief Norm value shift for robust penalizer
@see setVariationalRefinementEpsilon */
CV_WRAP virtual float getVariationalRefinementEpsilon() const = 0;
/** @copybrief getVariationalRefinementEpsilon @see getVariationalRefinementEpsilon */
CV_WRAP virtual void setVariationalRefinementEpsilon(float val) = 0;
/** @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

@ -67,6 +67,7 @@ class DISOpticalFlowImpl CV_FINAL : public DISOpticalFlow
float variational_refinement_alpha;
float variational_refinement_gamma;
float variational_refinement_delta;
float variational_refinement_epsilon;
bool use_mean_normalization;
bool use_spatial_propagation;
@ -92,6 +93,8 @@ class DISOpticalFlowImpl CV_FINAL : public DISOpticalFlow
void setVariationalRefinementDelta(float val) CV_OVERRIDE { variational_refinement_delta = val; }
float getVariationalRefinementGamma() const CV_OVERRIDE { return variational_refinement_gamma; }
void setVariationalRefinementGamma(float val) CV_OVERRIDE { variational_refinement_gamma = val; }
float getVariationalRefinementEpsilon() const CV_OVERRIDE { return variational_refinement_epsilon; }
void setVariationalRefinementEpsilon(float val) CV_OVERRIDE { variational_refinement_epsilon = val; }
bool getUseMeanNormalization() const CV_OVERRIDE { return use_mean_normalization; }
void setUseMeanNormalization(bool val) CV_OVERRIDE { use_mean_normalization = val; }
@ -219,6 +222,7 @@ DISOpticalFlowImpl::DISOpticalFlowImpl()
variational_refinement_alpha = 20.f;
variational_refinement_gamma = 10.f;
variational_refinement_delta = 5.f;
variational_refinement_epsilon = 0.01f;
border_size = 16;
use_mean_normalization = true;
@ -306,6 +310,7 @@ void DISOpticalFlowImpl::prepareBuffers(Mat &I0, Mat &I1, Mat &flow, bool use_fl
variational_refinement_processors[i]->setAlpha(variational_refinement_alpha);
variational_refinement_processors[i]->setDelta(variational_refinement_delta);
variational_refinement_processors[i]->setGamma(variational_refinement_gamma);
variational_refinement_processors[i]->setEpsilon(variational_refinement_epsilon);
variational_refinement_processors[i]->setSorIterations(5);
variational_refinement_processors[i]->setFixedPointIterations(variational_refinement_iter);
@ -1274,6 +1279,7 @@ void DISOpticalFlowImpl::ocl_prepareBuffers(UMat &I0, UMat &I1, InputArray flow,
variational_refinement_processors[i]->setAlpha(variational_refinement_alpha);
variational_refinement_processors[i]->setDelta(variational_refinement_delta);
variational_refinement_processors[i]->setGamma(variational_refinement_gamma);
variational_refinement_processors[i]->setEpsilon(variational_refinement_epsilon);
variational_refinement_processors[i]->setSorIterations(5);
variational_refinement_processors[i]->setFixedPointIterations(variational_refinement_iter);

@ -76,6 +76,8 @@ class VariationalRefinementImpl CV_FINAL : public VariationalRefinement
void setDelta(float val) CV_OVERRIDE { delta = val; }
float getGamma() const CV_OVERRIDE { return gamma; }
void setGamma(float val) CV_OVERRIDE { gamma = val; }
float getEpsilon() const CV_OVERRIDE { return epsilon; }
void setEpsilon(float val) CV_OVERRIDE { epsilon = val; }
protected: //!< internal buffers
/* This struct defines a special data layout for Mat_<float>. Original buffer is split into two: one for "red"

Loading…
Cancel
Save