Skip to content

Commit

Permalink
superres: apply CV_OVERRIDE/CV_FINAL
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Mar 28, 2018
1 parent 4a0fa57 commit a8eb3e1
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 85 deletions.
4 changes: 2 additions & 2 deletions modules/superres/include/opencv2/superres.hpp
Expand Up @@ -97,8 +97,8 @@ namespace cv
@param frame Output result
*/
void nextFrame(OutputArray frame);
void reset();
void nextFrame(OutputArray frame) CV_OVERRIDE;
void reset() CV_OVERRIDE;

/** @brief Clear all inner buffers.
*/
Expand Down
44 changes: 27 additions & 17 deletions modules/superres/src/btv_l1.cpp
Expand Up @@ -363,7 +363,7 @@ namespace
template <typename T>
struct BtvRegularizationBody : ParallelLoopBody
{
void operator ()(const Range& range) const;
void operator ()(const Range& range) const CV_OVERRIDE;

Mat src;
mutable Mat dst;
Expand Down Expand Up @@ -470,18 +470,28 @@ namespace
void process(InputArrayOfArrays src, OutputArray dst, InputArrayOfArrays forwardMotions,
InputArrayOfArrays backwardMotions, int baseIdx);

void collectGarbage();

CV_IMPL_PROPERTY(int, Scale, scale_)
CV_IMPL_PROPERTY(int, Iterations, iterations_)
CV_IMPL_PROPERTY(double, Tau, tau_)
CV_IMPL_PROPERTY(double, Labmda, lambda_)
CV_IMPL_PROPERTY(double, Alpha, alpha_)
CV_IMPL_PROPERTY(int, KernelSize, btvKernelSize_)
CV_IMPL_PROPERTY(int, BlurKernelSize, blurKernelSize_)
CV_IMPL_PROPERTY(double, BlurSigma, blurSigma_)
CV_IMPL_PROPERTY(int, TemporalAreaRadius, temporalAreaRadius_)
CV_IMPL_PROPERTY_S(Ptr<cv::superres::DenseOpticalFlowExt>, OpticalFlow, opticalFlow_)
void collectGarbage() CV_OVERRIDE;

inline int getScale() const CV_OVERRIDE { return scale_; }
inline void setScale(int val) CV_OVERRIDE { scale_ = val; }
inline int getIterations() const CV_OVERRIDE { return iterations_; }
inline void setIterations(int val) CV_OVERRIDE { iterations_ = val; }
inline double getTau() const CV_OVERRIDE { return tau_; }
inline void setTau(double val) CV_OVERRIDE { tau_ = val; }
inline double getLabmda() const CV_OVERRIDE { return lambda_; }
inline void setLabmda(double val) CV_OVERRIDE { lambda_ = val; }
inline double getAlpha() const CV_OVERRIDE { return alpha_; }
inline void setAlpha(double val) CV_OVERRIDE { alpha_ = val; }
inline int getKernelSize() const CV_OVERRIDE { return btvKernelSize_; }
inline void setKernelSize(int val) CV_OVERRIDE { btvKernelSize_ = val; }
inline int getBlurKernelSize() const CV_OVERRIDE { return blurKernelSize_; }
inline void setBlurKernelSize(int val) CV_OVERRIDE { blurKernelSize_ = val; }
inline double getBlurSigma() const CV_OVERRIDE { return blurSigma_; }
inline void setBlurSigma(double val) CV_OVERRIDE { blurSigma_ = val; }
inline int getTemporalAreaRadius() const CV_OVERRIDE { return temporalAreaRadius_; }
inline void setTemporalAreaRadius(int val) CV_OVERRIDE { temporalAreaRadius_ = val; }
inline Ptr<cv::superres::DenseOpticalFlowExt> getOpticalFlow() const CV_OVERRIDE { return opticalFlow_; }
inline void setOpticalFlow(const Ptr<cv::superres::DenseOpticalFlowExt>& val) CV_OVERRIDE { opticalFlow_ = val; }

protected:
int scale_;
Expand Down Expand Up @@ -798,18 +808,18 @@ namespace

////////////////////////////////////////////////////////////////////

class BTVL1 : public BTVL1_Base
class BTVL1 CV_FINAL : public BTVL1_Base
{
public:
BTVL1();

void collectGarbage();
void collectGarbage() CV_OVERRIDE;

protected:
void initImpl(Ptr<FrameSource>& frameSource);
void initImpl(Ptr<FrameSource>& frameSource) CV_OVERRIDE;
bool ocl_initImpl(Ptr<FrameSource>& frameSource);

void processImpl(Ptr<FrameSource>& frameSource, OutputArray output);
void processImpl(Ptr<FrameSource>& frameSource, OutputArray output) CV_OVERRIDE;
bool ocl_processImpl(Ptr<FrameSource>& frameSource, OutputArray output);

private:
Expand Down
30 changes: 20 additions & 10 deletions modules/superres/src/btv_l1_cuda.cpp
Expand Up @@ -218,16 +218,26 @@ namespace

void collectGarbage();

CV_IMPL_PROPERTY(int, Scale, scale_)
CV_IMPL_PROPERTY(int, Iterations, iterations_)
CV_IMPL_PROPERTY(double, Tau, tau_)
CV_IMPL_PROPERTY(double, Labmda, lambda_)
CV_IMPL_PROPERTY(double, Alpha, alpha_)
CV_IMPL_PROPERTY(int, KernelSize, btvKernelSize_)
CV_IMPL_PROPERTY(int, BlurKernelSize, blurKernelSize_)
CV_IMPL_PROPERTY(double, BlurSigma, blurSigma_)
CV_IMPL_PROPERTY(int, TemporalAreaRadius, temporalAreaRadius_)
CV_IMPL_PROPERTY_S(Ptr<cv::superres::DenseOpticalFlowExt>, OpticalFlow, opticalFlow_)
inline int getScale() const CV_OVERRIDE { return scale_; }
inline void setScale(int val) CV_OVERRIDE { scale_ = val; }
inline int getIterations() const CV_OVERRIDE { return iterations_; }
inline void setIterations(int val) CV_OVERRIDE { iterations_ = val; }
inline double getTau() const CV_OVERRIDE { return tau_; }
inline void setTau(double val) CV_OVERRIDE { tau_ = val; }
inline double getLabmda() const CV_OVERRIDE { return lambda_; }
inline void setLabmda(double val) CV_OVERRIDE { lambda_ = val; }
inline double getAlpha() const CV_OVERRIDE { return alpha_; }
inline void setAlpha(double val) CV_OVERRIDE { alpha_ = val; }
inline int getKernelSize() const CV_OVERRIDE { return btvKernelSize_; }
inline void setKernelSize(int val) CV_OVERRIDE { btvKernelSize_ = val; }
inline int getBlurKernelSize() const CV_OVERRIDE { return blurKernelSize_; }
inline void setBlurKernelSize(int val) CV_OVERRIDE { blurKernelSize_ = val; }
inline double getBlurSigma() const CV_OVERRIDE { return blurSigma_; }
inline void setBlurSigma(double val) CV_OVERRIDE { blurSigma_ = val; }
inline int getTemporalAreaRadius() const CV_OVERRIDE { return temporalAreaRadius_; }
inline void setTemporalAreaRadius(int val) CV_OVERRIDE { temporalAreaRadius_ = val; }
inline Ptr<cv::superres::DenseOpticalFlowExt> getOpticalFlow() const CV_OVERRIDE { return opticalFlow_; }
inline void setOpticalFlow(const Ptr<cv::superres::DenseOpticalFlowExt>& val) CV_OVERRIDE { opticalFlow_ = val; }

protected:
int scale_;
Expand Down
10 changes: 5 additions & 5 deletions modules/superres/src/frame_source.cpp
Expand Up @@ -58,8 +58,8 @@ namespace
class EmptyFrameSource : public FrameSource
{
public:
void nextFrame(OutputArray frame);
void reset();
void nextFrame(OutputArray frame) CV_OVERRIDE;
void reset() CV_OVERRIDE;
};

void EmptyFrameSource::nextFrame(OutputArray frame)
Expand Down Expand Up @@ -103,7 +103,7 @@ namespace
class CaptureFrameSource : public FrameSource
{
public:
void nextFrame(OutputArray frame);
void nextFrame(OutputArray frame) CV_OVERRIDE;

protected:
VideoCapture vc_;
Expand Down Expand Up @@ -135,7 +135,7 @@ namespace
public:
VideoFrameSource(const String& fileName);

void reset();
void reset() CV_OVERRIDE;

private:
String fileName_;
Expand All @@ -158,7 +158,7 @@ namespace
public:
CameraFrameSource(int deviceId);

void reset();
void reset() CV_OVERRIDE;

private:
int deviceId_;
Expand Down
141 changes: 90 additions & 51 deletions modules/superres/src/optical_flow.cpp
Expand Up @@ -58,8 +58,8 @@ namespace
public:
explicit CpuOpticalFlow(int work_type);

void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2);
void collectGarbage();
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2) CV_OVERRIDE;
void collectGarbage() CV_OVERRIDE;

protected:
virtual void impl(InputArray input0, InputArray input1, OutputArray dst) = 0;
Expand Down Expand Up @@ -179,23 +179,30 @@ namespace

namespace
{
class Farneback : public CpuOpticalFlow, public cv::superres::FarnebackOpticalFlow
class Farneback CV_FINAL : public CpuOpticalFlow, public cv::superres::FarnebackOpticalFlow
{
public:
Farneback();
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2);
void collectGarbage();

CV_IMPL_PROPERTY(double, PyrScale, pyrScale_)
CV_IMPL_PROPERTY(int, LevelsNumber, numLevels_)
CV_IMPL_PROPERTY(int, WindowSize, winSize_)
CV_IMPL_PROPERTY(int, Iterations, numIters_)
CV_IMPL_PROPERTY(int, PolyN, polyN_)
CV_IMPL_PROPERTY(double, PolySigma, polySigma_)
CV_IMPL_PROPERTY(int, Flags, flags_)
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2) CV_OVERRIDE;
void collectGarbage() CV_OVERRIDE;

inline double getPyrScale() const CV_OVERRIDE { return pyrScale_; }
inline void setPyrScale(double val) CV_OVERRIDE { pyrScale_ = val; }
inline int getLevelsNumber() const CV_OVERRIDE { return numLevels_; }
inline void setLevelsNumber(int val) CV_OVERRIDE { numLevels_ = val; }
inline int getWindowSize() const CV_OVERRIDE { return winSize_; }
inline void setWindowSize(int val) CV_OVERRIDE { winSize_ = val; }
inline int getIterations() const CV_OVERRIDE { return numIters_; }
inline void setIterations(int val) CV_OVERRIDE { numIters_ = val; }
inline int getPolyN() const CV_OVERRIDE { return polyN_; }
inline void setPolyN(int val) CV_OVERRIDE { polyN_ = val; }
inline double getPolySigma() const CV_OVERRIDE { return polySigma_; }
inline void setPolySigma(double val) CV_OVERRIDE { polySigma_ = val; }
inline int getFlags() const CV_OVERRIDE { return flags_; }
inline void setFlags(int val) CV_OVERRIDE { flags_ = val; }

protected:
void impl(InputArray input0, InputArray input1, OutputArray dst);
void impl(InputArray input0, InputArray input1, OutputArray dst) CV_OVERRIDE;

private:
double pyrScale_;
Expand Down Expand Up @@ -336,24 +343,32 @@ Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Simple()

namespace
{
class DualTVL1 : public CpuOpticalFlow, public virtual cv::superres::DualTVL1OpticalFlow
class DualTVL1 CV_FINAL : public CpuOpticalFlow, public virtual cv::superres::DualTVL1OpticalFlow
{
public:
DualTVL1();
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2);
void collectGarbage();

CV_WRAP_SAME_PROPERTY(double, Tau, (*alg_))
CV_WRAP_SAME_PROPERTY(double, Lambda, (*alg_))
CV_WRAP_SAME_PROPERTY(double, Theta, (*alg_))
CV_WRAP_SAME_PROPERTY(int, ScalesNumber, (*alg_))
CV_WRAP_SAME_PROPERTY(int, WarpingsNumber, (*alg_))
CV_WRAP_SAME_PROPERTY(double, Epsilon, (*alg_))
CV_WRAP_PROPERTY(int, Iterations, OuterIterations, (*alg_))
CV_WRAP_SAME_PROPERTY(bool, UseInitialFlow, (*alg_))
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2) CV_OVERRIDE;
void collectGarbage() CV_OVERRIDE;

inline double getTau() const CV_OVERRIDE { return (*alg_).getTau(); }
inline void setTau(double val) CV_OVERRIDE { (*alg_).setTau(val); }
inline double getLambda() const CV_OVERRIDE { return (*alg_).getLambda(); }
inline void setLambda(double val) CV_OVERRIDE { (*alg_).setLambda(val); }
inline double getTheta() const CV_OVERRIDE { return (*alg_).getTheta(); }
inline void setTheta(double val) CV_OVERRIDE { (*alg_).setTheta(val); }
inline int getScalesNumber() const CV_OVERRIDE { return (*alg_).getScalesNumber(); }
inline void setScalesNumber(int val) CV_OVERRIDE { (*alg_).setScalesNumber(val); }
inline int getWarpingsNumber() const CV_OVERRIDE { return (*alg_).getWarpingsNumber(); }
inline void setWarpingsNumber(int val) CV_OVERRIDE { (*alg_).setWarpingsNumber(val); }
inline double getEpsilon() const CV_OVERRIDE { return (*alg_).getEpsilon(); }
inline void setEpsilon(double val) CV_OVERRIDE { (*alg_).setEpsilon(val); }
inline int getIterations() const CV_OVERRIDE { return (*alg_).getOuterIterations(); }
inline void setIterations(int val) CV_OVERRIDE { (*alg_).setOuterIterations(val); }
inline bool getUseInitialFlow() const CV_OVERRIDE { return (*alg_).getUseInitialFlow(); }
inline void setUseInitialFlow(bool val) CV_OVERRIDE { (*alg_).setUseInitialFlow(val); }

protected:
void impl(InputArray input0, InputArray input1, OutputArray dst);
void impl(InputArray input0, InputArray input1, OutputArray dst) CV_OVERRIDE;

private:
Ptr<cv::DualTVL1OpticalFlow> alg_;
Expand Down Expand Up @@ -498,12 +513,18 @@ namespace
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2);
void collectGarbage();

