Class BackgroundSubtractorGMG


public class BackgroundSubtractorGMG extends BackgroundSubtractor
Background Subtractor module based on the algorithm given in CITE: Gold2012 . 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.
  • Constructor Details

    • BackgroundSubtractorGMG

      protected BackgroundSubtractorGMG(long addr)
  • Method Details

    • __fromPtr__

      public static BackgroundSubtractorGMG __fromPtr__(long addr)
    • apply

      public void apply(Mat image, Mat fgmask, double learningRate)
      Computes a foreground mask.
      Overrides:
      apply in class BackgroundSubtractor
      Parameters:
      image - Next video frame of type CV_8UC(n),CV_8SC(n),CV_16UC(n),CV_16SC(n),CV_32SC(n),CV_32FC(n),CV_64FC(n), where n is 1,2,3,4.
      fgmask - The output foreground mask as an 8-bit binary image.
      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.
    • apply

      public void apply(Mat image, Mat fgmask)
      Computes a foreground mask.
      Overrides:
      apply in class BackgroundSubtractor
      Parameters:
      image - Next video frame of type CV_8UC(n),CV_8SC(n),CV_16UC(n),CV_16SC(n),CV_32SC(n),CV_32FC(n),CV_64FC(n), where n is 1,2,3,4.
      fgmask - The output foreground mask as an 8-bit binary image. 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.
    • apply

      public void apply(Mat image, Mat knownForegroundMask, Mat fgmask, double learningRate)
      Computes a foreground mask with known foreground mask input.
      Overrides:
      apply in class BackgroundSubtractor
      Parameters:
      image - Next video frame.
      knownForegroundMask - The mask for inputting already known foreground.
      fgmask - The output foreground mask as an 8-bit binary image.
      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. Note: This method has a default virtual implementation that throws a "not implemented" error. Foreground masking may not be supported by all background subtractors.
    • apply

      public void apply(Mat image, Mat knownForegroundMask, Mat fgmask)
      Computes a foreground mask with known foreground mask input.
      Overrides:
      apply in class BackgroundSubtractor
      Parameters:
      image - Next video frame.
      knownForegroundMask - The mask for inputting already known foreground. 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. Note: This method has a default virtual implementation that throws a "not implemented" error. Foreground masking may not be supported by all background subtractors.
      fgmask - The output foreground mask as an 8-bit binary image.
    • getBackgroundImage

      public void getBackgroundImage(Mat backgroundImage)
      Description copied from class: BackgroundSubtractor
      Computes a background image.
      Overrides:
      getBackgroundImage in class BackgroundSubtractor
      Parameters:
      backgroundImage - The output background image. Note: Sometimes the background image can be very blurry, as it contain the average background statistics.
    • getMaxFeatures

      public int getMaxFeatures()
      Returns total number of distinct colors to maintain in histogram.
      Returns:
      automatically generated
    • setMaxFeatures

      public void setMaxFeatures(int maxFeatures)
      Sets total number of distinct colors to maintain in histogram.
      Parameters:
      maxFeatures - automatically generated
    • getDefaultLearningRate

      public double getDefaultLearningRate()
      Returns the learning rate of the algorithm. It lies between 0.0 and 1.0. It determines how quickly features are "forgotten" from histograms.
      Returns:
      automatically generated
    • setDefaultLearningRate

      public void setDefaultLearningRate(double lr)
      Sets the learning rate of the algorithm.
      Parameters:
      lr - automatically generated
    • getNumFrames

      public int getNumFrames()
      Returns the number of frames used to initialize background model.
      Returns:
      automatically generated
    • setNumFrames

      public void setNumFrames(int nframes)
      Sets the number of frames used to initialize background model.
      Parameters:
      nframes - automatically generated
    • getQuantizationLevels

      public int getQuantizationLevels()
      Returns the parameter used for quantization of color-space. It is the number of discrete levels in each channel to be used in histograms.
      Returns:
      automatically generated
    • setQuantizationLevels

      public void setQuantizationLevels(int nlevels)
      Sets the parameter used for quantization of color-space
      Parameters:
      nlevels - automatically generated
    • getBackgroundPrior

      public double getBackgroundPrior()
      Returns the prior probability that each individual pixel is a background pixel.
      Returns:
      automatically generated
    • setBackgroundPrior

      public void setBackgroundPrior(double bgprior)
      Sets the prior probability that each individual pixel is a background pixel.
      Parameters:
      bgprior - automatically generated
    • getSmoothingRadius

      public int getSmoothingRadius()
      Returns the kernel radius used for morphological operations
      Returns:
      automatically generated
    • setSmoothingRadius

      public void setSmoothingRadius(int radius)
      Sets the kernel radius used for morphological operations
      Parameters:
      radius - automatically generated
    • getDecisionThreshold

      public double getDecisionThreshold()
      Returns the value of decision threshold. Decision value is the value above which pixel is determined to be FG.
      Returns:
      automatically generated
    • setDecisionThreshold

      public void setDecisionThreshold(double thresh)
      Sets the value of decision threshold.
      Parameters:
      thresh - automatically generated
    • getUpdateBackgroundModel

      public boolean getUpdateBackgroundModel()
      Returns the status of background model update
      Returns:
      automatically generated
    • setUpdateBackgroundModel

      public void setUpdateBackgroundModel(boolean update)
      Sets the status of background model update
      Parameters:
      update - automatically generated
    • getMinVal

      public double getMinVal()
      Returns the minimum value taken on by pixels in image sequence. Usually 0.
      Returns:
      automatically generated
    • setMinVal

      public void setMinVal(double val)
      Sets the minimum value taken on by pixels in image sequence.
      Parameters:
      val - automatically generated
    • getMaxVal

      public double getMaxVal()
      Returns the maximum value taken on by pixels in image sequence. e.g. 1.0 or 255.
      Returns:
      automatically generated
    • setMaxVal

      public void setMaxVal(double val)
      Sets the maximum value taken on by pixels in image sequence.
      Parameters:
      val - automatically generated