diff --git a/modules/cudabgsegm/src/mog2.cpp b/modules/cudabgsegm/src/mog2.cpp index 47135a088b..719317014a 100644 --- a/modules/cudabgsegm/src/mog2.cpp +++ b/modules/cudabgsegm/src/mog2.cpp @@ -105,10 +105,21 @@ class MOG2Impl CV_FINAL : public cuda::BackgroundSubtractorMOG2 void setVarInit(double varInit) CV_OVERRIDE { constantsHost_.varInit_ = (float)varInit; } double getVarMin() const CV_OVERRIDE { return constantsHost_.varMin_; } - void setVarMin(double varMin) CV_OVERRIDE { constantsHost_.varMin_ = ::fminf((float)varMin, constantsHost_.varMax_); } - + void setVarMin(double varMin) CV_OVERRIDE { + if (nframes_ == 0) { + constantsHost_.varMin_ = (float)varMin; + } else { + constantsHost_.varMin_ = ::fminf((float)varMin, constantsHost_.varMax_); + } + } double getVarMax() const CV_OVERRIDE { return constantsHost_.varMax_; } - void setVarMax(double varMax) CV_OVERRIDE { constantsHost_.varMax_ = ::fmaxf(constantsHost_.varMin_, (float)varMax); } + void setVarMax(double varMax) CV_OVERRIDE { + if (nframes_ == 0) { + constantsHost_.varMax_ = (float)varMax; + } else { + constantsHost_.varMax_ = ::fmaxf(constantsHost_.varMin_, (float)varMax); + } + } double getComplexityReductionThreshold() const CV_OVERRIDE { return ct_; } void setComplexityReductionThreshold(double ct) CV_OVERRIDE { ct_ = (float)ct; }