CV_IMPL_PROPERTY(double, Alpha, alpha_)
CV_IMPL_PROPERTY(double, Gamma, gamma_)
CV_IMPL_PROPERTY(double, ScaleFactor, scaleFactor_)
CV_IMPL_PROPERTY(int, InnerIterations, innerIterations_)
CV_IMPL_PROPERTY(int, OuterIterations, outerIterations_)
CV_IMPL_PROPERTY(int, SolverIterations, solverIterations_)
inline double getAlpha() const CV_OVERRIDE { return alpha_; }
inline void setAlpha(double val) CV_OVERRIDE { alpha_ = val; }
inline double getGamma() const CV_OVERRIDE { return gamma_; }
inline void setGamma(double val) CV_OVERRIDE { gamma_ = val; }
inline double getScaleFactor() const CV_OVERRIDE { return scaleFactor_; }
inline void setScaleFactor(double val) CV_OVERRIDE { scaleFactor_ = val; }
inline int getInnerIterations() const CV_OVERRIDE { return innerIterations_; }
inline void setInnerIterations(int val) CV_OVERRIDE { innerIterations_ = val; }
inline int getOuterIterations() const CV_OVERRIDE { return outerIterations_; }
inline void setOuterIterations(int val) CV_OVERRIDE { outerIterations_ = val; }
inline int getSolverIterations() const CV_OVERRIDE { return solverIterations_; }
inline void setSolverIterations(int val) CV_OVERRIDE { solverIterations_ = val; }

