cudabgsegm.hpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. #ifndef OPENCV_CUDABGSEGM_HPP
  43. #define OPENCV_CUDABGSEGM_HPP
  44. #ifndef __cplusplus
  45. # error cudabgsegm.hpp header must be compiled as C++
  46. #endif
  47. #include "opencv2/core/cuda.hpp"
  48. #include "opencv2/video/background_segm.hpp"
  49. /**
  50. @addtogroup cuda
  51. @{
  52. @defgroup cudabgsegm Background Segmentation
  53. @}
  54. */
  55. namespace cv { namespace cuda {
  56. //! @addtogroup cudabgsegm
  57. //! @{
  58. ////////////////////////////////////////////////////
  59. // MOG
  60. /** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
  61. The class discriminates between foreground and background pixels by building and maintaining a model
  62. of the background. Any pixel which does not fit this model is then deemed to be foreground. The
  63. class implements algorithm described in @cite MOG2001 .
  64. @sa BackgroundSubtractorMOG
  65. @note
  66. - An example on gaussian mixture based background/foreground segmantation can be found at
  67. opencv_source_code/samples/gpu/bgfg_segm.cpp
  68. */
  69. class CV_EXPORTS BackgroundSubtractorMOG : public cv::BackgroundSubtractor
  70. {
  71. public:
  72. using cv::BackgroundSubtractor::apply;
  73. virtual void apply(InputArray image, OutputArray fgmask, double learningRate, Stream& stream) = 0;
  74. using cv::BackgroundSubtractor::getBackgroundImage;
  75. virtual void getBackgroundImage(OutputArray backgroundImage, Stream& stream) const = 0;
  76. virtual int getHistory() const = 0;
  77. virtual void setHistory(int nframes) = 0;
  78. virtual int getNMixtures() const = 0;
  79. virtual void setNMixtures(int nmix) = 0;
  80. virtual double getBackgroundRatio() const = 0;
  81. virtual void setBackgroundRatio(double backgroundRatio) = 0;
  82. virtual double getNoiseSigma() const = 0;
  83. virtual void setNoiseSigma(double noiseSigma) = 0;
  84. };
  85. /** @brief Creates mixture-of-gaussian background subtractor
  86. @param history Length of the history.
  87. @param nmixtures Number of Gaussian mixtures.
  88. @param backgroundRatio Background ratio.
  89. @param noiseSigma Noise strength (standard deviation of the brightness or each color channel). 0
  90. means some automatic value.
  91. */
  92. CV_EXPORTS Ptr<cuda::BackgroundSubtractorMOG>
  93. createBackgroundSubtractorMOG(int history = 200, int nmixtures = 5,
  94. double backgroundRatio = 0.7, double noiseSigma = 0);
  95. ////////////////////////////////////////////////////
  96. // MOG2
  97. /** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
  98. The class discriminates between foreground and background pixels by building and maintaining a model
  99. of the background. Any pixel which does not fit this model is then deemed to be foreground. The
  100. class implements algorithm described in @cite Zivkovic2004 .
  101. @sa BackgroundSubtractorMOG2
  102. */
  103. class CV_EXPORTS BackgroundSubtractorMOG2 : public cv::BackgroundSubtractorMOG2
  104. {
  105. public:
  106. using cv::BackgroundSubtractorMOG2::apply;
  107. using cv::BackgroundSubtractorMOG2::getBackgroundImage;
  108. virtual void apply(InputArray image, OutputArray fgmask, double learningRate, Stream& stream) = 0;
  109. virtual void getBackgroundImage(OutputArray backgroundImage, Stream& stream) const = 0;
  110. };
  111. /** @brief Creates MOG2 Background Subtractor
  112. @param history Length of the history.
  113. @param varThreshold Threshold on the squared Mahalanobis distance between the pixel and the model
  114. to decide whether a pixel is well described by the background model. This parameter does not
  115. affect the background update.
  116. @param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the
  117. speed a bit, so if you do not need this feature, set the parameter to false.
  118. */
  119. CV_EXPORTS Ptr<cuda::BackgroundSubtractorMOG2>
  120. createBackgroundSubtractorMOG2(int history = 500, double varThreshold = 16,
  121. bool detectShadows = true);
  122. //! @}
  123. }} // namespace cv { namespace cuda {
  124. #endif /* OPENCV_CUDABGSEGM_HPP */