openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/video/background_segm.hpp@0:0e0631af0305, 2021-01-29 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Fri Jan 29 04:53:38 2021 +0000
- Revision:
- 0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RyoheiHagimoto | 0:0e0631af0305 | 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2 | // |
RyoheiHagimoto | 0:0e0631af0305 | 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
RyoheiHagimoto | 0:0e0631af0305 | 4 | // |
RyoheiHagimoto | 0:0e0631af0305 | 5 | // By downloading, copying, installing or using the software you agree to this license. |
RyoheiHagimoto | 0:0e0631af0305 | 6 | // If you do not agree to this license, do not download, install, |
RyoheiHagimoto | 0:0e0631af0305 | 7 | // copy or use the software. |
RyoheiHagimoto | 0:0e0631af0305 | 8 | // |
RyoheiHagimoto | 0:0e0631af0305 | 9 | // |
RyoheiHagimoto | 0:0e0631af0305 | 10 | // License Agreement |
RyoheiHagimoto | 0:0e0631af0305 | 11 | // For Open Source Computer Vision Library |
RyoheiHagimoto | 0:0e0631af0305 | 12 | // |
RyoheiHagimoto | 0:0e0631af0305 | 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 15 | // Copyright (C) 2013, OpenCV Foundation, all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 16 | // Third party copyrights are property of their respective owners. |
RyoheiHagimoto | 0:0e0631af0305 | 17 | // |
RyoheiHagimoto | 0:0e0631af0305 | 18 | // Redistribution and use in source and binary forms, with or without modification, |
RyoheiHagimoto | 0:0e0631af0305 | 19 | // are permitted provided that the following conditions are met: |
RyoheiHagimoto | 0:0e0631af0305 | 20 | // |
RyoheiHagimoto | 0:0e0631af0305 | 21 | // * Redistribution's of source code must retain the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 22 | // this list of conditions and the following disclaimer. |
RyoheiHagimoto | 0:0e0631af0305 | 23 | // |
RyoheiHagimoto | 0:0e0631af0305 | 24 | // * Redistribution's in binary form must reproduce the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 25 | // this list of conditions and the following disclaimer in the documentation |
RyoheiHagimoto | 0:0e0631af0305 | 26 | // and/or other materials provided with the distribution. |
RyoheiHagimoto | 0:0e0631af0305 | 27 | // |
RyoheiHagimoto | 0:0e0631af0305 | 28 | // * The name of the copyright holders may not be used to endorse or promote products |
RyoheiHagimoto | 0:0e0631af0305 | 29 | // derived from this software without specific prior written permission. |
RyoheiHagimoto | 0:0e0631af0305 | 30 | // |
RyoheiHagimoto | 0:0e0631af0305 | 31 | // This software is provided by the copyright holders and contributors "as is" and |
RyoheiHagimoto | 0:0e0631af0305 | 32 | // any express or implied warranties, including, but not limited to, the implied |
RyoheiHagimoto | 0:0e0631af0305 | 33 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
RyoheiHagimoto | 0:0e0631af0305 | 34 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
RyoheiHagimoto | 0:0e0631af0305 | 35 | // indirect, incidental, special, exemplary, or consequential damages |
RyoheiHagimoto | 0:0e0631af0305 | 36 | // (including, but not limited to, procurement of substitute goods or services; |
RyoheiHagimoto | 0:0e0631af0305 | 37 | // loss of use, data, or profits; or business interruption) however caused |
RyoheiHagimoto | 0:0e0631af0305 | 38 | // and on any theory of liability, whether in contract, strict liability, |
RyoheiHagimoto | 0:0e0631af0305 | 39 | // or tort (including negligence or otherwise) arising in any way out of |
RyoheiHagimoto | 0:0e0631af0305 | 40 | // the use of this software, even if advised of the possibility of such damage. |
RyoheiHagimoto | 0:0e0631af0305 | 41 | // |
RyoheiHagimoto | 0:0e0631af0305 | 42 | //M*/ |
RyoheiHagimoto | 0:0e0631af0305 | 43 | |
RyoheiHagimoto | 0:0e0631af0305 | 44 | #ifndef OPENCV_BACKGROUND_SEGM_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 45 | #define OPENCV_BACKGROUND_SEGM_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 46 | |
RyoheiHagimoto | 0:0e0631af0305 | 47 | #include "opencv2/core.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 48 | |
RyoheiHagimoto | 0:0e0631af0305 | 49 | namespace cv |
RyoheiHagimoto | 0:0e0631af0305 | 50 | { |
RyoheiHagimoto | 0:0e0631af0305 | 51 | |
RyoheiHagimoto | 0:0e0631af0305 | 52 | //! @addtogroup video_motion |
RyoheiHagimoto | 0:0e0631af0305 | 53 | //! @{ |
RyoheiHagimoto | 0:0e0631af0305 | 54 | |
RyoheiHagimoto | 0:0e0631af0305 | 55 | /** @brief Base class for background/foreground segmentation. : |
RyoheiHagimoto | 0:0e0631af0305 | 56 | |
RyoheiHagimoto | 0:0e0631af0305 | 57 | The class is only used to define the common interface for the whole family of background/foreground |
RyoheiHagimoto | 0:0e0631af0305 | 58 | segmentation algorithms. |
RyoheiHagimoto | 0:0e0631af0305 | 59 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 60 | class CV_EXPORTS_W BackgroundSubtractor : public Algorithm |
RyoheiHagimoto | 0:0e0631af0305 | 61 | { |
RyoheiHagimoto | 0:0e0631af0305 | 62 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 63 | /** @brief Computes a foreground mask. |
RyoheiHagimoto | 0:0e0631af0305 | 64 | |
RyoheiHagimoto | 0:0e0631af0305 | 65 | @param image Next video frame. |
RyoheiHagimoto | 0:0e0631af0305 | 66 | @param fgmask The output foreground mask as an 8-bit binary image. |
RyoheiHagimoto | 0:0e0631af0305 | 67 | @param learningRate The value between 0 and 1 that indicates how fast the background model is |
RyoheiHagimoto | 0:0e0631af0305 | 68 | learnt. Negative parameter value makes the algorithm to use some automatically chosen learning |
RyoheiHagimoto | 0:0e0631af0305 | 69 | rate. 0 means that the background model is not updated at all, 1 means that the background model |
RyoheiHagimoto | 0:0e0631af0305 | 70 | is completely reinitialized from the last frame. |
RyoheiHagimoto | 0:0e0631af0305 | 71 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 72 | CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 73 | |
RyoheiHagimoto | 0:0e0631af0305 | 74 | /** @brief Computes a background image. |
RyoheiHagimoto | 0:0e0631af0305 | 75 | |
RyoheiHagimoto | 0:0e0631af0305 | 76 | @param backgroundImage The output background image. |
RyoheiHagimoto | 0:0e0631af0305 | 77 | |
RyoheiHagimoto | 0:0e0631af0305 | 78 | @note Sometimes the background image can be very blurry, as it contain the average background |
RyoheiHagimoto | 0:0e0631af0305 | 79 | statistics. |
RyoheiHagimoto | 0:0e0631af0305 | 80 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 81 | CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 82 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 83 | |
RyoheiHagimoto | 0:0e0631af0305 | 84 | |
RyoheiHagimoto | 0:0e0631af0305 | 85 | /** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm. |
RyoheiHagimoto | 0:0e0631af0305 | 86 | |
RyoheiHagimoto | 0:0e0631af0305 | 87 | The class implements the Gaussian mixture model background subtraction described in @cite Zivkovic2004 |
RyoheiHagimoto | 0:0e0631af0305 | 88 | and @cite Zivkovic2006 . |
RyoheiHagimoto | 0:0e0631af0305 | 89 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 90 | class CV_EXPORTS_W BackgroundSubtractorMOG2 : public BackgroundSubtractor |
RyoheiHagimoto | 0:0e0631af0305 | 91 | { |
RyoheiHagimoto | 0:0e0631af0305 | 92 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 93 | /** @brief Returns the number of last frames that affect the background model |
RyoheiHagimoto | 0:0e0631af0305 | 94 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 95 | CV_WRAP virtual int getHistory() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 96 | /** @brief Sets the number of last frames that affect the background model |
RyoheiHagimoto | 0:0e0631af0305 | 97 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 98 | CV_WRAP virtual void setHistory(int history) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 99 | |
RyoheiHagimoto | 0:0e0631af0305 | 100 | /** @brief Returns the number of gaussian components in the background model |
RyoheiHagimoto | 0:0e0631af0305 | 101 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 102 | CV_WRAP virtual int getNMixtures() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 103 | /** @brief Sets the number of gaussian components in the background model. |
RyoheiHagimoto | 0:0e0631af0305 | 104 | |
RyoheiHagimoto | 0:0e0631af0305 | 105 | The model needs to be reinitalized to reserve memory. |
RyoheiHagimoto | 0:0e0631af0305 | 106 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 107 | CV_WRAP virtual void setNMixtures(int nmixtures) = 0;//needs reinitialization! |
RyoheiHagimoto | 0:0e0631af0305 | 108 | |
RyoheiHagimoto | 0:0e0631af0305 | 109 | /** @brief Returns the "background ratio" parameter of the algorithm |
RyoheiHagimoto | 0:0e0631af0305 | 110 | |
RyoheiHagimoto | 0:0e0631af0305 | 111 | If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's |
RyoheiHagimoto | 0:0e0631af0305 | 112 | considered background and added to the model as a center of a new component. It corresponds to TB |
RyoheiHagimoto | 0:0e0631af0305 | 113 | parameter in the paper. |
RyoheiHagimoto | 0:0e0631af0305 | 114 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 115 | CV_WRAP virtual double getBackgroundRatio() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 116 | /** @brief Sets the "background ratio" parameter of the algorithm |
RyoheiHagimoto | 0:0e0631af0305 | 117 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 118 | CV_WRAP virtual void setBackgroundRatio(double ratio) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 119 | |
RyoheiHagimoto | 0:0e0631af0305 | 120 | /** @brief Returns the variance threshold for the pixel-model match |
RyoheiHagimoto | 0:0e0631af0305 | 121 | |
RyoheiHagimoto | 0:0e0631af0305 | 122 | The main threshold on the squared Mahalanobis distance to decide if the sample is well described by |
RyoheiHagimoto | 0:0e0631af0305 | 123 | the background model or not. Related to Cthr from the paper. |
RyoheiHagimoto | 0:0e0631af0305 | 124 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 125 | CV_WRAP virtual double getVarThreshold() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 126 | /** @brief Sets the variance threshold for the pixel-model match |
RyoheiHagimoto | 0:0e0631af0305 | 127 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 128 | CV_WRAP virtual void setVarThreshold(double varThreshold) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 129 | |
RyoheiHagimoto | 0:0e0631af0305 | 130 | /** @brief Returns the variance threshold for the pixel-model match used for new mixture component generation |
RyoheiHagimoto | 0:0e0631af0305 | 131 | |
RyoheiHagimoto | 0:0e0631af0305 | 132 | Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the |
RyoheiHagimoto | 0:0e0631af0305 | 133 | existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it |
RyoheiHagimoto | 0:0e0631af0305 | 134 | is considered foreground or added as a new component. 3 sigma =\> Tg=3\*3=9 is default. A smaller Tg |
RyoheiHagimoto | 0:0e0631af0305 | 135 | value generates more components. A higher Tg value may result in a small number of components but |
RyoheiHagimoto | 0:0e0631af0305 | 136 | they can grow too large. |
RyoheiHagimoto | 0:0e0631af0305 | 137 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 138 | CV_WRAP virtual double getVarThresholdGen() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 139 | /** @brief Sets the variance threshold for the pixel-model match used for new mixture component generation |
RyoheiHagimoto | 0:0e0631af0305 | 140 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 141 | CV_WRAP virtual void setVarThresholdGen(double varThresholdGen) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 142 | |
RyoheiHagimoto | 0:0e0631af0305 | 143 | /** @brief Returns the initial variance of each gaussian component |
RyoheiHagimoto | 0:0e0631af0305 | 144 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 145 | CV_WRAP virtual double getVarInit() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 146 | /** @brief Sets the initial variance of each gaussian component |
RyoheiHagimoto | 0:0e0631af0305 | 147 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 148 | CV_WRAP virtual void setVarInit(double varInit) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 149 | |
RyoheiHagimoto | 0:0e0631af0305 | 150 | CV_WRAP virtual double getVarMin() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 151 | CV_WRAP virtual void setVarMin(double varMin) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 152 | |
RyoheiHagimoto | 0:0e0631af0305 | 153 | CV_WRAP virtual double getVarMax() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 154 | CV_WRAP virtual void setVarMax(double varMax) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 155 | |
RyoheiHagimoto | 0:0e0631af0305 | 156 | /** @brief Returns the complexity reduction threshold |
RyoheiHagimoto | 0:0e0631af0305 | 157 | |
RyoheiHagimoto | 0:0e0631af0305 | 158 | This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05 |
RyoheiHagimoto | 0:0e0631af0305 | 159 | is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the |
RyoheiHagimoto | 0:0e0631af0305 | 160 | standard Stauffer&Grimson algorithm. |
RyoheiHagimoto | 0:0e0631af0305 | 161 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 162 | CV_WRAP virtual double getComplexityReductionThreshold() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 163 | /** @brief Sets the complexity reduction threshold |
RyoheiHagimoto | 0:0e0631af0305 | 164 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 165 | CV_WRAP virtual void setComplexityReductionThreshold(double ct) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 166 | |
RyoheiHagimoto | 0:0e0631af0305 | 167 | /** @brief Returns the shadow detection flag |
RyoheiHagimoto | 0:0e0631af0305 | 168 | |
RyoheiHagimoto | 0:0e0631af0305 | 169 | If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for |
RyoheiHagimoto | 0:0e0631af0305 | 170 | details. |
RyoheiHagimoto | 0:0e0631af0305 | 171 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 172 | CV_WRAP virtual bool getDetectShadows() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 173 | /** @brief Enables or disables shadow detection |
RyoheiHagimoto | 0:0e0631af0305 | 174 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 175 | CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 176 | |
RyoheiHagimoto | 0:0e0631af0305 | 177 | /** @brief Returns the shadow value |
RyoheiHagimoto | 0:0e0631af0305 | 178 | |
RyoheiHagimoto | 0:0e0631af0305 | 179 | Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 |
RyoheiHagimoto | 0:0e0631af0305 | 180 | in the mask always means background, 255 means foreground. |
RyoheiHagimoto | 0:0e0631af0305 | 181 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 182 | CV_WRAP virtual int getShadowValue() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 183 | /** @brief Sets the shadow value |
RyoheiHagimoto | 0:0e0631af0305 | 184 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 185 | CV_WRAP virtual void setShadowValue(int value) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 186 | |
RyoheiHagimoto | 0:0e0631af0305 | 187 | /** @brief Returns the shadow threshold |
RyoheiHagimoto | 0:0e0631af0305 | 188 | |
RyoheiHagimoto | 0:0e0631af0305 | 189 | A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in |
RyoheiHagimoto | 0:0e0631af0305 | 190 | the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel |
RyoheiHagimoto | 0:0e0631af0305 | 191 | is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra, |
RyoheiHagimoto | 0:0e0631af0305 | 192 | *Detecting Moving Shadows...*, IEEE PAMI,2003. |
RyoheiHagimoto | 0:0e0631af0305 | 193 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 194 | CV_WRAP virtual double getShadowThreshold() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 195 | /** @brief Sets the shadow threshold |
RyoheiHagimoto | 0:0e0631af0305 | 196 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 197 | CV_WRAP virtual void setShadowThreshold(double threshold) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 198 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 199 | |
RyoheiHagimoto | 0:0e0631af0305 | 200 | /** @brief Creates MOG2 Background Subtractor |
RyoheiHagimoto | 0:0e0631af0305 | 201 | |
RyoheiHagimoto | 0:0e0631af0305 | 202 | @param history Length of the history. |
RyoheiHagimoto | 0:0e0631af0305 | 203 | @param varThreshold Threshold on the squared Mahalanobis distance between the pixel and the model |
RyoheiHagimoto | 0:0e0631af0305 | 204 | to decide whether a pixel is well described by the background model. This parameter does not |
RyoheiHagimoto | 0:0e0631af0305 | 205 | affect the background update. |
RyoheiHagimoto | 0:0e0631af0305 | 206 | @param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the |
RyoheiHagimoto | 0:0e0631af0305 | 207 | speed a bit, so if you do not need this feature, set the parameter to false. |
RyoheiHagimoto | 0:0e0631af0305 | 208 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 209 | CV_EXPORTS_W Ptr<BackgroundSubtractorMOG2> |
RyoheiHagimoto | 0:0e0631af0305 | 210 | createBackgroundSubtractorMOG2(int history=500, double varThreshold=16, |
RyoheiHagimoto | 0:0e0631af0305 | 211 | bool detectShadows=true); |
RyoheiHagimoto | 0:0e0631af0305 | 212 | |
RyoheiHagimoto | 0:0e0631af0305 | 213 | /** @brief K-nearest neigbours - based Background/Foreground Segmentation Algorithm. |
RyoheiHagimoto | 0:0e0631af0305 | 214 | |
RyoheiHagimoto | 0:0e0631af0305 | 215 | The class implements the K-nearest neigbours background subtraction described in @cite Zivkovic2006 . |
RyoheiHagimoto | 0:0e0631af0305 | 216 | Very efficient if number of foreground pixels is low. |
RyoheiHagimoto | 0:0e0631af0305 | 217 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 218 | class CV_EXPORTS_W BackgroundSubtractorKNN : public BackgroundSubtractor |
RyoheiHagimoto | 0:0e0631af0305 | 219 | { |
RyoheiHagimoto | 0:0e0631af0305 | 220 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 221 | /** @brief Returns the number of last frames that affect the background model |
RyoheiHagimoto | 0:0e0631af0305 | 222 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 223 | CV_WRAP virtual int getHistory() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 224 | /** @brief Sets the number of last frames that affect the background model |
RyoheiHagimoto | 0:0e0631af0305 | 225 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 226 | CV_WRAP virtual void setHistory(int history) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 227 | |
RyoheiHagimoto | 0:0e0631af0305 | 228 | /** @brief Returns the number of data samples in the background model |
RyoheiHagimoto | 0:0e0631af0305 | 229 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 230 | CV_WRAP virtual int getNSamples() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 231 | /** @brief Sets the number of data samples in the background model. |
RyoheiHagimoto | 0:0e0631af0305 | 232 | |
RyoheiHagimoto | 0:0e0631af0305 | 233 | The model needs to be reinitalized to reserve memory. |
RyoheiHagimoto | 0:0e0631af0305 | 234 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 235 | CV_WRAP virtual void setNSamples(int _nN) = 0;//needs reinitialization! |
RyoheiHagimoto | 0:0e0631af0305 | 236 | |
RyoheiHagimoto | 0:0e0631af0305 | 237 | /** @brief Returns the threshold on the squared distance between the pixel and the sample |
RyoheiHagimoto | 0:0e0631af0305 | 238 | |
RyoheiHagimoto | 0:0e0631af0305 | 239 | The threshold on the squared distance between the pixel and the sample to decide whether a pixel is |
RyoheiHagimoto | 0:0e0631af0305 | 240 | close to a data sample. |
RyoheiHagimoto | 0:0e0631af0305 | 241 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 242 | CV_WRAP virtual double getDist2Threshold() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 243 | /** @brief Sets the threshold on the squared distance |
RyoheiHagimoto | 0:0e0631af0305 | 244 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 245 | CV_WRAP virtual void setDist2Threshold(double _dist2Threshold) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 246 | |
RyoheiHagimoto | 0:0e0631af0305 | 247 | /** @brief Returns the number of neighbours, the k in the kNN. |
RyoheiHagimoto | 0:0e0631af0305 | 248 | |
RyoheiHagimoto | 0:0e0631af0305 | 249 | K is the number of samples that need to be within dist2Threshold in order to decide that that |
RyoheiHagimoto | 0:0e0631af0305 | 250 | pixel is matching the kNN background model. |
RyoheiHagimoto | 0:0e0631af0305 | 251 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 252 | CV_WRAP virtual int getkNNSamples() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 253 | /** @brief Sets the k in the kNN. How many nearest neigbours need to match. |
RyoheiHagimoto | 0:0e0631af0305 | 254 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 255 | CV_WRAP virtual void setkNNSamples(int _nkNN) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 256 | |
RyoheiHagimoto | 0:0e0631af0305 | 257 | /** @brief Returns the shadow detection flag |
RyoheiHagimoto | 0:0e0631af0305 | 258 | |
RyoheiHagimoto | 0:0e0631af0305 | 259 | If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for |
RyoheiHagimoto | 0:0e0631af0305 | 260 | details. |
RyoheiHagimoto | 0:0e0631af0305 | 261 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 262 | CV_WRAP virtual bool getDetectShadows() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 263 | /** @brief Enables or disables shadow detection |
RyoheiHagimoto | 0:0e0631af0305 | 264 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 265 | CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 266 | |
RyoheiHagimoto | 0:0e0631af0305 | 267 | /** @brief Returns the shadow value |
RyoheiHagimoto | 0:0e0631af0305 | 268 | |
RyoheiHagimoto | 0:0e0631af0305 | 269 | Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 |
RyoheiHagimoto | 0:0e0631af0305 | 270 | in the mask always means background, 255 means foreground. |
RyoheiHagimoto | 0:0e0631af0305 | 271 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 272 | CV_WRAP virtual int getShadowValue() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 273 | /** @brief Sets the shadow value |
RyoheiHagimoto | 0:0e0631af0305 | 274 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 275 | CV_WRAP virtual void setShadowValue(int value) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 276 | |
RyoheiHagimoto | 0:0e0631af0305 | 277 | /** @brief Returns the shadow threshold |
RyoheiHagimoto | 0:0e0631af0305 | 278 | |
RyoheiHagimoto | 0:0e0631af0305 | 279 | A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in |
RyoheiHagimoto | 0:0e0631af0305 | 280 | the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel |
RyoheiHagimoto | 0:0e0631af0305 | 281 | is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra, |
RyoheiHagimoto | 0:0e0631af0305 | 282 | *Detecting Moving Shadows...*, IEEE PAMI,2003. |
RyoheiHagimoto | 0:0e0631af0305 | 283 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 284 | CV_WRAP virtual double getShadowThreshold() const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 285 | /** @brief Sets the shadow threshold |
RyoheiHagimoto | 0:0e0631af0305 | 286 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 287 | CV_WRAP virtual void setShadowThreshold(double threshold) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 288 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 289 | |
RyoheiHagimoto | 0:0e0631af0305 | 290 | /** @brief Creates KNN Background Subtractor |
RyoheiHagimoto | 0:0e0631af0305 | 291 | |
RyoheiHagimoto | 0:0e0631af0305 | 292 | @param history Length of the history. |
RyoheiHagimoto | 0:0e0631af0305 | 293 | @param dist2Threshold Threshold on the squared distance between the pixel and the sample to decide |
RyoheiHagimoto | 0:0e0631af0305 | 294 | whether a pixel is close to that sample. This parameter does not affect the background update. |
RyoheiHagimoto | 0:0e0631af0305 | 295 | @param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the |
RyoheiHagimoto | 0:0e0631af0305 | 296 | speed a bit, so if you do not need this feature, set the parameter to false. |
RyoheiHagimoto | 0:0e0631af0305 | 297 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 298 | CV_EXPORTS_W Ptr<BackgroundSubtractorKNN> |
RyoheiHagimoto | 0:0e0631af0305 | 299 | createBackgroundSubtractorKNN(int history=500, double dist2Threshold=400.0, |
RyoheiHagimoto | 0:0e0631af0305 | 300 | bool detectShadows=true); |
RyoheiHagimoto | 0:0e0631af0305 | 301 | |
RyoheiHagimoto | 0:0e0631af0305 | 302 | //! @} video_motion |
RyoheiHagimoto | 0:0e0631af0305 | 303 | |
RyoheiHagimoto | 0:0e0631af0305 | 304 | } // cv |
RyoheiHagimoto | 0:0e0631af0305 | 305 | |
RyoheiHagimoto | 0:0e0631af0305 | 306 | #endif |