mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
fixed warnings; added read/write methods; fixed docs
This commit is contained in:
@@ -82,6 +82,7 @@ public:
|
||||
varThreshold = defaultVarThreshold;
|
||||
backgroundRatio = defaultBackgroundRatio;
|
||||
noiseSigma = defaultNoiseSigma;
|
||||
name_ = "BackgroundSubtractor.MOG";
|
||||
}
|
||||
// the full constructor that takes the length of the history,
|
||||
// the number of gaussian mixtures, the background ratio parameter and the noise strength
|
||||
@@ -138,6 +139,24 @@ public:
|
||||
virtual double getNoiseSigma() const { return noiseSigma; }
|
||||
virtual void setNoiseSigma(double _noiseSigma) { noiseSigma = _noiseSigma; }
|
||||
|
||||
virtual void write(FileStorage& fs) const
|
||||
{
|
||||
fs << "name" << name_
|
||||
<< "history" << history
|
||||
<< "nmixtures" << nmixtures
|
||||
<< "backgroundRatio" << backgroundRatio
|
||||
<< "noiseSigma" << noiseSigma;
|
||||
}
|
||||
|
||||
virtual void read(const FileNode& fn)
|
||||
{
|
||||
CV_Assert( (std::string)fn["name"] == name_ );
|
||||
history = (int)fn["history"];
|
||||
nmixtures = (int)fn["nmixtures"];
|
||||
backgroundRatio = (double)fn["backgroundRatio"];
|
||||
noiseSigma = (double)fn["noiseSigma"];
|
||||
}
|
||||
|
||||
protected:
|
||||
Size frameSize;
|
||||
int frameType;
|
||||
@@ -148,6 +167,7 @@ protected:
|
||||
double varThreshold;
|
||||
double backgroundRatio;
|
||||
double noiseSigma;
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -117,7 +117,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 CV_EXPORTS BackgroundSubtractorMOG2Impl : public BackgroundSubtractorMOG2
|
||||
class BackgroundSubtractorMOG2Impl : public BackgroundSubtractorMOG2
|
||||
{
|
||||
public:
|
||||
//! the default constructor
|
||||
@@ -164,6 +164,7 @@ public:
|
||||
fCT = defaultfCT2;
|
||||
nShadowDetection = defaultnShadowDetection2;
|
||||
fTau = defaultfTau;
|
||||
name_ = "BackgroundSubtractor.MOG2";
|
||||
}
|
||||
//! the destructor
|
||||
~BackgroundSubtractorMOG2Impl() {}
|
||||
@@ -231,6 +232,40 @@ public:
|
||||
virtual double getShadowThreshold() const { return fTau; }
|
||||
virtual void setShadowThreshold(double value) { fTau = (float)value; }
|
||||
|
||||
virtual void write(FileStorage& fs) const
|
||||
{
|
||||
fs << "name" << name_
|
||||
<< "history" << history
|
||||
<< "nmixtures" << nmixtures
|
||||
<< "backgroundRatio" << backgroundRatio
|
||||
<< "varThreshold" << varThreshold
|
||||
<< "varThresholdGen" << varThresholdGen
|
||||
<< "varInit" << fVarInit
|
||||
<< "varMin" << fVarMin
|
||||
<< "varMax" << fVarMax
|
||||
<< "complexityReductionThreshold" << fCT
|
||||
<< "detectShadows" << (int)bShadowDetection
|
||||
<< "shadowValue" << nShadowDetection
|
||||
<< "shadowThreshold" << fTau;
|
||||
}
|
||||
|
||||
virtual void read(const FileNode& fn)
|
||||
{
|
||||
CV_Assert( (std::string)fn["name"] == name_ );
|
||||
history = (int)fn["history"];
|
||||
nmixtures = (int)fn["nmixtures"];
|
||||
backgroundRatio = (float)fn["backgroundRatio"];
|
||||
varThreshold = (double)fn["varThreshold"];
|
||||
varThresholdGen = (float)fn["varThresholdGen"];
|
||||
fVarInit = (float)fn["varInit"];
|
||||
fVarMin = (float)fn["varMin"];
|
||||
fVarMax = (float)fn["varMax"];
|
||||
fCT = (float)fn["complexityReductionThreshold"];
|
||||
bShadowDetection = (int)fn["detectShadows"] != 0;
|
||||
nShadowDetection = (int)fn["shadowValue"];
|
||||
fTau = (float)fn["shadowThreshold"];
|
||||
}
|
||||
|
||||
protected:
|
||||
Size frameSize;
|
||||
int frameType;
|
||||
@@ -284,6 +319,8 @@ protected:
|
||||
//version of the background. Tau is a threshold on how much darker the shadow can be.
|
||||
//Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
|
||||
//See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
|
||||
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
struct GaussBGStatModel2Params
|
||||
|
||||
@@ -53,11 +53,30 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
class CV_EXPORTS BackgroundSubtractorGMGImpl : public BackgroundSubtractorGMG
|
||||
class BackgroundSubtractorGMGImpl : public BackgroundSubtractorGMG
|
||||
{
|
||||
public:
|
||||
BackgroundSubtractorGMGImpl();
|
||||
~BackgroundSubtractorGMGImpl();
|
||||
BackgroundSubtractorGMGImpl()
|
||||
{
|
||||
/*
|
||||
* Default Parameter Values. Override with algorithm "set" method.
|
||||
*/
|
||||
maxFeatures = 64;
|
||||
learningRate = 0.025;
|
||||
numInitializationFrames = 120;
|
||||
quantizationLevels = 16;
|
||||
backgroundPrior = 0.8;
|
||||
decisionThreshold = 0.8;
|
||||
smoothingRadius = 7;
|
||||
updateBackgroundModel = true;
|
||||
minVal_ = maxVal_ = 0;
|
||||
name_ = "BackgroundSubtractor.GMG";
|
||||
}
|
||||
|
||||
~BackgroundSubtractorGMGImpl()
|
||||
{
|
||||
}
|
||||
|
||||
virtual AlgorithmInfo* info() const { return 0; }
|
||||
|
||||
/**
|
||||
@@ -117,6 +136,35 @@ public:
|
||||
CV_Error( CV_StsNotImplemented, "" );
|
||||
}
|
||||
|
||||
virtual void write(FileStorage& fs) const
|
||||
{
|
||||
fs << "name" << name_
|
||||
<< "maxFeatures" << maxFeatures
|
||||
<< "defaultLearningRate" << learningRate
|
||||
<< "numFrames" << numInitializationFrames
|
||||
<< "quantizationLevels" << quantizationLevels
|
||||
<< "backgroundPrior" << backgroundPrior
|
||||
<< "decisionThreshold" << decisionThreshold
|
||||
<< "smoothingRadius" << smoothingRadius
|
||||
<< "updateBackgroundModel" << (int)updateBackgroundModel;
|
||||
// we do not save minVal_ & maxVal_, since they depend on the image type.
|
||||
}
|
||||
|
||||
virtual void read(const FileNode& fn)
|
||||
{
|
||||
CV_Assert( (std::string)fn["name"] == name_ );
|
||||
maxFeatures = (int)fn["maxFeatures"];
|
||||
learningRate = (double)fn["defaultLearningRate"];
|
||||
numInitializationFrames = (int)fn["numFrames"];
|
||||
quantizationLevels = (int)fn["quantizationLevels"];
|
||||
backgroundPrior = (double)fn["backgroundPrior"];
|
||||
smoothingRadius = (int)fn["smoothingRadius"];
|
||||
decisionThreshold = (double)fn["decisionThreshold"];
|
||||
updateBackgroundModel = (int)fn["updateBackgroundModel"] != 0;
|
||||
minVal_ = maxVal_ = 0;
|
||||
frameSize_ = Size();
|
||||
}
|
||||
|
||||
//! Total number of distinct colors to maintain in histogram.
|
||||
int maxFeatures;
|
||||
//! Set between 0.0 and 1.0, determines how quickly features are "forgotten" from histograms.
|
||||
@@ -141,6 +189,8 @@ private:
|
||||
Size frameSize_;
|
||||
int frameNum_;
|
||||
|
||||
std::string name_;
|
||||
|
||||
Mat_<int> nfeatures_;
|
||||
Mat_<unsigned int> colors_;
|
||||
Mat_<float> weights_;
|
||||
@@ -148,25 +198,6 @@ private:
|
||||
Mat buf_;
|
||||
};
|
||||
|
||||
BackgroundSubtractorGMGImpl::BackgroundSubtractorGMGImpl()
|
||||
{
|
||||
/*
|
||||
* Default Parameter Values. Override with algorithm "set" method.
|
||||
*/
|
||||
maxFeatures = 64;
|
||||
learningRate = 0.025;
|
||||
numInitializationFrames = 120;
|
||||
quantizationLevels = 16;
|
||||
backgroundPrior = 0.8;
|
||||
decisionThreshold = 0.8;
|
||||
smoothingRadius = 7;
|
||||
updateBackgroundModel = true;
|
||||
minVal_ = maxVal_ = 0;
|
||||
}
|
||||
|
||||
BackgroundSubtractorGMGImpl::~BackgroundSubtractorGMGImpl()
|
||||
{
|
||||
}
|
||||
|
||||
void BackgroundSubtractorGMGImpl::initialize(Size frameSize, double minVal, double maxVal)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user