1 /*M/////////////////////////////////////////////////////////////////////////////////////// 2 // 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 // 5 // By downloading, copying, installing or using the software you agree to this license. 6 // If you do not agree to this license, do not download, install, 7 // copy or use the software. 8 // 9 // 10 // License Agreement 11 // For Open Source Computer Vision Library 12 // 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 15 // Third party copyrights are property of their respective owners. 16 // 17 // Redistribution and use in source and binary forms, with or without modification, 18 // are permitted provided that the following conditions are met: 19 // 20 // * Redistribution's of source code must retain the above copyright notice, 21 // this list of conditions and the following disclaimer. 22 // 23 // * Redistribution's in binary form must reproduce the above copyright notice, 24 // this list of conditions and the following disclaimer in the documentation 25 // and/or other materials provided with the distribution. 26 // 27 // * The name of the copyright holders may not be used to endorse or promote products 28 // derived from this software without specific prior written permission. 29 // 30 // This software is provided by the copyright holders and contributors "as is" and 31 // any express or implied warranties, including, but not limited to, the implied 32 // warranties of merchantability and fitness for a particular purpose are disclaimed. 33 // In no event shall the Intel Corporation or contributors be liable for any direct, 34 // indirect, incidental, special, exemplary, or consequential damages 35 // (including, but not limited to, procurement of substitute goods or services; 36 // loss of use, data, or profits; or business interruption) however caused 37 // and on any theory of liability, whether in contract, strict liability, 38 // or tort (including negligence or otherwise) arising in any way out of 39 // the use of this software, even if advised of the possibility of such damage. 40 // 41 //M*/ 42 43 #ifndef __OPENCV_CUDABGSEGM_HPP__ 44 #define __OPENCV_CUDABGSEGM_HPP__ 45 46 #ifndef __cplusplus 47 # error cudabgsegm.hpp header must be compiled as C++ 48 #endif 49 50 #include "opencv2/core/cuda.hpp" 51 #include "opencv2/video/background_segm.hpp" 52 53 /** 54 @addtogroup cuda 55 @{ 56 @defgroup cudabgsegm Background Segmentation 57 @} 58 */ 59 60 namespace cv { namespace cuda { 61 62 //! @addtogroup cudabgsegm 63 //! @{ 64 65 //////////////////////////////////////////////////// 66 // MOG 67 68 /** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm. 69 70 The class discriminates between foreground and background pixels by building and maintaining a model 71 of the background. Any pixel which does not fit this model is then deemed to be foreground. The 72 class implements algorithm described in @cite MOG2001 . 73 74 @sa BackgroundSubtractorMOG 75 76 @note 77 - An example on gaussian mixture based background/foreground segmantation can be found at 78 opencv_source_code/samples/gpu/bgfg_segm.cpp 79 */ 80 class CV_EXPORTS BackgroundSubtractorMOG : public cv::BackgroundSubtractor 81 { 82 public: 83 84 using cv::BackgroundSubtractor::apply; 85 virtual void apply(InputArray image, OutputArray fgmask, double learningRate, Stream& stream) = 0; 86 87 using cv::BackgroundSubtractor::getBackgroundImage; 88 virtual void getBackgroundImage(OutputArray backgroundImage, Stream& stream) const = 0; 89 90 virtual int getHistory() const = 0; 91 virtual void setHistory(int nframes) = 0; 92 93 virtual int getNMixtures() const = 0; 94 virtual void setNMixtures(int nmix) = 0; 95 96 virtual double getBackgroundRatio() const = 0; 97 virtual void setBackgroundRatio(double backgroundRatio) = 0; 98 99 virtual double getNoiseSigma() const = 0; 100 virtual void setNoiseSigma(double noiseSigma) = 0; 101 }; 102 103 /** @brief Creates mixture-of-gaussian background subtractor 104 105 @param history Length of the history. 106 @param nmixtures Number of Gaussian mixtures. 107 @param backgroundRatio Background ratio. 108 @param noiseSigma Noise strength (standard deviation of the brightness or each color channel). 0 109 means some automatic value. 110 */ 111 CV_EXPORTS Ptr<cuda::BackgroundSubtractorMOG> 112 createBackgroundSubtractorMOG(int history = 200, int nmixtures = 5, 113 double backgroundRatio = 0.7, double noiseSigma = 0); 114 115 //////////////////////////////////////////////////// 116 // MOG2 117 118 /** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm. 119 120 The class discriminates between foreground and background pixels by building and maintaining a model 121 of the background. Any pixel which does not fit this model is then deemed to be foreground. The 122 class implements algorithm described in @cite Zivkovic2004 . 123 124 @sa BackgroundSubtractorMOG2 125 */ 126 class CV_EXPORTS BackgroundSubtractorMOG2 : public cv::BackgroundSubtractorMOG2 127 { 128 public: 129 using cv::BackgroundSubtractorMOG2::apply; 130 using cv::BackgroundSubtractorMOG2::getBackgroundImage; 131 132 virtual void apply(InputArray image, OutputArray fgmask, double learningRate, Stream& stream) = 0; 133 134 virtual void getBackgroundImage(OutputArray backgroundImage, Stream& stream) const = 0; 135 }; 136 137 /** @brief Creates MOG2 Background Subtractor 138 139 @param history Length of the history. 140 @param varThreshold Threshold on the squared Mahalanobis distance between the pixel and the model 141 to decide whether a pixel is well described by the background model. This parameter does not 142 affect the background update. 143 @param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the 144 speed a bit, so if you do not need this feature, set the parameter to false. 145 */ 146 CV_EXPORTS Ptr<cuda::BackgroundSubtractorMOG2> 147 createBackgroundSubtractorMOG2(int history = 500, double varThreshold = 16, 148 bool detectShadows = true); 149 150 //! @} 151 152 }} // namespace cv { namespace cuda { 153 154 #endif /* __OPENCV_CUDABGSEGM_HPP__ */ 155