VAT  3.0
Video Analysis Tool
Classes | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
BackgroundSubtractorPAWCS Class Reference

#include <BackgroundSubtractorPAWCS.h>

Inheritance diagram for BackgroundSubtractorPAWCS:
BackgroundSubtractorLBSP

Classes

struct  ColorLBSPFeature
 
struct  GlobalWord
 
struct  GlobalWordBase
 
struct  LocalWord
 
struct  LocalWordBase
 
struct  PxInfo_PAWCS
 

Public Member Functions

 BackgroundSubtractorPAWCS (float fRelLBSPThreshold=BGSPAWCS_DEFAULT_LBSP_REL_SIMILARITY_THRESHOLD, size_t nDescDistThresholdOffset=BGSPAWCS_DEFAULT_DESC_DIST_THRESHOLD_OFFSET, size_t nMinColorDistThreshold=BGSPAWCS_DEFAULT_MIN_COLOR_DIST_THRESHOLD, size_t nMaxNbWords=BGSPAWCS_DEFAULT_MAX_NB_WORDS, size_t nSamplesForMovingAvgs=BGSPAWCS_DEFAULT_N_SAMPLES_FOR_MV_AVGS)
 full constructor
 
virtual ~BackgroundSubtractorPAWCS ()
 default destructor
 
virtual void initialize (const cv::Mat &oInitImg, const cv::Mat &oROI)
 (re)initiaization method; needs to be called before starting background subtraction
 
virtual void refreshModel (size_t nBaseOccCount, float fOccDecrFrac, bool bForceFGUpdate=false)
 refreshes all local (+ global) dictionaries based on the last analyzed frame
 
virtual void apply (cv::InputArray image, cv::OutputArray fgmask, double learningRateOverride=0)
 primary model update function; the learning param is used to override the internal learning speed (ignored when <= 0)
 
virtual void apply (cv::InputArray image, cv::OutputArray fgmask, cv::OutputArray _featureMap, cv::OutputArray _reliabilityMap, cv::OutputArray _foregroundRaw, double learningRateOverride=0)
 
virtual void getBackgroundImage (cv::OutputArray backgroundImage) const
 returns a copy of the latest reconstructed background image
 
virtual void getBackgroundDescriptorsImage (cv::OutputArray backgroundDescImage) const
 returns a copy of the latest reconstructed background descriptors image
 
- Public Member Functions inherited from BackgroundSubtractorLBSP
 BackgroundSubtractorLBSP (float fRelLBSPThreshold, size_t nLBSPThresholdOffset=0)
 full constructor
 
virtual ~BackgroundSubtractorLBSP ()
 default destructor
 
virtual void initialize (const cv::Mat &oInitImg)
 (re)initiaization method; needs to be called before starting background subtraction
 
virtual cv::Mat getROICopy () const
 returns a copy of the ROI used for descriptor extraction
 
virtual void setROI (cv::Mat &oROI)
 sets the ROI to be used for descriptor extraction (note: this function will reinit the model and return the usable ROI)
 
void setAutomaticModelReset (bool)
 turns automatic model reset on or off
 

Protected Types

typedef LocalWord< ColorLBSPFeature< 1 > > LocalWord_1ch
 
typedef LocalWord< ColorLBSPFeature< 3 > > LocalWord_3ch
 
typedef GlobalWord< ColorLBSPFeature< 1 > > GlobalWord_1ch
 
typedef GlobalWord< ColorLBSPFeature< 3 > > GlobalWord_3ch
 

Protected Member Functions

void CleanupDictionaries ()
 internal cleanup function for the dictionary structures
 

Static Protected Member Functions

static float GetLocalWordWeight (const LocalWordBase *w, size_t nCurrFrame, size_t nOffset)
 internal weight lookup function for local words
 
static float GetGlobalWordWeight (const GlobalWordBase *w)
 internal weight lookup function for global words
 

Protected Attributes

const size_t m_nMinColorDistThreshold
 absolute minimal color distance threshold ('R' or 'radius' in the original ViBe paper, used as the default/initial 'R(x)' value here)
 
