背景建模技术(六):帧处理(FrameProcessor)模块
前面几篇文章简单介绍了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);
下面给出此段代码的大致流程框架图:
背景建模技术(六):帧处理(FrameProcessor)模块的更多相关文章
- 背景建模技术(三):背景减法库(BGS Library)的基本框架与入口函数main()的功能
背景减法库(BGS Library = background subtraction library)包含了37种背景建模算法,也是目前国际上关于背景建模技术研究最全也最权威的资料.本文将更加详细的介 ...
- 背景建模技术(二):BgsLibrary的框架、背景建模的37种算法性能分析、背景建模技术的挑战
背景建模技术(二):BgsLibrary的框架.背景建模的37种算法性能分析.背景建模技术的挑战 1.基于MFC的BgsLibrary软件下载 下载地址:http://download.csdn.ne ...
- 背景建模技术(七):预处理(PreProcessor)模块
预处理(PreProcessor)模块是BgsLibrary中一个必选的模块,是真正进入背景建模算法的“预处理”过程,其主要功能包括‘去模糊’.‘获得灰度图’.'应用Canny算子‘等可选模块. 下面 ...
- 背景建模技术(五):视频捕获(VideoCapture)模块
本次对“视频捕获(VideoCapture)模块”做出分析,给出源代码和对应的程序流程框架. 视频捕获模块的主要功能是设置视频或相机参数,并读取设置配置参数,最后进入帧处理模块的process进程,该 ...
- 背景建模技术(四):视频分析(VideoAnalysis)模块
视频分析模块主要包含两个函数,一个是VideoAnalysis::setup(....),其主要功能就是确定测试的视频是视频文件或摄像头输入亦或是采用命令行参数:第二个函数是VideoAnalysis ...
- 【计算机视觉】背景建模--Vibe 算法优缺点分析
一.Vibe 算法的优点 Vibe背景建模为运动目标检测研究邻域开拓了新思路,是一种新颖.快速及有效的运动目标检测算法.其优点有以下两点: 1.思想简单,易于实现.Vibe通常随机选取邻域20个样本为 ...
- 浅析软件工程中的UML建模技术
一.基本信息 标题:浅析软件工程中的UML建模技术 时间:2018 出版源:电子世界 领域分类:软件工程:UML建模技术:需求分析 二.研究背景 问题定义:软件工程中UML建模技术的研究 难点:明确软 ...
- 背景建模或前景检測之PBAS
申明,本文非笔者原创,原文转载自:http://blog.csdn.net/kcust/article/details/9931575 Pixel-Based Adaptive Segmenter(P ...
- 【计算机视觉】背景建模之PBAS
本文是根据M. Hofmann等人在2012年的IEEE Workshop on Change Detection上发表的"Background Segmentation with Feed ...
随机推荐
- 【WXS全局对象】JSON
方法: 原型:JSON.stringify( Object ) 说明:将 object 对象转换为 JSON 字符串,并返回该字符串. 返回:[String] 原型:JSON.parse( [Stri ...
- 凸包算法(Graham扫描法)详解
先说下基础知识,不然不好理解后面的东西 两向量的X乘p1(x1,y1),p2(x2,y2) p1Xp2如果小于零则说明 p1在p2的逆时针方向 如果大于零则说明 p1在p2的顺时针方向 struct ...
- Apache--Override参数详解
1 AuthConfig 允许使用所有的权限指令,他们包括AuthDBMGroupFile AuthDBMUserFile AuthGroupFile AuthName AuthTypeAut ...
- CP文件覆盖问题
# \cp -r -a aaa/* /bbb[这次是完美的,没有提示按Y.传递了目录属性.没有略过目录]
- Linearization of the kernel functions in SVM(多项式模拟)
Description SVM(Support Vector Machine)is an important classification tool, which has a wide range o ...
- 利用JavaScriptSerializer类 进行Json对象的序列化和反序列化和过滤
项目下载:JavaScriptSerializer_对JSON对象序列化与反序列化及过滤器 利用<JavascriptSerializer类> 进行Json对象的序列化和反序列化 1. 首 ...
- linux系统中如何进入退出vim编辑器的方法及区别
在linux家族中,vim编辑器是系统自带的文本编辑器,其功能强大自不必说了. 偶有小白,刚接触linux,要修改某个文本文件,不可能像WINDOWS那样操作,更有甚者,进入VI编辑器后,无法退出以致 ...
- KindEditor是一套很方便的html编译器插件
KindEditor是一套很方便的html编译器插件.在这里做一个简单的使用介绍. 首先在官网上下载最新的KindEditor文件(里面有jsp,asp等不同版本文件夹,可以删掉你不需要的版本), 把 ...
- django设置首页
1.在views中添加一个def 为homepage basepath=os.getcwd()+'\\dockerApp\\app\\templates\\';def homepage(request ...
- Microsoft Edge goes Chromium
Microsoft Edge goes Chromium https://techcrunch.com/2018/12/06/microsoft-edge-goes-chromium-and-maco ...