From 1ca7ae963058aeb52b71c675047eaa1636ccc8b2 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 15 Mar 2018 16:17:01 +0300 Subject: [PATCH] video: apply CV_OVERRIDE/CV_FINAL --- .../include/opencv2/video/background_segm.hpp | 2 +- modules/video/src/bgfg_KNN.cpp | 42 +++++++-------- modules/video/src/bgfg_gaussmix2.cpp | 62 +++++++++++----------- modules/video/src/lkpyramid.cpp | 22 ++++---- modules/video/src/lkpyramid.hpp | 2 +- modules/video/src/optflowgf.cpp | 38 ++++++------- modules/video/src/tvl1flow.cpp | 56 +++++++++++-------- 7 files changed, 118 insertions(+), 106 deletions(-) diff --git a/modules/video/include/opencv2/video/background_segm.hpp b/modules/video/include/opencv2/video/background_segm.hpp index ea7a897..e1dfa15 100644 --- a/modules/video/include/opencv2/video/background_segm.hpp +++ b/modules/video/include/opencv2/video/background_segm.hpp @@ -205,7 +205,7 @@ public: rate. 0 means that the background model is not updated at all, 1 means that the background model is completely reinitialized from the last frame. */ - CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0; + CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE = 0; }; /** @brief Creates MOG2 Background Subtractor diff --git a/modules/video/src/bgfg_KNN.cpp b/modules/video/src/bgfg_KNN.cpp index d8ec99c..2866e2d 100755 --- a/modules/video/src/bgfg_KNN.cpp +++ b/modules/video/src/bgfg_KNN.cpp @@ -64,7 +64,7 @@ static const float defaultDist2Threshold = 20.0f*20.0f;//threshold on distance f static const unsigned char defaultnShadowDetection2 = (unsigned char)127; // value to use in the segmentation mask for shadows, set 0 not to do shadow detection static const float defaultfTau = 0.5f; // Tau - shadow threshold, see the paper for explanation -class BackgroundSubtractorKNNImpl : public BackgroundSubtractorKNN +class BackgroundSubtractorKNNImpl CV_FINAL : public BackgroundSubtractorKNN { public: //! the default constructor @@ -128,12 +128,12 @@ public: #endif } //! the destructor - ~BackgroundSubtractorKNNImpl() {} + ~BackgroundSubtractorKNNImpl() CV_OVERRIDE {} //! the update operator - void apply(InputArray image, OutputArray fgmask, double learningRate=-1); + void apply(InputArray image, OutputArray fgmask, double learningRate) CV_OVERRIDE; //! computes a background image which are the mean of all background gaussians - virtual void getBackgroundImage(OutputArray backgroundImage) const; + virtual void getBackgroundImage(OutputArray backgroundImage) const CV_OVERRIDE; //! re-initialization method void initialize(Size _frameSize, int _frameType) @@ -214,20 +214,20 @@ public: } } - virtual int getHistory() const { return history; } - virtual void setHistory(int _nframes) { history = _nframes; } + virtual int getHistory() const CV_OVERRIDE { return history; } + virtual void setHistory(int _nframes) CV_OVERRIDE { history = _nframes; } - virtual int getNSamples() const { return nN; } - virtual void setNSamples(int _nN) { nN = _nN; }//needs reinitialization! + virtual int getNSamples() const CV_OVERRIDE { return nN; } + virtual void setNSamples(int _nN) CV_OVERRIDE { nN = _nN; }//needs reinitialization! - virtual int getkNNSamples() const { return nkNN; } - virtual void setkNNSamples(int _nkNN) { nkNN = _nkNN; } + virtual int getkNNSamples() const CV_OVERRIDE { return nkNN; } + virtual void setkNNSamples(int _nkNN) CV_OVERRIDE { nkNN = _nkNN; } - virtual double getDist2Threshold() const { return fTb; } - virtual void setDist2Threshold(double _dist2Threshold) { fTb = (float)_dist2Threshold; } + virtual double getDist2Threshold() const CV_OVERRIDE { return fTb; } + virtual void setDist2Threshold(double _dist2Threshold) CV_OVERRIDE { fTb = (float)_dist2Threshold; } - virtual bool getDetectShadows() const { return bShadowDetection; } - virtual void setDetectShadows(bool detectshadows) + virtual bool getDetectShadows() const CV_OVERRIDE { return bShadowDetection; } + virtual void setDetectShadows(bool detectshadows) CV_OVERRIDE { if ((bShadowDetection && detectshadows) || (!bShadowDetection && !detectshadows)) return; @@ -241,13 +241,13 @@ public: #endif } - virtual int getShadowValue() const { return nShadowDetection; } - virtual void setShadowValue(int value) { nShadowDetection = (uchar)value; } + virtual int getShadowValue() const CV_OVERRIDE { return nShadowDetection; } + virtual void setShadowValue(int value) CV_OVERRIDE { nShadowDetection = (uchar)value; } - virtual double getShadowThreshold() const { return fTau; } - virtual void setShadowThreshold(double value) { fTau = (float)value; } + virtual double getShadowThreshold() const CV_OVERRIDE { return fTau; } + virtual void setShadowThreshold(double value) CV_OVERRIDE { fTau = (float)value; } - virtual void write(FileStorage& fs) const + virtual void write(FileStorage& fs) const CV_OVERRIDE { writeFormat(fs); fs << "name" << name_ @@ -260,7 +260,7 @@ public: << "shadowThreshold" << fTau; } - virtual void read(const FileNode& fn) + virtual void read(const FileNode& fn) CV_OVERRIDE { CV_Assert( (String)fn["name"] == name_ ); history = (int)fn["history"]; @@ -546,7 +546,7 @@ public: m_nShadowDetection = _nShadowDetection; } - void operator()(const Range& range) const + void operator()(const Range& range) const CV_OVERRIDE { int y0 = range.start, y1 = range.end; int ncols = src->cols, nchannels = src->channels(); diff --git a/modules/video/src/bgfg_gaussmix2.cpp b/modules/video/src/bgfg_gaussmix2.cpp index 68d06d8..f338b6c 100644 --- a/modules/video/src/bgfg_gaussmix2.cpp +++ b/modules/video/src/bgfg_gaussmix2.cpp @@ -118,7 +118,7 @@ static const unsigned char defaultnShadowDetection2 = (unsigned char)127; // val static const float defaultfTau = 0.5f; // Tau - shadow threshold, see the paper for explanation -class BackgroundSubtractorMOG2Impl : public BackgroundSubtractorMOG2 +class BackgroundSubtractorMOG2Impl CV_FINAL : public BackgroundSubtractorMOG2 { public: //! the default constructor @@ -174,12 +174,12 @@ public: #endif } //! the destructor - ~BackgroundSubtractorMOG2Impl() {} + ~BackgroundSubtractorMOG2Impl() CV_OVERRIDE {} //! the update operator - void apply(InputArray image, OutputArray fgmask, double learningRate=-1); + void apply(InputArray image, OutputArray fgmask, double learningRate) CV_OVERRIDE; //! computes a background image which are the mean of all background gaussians - virtual void getBackgroundImage(OutputArray backgroundImage) const; + virtual void getBackgroundImage(OutputArray backgroundImage) const CV_OVERRIDE; //! re-initiaization method void initialize(Size _frameSize, int _frameType) @@ -236,35 +236,35 @@ public: } } - virtual int getHistory() const { return history; } - virtual void setHistory(int _nframes) { history = _nframes; } + virtual int getHistory() const CV_OVERRIDE { return history; } + virtual void setHistory(int _nframes) CV_OVERRIDE { history = _nframes; } - virtual int getNMixtures() const { return nmixtures; } - virtual void setNMixtures(int nmix) { nmixtures = nmix; } + virtual int getNMixtures() const CV_OVERRIDE { return nmixtures; } + virtual void setNMixtures(int nmix) CV_OVERRIDE { nmixtures = nmix; } - virtual double getBackgroundRatio() const { return backgroundRatio; } - virtual void setBackgroundRatio(double _backgroundRatio) { backgroundRatio = (float)_backgroundRatio; } + virtual double getBackgroundRatio() const CV_OVERRIDE { return backgroundRatio; } + virtual void setBackgroundRatio(double _backgroundRatio) CV_OVERRIDE { backgroundRatio = (float)_backgroundRatio; } - virtual double getVarThreshold() const { return varThreshold; } - virtual void setVarThreshold(double _varThreshold) { varThreshold = _varThreshold; } + virtual double getVarThreshold() const CV_OVERRIDE { return varThreshold; } + virtual void setVarThreshold(double _varThreshold) CV_OVERRIDE { varThreshold = _varThreshold; } - virtual double getVarThresholdGen() const { return varThresholdGen; } - virtual void setVarThresholdGen(double _varThresholdGen) { varThresholdGen = (float)_varThresholdGen; } + virtual double getVarThresholdGen() const CV_OVERRIDE { return varThresholdGen; } + virtual void setVarThresholdGen(double _varThresholdGen) CV_OVERRIDE { varThresholdGen = (float)_varThresholdGen; } - virtual double getVarInit() const { return fVarInit; } - virtual void setVarInit(double varInit) { fVarInit = (float)varInit; } + virtual double getVarInit() const CV_OVERRIDE { return fVarInit; } + virtual void setVarInit(double varInit) CV_OVERRIDE { fVarInit = (float)varInit; } - virtual double getVarMin() const { return fVarMin; } - virtual void setVarMin(double varMin) { fVarMin = (float)varMin; } + virtual double getVarMin() const CV_OVERRIDE { return fVarMin; } + virtual void setVarMin(double varMin) CV_OVERRIDE { fVarMin = (float)varMin; } - virtual double getVarMax() const { return fVarMax; } - virtual void setVarMax(double varMax) { fVarMax = (float)varMax; } + virtual double getVarMax() const CV_OVERRIDE { return fVarMax; } + virtual void setVarMax(double varMax) CV_OVERRIDE { fVarMax = (float)varMax; } - virtual double getComplexityReductionThreshold() const { return fCT; } - virtual void setComplexityReductionThreshold(double ct) { fCT = (float)ct; } + virtual double getComplexityReductionThreshold() const CV_OVERRIDE { return fCT; } + virtual void setComplexityReductionThreshold(double ct) CV_OVERRIDE { fCT = (float)ct; } - virtual bool getDetectShadows() const { return bShadowDetection; } - virtual void setDetectShadows(bool detectshadows) + virtual bool getDetectShadows() const CV_OVERRIDE { return bShadowDetection; } + virtual void setDetectShadows(bool detectshadows) CV_OVERRIDE { if ((bShadowDetection && detectshadows) || (!bShadowDetection && !detectshadows)) return; @@ -278,13 +278,13 @@ public: #endif } - virtual int getShadowValue() const { return nShadowDetection; } - virtual void setShadowValue(int value) { nShadowDetection = (uchar)value; } + virtual int getShadowValue() const CV_OVERRIDE { return nShadowDetection; } + virtual void setShadowValue(int value) CV_OVERRIDE { nShadowDetection = (uchar)value; } - virtual double getShadowThreshold() const { return fTau; } - virtual void setShadowThreshold(double value) { fTau = (float)value; } + virtual double getShadowThreshold() const CV_OVERRIDE { return fTau; } + virtual void setShadowThreshold(double value) CV_OVERRIDE { fTau = (float)value; } - virtual void write(FileStorage& fs) const + virtual void write(FileStorage& fs) const CV_OVERRIDE { writeFormat(fs); fs << "name" << name_ @@ -302,7 +302,7 @@ public: << "shadowThreshold" << fTau; } - virtual void read(const FileNode& fn) + virtual void read(const FileNode& fn) CV_OVERRIDE { CV_Assert( (String)fn["name"] == name_ ); history = (int)fn["history"]; @@ -565,7 +565,7 @@ public: shadowVal = _shadowVal; } - void operator()(const Range& range) const + void operator()(const Range& range) const CV_OVERRIDE { int y0 = range.start, y1 = range.end; int ncols = src->cols, nchannels = src->channels(); diff --git a/modules/video/src/lkpyramid.cpp b/modules/video/src/lkpyramid.cpp index e646021..48f896d 100644 --- a/modules/video/src/lkpyramid.cpp +++ b/modules/video/src/lkpyramid.cpp @@ -819,25 +819,25 @@ namespace { } - virtual Size getWinSize() const {return winSize;} - virtual void setWinSize(Size winSize_){winSize = winSize_;} + virtual Size getWinSize() const CV_OVERRIDE { return winSize;} + virtual void setWinSize(Size winSize_) CV_OVERRIDE { winSize = winSize_;} - virtual int getMaxLevel() const {return maxLevel;} - virtual void setMaxLevel(int maxLevel_){maxLevel = maxLevel_;} + virtual int getMaxLevel() const CV_OVERRIDE { return maxLevel;} + virtual void setMaxLevel(int maxLevel_) CV_OVERRIDE { maxLevel = maxLevel_;} - virtual TermCriteria getTermCriteria() const {return criteria;} - virtual void setTermCriteria(TermCriteria& crit_){criteria=crit_;} + virtual TermCriteria getTermCriteria() const CV_OVERRIDE { return criteria;} + virtual void setTermCriteria(TermCriteria& crit_) CV_OVERRIDE { criteria=crit_;} - virtual int getFlags() const {return flags; } - virtual void setFlags(int flags_){flags=flags_;} + virtual int getFlags() const CV_OVERRIDE { return flags; } + virtual void setFlags(int flags_) CV_OVERRIDE { flags=flags_;} - virtual double getMinEigThreshold() const {return minEigThreshold;} - virtual void setMinEigThreshold(double minEigThreshold_){minEigThreshold=minEigThreshold_;} + virtual double getMinEigThreshold() const CV_OVERRIDE { return minEigThreshold;} + virtual void setMinEigThreshold(double minEigThreshold_) CV_OVERRIDE { minEigThreshold=minEigThreshold_;} virtual void calc(InputArray prevImg, InputArray nextImg, InputArray prevPts, InputOutputArray nextPts, OutputArray status, - OutputArray err = cv::noArray()); + OutputArray err = cv::noArray()) CV_OVERRIDE; private: #ifdef HAVE_OPENCL diff --git a/modules/video/src/lkpyramid.hpp b/modules/video/src/lkpyramid.hpp index 1b9d50b..9e62d06 100644 --- a/modules/video/src/lkpyramid.hpp +++ b/modules/video/src/lkpyramid.hpp @@ -15,7 +15,7 @@ namespace detail Size _winSize, TermCriteria _criteria, int _level, int _maxLevel, int _flags, float _minEigThreshold ); - void operator()(const Range& range) const; + void operator()(const Range& range) const CV_OVERRIDE; const Mat* prevImg; const Mat* nextImg; diff --git a/modules/video/src/optflowgf.cpp b/modules/video/src/optflowgf.cpp index cb2dc59..448dea2 100644 --- a/modules/video/src/optflowgf.cpp +++ b/modules/video/src/optflowgf.cpp @@ -597,31 +597,31 @@ public: { } - virtual int getNumLevels() const { return numLevels_; } - virtual void setNumLevels(int numLevels) { numLevels_ = numLevels; } + virtual int getNumLevels() const CV_OVERRIDE { return numLevels_; } + virtual void setNumLevels(int numLevels) CV_OVERRIDE { numLevels_ = numLevels; } - virtual double getPyrScale() const { return pyrScale_; } - virtual void setPyrScale(double pyrScale) { pyrScale_ = pyrScale; } + virtual double getPyrScale() const CV_OVERRIDE { return pyrScale_; } + virtual void setPyrScale(double pyrScale) CV_OVERRIDE { pyrScale_ = pyrScale; } - virtual bool getFastPyramids() const { return fastPyramids_; } - virtual void setFastPyramids(bool fastPyramids) { fastPyramids_ = fastPyramids; } + virtual bool getFastPyramids() const CV_OVERRIDE { return fastPyramids_; } + virtual void setFastPyramids(bool fastPyramids) CV_OVERRIDE { fastPyramids_ = fastPyramids; } - virtual int getWinSize() const { return winSize_; } - virtual void setWinSize(int winSize) { winSize_ = winSize; } + virtual int getWinSize() const CV_OVERRIDE { return winSize_; } + virtual void setWinSize(int winSize) CV_OVERRIDE { winSize_ = winSize; } - virtual int getNumIters() const { return numIters_; } - virtual void setNumIters(int numIters) { numIters_ = numIters; } + virtual int getNumIters() const CV_OVERRIDE { return numIters_; } + virtual void setNumIters(int numIters) CV_OVERRIDE { numIters_ = numIters; } - virtual int getPolyN() const { return polyN_; } - virtual void setPolyN(int polyN) { polyN_ = polyN; } + virtual int getPolyN() const CV_OVERRIDE { return polyN_; } + virtual void setPolyN(int polyN) CV_OVERRIDE { polyN_ = polyN; } - virtual double getPolySigma() const { return polySigma_; } - virtual void setPolySigma(double polySigma) { polySigma_ = polySigma; } + virtual double getPolySigma() const CV_OVERRIDE { return polySigma_; } + virtual void setPolySigma(double polySigma) CV_OVERRIDE { polySigma_ = polySigma; } - virtual int getFlags() const { return flags_; } - virtual void setFlags(int flags) { flags_ = flags; } + virtual int getFlags() const CV_OVERRIDE { return flags_; } + virtual void setFlags(int flags) CV_OVERRIDE { flags_ = flags; } - virtual void calc(InputArray I0, InputArray I1, InputOutputArray flow); + virtual void calc(InputArray I0, InputArray I1, InputOutputArray flow) CV_OVERRIDE; private: int numLevels_; @@ -800,7 +800,7 @@ private: flowy = curFlowY; return true; } - virtual void collectGarbage(){ + virtual void collectGarbage() CV_OVERRIDE { releaseMemory(); } void releaseMemory() @@ -1089,7 +1089,7 @@ private: return true; } #else // HAVE_OPENCL - virtual void collectGarbage(){} + virtual void collectGarbage() CV_OVERRIDE {} #endif }; diff --git a/modules/video/src/tvl1flow.cpp b/modules/video/src/tvl1flow.cpp index 42de2a3..061d047 100644 --- a/modules/video/src/tvl1flow.cpp +++ b/modules/video/src/tvl1flow.cpp @@ -102,21 +102,33 @@ public: } OpticalFlowDual_TVL1(); - void calc(InputArray I0, InputArray I1, InputOutputArray flow); - void collectGarbage(); - - CV_IMPL_PROPERTY(double, Tau, tau) - CV_IMPL_PROPERTY(double, Lambda, lambda) - CV_IMPL_PROPERTY(double, Theta, theta) - CV_IMPL_PROPERTY(double, Gamma, gamma) - CV_IMPL_PROPERTY(int, ScalesNumber, nscales) - CV_IMPL_PROPERTY(int, WarpingsNumber, warps) - CV_IMPL_PROPERTY(double, Epsilon, epsilon) - CV_IMPL_PROPERTY(int, InnerIterations, innerIterations) - CV_IMPL_PROPERTY(int, OuterIterations, outerIterations) - CV_IMPL_PROPERTY(bool, UseInitialFlow, useInitialFlow) - CV_IMPL_PROPERTY(double, ScaleStep, scaleStep) - CV_IMPL_PROPERTY(int, MedianFiltering, medianFiltering) + void calc(InputArray I0, InputArray I1, InputOutputArray flow) CV_OVERRIDE; + void collectGarbage() CV_OVERRIDE; + + 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 double getGamma() const CV_OVERRIDE { return gamma; } + inline void setGamma(double val) CV_OVERRIDE { gamma = 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 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 bool getUseInitialFlow() const CV_OVERRIDE { return useInitialFlow; } + inline void setUseInitialFlow(bool val) CV_OVERRIDE { useInitialFlow = val; } + inline double getScaleStep() const CV_OVERRIDE { return scaleStep; } + inline void setScaleStep(double val) CV_OVERRIDE { scaleStep = val; } + inline int getMedianFiltering() const CV_OVERRIDE { return medianFiltering; } + inline void setMedianFiltering(int val) CV_OVERRIDE { medianFiltering = val; } protected: double tau; @@ -628,7 +640,7 @@ bool OpticalFlowDual_TVL1::calc_ocl(InputArray _I0, InputArray _I1, InputOutputA struct BuildFlowMapBody : ParallelLoopBody { - void operator() (const Range& range) const; + void operator() (const Range& range) const CV_OVERRIDE; Mat_ u1; Mat_ u2; @@ -675,7 +687,7 @@ void buildFlowMap(const Mat_& u1, const Mat_& u2, Mat_& map struct CenteredGradientBody : ParallelLoopBody { - void operator() (const Range& range) const; + void operator() (const Range& range) const CV_OVERRIDE; Mat_ src; mutable Mat_ dx; @@ -762,7 +774,7 @@ void centeredGradient(const Mat_& src, Mat_& dx, Mat_& dy) struct ForwardGradientBody : ParallelLoopBody { - void operator() (const Range& range) const; + void operator() (const Range& range) const CV_OVERRIDE; Mat_ src; mutable Mat_ dx; @@ -832,7 +844,7 @@ void forwardGradient(const Mat_& src, Mat_& dx, Mat_& dy) struct DivergenceBody : ParallelLoopBody { - void operator() (const Range& range) const; + void operator() (const Range& range) const CV_OVERRIDE; Mat_ v1; Mat_ v2; @@ -891,7 +903,7 @@ void divergence(const Mat_& v1, const Mat_& v2, Mat_& div) struct CalcGradRhoBody : ParallelLoopBody { - void operator() (const Range& range) const; + void operator() (const Range& range) const CV_OVERRIDE; Mat_ I0; Mat_ I1w; @@ -961,7 +973,7 @@ void calcGradRho(const Mat_& I0, const Mat_& I1w, const Mat_ I1wx; Mat_ I1wy; @@ -1108,7 +1120,7 @@ float estimateU(const Mat_& v1, const Mat_& v2, const Mat_& struct EstimateDualVariablesBody : ParallelLoopBody { - void operator() (const Range& range) const; + void operator() (const Range& range) const CV_OVERRIDE; Mat_ u1x; Mat_ u1y; -- 2.7.4