3 #include "BackgroundSubtractorLBSP.h" 4 #include "custom_utils/DistanceUtils.h" 5 #include "custom_utils/RandUtils.h" 7 #include <opencv2/imgproc/imgproc.hpp> 8 #include <opencv2/highgui/highgui.hpp> 10 #include "ThermalColor.h" 11 #include "ReliabilityBg.h" 14 #define BGSPAWCS_DEFAULT_LBSP_REL_SIMILARITY_THRESHOLD (0.333f) 15 #define BGSPAWCS_DEFAULT_DESC_DIST_THRESHOLD_OFFSET (2) 17 #define BGSPAWCS_DEFAULT_MIN_COLOR_DIST_THRESHOLD (20) 19 #define BGSPAWCS_DEFAULT_MAX_NB_WORDS (50) 21 #define BGSPAWCS_DEFAULT_N_SAMPLES_FOR_MV_AVGS (100) 39 size_t nDescDistThresholdOffset=BGSPAWCS_DEFAULT_DESC_DIST_THRESHOLD_OFFSET,
40 size_t nMinColorDistThreshold=BGSPAWCS_DEFAULT_MIN_COLOR_DIST_THRESHOLD,
41 size_t nMaxNbWords=BGSPAWCS_DEFAULT_MAX_NB_WORDS,
42 size_t nSamplesForMovingAvgs=BGSPAWCS_DEFAULT_N_SAMPLES_FOR_MV_AVGS);
46 virtual void initialize(
const cv::Mat& oInitImg,
const cv::Mat& oROI);
48 virtual void refreshModel(
size_t nBaseOccCount,
float fOccDecrFrac,
bool bForceFGUpdate=
false);
50 virtual void apply(cv::InputArray image, cv::OutputArray fgmask,
double learningRateOverride=0);
51 virtual void apply(cv::InputArray image, cv::OutputArray fgmask, cv::OutputArray _featureMap, cv::OutputArray _reliabilityMap,
52 cv::OutputArray _foregroundRaw,
double learningRateOverride=0);
59 template<
size_t nChannels>
61 uchar anColor[nChannels];
62 ushort anDesc[nChannels];
75 cv::Mat oSpatioOccMap;
87 size_t nGlobalWordMapLookupIdx;
115 LocalWord_1ch* m_aLocalWordList_1ch, *m_pLocalWordListIter_1ch;
116 LocalWord_3ch* m_aLocalWordList_3ch, *m_pLocalWordListIter_3ch;
118 GlobalWord_1ch* m_aGlobalWordList_1ch, *m_pGlobalWordListIter_1ch;
119 GlobalWord_3ch* m_aGlobalWordList_3ch, *m_pGlobalWordListIter_3ch;
149 cv::Mat m_oFGMask_FloodedHoles;
150 cv::Mat m_oLastFGMask_dilated;
151 cv::Mat m_oLastFGMask_dilated_inverted;
152 cv::Mat m_oCurrRawFGBlinkMask;
153 cv::Mat m_oLastRawFGBlinkMask;
154 cv::Mat m_oTempGlobalWordWeightDiffFactor;
155 cv::Mat m_oMorphExStructElement;
159 cv::Mat reliabilityMap;
160 cv::Mat foregroundRaw;
161 cv::Mat reliabilityMap2;
163 cv::Mat reliabilityMap3;
166 float feature1, reliability1, feature2a, reliability2a, feature2b, reliability2b, feature3, reliability3;
167 float minScale, maxScale, threshold, scaleFactor;
cv::Mat m_oDistThresholdFrame
per-pixel distance thresholds (equivalent to 'R(x)' in PBAS, but used as a relative value to determin...
Definition: BackgroundSubtractorPAWCS.h:127
size_t m_nMaxGlobalWords
max/curr number of global words used to build the global background model (may vary based on img/chan...
Definition: BackgroundSubtractorPAWCS.h:97
cv::Mat m_oMeanDownSampledLastDistFrame_LT
per-pixel mean downsampled distances between consecutive frames (used to analyze camera movement and ...
Definition: BackgroundSubtractorPAWCS.h:133
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
Definition: BackgroundSubtractorPAWCS.cpp:59
cv::Mat m_oMeanRawSegmResFrame_LT
per-pixel mean raw segmentation results (used to detect unstable segmentation regions) ...
Definition: BackgroundSubtractorPAWCS.h:135
LocalWordBase ** m_apLocalWordDict
word lists & dictionaries
Definition: BackgroundSubtractorPAWCS.h:114
cv::Mat m_oMeanMinDistFrame_LT
per-pixel mean minimal distances from the model ('D_min(x)' in PBAS, used to control variation magnit...
Definition: BackgroundSubtractorPAWCS.h:131
virtual ~BackgroundSubtractorPAWCS()
default destructor
Definition: BackgroundSubtractorPAWCS.cpp:90
Definition: BackgroundSubtractorLBSP.h:23
void CleanupDictionaries()
internal cleanup function for the dictionary structures
Definition: BackgroundSubtractorPAWCS.cpp:1362
const size_t m_nDescDistThresholdOffset
absolute descriptor distance threshold offset
Definition: BackgroundSubtractorPAWCS.h:93
cv::Mat m_oFGMask_PreFlood
pre-allocated CV_8UC1 matrices used to speed up morph ops
Definition: BackgroundSubtractorPAWCS.h:148
Definition: BackgroundSubtractorPAWCS.h:73
virtual void getBackgroundImage(cv::OutputArray backgroundImage) const
returns a copy of the latest reconstructed background image
Definition: BackgroundSubtractorPAWCS.cpp:1307
cv::Mat m_oIllumUpdtRegionMask
a lookup map used to keep track of regions where illumination recently changed
Definition: BackgroundSubtractorPAWCS.h:123
cv::Mat m_oUnstableRegionMask
a lookup map used to keep track of unstable regions (based on segm. noise & local dist...
Definition: BackgroundSubtractorPAWCS.h:139
Definition: BackgroundSubtractorPAWCS.h:86
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)
Definition: BackgroundSubtractorPAWCS.h:95
Definition: BackgroundSubtractorPAWCS.h:79
virtual void getBackgroundDescriptorsImage(cv::OutputArray backgroundDescImage) const
returns a copy of the latest reconstructed background descriptors image
Definition: BackgroundSubtractorPAWCS.cpp:1342
size_t m_nLocalWordWeightOffset
current local word weight offset
Definition: BackgroundSubtractorPAWCS.h:111
cv::Mat featureMap
Features and reliability Maps.
Definition: BackgroundSubtractorPAWCS.h:158
cv::Mat m_oDownSampledFrame_MotionAnalysis
pre-allocated matrix used to downsample the input frame when needed
Definition: BackgroundSubtractorPAWCS.h:143
Definition: BackgroundSubtractorPAWCS.h:60
int m_nMedianBlurKernelSize
current kernel size for median blur post-proc filtering
Definition: BackgroundSubtractorPAWCS.h:103
Definition: BackgroundSubtractorPAWCS.h:64
virtual void refreshModel(size_t nBaseOccCount, float fOccDecrFrac, bool bForceFGUpdate=false)
refreshes all local (+ global) dictionaries based on the last analyzed frame
Definition: BackgroundSubtractorPAWCS.cpp:283
Definition: BackgroundSubtractorPAWCS.h:35
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 (ig...
Definition: BackgroundSubtractorPAWCS.cpp:612
cv::Mat m_oMeanFinalSegmResFrame_LT
per-pixel mean raw segmentation results (used to detect unstable segmentation regions) ...
Definition: BackgroundSubtractorPAWCS.h:137
Definition: BackgroundSubtractorPAWCS.h:70
static float GetGlobalWordWeight(const GlobalWordBase *w)
internal weight lookup function for global words
Definition: BackgroundSubtractorPAWCS.cpp:1408
static float GetLocalWordWeight(const LocalWordBase *w, size_t nCurrFrame, size_t nOffset)
internal weight lookup function for local words
Definition: BackgroundSubtractorPAWCS.cpp:1404
cv::Mat m_oLastRawFGMask
the foreground mask generated by the method at [t-1] (without post-proc, used for blinking px detecti...
Definition: BackgroundSubtractorPAWCS.h:145
virtual void initialize(const cv::Mat &oInitImg, const cv::Mat &oROI)
(re)initiaization method; needs to be called before starting background subtraction ...
Definition: BackgroundSubtractorPAWCS.cpp:94
cv::Mat m_oUpdateRateFrame
per-pixel update rates ('T(x)' in PBAS, which contains pixel-level 'sigmas', as referred to in ViBe) ...
Definition: BackgroundSubtractorPAWCS.h:125
cv::Mat m_oDistThresholdVariationFrame
per-pixel distance threshold variation modulators ('v(x)', relative value used to modulate 'R(x)' and...
Definition: BackgroundSubtractorPAWCS.h:129
size_t m_nDownSampledROIPxCount
total pixel count for the downsampled ROIs
Definition: BackgroundSubtractorPAWCS.h:109
float m_fLastNonFlatRegionRatio
last calculated non-flat region ratio
Definition: BackgroundSubtractorPAWCS.h:101
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)
Definition: BackgroundSubtractorPAWCS.h:91
cv::Mat m_oDownSampledROI_MotionAnalysis
downsampled version of the ROI used for cam motion analysis
Definition: BackgroundSubtractorPAWCS.h:107
cv::Mat m_oBlinksFrame
per-pixel blink detection map ('Z(x)')
Definition: BackgroundSubtractorPAWCS.h:141
Definition: ReliabilityBg.h:8
cv::Size m_oDownSampledFrameSize_MotionAnalysis
specifies the downsampled frame size used for cam motion analysis & gword lookup maps ...
Definition: BackgroundSubtractorPAWCS.h:105
const size_t m_nSamplesForMovingAvgs
number of samples to use to compute the learning rate of moving averages
Definition: BackgroundSubtractorPAWCS.h:99