/// <summary> /// Release all the unmanaged memory associated with this background model. /// </summary> protected override void DisposeObject() { if (IntPtr.Zero != _ptr) { BgSegmInvoke.cveBackgroundSubtractorMOGRelease(ref _ptr, ref _sharedPtr); _backgroundSubtractorPtr = IntPtr.Zero; _algorithmPtr = IntPtr.Zero; } }
/// <summary> /// Creates a CNT Background Subtractor. /// </summary> /// <param name="minPixelStability">number of frames with same pixel color to consider stable</param> /// <param name="useHistory">determines if we're giving a pixel credit for being stable for a long time</param> /// <param name="maxPixelStability">maximum allowed credit for a pixel in history</param> /// <param name="isParallel">determines if we're parallelizing the algorithm</param> public BackgroundSubtractorCNT( int minPixelStability = 15, bool useHistory = true, int maxPixelStability = 15 * 60, bool isParallel = true) { _ptr = BgSegmInvoke.cveBackgroundSubtractorCNTCreate( minPixelStability, useHistory, maxPixelStability, isParallel, ref _backgroundSubtractorPtr, ref _algorithmPtr, ref _sharedPtr); }
/// <summary> /// Creates an instance of BackgroundSubtractorGSOC algorithm. /// </summary> /// <param name="mc">Whether to use camera motion compensation.</param> /// <param name="nSamples">Number of samples to maintain at each point of the frame.</param> /// <param name="replaceRate">Probability of replacing the old sample - how fast the model will update itself.</param> /// <param name="propagationRate">Probability of propagating to neighbors.</param> /// <param name="hitsThreshold">How many positives the sample must get before it will be considered as a possible replacement.</param> /// <param name="alpha">Scale coefficient for threshold.</param> /// <param name="beta">Bias coefficient for threshold.</param> /// <param name="blinkingSupressionDecay">Blinking supression decay factor.</param> /// <param name="blinkingSupressionMultiplier">Blinking supression multiplier.</param> /// <param name="noiseRemovalThresholdFacBG">Strength of the noise removal for background points.</param> /// <param name="noiseRemovalThresholdFacFG">Strength of the noise removal for foreground points.</param> public BackgroundSubtractorGSOC( BackgroundSubtractorLSBP.CameraMotionCompensation mc = BackgroundSubtractorLSBP.CameraMotionCompensation.None, int nSamples = 20, float replaceRate = 0.003f, float propagationRate = 0.01f, int hitsThreshold = 32, float alpha = 0.01f, float beta = 0.0022f, float blinkingSupressionDecay = 0.1f, float blinkingSupressionMultiplier = 0.1f, float noiseRemovalThresholdFacBG = 0.0004f, float noiseRemovalThresholdFacFG = 0.0008f) { _ptr = BgSegmInvoke.cveBackgroundSubtractorGSOCCreate(mc, nSamples, replaceRate, propagationRate, hitsThreshold, alpha, beta, blinkingSupressionDecay, blinkingSupressionMultiplier, noiseRemovalThresholdFacBG, noiseRemovalThresholdFacFG, ref _backgroundSubtractorPtr, ref _algorithmPtr, ref _sharedPtr); }
/// <summary> /// Creates an instance of BackgroundSubtractorLSBP algorithm. /// </summary> /// <param name="mc">Whether to use camera motion compensation.</param> /// <param name="nSamples">Number of samples to maintain at each point of the frame.</param> /// <param name="LSBPRadius">LSBP descriptor radius.</param> /// <param name="tlower">Lower bound for T-values.</param> /// <param name="tupper">Upper bound for T-values.</param> /// <param name="tinc">Increase step for T-values.</param> /// <param name="tdec">Decrease step for T-values.</param> /// <param name="rscale">Scale coefficient for threshold values.</param> /// <param name="rincdec">Increase/Decrease step for threshold values.</param> /// <param name="noiseRemovalThresholdFacBG">Strength of the noise removal for background points.</param> /// <param name="noiseRemovalThresholdFacFG">Strength of the noise removal for foreground points.</param> /// <param name="LSBPthreshold">Threshold for LSBP binary string.</param> /// <param name="minCount">Minimal number of matches for sample to be considered as foreground.</param> public BackgroundSubtractorLSBP( CameraMotionCompensation mc = CameraMotionCompensation.None, int nSamples = 20, int LSBPRadius = 16, float tlower = 2.0f, float tupper = 32.0f, float tinc = 1.0f, float tdec = 0.05f, float rscale = 10.0f, float rincdec = 0.005f, float noiseRemovalThresholdFacBG = 0.0004f, float noiseRemovalThresholdFacFG = 0.0008f, int LSBPthreshold = 8, int minCount = 2) { _ptr = BgSegmInvoke.cveBackgroundSubtractorLSBPCreate( mc, nSamples, LSBPRadius, tlower, tupper, tinc, tdec, rscale, rincdec, noiseRemovalThresholdFacBG, noiseRemovalThresholdFacFG, LSBPthreshold, minCount, ref _backgroundSubtractorPtr, ref _algorithmPtr, ref _sharedPtr); }
/// <summary> /// Create an "Improved adaptive Gaussian mixture model for background subtraction". /// </summary> /// <param name="history">The length of the history.</param> /// <param name="nMixtures">The maximum number of gaussian mixtures.</param> /// <param name="backgroundRatio">Background ratio</param> /// <param name="noiseSigma">Noise strength (standard deviation of the brightness or each color channel). 0 means some automatic value.</param> public BackgroundSubtractorMOG( int history = 200, int nMixtures = 5, double backgroundRatio = 0.7, double noiseSigma = 0) { _ptr = BgSegmInvoke.cveBackgroundSubtractorMOGCreate(history, nMixtures, backgroundRatio, noiseSigma, ref _backgroundSubtractorPtr, ref _algorithmPtr, ref _sharedPtr); }
/// <summary> /// Create a background subtractor module based on GMG /// </summary> /// <param name="initializationFrames">Number of frames used to initialize the background models.</param> /// <param name="decisionThreshold">Threshold value, above which it is marked foreground, else background.</param> public BackgroundSubtractorGMG(int initializationFrames, double decisionThreshold) { _ptr = BgSegmInvoke.cveBackgroundSubtractorGMGCreate(initializationFrames, decisionThreshold, ref _backgroundSubtractorPtr, ref _algorithmPtr, ref _sharedPtr); }