protected:
void impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2);
Expand Down Expand Up @@ -579,9 +600,12 @@ namespace
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2);
void collectGarbage();

CV_IMPL_PROPERTY(int, WindowSize, winSize_)
CV_IMPL_PROPERTY(int, MaxLevel, maxLevel_)
CV_IMPL_PROPERTY(int, Iterations, iterations_)
inline int getWindowSize() const CV_OVERRIDE { return winSize_; }
inline void setWindowSize(int val) CV_OVERRIDE { winSize_ = val; }
inline int getMaxLevel() const CV_OVERRIDE { return maxLevel_; }
inline void setMaxLevel(int val) CV_OVERRIDE { maxLevel_ = val; }
inline int getIterations() const CV_OVERRIDE { return iterations_; }
inline void setIterations(int val) CV_OVERRIDE { iterations_ = val; }

protected:
void impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2);
Expand Down Expand Up @@ -648,13 +672,20 @@ namespace
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2);
void collectGarbage();

CV_IMPL_PROPERTY(double, PyrScale, pyrScale_)
CV_IMPL_PROPERTY(int, LevelsNumber, numLevels_)
CV_IMPL_PROPERTY(int, WindowSize, winSize_)
CV_IMPL_PROPERTY(int, Iterations, numIters_)
CV_IMPL_PROPERTY(int, PolyN, polyN_)
CV_IMPL_PROPERTY(double, PolySigma, polySigma_)
CV_IMPL_PROPERTY(int, Flags, flags_)
inline double getPyrScale() const CV_OVERRIDE { return pyrScale_; }
inline void setPyrScale(double val) CV_OVERRIDE { pyrScale_ = val; }
inline int getLevelsNumber() const CV_OVERRIDE { return numLevels_; }
inline void setLevelsNumber(int val) CV_OVERRIDE { numLevels_ = val; }
inline int getWindowSize() const CV_OVERRIDE { return winSize_; }
inline void setWindowSize(int val) CV_OVERRIDE { winSize_ = val; }
inline int getIterations() const CV_OVERRIDE { return numIters_; }
inline void setIterations(int val) CV_OVERRIDE { numIters_ = val; }
inline int getPolyN() const CV_OVERRIDE { return polyN_; }
inline void setPolyN(int val) CV_OVERRIDE { polyN_ = val; }
inline double getPolySigma() const CV_OVERRIDE { return polySigma_; }
inline void setPolySigma(double val) CV_OVERRIDE { polySigma_ = val; }
inline int getFlags() const CV_OVERRIDE { return flags_; }
inline void setFlags(int val) CV_OVERRIDE { flags_ = val; }

protected:
void impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2);
Expand Down Expand Up @@ -733,14 +764,22 @@ namespace
void calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2);
void collectGarbage();

CV_IMPL_PROPERTY(double, Tau, tau_)
CV_IMPL_PROPERTY(double, Lambda, lambda_)
CV_IMPL_PROPERTY(double, Theta, theta_)
CV_IMPL_PROPERTY(int, ScalesNumber, nscales_)
CV_IMPL_PROPERTY(int, WarpingsNumber, warps_)
CV_IMPL_PROPERTY(double, Epsilon, epsilon_)
CV_IMPL_PROPERTY(int, Iterations, iterations_)
CV_IMPL_PROPERTY(bool, UseInitialFlow, useInitialFlow_)
inline double getTau() const CV_OVERRIDE { return tau_; }
inline void setTau(double val) CV_OVERRIDE { tau_ = val; }
inline double getLambda() const CV_OVERRIDE { return lambda_; }
inline void setLambda(double val) CV_OVERRIDE { lambda_ = val; }
inline double getTheta() const CV_OVERRIDE { return theta_; }
inline void setTheta(double val) CV_OVERRIDE { theta_ = val; }
inline int getScalesNumber() const CV_OVERRIDE { return nscales_; }
inline void setScalesNumber(int val) CV_OVERRIDE { nscales_ = val; }
inline int getWarpingsNumber() const CV_OVERRIDE { return warps_; }
inline void setWarpingsNumber(int val) CV_OVERRIDE { warps_ = val; }
inline double getEpsilon() const CV_OVERRIDE { return epsilon_; }
inline void setEpsilon(double val) CV_OVERRIDE { epsilon_ = val; }
inline int getIterations() const CV_OVERRIDE { return iterations_; }
inline void setIterations(int val) CV_OVERRIDE { iterations_ = val; }
inline bool getUseInitialFlow() const CV_OVERRIDE { return useInitialFlow_; }
inline void setUseInitialFlow(bool val) CV_OVERRIDE { useInitialFlow_ = val; }

protected:
void impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2);
Expand Down

0 comments on commit a8eb3e1

Please sign in to comment.