前面几篇文章简单介绍了BgsLibrary的入口函数、视频分析和视频捕获模块,本文将简单介绍帧处理模块,即对每一帧进行处理的函数,也就是真正调用背景建模算法的接口处。
下面贴出源码供大家分析:
#include "FrameProcessor.h"
#include <iomanip>
namespace bgslibrary
{
FrameProcessor::FrameProcessor() : firstTime(true), frameNumber(0), duration(0), tictoc(""), frameToStop(0)
{
std::cout << "FrameProcessor()" << std::endl;
loadConfig();
saveConfig();
}
FrameProcessor::~FrameProcessor()
{
std::cout << "~FrameProcessor()" << std::endl;
}
void FrameProcessor::init()
{
if (enablePreProcessor)
preProcessor = new PreProcessor;
if (enableFrameDifferenceBGS)
frameDifference = new FrameDifferenceBGS;
if (enableStaticFrameDifferenceBGS)
staticFrameDifference = new StaticFrameDifferenceBGS;
if (enableWeightedMovingMeanBGS)
weightedMovingMean = new WeightedMovingMeanBGS;
if (enableWeightedMovingVarianceBGS)
weightedMovingVariance = new WeightedMovingVarianceBGS;
if (enableMixtureOfGaussianV1BGS)
mixtureOfGaussianV1BGS = new MixtureOfGaussianV1BGS;
if (enableMixtureOfGaussianV2BGS)
mixtureOfGaussianV2BGS = new MixtureOfGaussianV2BGS;
if (enableAdaptiveBackgroundLearning)
adaptiveBackgroundLearning = new AdaptiveBackgroundLearning;
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
if (enableGMG)
gmg = new GMG;
#endif
if (enableDPAdaptiveMedianBGS)
adaptiveMedian = new DPAdaptiveMedianBGS;
if (enableDPGrimsonGMMBGS)
grimsonGMM = new DPGrimsonGMMBGS;
if (enableDPZivkovicAGMMBGS)
zivkovicAGMM = new DPZivkovicAGMMBGS;
if (enableDPMeanBGS)
temporalMean = new DPMeanBGS;
if (enableDPWrenGABGS)
wrenGA = new DPWrenGABGS;
if (enableDPPratiMediodBGS)
pratiMediod = new DPPratiMediodBGS;
if (enableDPEigenbackgroundBGS)
eigenBackground = new DPEigenbackgroundBGS;
if (enableDPTextureBGS)
textureBGS = new DPTextureBGS;
if (enableT2FGMM_UM)
type2FuzzyGMM_UM = new T2FGMM_UM;
if (enableT2FGMM_UV)
type2FuzzyGMM_UV = new T2FGMM_UV;
if (enableT2FMRF_UM)
type2FuzzyMRF_UM = new T2FMRF_UM;
if (enableT2FMRF_UV)
type2FuzzyMRF_UV = new T2FMRF_UV;
if (enableFuzzySugenoIntegral)
fuzzySugenoIntegral = new FuzzySugenoIntegral;
if (enableFuzzyChoquetIntegral)
fuzzyChoquetIntegral = new FuzzyChoquetIntegral;
if (enableLBSimpleGaussian)
lbSimpleGaussian = new LBSimpleGaussian;
if (enableLBFuzzyGaussian)
lbFuzzyGaussian = new LBFuzzyGaussian;
if (enableLBMixtureOfGaussians)
lbMixtureOfGaussians = new LBMixtureOfGaussians;
if (enableLBAdaptiveSOM)
lbAdaptiveSOM = new LBAdaptiveSOM;
if (enableLBFuzzyAdaptiveSOM)
lbFuzzyAdaptiveSOM = new LBFuzzyAdaptiveSOM;
if (enableLbpMrf)
lbpMrf = new LbpMrf;
if(enableMultiLayerBGS)
multiLayerBGS = new MultiLayerBGS;
//if(enablePBAS)
// pixelBasedAdaptiveSegmenter = new PixelBasedAdaptiveSegmenter;
if (enableVuMeter)
vuMeter = new VuMeter;
if (enableKDE)
kde = new KDE;
if (enableIMBS)
imbs = new IndependentMultimodalBGS;
if (enableMultiCueBGS)
mcbgs = new SJN_MultiCueBGS;
if (enableSigmaDeltaBGS)
sdbgs = new SigmaDeltaBGS;
if (enableSuBSENSEBGS)
ssbgs = new SuBSENSEBGS;
if (enableLOBSTERBGS)
lobgs = new LOBSTERBGS;
if (enableForegroundMaskAnalysis)
foregroundMaskAnalysis = new ForegroundMaskAnalysis;
}
void FrameProcessor::process(std::string name, IBGS *bgs, const cv::Mat &img_input, cv::Mat &img_bgs)
{
if (tictoc == name)
tic(name);
cv::Mat img_bkgmodel;
bgs->process(img_input, img_bgs, img_bkgmodel);//直接调用各种背景建模算法
if (tictoc == name)
toc();
}
void FrameProcessor::process(const cv::Mat &img_input)
{
frameNumber++;
///enablePreProcessor///
if (enablePreProcessor)
preProcessor->process(img_input, img_prep);
/******************************************************************/
/*根据config文件使能各种背景建模算法,可以同时使用多种背景建模算法*/
/******************************************************************/
///1:Frame Difference
if (enableFrameDifferenceBGS)
process("FrameDifferenceBGS", frameDifference, img_prep, img_framediff);
///2:Static Frame Difference
if (enableStaticFrameDifferenceBGS)
process("StaticFrameDifferenceBGS", staticFrameDifference, img_prep, img_staticfdiff);
///3:Weighted Moving Mean
if (enableWeightedMovingMeanBGS)
process("WeightedMovingMeanBGS", weightedMovingMean, img_prep, img_wmovmean);
///4:Weighted Moving Variance
if (enableWeightedMovingVarianceBGS)
process("WeightedMovingVarianceBGS", weightedMovingVariance, img_prep, img_movvar);
///5:Gaussian Mixture Model
if (enableMixtureOfGaussianV1BGS)
process("MixtureOfGaussianV1BGS", mixtureOfGaussianV1BGS, img_prep, img_mog1);
///6:Gaussian Mixture Model
if (enableMixtureOfGaussianV2BGS)
process("MixtureOfGaussianV2BGS", mixtureOfGaussianV2BGS, img_prep, img_mog2);
///7:Adaptive Background Learning
if (enableAdaptiveBackgroundLearning)
process("AdaptiveBackgroundLearning", adaptiveBackgroundLearning, img_prep, img_bkgl_fgmask);
///8:GMG
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
if (enableGMG)
process("GMG", gmg, img_prep, img_gmg);
#endif
///9:Adaptive Median
if (enableDPAdaptiveMedianBGS)
process("DPAdaptiveMedianBGS", adaptiveMedian, img_prep, img_adpmed);
///10:Gaussian Mixture Model
if (enableDPGrimsonGMMBGS)
process("DPGrimsonGMMBGS", grimsonGMM, img_prep, img_grigmm);
///11:Gaussian Mixture Model
if (enableDPZivkovicAGMMBGS)
process("DPZivkovicAGMMBGS", zivkovicAGMM, img_prep, img_zivgmm);
///12:Temporal Mean
if (enableDPMeanBGS)
process("DPMeanBGS", temporalMean, img_prep, img_tmpmean);
///13:Gaussian Average
if (enableDPWrenGABGS)
process("DPWrenGABGS", wrenGA, img_prep, img_wrenga);
///14:Temporal Median
if (enableDPPratiMediodBGS)
process("DPPratiMediodBGS", pratiMediod, img_prep, img_pramed);
///15:Eigen background / SL-PCA
if (enableDPEigenbackgroundBGS)
process("DPEigenbackgroundBGS", eigenBackground, img_prep, img_eigbkg);
///16:Texture BGS
if (enableDPTextureBGS)
process("DPTextureBGS", textureBGS, img_prep, img_texbgs);
///17:Type-2 Fuzzy GMM-UM
if (enableT2FGMM_UM)
process("T2FGMM_UM", type2FuzzyGMM_UM, img_prep, img_t2fgmm_um);
///18:Type-2 Fuzzy GMM-UV
if (enableT2FGMM_UV)
process("T2FGMM_UV", type2FuzzyGMM_UV, img_prep, img_t2fgmm_uv);
///19:Type-2 Fuzzy GMM-UM with MRF
if (enableT2FMRF_UM)
process("T2FMRF_UM", type2FuzzyMRF_UM, img_prep, img_t2fmrf_um);
///20:Type-2 Fuzzy GMM-UV with MRF
if (enableT2FMRF_UV)
process("T2FMRF_UV", type2FuzzyMRF_UV, img_prep, img_t2fmrf_uv);
///21:Fuzzy Sugeno Integral
if (enableFuzzySugenoIntegral)
process("FuzzySugenoIntegral", fuzzySugenoIntegral, img_prep, img_fsi);
///22:Fuzzy Choquet Integral
if (enableFuzzyChoquetIntegral)
process("FuzzyChoquetIntegral", fuzzyChoquetIntegral, img_prep, img_fci);
///23:Simple Gaussian
if (enableLBSimpleGaussian)
process("LBSimpleGaussian", lbSimpleGaussian, img_prep, img_lb_sg);
///24:Fuzzy Gaussian of Laurence Bender
if (enableLBFuzzyGaussian)
process("LBFuzzyGaussian", lbFuzzyGaussian, img_prep, img_lb_fg);
///25:Gaussian Mixture Model
if (enableLBMixtureOfGaussians)
process("LBMixtureOfGaussians", lbMixtureOfGaussians, img_prep, img_lb_mog);
///26:Adaptive SOM
if (enableLBAdaptiveSOM)
process("LBAdaptiveSOM", lbAdaptiveSOM, img_prep, img_lb_som);
///27:Fuzzy Adaptive SOM
if (enableLBFuzzyAdaptiveSOM)
process("LBFuzzyAdaptiveSOM", lbFuzzyAdaptiveSOM, img_prep, img_lb_fsom);
///28:LbpMrf
if (enableLbpMrf)
process("LbpMrf", lbpMrf, img_prep, img_lbp_mrf);
///29:Multi-Layer BGS
if(enableMultiLayerBGS)
{
multiLayerBGS->setStatus(MultiLayerBGS::MLBGS_LEARN);
//multiLayerBGS->setStatus(MultiLayerBGS::MLBGS_DETECT);
process("MultiLayerBGS", multiLayerBGS, img_prep, img_mlbgs);
}
///30:Pixel-Based Adaptive Segmenter
//if(enablePBAS)
// process("PBAS", pixelBasedAdaptiveSegmenter, img_prep, img_pt_pbas);
///31:VuMeter
if (enableVuMeter)
process("VuMeter", vuMeter, img_prep, img_vumeter);
///32:Kernel Density Estimation
if (enableKDE)
process("KDE", kde, img_prep, img_kde);
///33:Independent Multimodal BGS
if (enableIMBS)
process("IMBS", imbs, img_prep, img_imbs);
///34:MultiCue BGS
if (enableMultiCueBGS)
process("MultiCueBGS", mcbgs, img_prep, img_mcbgs);
///35:Sigma-Delta
if (enableSigmaDeltaBGS)
process("SigmaDeltaBGS", sdbgs, img_prep, img_sdbgs);
///36:SuBSENSE
if (enableSuBSENSEBGS)
process("SuBSENSEBGS", ssbgs, img_prep, img_ssbgs);
///37:LOBSTER
if (enableLOBSTERBGS)
process("LOBSTERBGS", lobgs, img_prep, img_lobgs);
///enableForegroundMaskAnalysis///
if (enableForegroundMaskAnalysis)
{
foregroundMaskAnalysis->stopAt = frameToStop;
foregroundMaskAnalysis->img_ref_path = imgref;
foregroundMaskAnalysis->process(frameNumber, "FrameDifferenceBGS", img_framediff);
foregroundMaskAnalysis->process(frameNumber, "StaticFrameDifferenceBGS", img_staticfdiff);
foregroundMaskAnalysis->process(frameNumber, "WeightedMovingMeanBGS", img_wmovmean);
foregroundMaskAnalysis->process(frameNumber, "WeightedMovingVarianceBGS", img_movvar);
foregroundMaskAnalysis->process(frameNumber, "MixtureOfGaussianV1BGS", img_mog1);
foregroundMaskAnalysis->process(frameNumber, "MixtureOfGaussianV2BGS", img_mog2);
foregroundMaskAnalysis->process(frameNumber, "AdaptiveBackgroundLearning", img_bkgl_fgmask);
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
foregroundMaskAnalysis->process(frameNumber, "GMG", img_gmg);
#endif
foregroundMaskAnalysis->process(frameNumber, "DPAdaptiveMedianBGS", img_adpmed);
foregroundMaskAnalysis->process(frameNumber, "DPGrimsonGMMBGS", img_grigmm);
foregroundMaskAnalysis->process(frameNumber, "DPZivkovicAGMMBGS", img_zivgmm);
foregroundMaskAnalysis->process(frameNumber, "DPMeanBGS", img_tmpmean);
foregroundMaskAnalysis->process(frameNumber, "DPWrenGABGS", img_wrenga);
foregroundMaskAnalysis->process(frameNumber, "DPPratiMediodBGS", img_pramed);
foregroundMaskAnalysis->process(frameNumber, "DPEigenbackgroundBGS", img_eigbkg);
foregroundMaskAnalysis->process(frameNumber, "DPTextureBGS", img_texbgs);
foregroundMaskAnalysis->process(frameNumber, "T2FGMM_UM", img_t2fgmm_um);
foregroundMaskAnalysis->process(frameNumber, "T2FGMM_UV", img_t2fgmm_uv);
foregroundMaskAnalysis->process(frameNumber, "T2FMRF_UM", img_t2fmrf_um);
foregroundMaskAnalysis->process(frameNumber, "T2FMRF_UV", img_t2fmrf_uv);
foregroundMaskAnalysis->process(frameNumber, "FuzzySugenoIntegral", img_fsi);
foregroundMaskAnalysis->process(frameNumber, "FuzzyChoquetIntegral", img_fci);
foregroundMaskAnalysis->process(frameNumber, "LBSimpleGaussian", img_lb_sg);
foregroundMaskAnalysis->process(frameNumber, "LBFuzzyGaussian", img_lb_fg);
foregroundMaskAnalysis->process(frameNumber, "LBMixtureOfGaussians", img_lb_mog);
foregroundMaskAnalysis->process(frameNumber, "LBAdaptiveSOM", img_lb_som);
foregroundMaskAnalysis->process(frameNumber, "LBFuzzyAdaptiveSOM", img_lb_fsom);
foregroundMaskAnalysis->process(frameNumber, "LbpMrf", img_lbp_mrf);
foregroundMaskAnalysis->process(frameNumber, "MultiLayerBGS", img_mlbgs);
//foregroundMaskAnalysis->process(frameNumber, "PBAS", img_pt_pbas);
foregroundMaskAnalysis->process(frameNumber, "VuMeter", img_vumeter);
foregroundMaskAnalysis->process(frameNumber, "KDE", img_kde);
foregroundMaskAnalysis->process(frameNumber, "IMBS", img_imbs);
foregroundMaskAnalysis->process(frameNumber, "MultiCueBGS", img_mcbgs);
foregroundMaskAnalysis->process(frameNumber, "SigmaDeltaBGS", img_sdbgs);
foregroundMaskAnalysis->process(frameNumber, "SuBSENSEBGS", img_ssbgs);
foregroundMaskAnalysis->process(frameNumber, "LOBSTERBGS", img_lobgs);
}
firstTime = false;
}
void FrameProcessor::finish(void)
{
/*if(enableMultiLayerBGS)
multiLayerBGS->finish();
if(enableLBSimpleGaussian)
lbSimpleGaussian->finish();
if(enableLBFuzzyGaussian)
lbFuzzyGaussian->finish();
if(enableLBMixtureOfGaussians)
lbMixtureOfGaussians->finish();
if(enableLBAdaptiveSOM)
lbAdaptiveSOM->finish();
if(enableLBFuzzyAdaptiveSOM)
lbFuzzyAdaptiveSOM->finish();*/
if (enableForegroundMaskAnalysis)
delete foregroundMaskAnalysis;
if (enableLOBSTERBGS)
delete lobgs;
if (enableSuBSENSEBGS)
delete ssbgs;
if (enableSigmaDeltaBGS)
delete sdbgs;
if (enableMultiCueBGS)
delete mcbgs;
if (enableIMBS)
delete imbs;
if (enableKDE)
delete kde;
if (enableVuMeter)
delete vuMeter;
//if(enablePBAS)
// delete pixelBasedAdaptiveSegmenter;
if (enableMultiLayerBGS)
delete multiLayerBGS;
if (enableLBFuzzyAdaptiveSOM)
delete lbFuzzyAdaptiveSOM;
if (enableLBAdaptiveSOM)
delete lbAdaptiveSOM;
if (enableLBMixtureOfGaussians)
delete lbMixtureOfGaussians;
if (enableLBFuzzyGaussian)
delete lbFuzzyGaussian;
if (enableLBSimpleGaussian)
delete lbSimpleGaussian;
#if !defined(_WIN32)
if (enableLbpMrf)
delete lbpMrf;
#endif
if(enableFuzzyChoquetIntegral)
delete fuzzyChoquetIntegral;
if (enableFuzzySugenoIntegral)
delete fuzzySugenoIntegral;
if (enableT2FMRF_UV)
delete type2FuzzyMRF_UV;
if (enableT2FMRF_UM)
delete type2FuzzyMRF_UM;
if (enableT2FGMM_UV)
delete type2FuzzyGMM_UV;
if (enableT2FGMM_UM)
delete type2FuzzyGMM_UM;
if (enableDPTextureBGS)
delete textureBGS;
if (enableDPEigenbackgroundBGS)
delete eigenBackground;
if (enableDPPratiMediodBGS)
delete pratiMediod;
if (enableDPWrenGABGS)
delete wrenGA;
if (enableDPMeanBGS)
delete temporalMean;
if (enableDPZivkovicAGMMBGS)
delete zivkovicAGMM;
if (enableDPGrimsonGMMBGS)
delete grimsonGMM;
if (enableDPAdaptiveMedianBGS)
delete adaptiveMedian;
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
if (enableGMG)
delete gmg;
#endif
if (enableAdaptiveBackgroundLearning)
delete adaptiveBackgroundLearning;
if (enableMixtureOfGaussianV2BGS)
delete mixtureOfGaussianV2BGS;
if (enableMixtureOfGaussianV1BGS)
delete mixtureOfGaussianV1BGS;
if (enableWeightedMovingVarianceBGS)
delete weightedMovingVariance;
if (enableWeightedMovingMeanBGS)
delete weightedMovingMean;
if (enableStaticFrameDifferenceBGS)
delete staticFrameDifference;
if (enableFrameDifferenceBGS)
delete frameDifference;
if (enablePreProcessor)
delete preProcessor;
}
void FrameProcessor::tic(std::string value)
{
processname = value;
duration = static_cast<double>(cv::getTickCount());
}
void FrameProcessor::toc()
{
duration = (static_cast<double>(cv::getTickCount()) - duration) / cv::getTickFrequency();
std::cout << processname << "\ttime(sec):" << std::fixed << std::setprecision(6) << duration << std::endl;
}
void FrameProcessor::saveConfig()
{
CvFileStorage* fs = cvOpenFileStorage("./config/FrameProcessor.xml", 0, CV_STORAGE_WRITE);
cvWriteString(fs, "tictoc", tictoc.c_str());
cvWriteInt(fs, "enablePreProcessor", enablePreProcessor);
cvWriteInt(fs, "enableForegroundMaskAnalysis", enableForegroundMaskAnalysis);
cvWriteInt(fs, "enableFrameDifferenceBGS", enableFrameDifferenceBGS);
cvWriteInt(fs, "enableStaticFrameDifferenceBGS", enableStaticFrameDifferenceBGS);
cvWriteInt(fs, "enableWeightedMovingMeanBGS", enableWeightedMovingMeanBGS);
cvWriteInt(fs, "enableWeightedMovingVarianceBGS", enableWeightedMovingVarianceBGS);
cvWriteInt(fs, "enableMixtureOfGaussianV1BGS", enableMixtureOfGaussianV1BGS);
cvWriteInt(fs, "enableMixtureOfGaussianV2BGS", enableMixtureOfGaussianV2BGS);
cvWriteInt(fs, "enableAdaptiveBackgroundLearning", enableAdaptiveBackgroundLearning);
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
cvWriteInt(fs, "enableGMG", enableGMG);
#endif
cvWriteInt(fs, "enableDPAdaptiveMedianBGS", enableDPAdaptiveMedianBGS);
cvWriteInt(fs, "enableDPGrimsonGMMBGS", enableDPGrimsonGMMBGS);
cvWriteInt(fs, "enableDPZivkovicAGMMBGS", enableDPZivkovicAGMMBGS);
cvWriteInt(fs, "enableDPMeanBGS", enableDPMeanBGS);
cvWriteInt(fs, "enableDPWrenGABGS", enableDPWrenGABGS);
cvWriteInt(fs, "enableDPPratiMediodBGS", enableDPPratiMediodBGS);
cvWriteInt(fs, "enableDPEigenbackgroundBGS", enableDPEigenbackgroundBGS);
cvWriteInt(fs, "enableDPTextureBGS", enableDPTextureBGS);
cvWriteInt(fs, "enableT2FGMM_UM", enableT2FGMM_UM);
cvWriteInt(fs, "enableT2FGMM_UV", enableT2FGMM_UV);
cvWriteInt(fs, "enableT2FMRF_UM", enableT2FMRF_UM);
cvWriteInt(fs, "enableT2FMRF_UV", enableT2FMRF_UV);
cvWriteInt(fs, "enableFuzzySugenoIntegral", enableFuzzySugenoIntegral);
cvWriteInt(fs, "enableFuzzyChoquetIntegral", enableFuzzyChoquetIntegral);
cvWriteInt(fs, "enableLBSimpleGaussian", enableLBSimpleGaussian);
cvWriteInt(fs, "enableLBFuzzyGaussian", enableLBFuzzyGaussian);
cvWriteInt(fs, "enableLBMixtureOfGaussians", enableLBMixtureOfGaussians);
cvWriteInt(fs, "enableLBAdaptiveSOM", enableLBAdaptiveSOM);
cvWriteInt(fs, "enableLBFuzzyAdaptiveSOM", enableLBFuzzyAdaptiveSOM);
cvWriteInt(fs, "enableLbpMrf", enableLbpMrf);
cvWriteInt(fs, "enableMultiLayerBGS", enableMultiLayerBGS);
//cvWriteInt(fs, "enablePBAS", enablePBAS);
cvWriteInt(fs, "enableVuMeter", enableVuMeter);
cvWriteInt(fs, "enableKDE", enableKDE);
cvWriteInt(fs, "enableIMBS", enableIMBS);
cvWriteInt(fs, "enableMultiCueBGS", enableMultiCueBGS);
cvWriteInt(fs, "enableSigmaDeltaBGS", enableSigmaDeltaBGS);
cvWriteInt(fs, "enableSuBSENSEBGS", enableSuBSENSEBGS);
cvWriteInt(fs, "enableLOBSTERBGS", enableLOBSTERBGS);
cvReleaseFileStorage(&fs);
}
void FrameProcessor::loadConfig()
{
CvFileStorage* fs = cvOpenFileStorage("./config/FrameProcessor.xml", 0, CV_STORAGE_READ);
tictoc = cvReadStringByName(fs, 0, "tictoc", "");
enablePreProcessor = cvReadIntByName(fs, 0, "enablePreProcessor", true);
enableForegroundMaskAnalysis = cvReadIntByName(fs, 0, "enableForegroundMaskAnalysis", false);
enableFrameDifferenceBGS = cvReadIntByName(fs, 0, "enableFrameDifferenceBGS", false);
enableStaticFrameDifferenceBGS = cvReadIntByName(fs, 0, "enableStaticFrameDifferenceBGS", false);
enableWeightedMovingMeanBGS = cvReadIntByName(fs, 0, "enableWeightedMovingMeanBGS", false);
enableWeightedMovingVarianceBGS = cvReadIntByName(fs, 0, "enableWeightedMovingVarianceBGS", false);
enableMixtureOfGaussianV1BGS = cvReadIntByName(fs, 0, "enableMixtureOfGaussianV1BGS", false);
enableMixtureOfGaussianV2BGS = cvReadIntByName(fs, 0, "enableMixtureOfGaussianV2BGS", false);
enableAdaptiveBackgroundLearning = cvReadIntByName(fs, 0, "enableAdaptiveBackgroundLearning", false);
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
enableGMG = cvReadIntByName(fs, 0, "enableGMG", false);
#endif
enableDPAdaptiveMedianBGS = cvReadIntByName(fs, 0, "enableDPAdaptiveMedianBGS", false);
enableDPGrimsonGMMBGS = cvReadIntByName(fs, 0, "enableDPGrimsonGMMBGS", false);
enableDPZivkovicAGMMBGS = cvReadIntByName(fs, 0, "enableDPZivkovicAGMMBGS", false);
enableDPMeanBGS = cvReadIntByName(fs, 0, "enableDPMeanBGS", false);
enableDPWrenGABGS = cvReadIntByName(fs, 0, "enableDPWrenGABGS", false);
enableDPPratiMediodBGS = cvReadIntByName(fs, 0, "enableDPPratiMediodBGS", false);
enableDPEigenbackgroundBGS = cvReadIntByName(fs, 0, "enableDPEigenbackgroundBGS", false);
enableDPTextureBGS = cvReadIntByName(fs, 0, "enableDPTextureBGS", false);
enableT2FGMM_UM = cvReadIntByName(fs, 0, "enableT2FGMM_UM", false);
enableT2FGMM_UV = cvReadIntByName(fs, 0, "enableT2FGMM_UV", false);
enableT2FMRF_UM = cvReadIntByName(fs, 0, "enableT2FMRF_UM", false);
enableT2FMRF_UV = cvReadIntByName(fs, 0, "enableT2FMRF_UV", false);
enableFuzzySugenoIntegral = cvReadIntByName(fs, 0, "enableFuzzySugenoIntegral", false);
enableFuzzyChoquetIntegral = cvReadIntByName(fs, 0, "enableFuzzyChoquetIntegral", false);
enableLBSimpleGaussian = cvReadIntByName(fs, 0, "enableLBSimpleGaussian", false);
enableLBFuzzyGaussian = cvReadIntByName(fs, 0, "enableLBFuzzyGaussian", false);
enableLBMixtureOfGaussians = cvReadIntByName(fs, 0, "enableLBMixtureOfGaussians", false);
enableLBAdaptiveSOM = cvReadIntByName(fs, 0, "enableLBAdaptiveSOM", false);
enableLBFuzzyAdaptiveSOM = cvReadIntByName(fs, 0, "enableLBFuzzyAdaptiveSOM", false);
enableLbpMrf = cvReadIntByName(fs, 0, "enableLbpMrf", false);
enableMultiLayerBGS = cvReadIntByName(fs, 0, "enableMultiLayerBGS", false);
//enablePBAS = cvReadIntByName(fs, 0, "enablePBAS", false);
enableVuMeter = cvReadIntByName(fs, 0, "enableVuMeter", false);
enableKDE = cvReadIntByName(fs, 0, "enableKDE", false);
enableIMBS = cvReadIntByName(fs, 0, "enableIMBS", false);
enableMultiCueBGS = cvReadIntByName(fs, 0, "enableMultiCueBGS", false);
enableSigmaDeltaBGS = cvReadIntByName(fs, 0, "enableSigmaDeltaBGS", false);
enableSuBSENSEBGS = cvReadIntByName(fs, 0, "enableSuBSENSEBGS", false);
enableLOBSTERBGS = cvReadIntByName(fs, 0, "enableLOBSTERBGS", false);
cvReleaseFileStorage(&fs);
}
}
其实,从源码中可以看出,本函数所做的工作并不多,主要就是调用背景建模算法的接口,其接口处是:bgs->process(img_input, img_bgs, img_bkgmodel);
下面给出此段代码的大致流程框架图: