背景建模技术(六):帧处理(FrameProcessor)模块

简介: <p>前面几篇文章简单介绍了<a target="_blank" href="http://blog.csdn.net/frd2009041510/article/details/45716009">BgsLibrary的入口函数</a>、<a target="_blank" href="http://blog.csdn.net/frd2009041510/article/details/

前面几篇文章简单介绍了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);


下面给出此段代码的大致流程框架图:







相关实践学习
部署高可用架构
本场景主要介绍如何使用云服务器ECS、负载均衡SLB、云数据库RDS和数据传输服务产品来部署多可用区高可用架构。
负载均衡入门与产品使用指南
负载均衡(Server Load Balancer)是对多台云服务器进行流量分发的负载均衡服务,可以通过流量分发扩展应用系统对外的服务能力,通过消除单点故障提升应用系统的可用性。 本课程主要介绍负载均衡的相关技术以及阿里云负载均衡产品的使用方法。
目录
相关文章
|
存储 前端开发 数据可视化
3D激光SLAM:LeGO-LOAM---两步优化的帧间里程计及代码分析
**LeGO-LOAM**的全称是 Lightweight and Ground-Optimized Lidar Odometry and Mapping on Variable Terrain 其中LeGO就是轻量级和利用地面优化,轻量级的实现就是通过两步的优化方式,利用地面优化的部分也在两步优化的第一步中。 和原始LOAM一样,通过前后两帧点云来估计两帧之间的运动,从而累加得到前端里程计的输出,和上述方法使用线面约束同时优化六自由度帧间位姿不同,LeGO-LOAM的前端分成两个步骤,每个步骤估计三自由度的变量。 通过这种方式进行帧间里程计的运算,可以提供运算效率,使得可以在嵌入式平台
3D激光SLAM:LeGO-LOAM---两步优化的帧间里程计及代码分析
|
8月前
|
算法
【信号去噪和正交采样】流水线过程的一部分,用于对L波段次级雷达中接收的信号进行降噪(Matlab代码实现)
【信号去噪和正交采样】流水线过程的一部分,用于对L波段次级雷达中接收的信号进行降噪(Matlab代码实现)
|
7月前
|
机器学习/深度学习 传感器 算法
【视频处理】通过调用图像来重建新影片及计算颜色通道的平均灰度值,并检测帧与前一帧之间的差异(Matlab代码实现)
【视频处理】通过调用图像来重建新影片及计算颜色通道的平均灰度值,并检测帧与前一帧之间的差异(Matlab代码实现)
|
12月前
|
算法
m基于混合高斯模型和帧间差分相融合的自适应视频背景提取算法matlab仿真
m基于混合高斯模型和帧间差分相融合的自适应视频背景提取算法matlab仿真
140 0
|
算法
基于基于全局差错能量函数的双目图像立体匹配算法matlab仿真,并提取图像的深度信息
基于基于全局差错能量函数的双目图像立体匹配算法matlab仿真,并提取图像的深度信息
137 0
基于基于全局差错能量函数的双目图像立体匹配算法matlab仿真,并提取图像的深度信息
|
前端开发 定位技术
3D激光SLAM:ALOAM---后端lasermapping通过Ceres进行帧到地图的位姿优化
上一篇博客构建了线约束和面约束,添加到了残差模块。 [ALOAM:后端 lasermapping构建角点约束与面点约束](https://www.guyuehome.com/38660) 本片主要介绍通过ceres构建的约束的CostFuction,及后续的通过Ceres进行位姿优化
3D激光SLAM:ALOAM---后端lasermapping通过Ceres进行帧到地图的位姿优化
|
前端开发 定位技术 C++
3D激光SLAM:ALOAM---帧间里程计代码解读
A-LOAM的cpp有四个,其中 kittiHelper.cpp 的作用是将kitti数据集转为rosbag 剩下的三个是作为 slam 的 部分,分别是: - laserMappin.cpp ++++ 当前帧到地图的优化 - laserOdometry.cpp ++++ 帧间里程计 - scanRegistration.cpp ++++ 前端lidar点预处理及特征提取
3D激光SLAM:ALOAM---帧间里程计代码解读
|
算法
《数字视频和高清:算法和接口》一第2章 图像的采样和显示
本节书摘来华章计算机《数字视频和高清:算法和接口》一书中的第2章 , [加]查尔斯·波因顿(Charles Poynton)著 刘开华 褚晶辉 马永涛 吕卫 宫霄霖 等译 译更多章节内容可以访问云栖社区“华章计算机”公众号查看。
933 0
|
算法
《数字视频和高清:算法和接口》一1.3图像采样
本节书摘来华章计算机《数字视频和高清:算法和接口》一书中的第1章 ,第1.3节, [加]查尔斯·波因顿(Charles Poynton)著 刘开华 褚晶辉 马永涛 吕卫 宫霄霖 等译 译更多章节内容可以访问云栖社区“华章计算机”公众号查看。
750 0