mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
fixed warnings; added read/write methods; fixed docs
This commit is contained in:
parent
07e0f7bf59
commit
09127aa358
@ -158,7 +158,6 @@ findTransformECC
|
||||
Finds the geometric transform (warp) between two images in terms of the ECC criterion [EP08]_.
|
||||
|
||||
.. ocv:function:: double findTransformECC( InputArray templateImage, InputArray inputImage, InputOutputArray warpMatrix, int motionType=MOTION_AFFINE, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001))
|
||||
.. ocv:cfunction:: double cvFindTransformECC( const CvArr* templateImage, const CvArr* inputImage, CvMat* warpMatrix, const int motionType, const CvTermCriteria criteria)
|
||||
|
||||
:param templateImage: single-channel template image; ``CV_8U`` or ``CV_32F`` array.
|
||||
|
||||
@ -167,9 +166,13 @@ Finds the geometric transform (warp) between two images in terms of the ECC crit
|
||||
:param warpMatrix: floating-point :math:`2\times 3` or :math:`3\times 3` mapping matrix (warp).
|
||||
|
||||
:param motionType: parameter, specifying the type of motion:
|
||||
|
||||
* **MOTION_TRANSLATION** sets a translational motion model; ``warpMatrix`` is :math:`2\times 3` with the first :math:`2\times 2` part being the unity matrix and the rest two parameters being estimated.
|
||||
|
||||
* **MOTION_EUCLIDEAN** sets a Euclidean (rigid) transformation as motion model; three parameters are estimated; ``warpMatrix`` is :math:`2\times 3`.
|
||||
|
||||
* **MOTION_AFFINE** sets an affine motion model (DEFAULT); six parameters are estimated; ``warpMatrix`` is :math:`2\times 3`.
|
||||
|
||||
* **MOTION_HOMOGRAPHY** sets a homography as a motion model; eight parameters are estimated;``warpMatrix`` is :math:`3\times 3`.
|
||||
|
||||
:param criteria: parameter, specifying the termination criteria of the ECC algorithm; ``criteria.epsilon`` defines the threshold of the increment in the correlation coefficient between two iterations (a negative ``criteria.epsilon`` makes ``criteria.maxcount`` the only termination criterion). Default values are shown in the declaration above.
|
||||
@ -177,13 +180,13 @@ Finds the geometric transform (warp) between two images in terms of the ECC crit
|
||||
|
||||
The function estimates the optimum transformation (``warpMatrix``) with respect to ECC criterion ([EP08]_), that is
|
||||
|
||||
..math::
|
||||
.. math::
|
||||
|
||||
\texttt{warpMatrix} = \texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))
|
||||
|
||||
where
|
||||
|
||||
..math::
|
||||
.. math::
|
||||
|
||||
\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}
|
||||
|
||||
@ -479,7 +482,7 @@ Base class for background/foreground segmentation. ::
|
||||
{
|
||||
public:
|
||||
virtual ~BackgroundSubtractor();
|
||||
virtual void operator()(InputArray image, OutputArray fgmask, double learningRate=0);
|
||||
virtual void apply(InputArray image, OutputArray fgmask, double learningRate=0);
|
||||
virtual void getBackgroundImage(OutputArray backgroundImage) const;
|
||||
};
|
||||
|
||||
@ -487,18 +490,19 @@ Base class for background/foreground segmentation. ::
|
||||
The class is only used to define the common interface for the whole family of background/foreground segmentation algorithms.
|
||||
|
||||
|
||||
BackgroundSubtractor::operator()
|
||||
BackgroundSubtractor::apply
|
||||
--------------------------------
|
||||
Computes a foreground mask.
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractor::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
|
||||
.. ocv:function:: void BackgroundSubtractor::apply(InputArray image, OutputArray fgmask, double learningRate=-1)
|
||||
|
||||
.. ocv:pyfunction:: cv2.BackgroundSubtractor.apply(image[, fgmask[, learningRate]]) -> fgmask
|
||||
|
||||
:param image: Next video frame.
|
||||
|
||||
:param fgmask: The output foreground mask as an 8-bit binary image.
|
||||
|
||||
|
||||
:param learningRate: The value between 0 and 1 that indicates how fast the background model is learnt. Negative parameter value makes the algorithm to use some automatically chosen learning 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.
|
||||
|
||||
BackgroundSubtractor::getBackgroundImage
|
||||
----------------------------------------
|
||||
@ -517,20 +521,16 @@ BackgroundSubtractorMOG
|
||||
|
||||
Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
|
||||
|
||||
The class implements the algorithm described in P. KadewTraKuPong and R. Bowden, *An improved adaptive background mixture model for real-time tracking with shadow detection*, Proc. 2nd European Workshop on Advanced Video-Based Surveillance Systems, 2001: http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf
|
||||
The class implements the algorithm described in [KB2001]_.
|
||||
|
||||
|
||||
|
||||
|
||||
BackgroundSubtractorMOG::BackgroundSubtractorMOG
|
||||
createBackgroundSubtractorMOG
|
||||
------------------------------------------------
|
||||
The constructors.
|
||||
Creates mixture-of-gaussian background subtractor
|
||||
|
||||
.. ocv:function:: BackgroundSubtractorMOG::BackgroundSubtractorMOG()
|
||||
.. ocv:function:: Ptr<BackgroundSubtractorMOG> createBackgroundSubtractorMOG(int history=200, int nmixtures=5, double backgroundRatio=0.7, double noiseSigma=0)
|
||||
|
||||
.. ocv:function:: BackgroundSubtractorMOG::BackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio, double noiseSigma=0)
|
||||
|
||||
.. ocv:pyfunction:: cv2.BackgroundSubtractorMOG([history, nmixtures, backgroundRatio[, noiseSigma]]) -> <BackgroundSubtractorMOG object>
|
||||
.. ocv:pyfunction:: cv2.createBackgroundSubtractorMOG([history, nmixtures, backgroundRatio, noiseSigma]) -> <BackgroundSubtractorMOG object>
|
||||
|
||||
:param history: Length of the history.
|
||||
|
||||
@ -538,20 +538,7 @@ The constructors.
|
||||
|
||||
:param backgroundRatio: Background ratio.
|
||||
|
||||
:param noiseSigma: Noise strength.
|
||||
|
||||
Default constructor sets all parameters to default values.
|
||||
|
||||
|
||||
|
||||
|
||||
BackgroundSubtractorMOG::operator()
|
||||
-----------------------------------
|
||||
Updates the background model and returns the foreground mask
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
|
||||
|
||||
Parameters are the same as in :ocv:funcx:`BackgroundSubtractor::operator()`
|
||||
:param noiseSigma: Noise strength (standard deviation of the brightness or each color channel). 0 means some automatic value.
|
||||
|
||||
|
||||
BackgroundSubtractorMOG2
|
||||
@ -560,84 +547,147 @@ Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
|
||||
|
||||
.. ocv:class:: BackgroundSubtractorMOG2 : public BackgroundSubtractor
|
||||
|
||||
Here are important members of the class that control the algorithm, which you can set after constructing the class instance:
|
||||
|
||||
.. ocv:member:: int nmixtures
|
||||
|
||||
Maximum allowed number of mixture components. Actual number is determined dynamically per pixel.
|
||||
|
||||
.. ocv:member:: float backgroundRatio
|
||||
|
||||
Threshold defining whether the component is significant enough to be included into the background model ( corresponds to ``TB=1-cf`` from the paper??which paper??). ``cf=0.1 => TB=0.9`` is default. For ``alpha=0.001``, it means that the mode should exist for approximately 105 frames before it is considered foreground.
|
||||
|
||||
.. ocv:member:: float varThresholdGen
|
||||
|
||||
Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to ``Tg``). If it is not close to any component, a new component is generated. ``3 sigma => Tg=3*3=9`` is default. A smaller ``Tg`` value generates more components. A higher ``Tg`` value may result in a small number of components but they can grow too large.
|
||||
|
||||
.. ocv:member:: float fVarInit
|
||||
|
||||
Initial variance for the newly generated components. It affects the speed of adaptation. The parameter value is based on your estimate of the typical standard deviation from the images. OpenCV uses 15 as a reasonable value.
|
||||
|
||||
.. ocv:member:: float fVarMin
|
||||
|
||||
Parameter used to further control the variance.
|
||||
|
||||
.. ocv:member:: float fVarMax
|
||||
|
||||
Parameter used to further control the variance.
|
||||
|
||||
.. ocv:member:: float fCT
|
||||
|
||||
Complexity reduction parameter. This parameter defines the number of samples needed to accept to prove the component exists. ``CT=0.05`` is a default value for all the samples. By setting ``CT=0`` you get an algorithm very similar to the standard Stauffer&Grimson algorithm.
|
||||
|
||||
.. ocv:member:: uchar nShadowDetection
|
||||
|
||||
The value for marking shadow pixels in the output foreground mask. Default value is 127.
|
||||
|
||||
.. ocv:member:: float fTau
|
||||
|
||||
Shadow threshold. The shadow is detected if the pixel is a darker version of the background. ``Tau`` is a threshold defining how much darker the shadow can be. ``Tau= 0.5`` means that if a pixel is more than twice darker then it is not shadow. See Prati,Mikic,Trivedi,Cucchiarra, *Detecting Moving Shadows...*, IEEE PAMI,2003.
|
||||
The class implements the Gaussian mixture model background subtraction described in [Zivkovic2004]_ and [Zivkovic2006]_ .
|
||||
|
||||
|
||||
The class implements the Gaussian mixture model background subtraction described in:
|
||||
|
||||
* Z.Zivkovic, *Improved adaptive Gausian mixture model for background subtraction*, International Conference Pattern Recognition, UK, August, 2004, http://www.zoranz.net/Publications/zivkovic2004ICPR.pdf. The code is very fast and performs also shadow detection. Number of Gausssian components is adapted per pixel.
|
||||
|
||||
* Z.Zivkovic, F. van der Heijden, *Efficient Adaptive Density Estimapion per Image Pixel for the Task of Background Subtraction*, Pattern Recognition Letters, vol. 27, no. 7, pages 773-780, 2006. The algorithm similar to the standard Stauffer&Grimson algorithm with additional selection of the number of the Gaussian components based on: Z.Zivkovic, F.van der Heijden, Recursive unsupervised learning of finite mixture models, IEEE Trans. on Pattern Analysis and Machine Intelligence, vol.26, no.5, pages 651-656, 2004.
|
||||
|
||||
|
||||
BackgroundSubtractorMOG2::BackgroundSubtractorMOG2
|
||||
createBackgroundSubtractorMOG2
|
||||
--------------------------------------------------
|
||||
The constructors.
|
||||
Creates MOG2 Background Subtractor
|
||||
|
||||
.. ocv:function:: BackgroundSubtractorMOG2::BackgroundSubtractorMOG2()
|
||||
.. ocv:function:: Ptr<BackgroundSubtractorMOG2> createBackgroundSubtractorMOG2( int history=500, double varThreshold=16, bool detectShadows=true )
|
||||
|
||||
.. ocv:function:: BackgroundSubtractorMOG2::BackgroundSubtractorMOG2( int history, float varThreshold, bool bShadowDetection=true )
|
||||
:param history: Length of the history.
|
||||
|
||||
:param history: Length of the history.
|
||||
:param varThreshold: Threshold on the squared Mahalanobis distance between the pixel and the model to decide whether a pixel is well described by the background model. This parameter does not affect the background update.
|
||||
|
||||
:param varThreshold: Threshold on the squared Mahalanobis distance to decide whether it is well described by the background model (see Cthr??). This parameter does not affect the background update. A typical value could be 4 sigma, that is, ``varThreshold=4*4=16;`` (see Tb??).
|
||||
|
||||
:param bShadowDetection: Parameter defining whether shadow detection should be enabled (``true`` or ``false``).
|
||||
:param detectShadows: If true, the algorithm will detect shadows and mark them. It decreases the speed a bit, so if you do not need this feature, set the parameter to false.
|
||||
|
||||
|
||||
BackgroundSubtractorMOG2::getHistory
|
||||
--------------------------------------
|
||||
Returns the number of last frames that affect the background model
|
||||
|
||||
BackgroundSubtractorMOG2::operator()
|
||||
------------------------------------
|
||||
Updates the background model and computes the foreground mask
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::operator()(InputArray image, OutputArray fgmask, double learningRate=-1)
|
||||
|
||||
See :ocv:funcx:`BackgroundSubtractor::operator()`.
|
||||
.. ocv:function:: int BackgroundSubtractorMOG2::getHistory() const
|
||||
|
||||
|
||||
BackgroundSubtractorMOG2::getBackgroundImage
|
||||
--------------------------------------------
|
||||
Returns background image
|
||||
BackgroundSubtractorMOG2::setHistory
|
||||
--------------------------------------
|
||||
Sets the number of last frames that affect the background model
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::getBackgroundImage(OutputArray backgroundImage)
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setHistory(int history)
|
||||
|
||||
See :ocv:func:`BackgroundSubtractor::getBackgroundImage`.
|
||||
|
||||
BackgroundSubtractorMOG2::getNMixtures
|
||||
--------------------------------------
|
||||
Returns the number of gaussian components in the background model
|
||||
|
||||
.. ocv:function:: int BackgroundSubtractorMOG2::getNMixtures() const
|
||||
|
||||
|
||||
BackgroundSubtractorMOG2::setNMixtures
|
||||
--------------------------------------
|
||||
Sets the number of gaussian components in the background model
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setNMixtures(int nmixtures)
|
||||
|
||||
|
||||
BackgroundSubtractorMOG2::getBackgroundRatio
|
||||
---------------------------------------------
|
||||
Returns the "background ratio" parameter of the algorithm
|
||||
|
||||
.. ocv:function:: double BackgroundSubtractorMOG2::getBackgroundRatio() const
|
||||
|
||||
If a foreground pixel keeps semi-constant value for about ``backgroundRatio*history`` frames, it's considered background and added to the model as a center of a new component. It corresponds to ``TB`` parameter in the paper.
|
||||
|
||||
BackgroundSubtractorMOG2::setBackgroundRatio
|
||||
---------------------------------------------
|
||||
Sets the "background ratio" parameter of the algorithm
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setBackgroundRatio(double ratio)
|
||||
|
||||
BackgroundSubtractorMOG2::getVarThresholdGen
|
||||
---------------------------------------------
|
||||
Returns the variance scale factor for the pixel-model match
|
||||
|
||||
.. ocv:function:: double BackgroundSubtractorMOG2::getVarThresholdGen() const
|
||||
|
||||
Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to ``Tg`` in the paper). If a pixel is not close to any component, it is considered foreground or added as a new component. ``3 sigma => Tg=3*3=9`` is default. A smaller ``Tg`` value generates more components. A higher ``Tg`` value may result in a small number of components but they can grow too large.
|
||||
|
||||
BackgroundSubtractorMOG2::setVarThresholdGen
|
||||
---------------------------------------------
|
||||
Sets the variance scale factor for the pixel-model match
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setVarThresholdGen(double varThresholdGen)
|
||||
|
||||
BackgroundSubtractorMOG2::getVarInit
|
||||
---------------------------------------------
|
||||
Returns the initial variance of each gaussian component
|
||||
|
||||
.. ocv:function:: double BackgroundSubtractorMOG2::getVarInit() const
|
||||
|
||||
BackgroundSubtractorMOG2::setVarInit
|
||||
---------------------------------------------
|
||||
Sets the initial variance of each gaussian component
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setVarInit(double varInit)
|
||||
|
||||
|
||||
BackgroundSubtractorMOG2::getComplexityReductionThreshold
|
||||
----------------------------------------------------------
|
||||
Returns the complexity reduction threshold
|
||||
|
||||
.. ocv:function:: double BackgroundSubtractorMOG2::getComplexityReductionThreshold() const
|
||||
|
||||
This parameter defines the number of samples needed to accept to prove the component exists. ``CT=0.05`` is a default value for all the samples. By setting ``CT=0`` you get an algorithm very similar to the standard Stauffer&Grimson algorithm.
|
||||
|
||||
BackgroundSubtractorMOG2::setComplexityReductionThreshold
|
||||
----------------------------------------------------------
|
||||
Sets the complexity reduction threshold
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setComplexityReductionThreshold(double ct)
|
||||
|
||||
|
||||
BackgroundSubtractorMOG2::getDetectShadows
|
||||
---------------------------------------------
|
||||
Returns the shadow detection flag
|
||||
|
||||
.. ocv:function:: bool BackgroundSubtractorMOG2::getDetectShadows() const
|
||||
|
||||
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for details.
|
||||
|
||||
BackgroundSubtractorMOG2::setDetectShadows
|
||||
---------------------------------------------
|
||||
Enables or disables shadow detection
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setDetectShadows(bool detectShadows)
|
||||
|
||||
BackgroundSubtractorMOG2::getShadowValue
|
||||
---------------------------------------------
|
||||
Returns the shadow value
|
||||
|
||||
.. ocv:function:: int BackgroundSubtractorMOG2::getShadowValue() const
|
||||
|
||||
Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 in the mask always means background, 255 means foreground.
|
||||
|
||||
BackgroundSubtractorMOG2::setShadowValue
|
||||
---------------------------------------------
|
||||
Sets the shadow value
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setShadowValue(int shadowValue)
|
||||
|
||||
BackgroundSubtractorMOG2::getShadowThreshold
|
||||
---------------------------------------------
|
||||
Returns the shadow threshold
|
||||
|
||||
.. ocv:function:: int BackgroundSubtractorMOG2::getShadowThreshold() const
|
||||
|
||||
A shadow is detected if the pixel is a darker version of the background. The shadow threshold (``Tau`` in the paper) is a threshold defining how much darker the shadow can be. ``Tau= 0.5`` means that if a pixel is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra, *Detecting Moving Shadows...*, IEEE PAMI,2003.
|
||||
|
||||
BackgroundSubtractorMOG2::setShadowThreshold
|
||||
---------------------------------------------
|
||||
Sets the shadow threshold
|
||||
|
||||
.. ocv:function:: void BackgroundSubtractorMOG2::setShadowThreshold(int shadowValue)
|
||||
|
||||
|
||||
calcOpticalFlowSF
|
||||
@ -756,10 +806,16 @@ Releases all inner buffers.
|
||||
|
||||
.. [Davis97] Davis, J.W. and Bobick, A.F. “The Representation and Recognition of Action Using Temporal Templates”, CVPR97, 1997
|
||||
|
||||
.. [EP08] Evangelidis, G.D. and Psarakis E.Z. "Parametric Image Alignment using Enhanced Correlation Coefficient Maximization", IEEE Transactions on PAMI, vol. 32, no. 10, 2008
|
||||
|
||||
.. [Farneback2003] Gunnar Farneback, Two-frame motion estimation based on polynomial expansion, Lecture Notes in Computer Science, 2003, (2749), , 363-370.
|
||||
|
||||
.. [Horn81] Berthold K.P. Horn and Brian G. Schunck. Determining Optical Flow. Artificial Intelligence, 17, pp. 185-203, 1981.
|
||||
|
||||
.. [KB2001] P. KadewTraKuPong and R. Bowden. "An improved adaptive background mixture model for real-time tracking with shadow detection", Proc. 2nd European Workshop on Advanced Video-Based Surveillance Systems, 2001: http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf
|
||||
|
||||
.. [Javier2012] Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
|
||||
|
||||
.. [Lucas81] Lucas, B., and Kanade, T. An Iterative Image Registration Technique with an Application to Stereo Vision, Proc. of 7th International Joint Conference on Artificial Intelligence (IJCAI), pp. 674-679.
|
||||
|
||||
.. [Welch95] Greg Welch and Gary Bishop “An Introduction to the Kalman Filter”, 1995
|
||||
@ -768,6 +824,6 @@ Releases all inner buffers.
|
||||
|
||||
.. [Zach2007] C. Zach, T. Pock and H. Bischof. "A Duality Based Approach for Realtime TV-L1 Optical Flow", In Proceedings of Pattern Recognition (DAGM), Heidelberg, Germany, pp. 214-223, 2007
|
||||
|
||||
.. [Javier2012] Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
|
||||
.. [Zivkovic2004] Z. Zivkovic. Improved adaptive Gausian mixture model for background subtraction*, International Conference Pattern Recognition, UK, August, 2004, http://www.zoranz.net/Publications/zivkovic2004ICPR.pdf. The code is very fast and performs also shadow detection. Number of Gausssian components is adapted per pixel.
|
||||
|
||||
.. [EP08] Evangelidis, G.D. and Psarakis E.Z. "Parametric Image Alignment using Enhanced Correlation Coefficient Maximization", IEEE Transactions on PAMI, vol. 32, no. 10, 2008
|
||||
.. [Zivkovic2006] Z.Zivkovic, F. van der Heijden. "Efficient Adaptive Density Estimapion per Image Pixel for the Task of Background Subtraction", Pattern Recognition Letters, vol. 27, no. 7, pages 773-780, 2006.
|
||||
|
@ -59,7 +59,7 @@ class BackgroundSubtractor : public Algorithm
|
||||
{
|
||||
public:
|
||||
//! the update operator that takes the next video frame and returns the current foreground mask as 8-bit binary image.
|
||||
virtual void apply(InputArray image, OutputArray fgmask, double learningRate=0) = 0;
|
||||
virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0;
|
||||
|
||||
//! computes a background image
|
||||
virtual void getBackgroundImage(OutputArray backgroundImage) const = 0;
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user