const size_t m_nDescDistThresholdOffset
 absolute descriptor distance threshold offset
 
size_t m_nMaxLocalWords
 max/curr number of local words used to build background submodels (for a single pixel, similar to 'N' in ViBe/PBAS, may vary based on img/channel size)
 
size_t m_nCurrLocalWords
 
size_t m_nMaxGlobalWords
 max/curr number of global words used to build the global background model (may vary based on img/channel size)
 
size_t m_nCurrGlobalWords
 
const size_t m_nSamplesForMovingAvgs
 number of samples to use to compute the learning rate of moving averages
 
float m_fLastNonFlatRegionRatio
 last calculated non-flat region ratio
 
int m_nMedianBlurKernelSize
 current kernel size for median blur post-proc filtering
 
cv::Size m_oDownSampledFrameSize_MotionAnalysis
 specifies the downsampled frame size used for cam motion analysis & gword lookup maps
 
cv::Size m_oDownSampledFrameSize_GlobalWordLookup
 
cv::Mat m_oDownSampledROI_MotionAnalysis
 downsampled version of the ROI used for cam motion analysis
 
size_t m_nDownSampledROIPxCount
 total pixel count for the downsampled ROIs
 
size_t m_nLocalWordWeightOffset
 current local word weight offset
 
LocalWordBase ** m_apLocalWordDict
 word lists & dictionaries
 
LocalWord_1chm_aLocalWordList_1ch
 
LocalWord_1chm_pLocalWordListIter_1ch
 
LocalWord_3chm_aLocalWordList_3ch
 
LocalWord_3chm_pLocalWordListIter_3ch
 
GlobalWordBase ** m_apGlobalWordDict
 
GlobalWord_1chm_aGlobalWordList_1ch
 
GlobalWord_1chm_pGlobalWordListIter_1ch
 
GlobalWord_3chm_aGlobalWordList_3ch
 
GlobalWord_3chm_pGlobalWordListIter_3ch
 
PxInfo_PAWCSm_aPxInfoLUT_PAWCS
 
cv::Mat m_oIllumUpdtRegionMask
 a lookup map used to keep track of regions where illumination recently changed
 
cv::Mat m_oUpdateRateFrame
 per-pixel update rates ('T(x)' in PBAS, which contains pixel-level 'sigmas', as referred to in ViBe)
 
cv::Mat m_oDistThresholdFrame
 per-pixel distance thresholds (equivalent to 'R(x)' in PBAS, but used as a relative value to determine both intensity and descriptor variation thresholds)
 
cv::Mat m_oDistThresholdVariationFrame
 per-pixel distance threshold variation modulators ('v(x)', relative value used to modulate 'R(x)' and 'T(x)' variations)
 
cv::Mat m_oMeanMinDistFrame_LT
 per-pixel mean minimal distances from the model ('D_min(x)' in PBAS, used to control variation magnitude and direction of 'T(x)' and 'R(x)')
 
cv::Mat m_oMeanMinDistFrame_ST
 
cv::Mat m_oMeanDownSampledLastDistFrame_LT
 per-pixel mean downsampled distances between consecutive frames (used to analyze camera movement and force global model resets automatically)
 
cv::Mat m_oMeanDownSampledLastDistFrame_ST
 
cv::Mat m_oMeanRawSegmResFrame_LT
 per-pixel mean raw segmentation results (used to detect unstable segmentation regions)
 
cv::Mat m_oMeanRawSegmResFrame_ST
 
cv::Mat m_oMeanFinalSegmResFrame_LT
 per-pixel mean raw segmentation results (used to detect unstable segmentation regions)
 
cv::Mat m_oMeanFinalSegmResFrame_ST
 
cv::Mat m_oUnstableRegionMask
 a lookup map used to keep track of unstable regions (based on segm. noise & local dist. thresholds)
 
cv::Mat m_oBlinksFrame
 per-pixel blink detection map ('Z(x)')
 
cv::Mat m_oDownSampledFrame_MotionAnalysis
 pre-allocated matrix used to downsample the input frame when needed
 
