bgsegm.hpp 7.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
/*
By downloading, copying, installing or using the software you agree to this
license. If you do not agree to this license, do not download, install,
copy or use the software.


                          License Agreement
               For Open Source Computer Vision Library
                       (3-clause BSD License)

Copyright (C) 2013, OpenCV Foundation, all rights reserved.
Third party copyrights are property of their respective owners.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.

  * Neither the names of the copyright holders nor the names of the contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.

This software is provided by the copyright holders and contributors "as is" and
any express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall copyright holders or contributors be liable for
any direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused
and on any theory of liability, whether in contract, strict liability,
or tort (including negligence or otherwise) arising in any way out of
the use of this software, even if advised of the possibility of such damage.
*/

#ifndef __OPENCV_BGSEGM_HPP__
#define __OPENCV_BGSEGM_HPP__

#include "opencv2/video.hpp"

#ifdef __cplusplus

47 48 49
/** @defgroup bgsegm Improved Background-Foreground Segmentation Methods
*/

50 51 52 53 54
namespace cv
{
namespace bgsegm
{

55 56
//! @addtogroup bgsegm
//! @{
57

58
/** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
59

60
The class implements the algorithm described in @cite KB2001 .
61
 */
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
class CV_EXPORTS_W BackgroundSubtractorMOG : public BackgroundSubtractor
{
public:
    CV_WRAP virtual int getHistory() const = 0;
    CV_WRAP virtual void setHistory(int nframes) = 0;

    CV_WRAP virtual int getNMixtures() const = 0;
    CV_WRAP virtual void setNMixtures(int nmix) = 0;

    CV_WRAP virtual double getBackgroundRatio() const = 0;
    CV_WRAP virtual void setBackgroundRatio(double backgroundRatio) = 0;

    CV_WRAP virtual double getNoiseSigma() const = 0;
    CV_WRAP virtual void setNoiseSigma(double noiseSigma) = 0;
};

78 79 80 81 82 83 84 85
/** @brief Creates mixture-of-gaussian background subtractor

@param history Length of the history.
@param nmixtures Number of Gaussian mixtures.
@param backgroundRatio Background ratio.
@param noiseSigma Noise strength (standard deviation of the brightness or each color channel). 0
means some automatic value.
 */
86 87 88
CV_EXPORTS_W Ptr<BackgroundSubtractorMOG>
    createBackgroundSubtractorMOG(int history=200, int nmixtures=5,
                                  double backgroundRatio=0.7, double noiseSigma=0);
89

90 91

/** @brief Background Subtractor module based on the algorithm given in @cite Gold2012 .
92 93 94 95 96 97

 Takes a series of images and returns a sequence of mask (8UC1)
 images of the same size, where 255 indicates Foreground and 0 represents Background.
 This class implements an algorithm described in "Visual Tracking of Human Visitors under
 Variable-Lighting Conditions for a Responsive Audio Art Installation," A. Godbehere,
 A. Matsukawa, K. Goldberg, American Control Conference, Montreal, June 2012.
98 99 100 101
 */
class CV_EXPORTS_W BackgroundSubtractorGMG : public BackgroundSubtractor
{
public:
102 103
    /** @brief Returns total number of distinct colors to maintain in histogram.
    */
104
    CV_WRAP virtual int getMaxFeatures() const = 0;
105 106
    /** @brief Sets total number of distinct colors to maintain in histogram.
    */
107 108
    CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;

109 110 111 112 113
    /** @brief Returns the learning rate of the algorithm.

    It lies between 0.0 and 1.0. It determines how quickly features are "forgotten" from
    histograms.
     */
114
    CV_WRAP virtual double getDefaultLearningRate() const = 0;
115 116
    /** @brief Sets the learning rate of the algorithm.
    */
117 118
    CV_WRAP virtual void setDefaultLearningRate(double lr) = 0;

119 120
    /** @brief Returns the number of frames used to initialize background model.
    */
121
    CV_WRAP virtual int getNumFrames() const = 0;
122 123
    /** @brief Sets the number of frames used to initialize background model.
    */
124 125
    CV_WRAP virtual void setNumFrames(int nframes) = 0;

126 127 128 129
    /** @brief Returns the parameter used for quantization of color-space.

    It is the number of discrete levels in each channel to be used in histograms.
     */
130
    CV_WRAP virtual int getQuantizationLevels() const = 0;
131 132
    /** @brief Sets the parameter used for quantization of color-space
    */
133 134
    CV_WRAP virtual void setQuantizationLevels(int nlevels) = 0;

135 136
    /** @brief Returns the prior probability that each individual pixel is a background pixel.
    */
137
    CV_WRAP virtual double getBackgroundPrior() const = 0;
138 139
    /** @brief Sets the prior probability that each individual pixel is a background pixel.
    */
140 141
    CV_WRAP virtual void setBackgroundPrior(double bgprior) = 0;

142 143
    /** @brief Returns the kernel radius used for morphological operations
    */
144
    CV_WRAP virtual int getSmoothingRadius() const = 0;
145 146
    /** @brief Sets the kernel radius used for morphological operations
    */
147 148
    CV_WRAP virtual void setSmoothingRadius(int radius) = 0;

149 150 151 152
    /** @brief Returns the value of decision threshold.

    Decision value is the value above which pixel is determined to be FG.
     */
153
    CV_WRAP virtual double getDecisionThreshold() const = 0;
154 155
    /** @brief Sets the value of decision threshold.
    */
156 157
    CV_WRAP virtual void setDecisionThreshold(double thresh) = 0;

158 159
    /** @brief Returns the status of background model update
    */
160
    CV_WRAP virtual bool getUpdateBackgroundModel() const = 0;
161 162
    /** @brief Sets the status of background model update
    */
163 164
    CV_WRAP virtual void setUpdateBackgroundModel(bool update) = 0;

165 166
    /** @brief Returns the minimum value taken on by pixels in image sequence. Usually 0.
    */
167
    CV_WRAP virtual double getMinVal() const = 0;
168 169
    /** @brief Sets the minimum value taken on by pixels in image sequence.
    */
170 171
    CV_WRAP virtual void setMinVal(double val) = 0;

172 173
    /** @brief Returns the maximum value taken on by pixels in image sequence. e.g. 1.0 or 255.
    */
174
    CV_WRAP virtual double getMaxVal() const = 0;
175 176
    /** @brief Sets the maximum value taken on by pixels in image sequence.
    */
177 178 179
    CV_WRAP virtual void setMaxVal(double val) = 0;
};

180 181 182 183 184
/** @brief Creates a GMG Background Subtractor

@param initializationFrames number of frames used to initialize the background models.
@param decisionThreshold Threshold value, above which it is marked foreground, else background.
 */
185 186 187
CV_EXPORTS_W Ptr<BackgroundSubtractorGMG> createBackgroundSubtractorGMG(int initializationFrames=120,
                                                                        double decisionThreshold=0.8);                                  

188 189
//! @}

190 191 192 193 194
}
}

#endif
#endif