cv::Mat m_oLastRawFGMask
 the foreground mask generated by the method at [t-1] (without post-proc, used for blinking px detection)
 
cv::Mat m_oFGMask_PreFlood
 pre-allocated CV_8UC1 matrices used to speed up morph ops
 
cv::Mat m_oFGMask_FloodedHoles
 
cv::Mat m_oLastFGMask_dilated
 
cv::Mat m_oLastFGMask_dilated_inverted
 
cv::Mat m_oCurrRawFGBlinkMask
 
cv::Mat m_oLastRawFGBlinkMask
 
cv::Mat m_oTempGlobalWordWeightDiffFactor
 
cv::Mat m_oMorphExStructElement
 
cv::Mat featureMap
 Features and reliability Maps.
 
cv::Mat reliabilityMap
 
cv::Mat foregroundRaw
 
cv::Mat reliabilityMap2
 
cv::Mat featureMap3
 
cv::Mat reliabilityMap3
 
ReliabilityBg reliabilityBg
 
float feature1
 
float reliability1
 
float feature2a
 
float reliability2a
 
float feature2b
 
float reliability2b
 
float feature3
 
float reliability3
 
float minScale
 
float maxScale
 
float threshold
 
float scaleFactor
 
- Protected Attributes inherited from BackgroundSubtractorLBSP
cv::Mat m_oROI
 background model ROI used for LBSP descriptor extraction (specific to the input image size)
 
cv::Size m_oImgSize
 input image size
 
size_t m_nImgChannels
 input image channel size
 
int m_nImgType
 input image type
 
const size_t m_nLBSPThresholdOffset
 LBSP internal threshold offset value, used to reduce texture noise in dark regions.
 
const float m_fRelLBSPThreshold
 LBSP relative internal threshold (kept here since we don't keep an LBSP object)
 
size_t m_nTotPxCount
 total number of pixels (depends on the input frame size) & total number of relevant pixels
 
size_t m_nTotRelevantPxCount
 
size_t m_nFrameIndex
 current frame index, frame count since last model reset & model reset cooldown counters
 
size_t m_nFramesSinceLastReset
 
size_t m_nModelResetCooldown
 
size_t m_anLBSPThreshold_8bitLUT [UCHAR_MAX+1]
 pre-allocated internal LBSP threshold values LUT for all possible 8-bit intensities
 
size_t * m_aPxIdxLUT
 internal pixel index LUT for all relevant analysis regions (based on the provided ROI)
 
PxInfoBasem_aPxInfoLUT
 internal pixel info LUT for all possible pixel indexes
 
const int m_nDefaultMedianBlurKernelSize
 default kernel size for median blur post-proc filtering
 
bool m_bInitialized
 specifies whether the algorithm is fully initialized or not
 
bool m_bAutoModelResetEnabled
 specifies whether automatic model resets are enabled or not
 
bool m_bUsingMovingCamera
 specifies whether the camera is considered moving or not
 
cv::Mat m_oLastColorFrame
 copy of latest pixel intensities (used when refreshing model)
 
cv::Mat m_oLastDescFrame
 copy of latest descriptors (used when refreshing model)
 
cv::Mat m_oLastFGMask
 the foreground mask generated by the method at [t-1]
 

Additional Inherited Members

- Public Attributes inherited from BackgroundSubtractorLBSP
int m_nDebugCoordX
 
int m_nDebugCoordY
 
std::string m_sDebugName
 
cv::FileStorage * m_pDebugFS
 

Detailed Description

Pixel-based Adaptive Word Consensus Segmenter (PAWCS) change detection algorithm.

Note: both grayscale and RGB/BGR images may be used with this extractor (parameters are adjusted automatically). For optimal grayscale results, use CV_8UC1 frames instead of CV_8UC3.

For more details on the different parameters or on the algorithm itself, see P.-L. St-Charles et al., "A Self-Adjusting Approach to Change Detection Based on Background Word Consensus", in WACV 2015.

This algorithm is currently NOT thread-safe.


The documentation for this class was generated from the following files: