diff --git a/Config.h b/Config.h
index 01cf721..61a992d 100644
--- a/Config.h
+++ b/Config.h
@@ -16,7 +16,10 @@ along with BGSLibrary. If not, see .
*/
#pragma once
-const int KEY_REPEAT = 'r';
-const int KEY_SPACE = 32;
-const int KEY_ESC = 27;
-const int KEY_ESC2 = 'q';
+namespace bgslibrary
+{
+ const int KEY_REPEAT = 'r';
+ const int KEY_SPACE = 32;
+ const int KEY_ESC = 27;
+ const int KEY_ESC2 = 'q';
+}
diff --git a/FrameProcessor.cpp b/FrameProcessor.cpp
index 72cea5b..9f9bc28 100644
--- a/FrameProcessor.cpp
+++ b/FrameProcessor.cpp
@@ -16,542 +16,569 @@ along with BGSLibrary. If not, see .
*/
#include "FrameProcessor.h"
-FrameProcessor::FrameProcessor() : firstTime(true), frameNumber(0), duration(0), tictoc(""), frameToStop(0)
+namespace bgslibrary
{
- std::cout << "FrameProcessor()" << std::endl;
+ FrameProcessor::FrameProcessor() : firstTime(true), frameNumber(0), duration(0), tictoc(""), frameToStop(0)
+ {
+ std::cout << "FrameProcessor()" << std::endl;
- loadConfig();
- saveConfig();
-}
+ loadConfig();
+ saveConfig();
+ }
-FrameProcessor::~FrameProcessor()
-{
- std::cout << "~FrameProcessor()" << std::endl;
-}
+ FrameProcessor::~FrameProcessor()
+ {
+ std::cout << "~FrameProcessor()" << std::endl;
+ }
-void FrameProcessor::init()
-{
- if(enablePreProcessor)
- preProcessor = new PreProcessor;
+ void FrameProcessor::init()
+ {
+ if (enablePreProcessor)
+ preProcessor = new PreProcessor;
- if(enableFrameDifferenceBGS)
- frameDifference = new FrameDifferenceBGS;
+ if (enableFrameDifferenceBGS)
+ frameDifference = new FrameDifferenceBGS;
- if(enableStaticFrameDifferenceBGS)
- staticFrameDifference = new StaticFrameDifferenceBGS;
+ if (enableStaticFrameDifferenceBGS)
+ staticFrameDifference = new StaticFrameDifferenceBGS;
- if(enableWeightedMovingMeanBGS)
- weightedMovingMean = new WeightedMovingMeanBGS;
+ if (enableWeightedMovingMeanBGS)
+ weightedMovingMean = new WeightedMovingMeanBGS;
- if(enableWeightedMovingVarianceBGS)
- weightedMovingVariance = new WeightedMovingVarianceBGS;
+ if (enableWeightedMovingVarianceBGS)
+ weightedMovingVariance = new WeightedMovingVarianceBGS;
- if(enableMixtureOfGaussianV1BGS)
- mixtureOfGaussianV1BGS = new MixtureOfGaussianV1BGS;
+ if (enableMixtureOfGaussianV1BGS)
+ mixtureOfGaussianV1BGS = new MixtureOfGaussianV1BGS;
- if(enableMixtureOfGaussianV2BGS)
- mixtureOfGaussianV2BGS = new MixtureOfGaussianV2BGS;
+ if (enableMixtureOfGaussianV2BGS)
+ mixtureOfGaussianV2BGS = new MixtureOfGaussianV2BGS;
- if(enableAdaptiveBackgroundLearning)
- adaptiveBackgroundLearning = new AdaptiveBackgroundLearning;
+ if (enableAdaptiveBackgroundLearning)
+ adaptiveBackgroundLearning = new AdaptiveBackgroundLearning;
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
- if(enableGMG)
- gmg = new GMG;
+ if (enableGMG)
+ gmg = new GMG;
#endif
- if(enableDPAdaptiveMedianBGS)
- adaptiveMedian = new DPAdaptiveMedianBGS;
+ if (enableDPAdaptiveMedianBGS)
+ adaptiveMedian = new DPAdaptiveMedianBGS;
- if(enableDPGrimsonGMMBGS)
- grimsonGMM = new DPGrimsonGMMBGS;
+ if (enableDPGrimsonGMMBGS)
+ grimsonGMM = new DPGrimsonGMMBGS;
- if(enableDPZivkovicAGMMBGS)
- zivkovicAGMM = new DPZivkovicAGMMBGS;
+ if (enableDPZivkovicAGMMBGS)
+ zivkovicAGMM = new DPZivkovicAGMMBGS;
- if(enableDPMeanBGS)
- temporalMean = new DPMeanBGS;
+ if (enableDPMeanBGS)
+ temporalMean = new DPMeanBGS;
- if(enableDPWrenGABGS)
- wrenGA = new DPWrenGABGS;
+ if (enableDPWrenGABGS)
+ wrenGA = new DPWrenGABGS;
- if(enableDPPratiMediodBGS)
- pratiMediod = new DPPratiMediodBGS;
+ if (enableDPPratiMediodBGS)
+ pratiMediod = new DPPratiMediodBGS;
- if(enableDPEigenbackgroundBGS)
- eigenBackground = new DPEigenbackgroundBGS;
+ if (enableDPEigenbackgroundBGS)
+ eigenBackground = new DPEigenbackgroundBGS;
- if(enableDPTextureBGS)
- textureBGS = new DPTextureBGS;
+ if (enableDPTextureBGS)
+ textureBGS = new DPTextureBGS;
- if(enableT2FGMM_UM)
- type2FuzzyGMM_UM = new T2FGMM_UM;
+ if (enableT2FGMM_UM)
+ type2FuzzyGMM_UM = new T2FGMM_UM;
- if(enableT2FGMM_UV)
- type2FuzzyGMM_UV = new T2FGMM_UV;
+ if (enableT2FGMM_UV)
+ type2FuzzyGMM_UV = new T2FGMM_UV;
- if(enableT2FMRF_UM)
- type2FuzzyMRF_UM = new T2FMRF_UM;
+ if (enableT2FMRF_UM)
+ type2FuzzyMRF_UM = new T2FMRF_UM;
- if(enableT2FMRF_UV)
- type2FuzzyMRF_UV = new T2FMRF_UV;
+ if (enableT2FMRF_UV)
+ type2FuzzyMRF_UV = new T2FMRF_UV;
- if(enableFuzzySugenoIntegral)
- fuzzySugenoIntegral = new FuzzySugenoIntegral;
+ if (enableFuzzySugenoIntegral)
+ fuzzySugenoIntegral = new FuzzySugenoIntegral;
- if(enableFuzzyChoquetIntegral)
- fuzzyChoquetIntegral = new FuzzyChoquetIntegral;
-
- if(enableLBSimpleGaussian)
- lbSimpleGaussian = new LBSimpleGaussian;
+ if (enableFuzzyChoquetIntegral)
+ fuzzyChoquetIntegral = new FuzzyChoquetIntegral;
- if(enableLBFuzzyGaussian)
- lbFuzzyGaussian = new LBFuzzyGaussian;
+ if (enableLBSimpleGaussian)
+ lbSimpleGaussian = new LBSimpleGaussian;
- if(enableLBMixtureOfGaussians)
- lbMixtureOfGaussians = new LBMixtureOfGaussians;
+ if (enableLBFuzzyGaussian)
+ lbFuzzyGaussian = new LBFuzzyGaussian;
- if(enableLBAdaptiveSOM)
- lbAdaptiveSOM = new LBAdaptiveSOM;
+ if (enableLBMixtureOfGaussians)
+ lbMixtureOfGaussians = new LBMixtureOfGaussians;
- if(enableLBFuzzyAdaptiveSOM)
- lbFuzzyAdaptiveSOM = new LBFuzzyAdaptiveSOM;
+ if (enableLBAdaptiveSOM)
+ lbAdaptiveSOM = new LBAdaptiveSOM;
- #if !defined(_WIN32)
- if(enableLbpMrf)
- lbpMrf = new LbpMrf;
- #endif
+ if (enableLBFuzzyAdaptiveSOM)
+ lbFuzzyAdaptiveSOM = new LBFuzzyAdaptiveSOM;
- if(enableMultiLayerBGS)
- multiLayerBGS = new MultiLayerBGS;
+#if !defined(_WIN32)
+ if (enableLbpMrf)
+ lbpMrf = new LbpMrf;
+#endif
- //if(enablePBAS)
- // pixelBasedAdaptiveSegmenter = new PixelBasedAdaptiveSegmenter;
+ if(enableMultiLayerBGS)
+ multiLayerBGS = new MultiLayerBGS;
- if(enableVuMeter)
- vuMeter = new VuMeter;
+ //if(enablePBAS)
+ // pixelBasedAdaptiveSegmenter = new PixelBasedAdaptiveSegmenter;
- if(enableKDE)
- kde = new KDE;
+ if (enableVuMeter)
+ vuMeter = new VuMeter;
- if(enableForegroundMaskAnalysis)
- foregroundMaskAnalysis = new ForegroundMaskAnalysis;
-}
+ if (enableKDE)
+ kde = new KDE;
-void FrameProcessor::process(std::string name, IBGS *bgs, const cv::Mat &img_input, cv::Mat &img_bgs)
-{
- if(tictoc == name)
- tic(name);
+ if (enableIMBS)
+ imbs = new IndependentMultimodalBGS;
- cv::Mat img_bkgmodel;
- bgs->process(img_input, img_bgs, img_bkgmodel);
+ if (enableMultiCueBGS)
+ mcbgs = new SJN_MultiCueBGS;
- if(tictoc == name)
- toc();
-}
+ if (enableForegroundMaskAnalysis)
+ foregroundMaskAnalysis = new ForegroundMaskAnalysis;
+ }
-void FrameProcessor::process(const cv::Mat &img_input)
-{
- frameNumber++;
-
- if(enablePreProcessor)
- preProcessor->process(img_input, img_prep);
-
- if(enableFrameDifferenceBGS)
- process("FrameDifferenceBGS", frameDifference, img_prep, img_framediff);
-
- if(enableStaticFrameDifferenceBGS)
- process("StaticFrameDifferenceBGS", staticFrameDifference, img_prep, img_staticfdiff);
-
- if(enableWeightedMovingMeanBGS)
- process("WeightedMovingMeanBGS", weightedMovingMean, img_prep, img_wmovmean);
-
- if(enableWeightedMovingVarianceBGS)
- process("WeightedMovingVarianceBGS", weightedMovingVariance, img_prep, img_movvar);
-
- if(enableMixtureOfGaussianV1BGS)
- process("MixtureOfGaussianV1BGS", mixtureOfGaussianV1BGS, img_prep, img_mog1);
-
- if(enableMixtureOfGaussianV2BGS)
- process("MixtureOfGaussianV2BGS", mixtureOfGaussianV2BGS, img_prep, img_mog2);
-
- if(enableAdaptiveBackgroundLearning)
- process("AdaptiveBackgroundLearning", adaptiveBackgroundLearning, img_prep, img_bkgl_fgmask);
+ void FrameProcessor::process(std::string name, IBGS *bgs, const cv::Mat &img_input, cv::Mat &img_bgs)
+ {
+ if (tictoc == name)
+ tic(name);
-#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
- if(enableGMG)
- process("GMG", gmg, img_prep, img_gmg);
-#endif
+ cv::Mat img_bkgmodel;
+ bgs->process(img_input, img_bgs, img_bkgmodel);
- if(enableDPAdaptiveMedianBGS)
- process("DPAdaptiveMedianBGS", adaptiveMedian, img_prep, img_adpmed);
-
- if(enableDPGrimsonGMMBGS)
- process("DPGrimsonGMMBGS", grimsonGMM, img_prep, img_grigmm);
-
- if(enableDPZivkovicAGMMBGS)
- process("DPZivkovicAGMMBGS", zivkovicAGMM, img_prep, img_zivgmm);
-
- if(enableDPMeanBGS)
- process("DPMeanBGS", temporalMean, img_prep, img_tmpmean);
-
- if(enableDPWrenGABGS)
- process("DPWrenGABGS", wrenGA, img_prep, img_wrenga);
-
- if(enableDPPratiMediodBGS)
- process("DPPratiMediodBGS", pratiMediod, img_prep, img_pramed);
-
- if(enableDPEigenbackgroundBGS)
- process("DPEigenbackgroundBGS", eigenBackground, img_prep, img_eigbkg);
-
- if(enableDPTextureBGS)
- process("DPTextureBGS", textureBGS, img_prep, img_texbgs);
-
- if(enableT2FGMM_UM)
- process("T2FGMM_UM", type2FuzzyGMM_UM, img_prep, img_t2fgmm_um);
-
- if(enableT2FGMM_UV)
- process("T2FGMM_UV", type2FuzzyGMM_UV, img_prep, img_t2fgmm_uv);
-
- if(enableT2FMRF_UM)
- process("T2FMRF_UM", type2FuzzyMRF_UM, img_prep, img_t2fmrf_um);
-
- if(enableT2FMRF_UV)
- process("T2FMRF_UV", type2FuzzyMRF_UV, img_prep, img_t2fmrf_uv);
-
- if(enableFuzzySugenoIntegral)
- process("FuzzySugenoIntegral", fuzzySugenoIntegral, img_prep, img_fsi);
-
- if(enableFuzzyChoquetIntegral)
- process("FuzzyChoquetIntegral", fuzzyChoquetIntegral, img_prep, img_fci);
-
- if(enableLBSimpleGaussian)
- process("LBSimpleGaussian", lbSimpleGaussian, img_prep, img_lb_sg);
-
- if(enableLBFuzzyGaussian)
- process("LBFuzzyGaussian", lbFuzzyGaussian, img_prep, img_lb_fg);
-
- if(enableLBMixtureOfGaussians)
- process("LBMixtureOfGaussians", lbMixtureOfGaussians, img_prep, img_lb_mog);
-
- if(enableLBAdaptiveSOM)
- process("LBAdaptiveSOM", lbAdaptiveSOM, img_prep, img_lb_som);
-
- if(enableLBFuzzyAdaptiveSOM)
- process("LBFuzzyAdaptiveSOM", lbFuzzyAdaptiveSOM, img_prep, img_lb_fsom);
-
- #if !defined(_WIN32)
- if(enableLbpMrf)
- process("LbpMrf", lbpMrf, img_prep, img_lbp_mrf);
- #endif
-
- if(enableMultiLayerBGS)
- {
- multiLayerBGS->setStatus(MultiLayerBGS::Status::MLBGS_LEARN);
- //multiLayerBGS->setStatus(MultiLayerBGS::Status::MLBGS_DETECT);
- process("MultiLayerBGS", multiLayerBGS, img_prep, img_mlbgs);
+ if (tictoc == name)
+ toc();
}
-
- //if(enablePBAS)
- // process("PBAS", pixelBasedAdaptiveSegmenter, img_prep, img_pt_pbas);
-
- if(enableVuMeter)
- process("VuMeter", vuMeter, img_prep, img_vumeter);
-
- if(enableKDE)
- process("KDE", kde, img_prep, img_kde);
-
- if(enableForegroundMaskAnalysis)
+
+ void FrameProcessor::process(const cv::Mat &img_input)
{
- 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);
+ frameNumber++;
+
+ if (enablePreProcessor)
+ preProcessor->process(img_input, img_prep);
+
+ if (enableFrameDifferenceBGS)
+ process("FrameDifferenceBGS", frameDifference, img_prep, img_framediff);
+
+ if (enableStaticFrameDifferenceBGS)
+ process("StaticFrameDifferenceBGS", staticFrameDifference, img_prep, img_staticfdiff);
+
+ if (enableWeightedMovingMeanBGS)
+ process("WeightedMovingMeanBGS", weightedMovingMean, img_prep, img_wmovmean);
+
+ if (enableWeightedMovingVarianceBGS)
+ process("WeightedMovingVarianceBGS", weightedMovingVariance, img_prep, img_movvar);
+
+ if (enableMixtureOfGaussianV1BGS)
+ process("MixtureOfGaussianV1BGS", mixtureOfGaussianV1BGS, img_prep, img_mog1);
+
+ if (enableMixtureOfGaussianV2BGS)
+ process("MixtureOfGaussianV2BGS", mixtureOfGaussianV2BGS, img_prep, img_mog2);
+
+ if (enableAdaptiveBackgroundLearning)
+ process("AdaptiveBackgroundLearning", adaptiveBackgroundLearning, img_prep, img_bkgl_fgmask);
+
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
- foregroundMaskAnalysis->process(frameNumber, "GMG", img_gmg);
+ if (enableGMG)
+ process("GMG", gmg, img_prep, 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);
- #if !defined(_WIN32)
- foregroundMaskAnalysis->process(frameNumber, "LbpMrf", img_lbp_mrf);
- #endif
- 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);
- }
- firstTime = false;
-}
+ if (enableDPAdaptiveMedianBGS)
+ process("DPAdaptiveMedianBGS", adaptiveMedian, img_prep, img_adpmed);
-void FrameProcessor::finish(void)
-{
- /*if(enableMultiLayerBGS)
+ if (enableDPGrimsonGMMBGS)
+ process("DPGrimsonGMMBGS", grimsonGMM, img_prep, img_grigmm);
+
+ if (enableDPZivkovicAGMMBGS)
+ process("DPZivkovicAGMMBGS", zivkovicAGMM, img_prep, img_zivgmm);
+
+ if (enableDPMeanBGS)
+ process("DPMeanBGS", temporalMean, img_prep, img_tmpmean);
+
+ if (enableDPWrenGABGS)
+ process("DPWrenGABGS", wrenGA, img_prep, img_wrenga);
+
+ if (enableDPPratiMediodBGS)
+ process("DPPratiMediodBGS", pratiMediod, img_prep, img_pramed);
+
+ if (enableDPEigenbackgroundBGS)
+ process("DPEigenbackgroundBGS", eigenBackground, img_prep, img_eigbkg);
+
+ if (enableDPTextureBGS)
+ process("DPTextureBGS", textureBGS, img_prep, img_texbgs);
+
+ if (enableT2FGMM_UM)
+ process("T2FGMM_UM", type2FuzzyGMM_UM, img_prep, img_t2fgmm_um);
+
+ if (enableT2FGMM_UV)
+ process("T2FGMM_UV", type2FuzzyGMM_UV, img_prep, img_t2fgmm_uv);
+
+ if (enableT2FMRF_UM)
+ process("T2FMRF_UM", type2FuzzyMRF_UM, img_prep, img_t2fmrf_um);
+
+ if (enableT2FMRF_UV)
+ process("T2FMRF_UV", type2FuzzyMRF_UV, img_prep, img_t2fmrf_uv);
+
+ if (enableFuzzySugenoIntegral)
+ process("FuzzySugenoIntegral", fuzzySugenoIntegral, img_prep, img_fsi);
+
+ if (enableFuzzyChoquetIntegral)
+ process("FuzzyChoquetIntegral", fuzzyChoquetIntegral, img_prep, img_fci);
+
+ if (enableLBSimpleGaussian)
+ process("LBSimpleGaussian", lbSimpleGaussian, img_prep, img_lb_sg);
+
+ if (enableLBFuzzyGaussian)
+ process("LBFuzzyGaussian", lbFuzzyGaussian, img_prep, img_lb_fg);
+
+ if (enableLBMixtureOfGaussians)
+ process("LBMixtureOfGaussians", lbMixtureOfGaussians, img_prep, img_lb_mog);
+
+ if (enableLBAdaptiveSOM)
+ process("LBAdaptiveSOM", lbAdaptiveSOM, img_prep, img_lb_som);
+
+ if (enableLBFuzzyAdaptiveSOM)
+ process("LBFuzzyAdaptiveSOM", lbFuzzyAdaptiveSOM, img_prep, img_lb_fsom);
+
+#if !defined(_WIN32)
+ if (enableLbpMrf)
+ process("LbpMrf", lbpMrf, img_prep, img_lbp_mrf);
+#endif
+
+ if(enableMultiLayerBGS)
+ {
+ multiLayerBGS->setStatus(MultiLayerBGS::Status::MLBGS_LEARN);
+ //multiLayerBGS->setStatus(MultiLayerBGS::Status::MLBGS_DETECT);
+ process("MultiLayerBGS", multiLayerBGS, img_prep, img_mlbgs);
+ }
+
+ //if(enablePBAS)
+ // process("PBAS", pixelBasedAdaptiveSegmenter, img_prep, img_pt_pbas);
+
+ if (enableVuMeter)
+ process("VuMeter", vuMeter, img_prep, img_vumeter);
+
+ if (enableKDE)
+ process("KDE", kde, img_prep, img_kde);
+
+ if (enableIMBS)
+ process("IMBS", imbs, img_prep, img_imbs);
+
+ if (enableMultiCueBGS)
+ process("MultiCueBGS", mcbgs, img_prep, img_mcbgs);
+
+ 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);
+#if !defined(_WIN32)
+ foregroundMaskAnalysis->process(frameNumber, "LbpMrf", img_lbp_mrf);
+#endif
+ 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);
+ }
+
+ firstTime = false;
+ }
+
+ void FrameProcessor::finish(void)
+ {
+ /*if(enableMultiLayerBGS)
multiLayerBGS->finish();
- if(enableLBSimpleGaussian)
+ if(enableLBSimpleGaussian)
lbSimpleGaussian->finish();
-
- if(enableLBFuzzyGaussian)
+
+ if(enableLBFuzzyGaussian)
lbFuzzyGaussian->finish();
- if(enableLBMixtureOfGaussians)
+ if(enableLBMixtureOfGaussians)
lbMixtureOfGaussians->finish();
- if(enableLBAdaptiveSOM)
+ if(enableLBAdaptiveSOM)
lbAdaptiveSOM->finish();
- if(enableLBFuzzyAdaptiveSOM)
+ if(enableLBFuzzyAdaptiveSOM)
lbFuzzyAdaptiveSOM->finish();*/
-
- if(enableForegroundMaskAnalysis)
- delete foregroundMaskAnalysis;
-
- if(enableKDE)
- delete kde;
-
- if(enableVuMeter)
- delete vuMeter;
-
- //if(enablePBAS)
- // delete pixelBasedAdaptiveSegmenter;
- if(enableMultiLayerBGS)
- delete multiLayerBGS;
-
- if(enableLBFuzzyAdaptiveSOM)
- delete lbFuzzyAdaptiveSOM;
+ if (enableForegroundMaskAnalysis)
+ delete foregroundMaskAnalysis;
+
+ if (enableMultiCueBGS)
+ delete mcbgs;
+
+ if (enableIMBS)
+ delete imbs;
+
+ if (enableKDE)
+ delete kde;
- if(enableLBAdaptiveSOM)
- delete lbAdaptiveSOM;
+ if (enableVuMeter)
+ delete vuMeter;
- if(enableLBMixtureOfGaussians)
- delete lbMixtureOfGaussians;
+ //if(enablePBAS)
+ // delete pixelBasedAdaptiveSegmenter;
- if(enableLBFuzzyGaussian)
- delete lbFuzzyGaussian;
+ if (enableMultiLayerBGS)
+ delete multiLayerBGS;
- if(enableLBSimpleGaussian)
- delete lbSimpleGaussian;
+ if (enableLBFuzzyAdaptiveSOM)
+ delete lbFuzzyAdaptiveSOM;
- #if !defined(_WIN32)
- if(enableLbpMrf)
- delete lbpMrf;
- #endif
+ if (enableLBAdaptiveSOM)
+ delete lbAdaptiveSOM;
- if(enableFuzzyChoquetIntegral)
- delete fuzzyChoquetIntegral;
+ if (enableLBMixtureOfGaussians)
+ delete lbMixtureOfGaussians;
- if(enableFuzzySugenoIntegral)
- delete fuzzySugenoIntegral;
+ if (enableLBFuzzyGaussian)
+ delete lbFuzzyGaussian;
+
+ if (enableLBSimpleGaussian)
+ delete lbSimpleGaussian;
+
+#if !defined(_WIN32)
+ if (enableLbpMrf)
+ delete lbpMrf;
+#endif
- if(enableT2FMRF_UV)
- delete type2FuzzyMRF_UV;
+ if(enableFuzzyChoquetIntegral)
+ delete fuzzyChoquetIntegral;
- if(enableT2FMRF_UM)
- delete type2FuzzyMRF_UM;
+ if (enableFuzzySugenoIntegral)
+ delete fuzzySugenoIntegral;
- if(enableT2FGMM_UV)
- delete type2FuzzyGMM_UV;
+ if (enableT2FMRF_UV)
+ delete type2FuzzyMRF_UV;
- if(enableT2FGMM_UM)
- delete type2FuzzyGMM_UM;
+ if (enableT2FMRF_UM)
+ delete type2FuzzyMRF_UM;
- if(enableDPTextureBGS)
- delete textureBGS;
+ if (enableT2FGMM_UV)
+ delete type2FuzzyGMM_UV;
- if(enableDPEigenbackgroundBGS)
- delete eigenBackground;
+ if (enableT2FGMM_UM)
+ delete type2FuzzyGMM_UM;
- if(enableDPPratiMediodBGS)
- delete pratiMediod;
+ if (enableDPTextureBGS)
+ delete textureBGS;
- if(enableDPWrenGABGS)
- delete wrenGA;
+ if (enableDPEigenbackgroundBGS)
+ delete eigenBackground;
- if(enableDPMeanBGS)
- delete temporalMean;
+ if (enableDPPratiMediodBGS)
+ delete pratiMediod;
- if(enableDPZivkovicAGMMBGS)
- delete zivkovicAGMM;
+ if (enableDPWrenGABGS)
+ delete wrenGA;
- if(enableDPGrimsonGMMBGS)
- delete grimsonGMM;
+ if (enableDPMeanBGS)
+ delete temporalMean;
- if(enableDPAdaptiveMedianBGS)
- delete adaptiveMedian;
+ 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;
+ if (enableGMG)
+ delete gmg;
#endif
- if(enableAdaptiveBackgroundLearning)
- delete adaptiveBackgroundLearning;
+ if (enableAdaptiveBackgroundLearning)
+ delete adaptiveBackgroundLearning;
- if(enableMixtureOfGaussianV2BGS)
- delete mixtureOfGaussianV2BGS;
+ if (enableMixtureOfGaussianV2BGS)
+ delete mixtureOfGaussianV2BGS;
- if(enableMixtureOfGaussianV1BGS)
- delete mixtureOfGaussianV1BGS;
+ if (enableMixtureOfGaussianV1BGS)
+ delete mixtureOfGaussianV1BGS;
- if(enableWeightedMovingVarianceBGS)
- delete weightedMovingVariance;
+ if (enableWeightedMovingVarianceBGS)
+ delete weightedMovingVariance;
- if(enableWeightedMovingMeanBGS)
- delete weightedMovingMean;
+ if (enableWeightedMovingMeanBGS)
+ delete weightedMovingMean;
- if(enableStaticFrameDifferenceBGS)
- delete staticFrameDifference;
+ if (enableStaticFrameDifferenceBGS)
+ delete staticFrameDifference;
- if(enableFrameDifferenceBGS)
- delete frameDifference;
+ if (enableFrameDifferenceBGS)
+ delete frameDifference;
- if(enablePreProcessor)
- delete preProcessor;
-}
+ if (enablePreProcessor)
+ delete preProcessor;
+ }
-void FrameProcessor::tic(std::string value)
-{
- processname = value;
- duration = static_cast(cv::getTickCount());
-}
+ void FrameProcessor::tic(std::string value)
+ {
+ processname = value;
+ duration = static_cast(cv::getTickCount());
+ }
-void FrameProcessor::toc()
-{
- duration = (static_cast(cv::getTickCount()) - duration)/cv::getTickFrequency();
- std::cout << processname << "\ttime(sec):" << std::fixed << std::setprecision(6) << duration << std::endl;
-}
+ void FrameProcessor::toc()
+ {
+ duration = (static_cast(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);
+ void FrameProcessor::saveConfig()
+ {
+ CvFileStorage* fs = cvOpenFileStorage("./config/FrameProcessor.xml", 0, CV_STORAGE_WRITE);
+
+ cvWriteString(fs, "tictoc", tictoc.c_str());
- cvWriteString(fs, "tictoc", tictoc.c_str());
+ cvWriteInt(fs, "enablePreProcessor", enablePreProcessor);
- cvWriteInt(fs, "enablePreProcessor", enablePreProcessor);
-
- cvWriteInt(fs, "enableForegroundMaskAnalysis", enableForegroundMaskAnalysis);
+ 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);
+ 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);
+ 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);
-
- #if !defined(_WIN32)
- cvWriteInt(fs, "enableLbpMrf", enableLbpMrf);
- #endif
-
- cvWriteInt(fs, "enableMultiLayerBGS", enableMultiLayerBGS);
- //cvWriteInt(fs, "enablePBAS", enablePBAS);
- cvWriteInt(fs, "enableVuMeter", enableVuMeter);
- cvWriteInt(fs, "enableKDE", enableKDE);
-
- 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);
+ 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);
+
+#if !defined(_WIN32)
+ cvWriteInt(fs, "enableLbpMrf", enableLbpMrf);
+#endif
+
+ cvWriteInt(fs, "enableMultiLayerBGS", enableMultiLayerBGS);
+ //cvWriteInt(fs, "enablePBAS", enablePBAS);
+ cvWriteInt(fs, "enableVuMeter", enableVuMeter);
+ cvWriteInt(fs, "enableKDE", enableKDE);
+ cvWriteInt(fs, "enableIMBS", enableIMBS);
+ cvWriteInt(fs, "enableMultiCueBGS", enableMultiCueBGS);
+
+ 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);
+ 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);
+
+#if !defined(_WIN32)
+ enableLbpMrf = cvReadIntByName(fs, 0, "enableLbpMrf", 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);
-
- #if !defined(_WIN32)
- enableLbpMrf = cvReadIntByName(fs, 0, "enableLbpMrf", false);
- #endif
-
- enableMultiLayerBGS = cvReadIntByName(fs, 0, "enableMultiLayerBGS", false);
- //enablePBAS = cvReadIntByName(fs, 0, "enablePBAS", false);
- enableVuMeter = cvReadIntByName(fs, 0, "enableVuMeter", false);
- enableKDE = cvReadIntByName(fs, 0, "enableKDE", false);
-
- cvReleaseFileStorage(&fs);
+ 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);
+
+ cvReleaseFileStorage(&fs);
+ }
}
diff --git a/FrameProcessor.h b/FrameProcessor.h
index 742b7bd..91ce08c 100644
--- a/FrameProcessor.h
+++ b/FrameProcessor.h
@@ -66,173 +66,186 @@ along with BGSLibrary. If not, see .
//#include "package_bgs/pt/PixelBasedAdaptiveSegmenter.h"
#include "package_bgs/av/VuMeter.h"
#include "package_bgs/ae/KDE.h"
+#include "package_bgs/db/IndependentMultimodalBGS.h"
+#include "package_bgs/sjn/SJN_MultiCueBGS.h"
#include "package_analysis/ForegroundMaskAnalysis.h"
-class FrameProcessor : public IFrameProcessor
+namespace bgslibrary
{
-private:
- bool firstTime;
- long frameNumber;
- std::string processname;
- double duration;
- std::string tictoc;
-
- cv::Mat img_prep;
- PreProcessor* preProcessor;
- bool enablePreProcessor;
-
- cv::Mat img_framediff;
- FrameDifferenceBGS* frameDifference;
- bool enableFrameDifferenceBGS;
-
- cv::Mat img_staticfdiff;
- StaticFrameDifferenceBGS* staticFrameDifference;
- bool enableStaticFrameDifferenceBGS;
-
- cv::Mat img_wmovmean;
- WeightedMovingMeanBGS* weightedMovingMean;
- bool enableWeightedMovingMeanBGS;
-
- cv::Mat img_movvar;
- WeightedMovingVarianceBGS* weightedMovingVariance;
- bool enableWeightedMovingVarianceBGS;
-
- cv::Mat img_mog1;
- MixtureOfGaussianV1BGS* mixtureOfGaussianV1BGS;
- bool enableMixtureOfGaussianV1BGS;
-
- cv::Mat img_mog2;
- MixtureOfGaussianV2BGS* mixtureOfGaussianV2BGS;
- bool enableMixtureOfGaussianV2BGS;
-
- cv::Mat img_bkgl_fgmask;
- AdaptiveBackgroundLearning* adaptiveBackgroundLearning;
- bool enableAdaptiveBackgroundLearning;
+ class FrameProcessor : public IFrameProcessor
+ {
+ private:
+ bool firstTime;
+ long frameNumber;
+ std::string processname;
+ double duration;
+ std::string tictoc;
+
+ cv::Mat img_prep;
+ PreProcessor* preProcessor;
+ bool enablePreProcessor;
+
+ cv::Mat img_framediff;
+ FrameDifferenceBGS* frameDifference;
+ bool enableFrameDifferenceBGS;
+
+ cv::Mat img_staticfdiff;
+ StaticFrameDifferenceBGS* staticFrameDifference;
+ bool enableStaticFrameDifferenceBGS;
+
+ cv::Mat img_wmovmean;
+ WeightedMovingMeanBGS* weightedMovingMean;
+ bool enableWeightedMovingMeanBGS;
+
+ cv::Mat img_movvar;
+ WeightedMovingVarianceBGS* weightedMovingVariance;
+ bool enableWeightedMovingVarianceBGS;
+
+ cv::Mat img_mog1;
+ MixtureOfGaussianV1BGS* mixtureOfGaussianV1BGS;
+ bool enableMixtureOfGaussianV1BGS;
+
+ cv::Mat img_mog2;
+ MixtureOfGaussianV2BGS* mixtureOfGaussianV2BGS;
+ bool enableMixtureOfGaussianV2BGS;
+
+ cv::Mat img_bkgl_fgmask;
+ AdaptiveBackgroundLearning* adaptiveBackgroundLearning;
+ bool enableAdaptiveBackgroundLearning;
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
- cv::Mat img_gmg;
- GMG* gmg;
- bool enableGMG;
+ cv::Mat img_gmg;
+ GMG* gmg;
+ bool enableGMG;
#endif
- cv::Mat img_adpmed;
- DPAdaptiveMedianBGS* adaptiveMedian;
- bool enableDPAdaptiveMedianBGS;
-
- cv::Mat img_grigmm;
- DPGrimsonGMMBGS* grimsonGMM;
- bool enableDPGrimsonGMMBGS;
-
- cv::Mat img_zivgmm;
- DPZivkovicAGMMBGS* zivkovicAGMM;
- bool enableDPZivkovicAGMMBGS;
-
- cv::Mat img_tmpmean;
- DPMeanBGS* temporalMean;
- bool enableDPMeanBGS;
-
- cv::Mat img_wrenga;
- DPWrenGABGS* wrenGA;
- bool enableDPWrenGABGS;
-
- cv::Mat img_pramed;
- DPPratiMediodBGS* pratiMediod;
- bool enableDPPratiMediodBGS;
-
- cv::Mat img_eigbkg;
- DPEigenbackgroundBGS* eigenBackground;
- bool enableDPEigenbackgroundBGS;
-
- cv::Mat img_texbgs;
- DPTextureBGS* textureBGS;
- bool enableDPTextureBGS;
-
- cv::Mat img_t2fgmm_um;
- T2FGMM_UM* type2FuzzyGMM_UM;
- bool enableT2FGMM_UM;
-
- cv::Mat img_t2fgmm_uv;
- T2FGMM_UV* type2FuzzyGMM_UV;
- bool enableT2FGMM_UV;
-
- cv::Mat img_t2fmrf_um;
- T2FMRF_UM* type2FuzzyMRF_UM;
- bool enableT2FMRF_UM;
-
- cv::Mat img_t2fmrf_uv;
- T2FMRF_UV* type2FuzzyMRF_UV;
- bool enableT2FMRF_UV;
-
- cv::Mat img_fsi;
- FuzzySugenoIntegral* fuzzySugenoIntegral;
- bool enableFuzzySugenoIntegral;
-
- cv::Mat img_fci;
- FuzzyChoquetIntegral* fuzzyChoquetIntegral;
- bool enableFuzzyChoquetIntegral;
-
- cv::Mat img_lb_sg;
- LBSimpleGaussian* lbSimpleGaussian;
- bool enableLBSimpleGaussian;
-
- cv::Mat img_lb_fg;
- LBFuzzyGaussian* lbFuzzyGaussian;
- bool enableLBFuzzyGaussian;
-
- cv::Mat img_lb_mog;
- LBMixtureOfGaussians* lbMixtureOfGaussians;
- bool enableLBMixtureOfGaussians;
-
- cv::Mat img_lb_som;
- LBAdaptiveSOM* lbAdaptiveSOM;
- bool enableLBAdaptiveSOM;
-
- cv::Mat img_lb_fsom;
- LBFuzzyAdaptiveSOM* lbFuzzyAdaptiveSOM;
- bool enableLBFuzzyAdaptiveSOM;
-
- #if !defined(_WIN32)
- cv::Mat img_lbp_mrf;
- LbpMrf* lbpMrf;
- bool enableLbpMrf;
- #endif
-
- cv::Mat img_mlbgs;
- MultiLayerBGS* multiLayerBGS;
- bool enableMultiLayerBGS;
-
- //cv::Mat img_pt_pbas;
- //PixelBasedAdaptiveSegmenter* pixelBasedAdaptiveSegmenter;
- //bool enablePBAS;
-
- cv::Mat img_vumeter;
- VuMeter* vuMeter;
- bool enableVuMeter;
-
- cv::Mat img_kde;
- KDE* kde;
- bool enableKDE;
-
- ForegroundMaskAnalysis* foregroundMaskAnalysis;
- bool enableForegroundMaskAnalysis;
-
-public:
- FrameProcessor();
- ~FrameProcessor();
-
- long frameToStop;
- std::string imgref;
-
- void init();
- void process(const cv::Mat &img_input);
- void finish(void);
-
-private:
- void process(std::string name, IBGS *bgs, const cv::Mat &img_input, cv::Mat &img_bgs);
- void tic(std::string value);
- void toc();
-
- void saveConfig();
- void loadConfig();
-};
+ cv::Mat img_adpmed;
+ DPAdaptiveMedianBGS* adaptiveMedian;
+ bool enableDPAdaptiveMedianBGS;
+
+ cv::Mat img_grigmm;
+ DPGrimsonGMMBGS* grimsonGMM;
+ bool enableDPGrimsonGMMBGS;
+
+ cv::Mat img_zivgmm;
+ DPZivkovicAGMMBGS* zivkovicAGMM;
+ bool enableDPZivkovicAGMMBGS;
+
+ cv::Mat img_tmpmean;
+ DPMeanBGS* temporalMean;
+ bool enableDPMeanBGS;
+
+ cv::Mat img_wrenga;
+ DPWrenGABGS* wrenGA;
+ bool enableDPWrenGABGS;
+
+ cv::Mat img_pramed;
+ DPPratiMediodBGS* pratiMediod;
+ bool enableDPPratiMediodBGS;
+
+ cv::Mat img_eigbkg;
+ DPEigenbackgroundBGS* eigenBackground;
+ bool enableDPEigenbackgroundBGS;
+
+ cv::Mat img_texbgs;
+ DPTextureBGS* textureBGS;
+ bool enableDPTextureBGS;
+
+ cv::Mat img_t2fgmm_um;
+ T2FGMM_UM* type2FuzzyGMM_UM;
+ bool enableT2FGMM_UM;
+
+ cv::Mat img_t2fgmm_uv;
+ T2FGMM_UV* type2FuzzyGMM_UV;
+ bool enableT2FGMM_UV;
+
+ cv::Mat img_t2fmrf_um;
+ T2FMRF_UM* type2FuzzyMRF_UM;
+ bool enableT2FMRF_UM;
+
+ cv::Mat img_t2fmrf_uv;
+ T2FMRF_UV* type2FuzzyMRF_UV;
+ bool enableT2FMRF_UV;
+
+ cv::Mat img_fsi;
+ FuzzySugenoIntegral* fuzzySugenoIntegral;
+ bool enableFuzzySugenoIntegral;
+
+ cv::Mat img_fci;
+ FuzzyChoquetIntegral* fuzzyChoquetIntegral;
+ bool enableFuzzyChoquetIntegral;
+
+ cv::Mat img_lb_sg;
+ LBSimpleGaussian* lbSimpleGaussian;
+ bool enableLBSimpleGaussian;
+
+ cv::Mat img_lb_fg;
+ LBFuzzyGaussian* lbFuzzyGaussian;
+ bool enableLBFuzzyGaussian;
+
+ cv::Mat img_lb_mog;
+ LBMixtureOfGaussians* lbMixtureOfGaussians;
+ bool enableLBMixtureOfGaussians;
+
+ cv::Mat img_lb_som;
+ LBAdaptiveSOM* lbAdaptiveSOM;
+ bool enableLBAdaptiveSOM;
+
+ cv::Mat img_lb_fsom;
+ LBFuzzyAdaptiveSOM* lbFuzzyAdaptiveSOM;
+ bool enableLBFuzzyAdaptiveSOM;
+
+#if !defined(_WIN32)
+ cv::Mat img_lbp_mrf;
+ LbpMrf* lbpMrf;
+ bool enableLbpMrf;
+#endif
+
+ cv::Mat img_mlbgs;
+ MultiLayerBGS* multiLayerBGS;
+ bool enableMultiLayerBGS;
+
+ //cv::Mat img_pt_pbas;
+ //PixelBasedAdaptiveSegmenter* pixelBasedAdaptiveSegmenter;
+ //bool enablePBAS;
+
+ cv::Mat img_vumeter;
+ VuMeter* vuMeter;
+ bool enableVuMeter;
+
+ cv::Mat img_kde;
+ KDE* kde;
+ bool enableKDE;
+
+ cv::Mat img_imbs;
+ IndependentMultimodalBGS* imbs;
+ bool enableIMBS;
+
+ cv::Mat img_mcbgs;
+ SJN_MultiCueBGS* mcbgs;
+ bool enableMultiCueBGS;
+
+ ForegroundMaskAnalysis* foregroundMaskAnalysis;
+ bool enableForegroundMaskAnalysis;
+
+ public:
+ FrameProcessor();
+ ~FrameProcessor();
+
+ long frameToStop;
+ std::string imgref;
+
+ void init();
+ void process(const cv::Mat &img_input);
+ void finish(void);
+
+ private:
+ void process(std::string name, IBGS *bgs, const cv::Mat &img_input, cv::Mat &img_bgs);
+ void tic(std::string value);
+ void toc();
+
+ void saveConfig();
+ void loadConfig();
+ };
+}
diff --git a/IFrameProcessor.h b/IFrameProcessor.h
index ef50b1f..b3a4441 100644
--- a/IFrameProcessor.h
+++ b/IFrameProcessor.h
@@ -18,9 +18,12 @@ along with BGSLibrary. If not, see .
#include
-class IFrameProcessor
+namespace bgslibrary
{
+ class IFrameProcessor
+ {
public:
- virtual void process(const cv:: Mat &input) = 0;
- virtual ~IFrameProcessor(){}
-};
\ No newline at end of file
+ virtual void process(const cv::Mat &input) = 0;
+ virtual ~IFrameProcessor(){}
+ };
+}
diff --git a/Main.cpp b/Main.cpp
index 4e59ee5..3d27e61 100644
--- a/Main.cpp
+++ b/Main.cpp
@@ -18,65 +18,68 @@ along with BGSLibrary. If not, see .
#include "VideoAnalysis.h"
#include
-class Main
+namespace bgslibrary
{
-private:
- Main();
-
-public:
- static void start(int argc, const char **argv)
+ class Main
{
- std::cout << "-----------------------------------------" << std::endl;
- std::cout << "Background Subtraction Library v1.7.0 " << std::endl;
- std::cout << "http://code.google.com/p/bgslibrary " << std::endl;
- std::cout << "by: " << std::endl;
- std::cout << "Andrews Sobral (andrewssobral@gmail.com) " << std::endl;
- std::cout << "-----------------------------------------" << std::endl;
- std::cout << "Using OpenCV version " << CV_VERSION << std::endl;
-
- try
+ private:
+ Main();
+
+ public:
+ static void start(int argc, const char **argv)
{
- int key = KEY_ESC;
+ std::cout << "-----------------------------------------" << std::endl;
+ std::cout << "Background Subtraction Library v1.9.0 " << std::endl;
+ std::cout << "http://code.google.com/p/bgslibrary " << std::endl;
+ std::cout << "by: " << std::endl;
+ std::cout << "Andrews Sobral (andrewssobral@gmail.com) " << std::endl;
+ std::cout << "-----------------------------------------" << std::endl;
+ std::cout << "Using OpenCV version " << CV_VERSION << std::endl;
- do
+ try
{
- VideoAnalysis* videoAnalysis = new VideoAnalysis;
+ int key = KEY_ESC;
- if(videoAnalysis->setup(argc, argv))
+ do
{
- videoAnalysis->start();
+ VideoAnalysis* videoAnalysis = new VideoAnalysis;
- std::cout << "Processing finished, enter:" << std::endl;
- std::cout << "R - Repeat" << std::endl;
- std::cout << "Q - Quit" << std::endl;
+ if (videoAnalysis->setup(argc, argv))
+ {
+ videoAnalysis->start();
- key = cv::waitKey();
- }
+ std::cout << "Processing finished, enter:" << std::endl;
+ std::cout << "R - Repeat" << std::endl;
+ std::cout << "Q - Quit" << std::endl;
- cv::destroyAllWindows();
- delete videoAnalysis;
+ key = cv::waitKey();
+ }
- }while(key == KEY_REPEAT);
- }
- catch(const std::exception& ex)
- {
- std::cout << "std::exception:" << ex.what() << std::endl;
- return;
- }
- catch(...)
- {
- std::cout << "Unknow error" << std::endl;
- return;
- }
+ cv::destroyAllWindows();
+ delete videoAnalysis;
+
+ } while (key == KEY_REPEAT);
+ }
+ catch (const std::exception& ex)
+ {
+ std::cout << "std::exception:" << ex.what() << std::endl;
+ return;
+ }
+ catch (...)
+ {
+ std::cout << "Unknow error" << std::endl;
+ return;
+ }
#ifdef WIN32
- //system("pause");
+ //system("pause");
#endif
- }
-};
+ }
+ };
+}
int main(int argc, const char **argv)
{
- Main::start(argc, argv);
+ bgslibrary::Main::start(argc, argv);
return 0;
}
diff --git a/PreProcessor.cpp b/PreProcessor.cpp
index 834996b..6f4ebbe 100644
--- a/PreProcessor.cpp
+++ b/PreProcessor.cpp
@@ -16,131 +16,134 @@ along with BGSLibrary. If not, see .
*/
#include "PreProcessor.h"
-PreProcessor::PreProcessor() : firstTime(true), equalizeHist(false), gaussianBlur(false)
+namespace bgslibrary
{
- std::cout << "PreProcessor()" << std::endl;
-}
-
-PreProcessor::~PreProcessor()
-{
- std::cout << "~PreProcessor()" << std::endl;
-}
+ PreProcessor::PreProcessor() : firstTime(true), equalizeHist(false), gaussianBlur(false)
+ {
+ std::cout << "PreProcessor()" << std::endl;
+ }
+
+ PreProcessor::~PreProcessor()
+ {
+ std::cout << "~PreProcessor()" << std::endl;
+ }
+
+ void PreProcessor::setEqualizeHist(bool value)
+ {
+ equalizeHist = value;
+ }
+
+ void PreProcessor::setGaussianBlur(bool value)
+ {
+ gaussianBlur = value;
+ }
+
+ cv::Mat PreProcessor::getGrayScale()
+ {
+ return img_gray.clone();
+ }
+
+ void PreProcessor::process(const cv::Mat &img_input, cv::Mat &img_output)
+ {
+ if (img_input.empty())
+ return;
+
+ loadConfig();
+
+ if (firstTime)
+ saveConfig();
+
+ img_input.copyTo(img_output);
+
+ // Converts image from one color space to another
+ // http://opencv.willowgarage.com/documentation/cpp/miscellaneous_image_transformations.html#cv-cvtcolor
+ cv::cvtColor(img_input, img_gray, CV_BGR2GRAY);
+ //img_gray.copyTo(img_output);
+
+ // Equalizes the histogram of a grayscale image
+ // http://opencv.willowgarage.com/documentation/cpp/histograms.html#cv-equalizehist
+ if (equalizeHist)
+ cv::equalizeHist(img_output, img_output);
+
+ // Smoothes image using a Gaussian filter
+ // http://opencv.willowgarage.com/documentation/cpp/imgproc_image_filtering.html#GaussianBlur
+ if (gaussianBlur)
+ cv::GaussianBlur(img_output, img_output, cv::Size(7, 7), 1.5);
+
+ if (enableShow)
+ cv::imshow("Pre Processor", img_output);
+
+ firstTime = false;
+ }
+
+ void PreProcessor::rotate(const cv::Mat &img_input, cv::Mat &img_output, float angle)
+ {
+ IplImage* image = new IplImage(img_input);
+
+ //IplImage *rotatedImage = cvCreateImage(cvSize(480,320), IPL_DEPTH_8U, image->nChannels);
+ //IplImage *rotatedImage = cvCreateImage(cvSize(image->width,image->height), IPL_DEPTH_8U, image->nChannels);
+ IplImage* rotatedImage = cvCreateImage(cvSize(image->height, image->width), IPL_DEPTH_8U, image->nChannels);
+
+ CvPoint2D32f center;
+ //center.x = 160;
+ //center.y = 160;
+ center.x = (image->height / 2);
+ center.y = (image->width / 2);
+
+ CvMat* mapMatrix = cvCreateMat(2, 3, CV_32FC1);
+
+ cv2DRotationMatrix(center, angle, 1.0, mapMatrix);
+ cvWarpAffine(image, rotatedImage, mapMatrix, CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS, cvScalarAll(0));
+
+ cv::Mat img_rot(rotatedImage);
+ img_rot.copyTo(img_output);
+
+ cvReleaseImage(&image);
+ cvReleaseImage(&rotatedImage);
+ cvReleaseMat(&mapMatrix);
+ }
+
+ void PreProcessor::applyCanny(const cv::Mat &img_input, cv::Mat &img_output)
+ {
+ if (img_input.empty())
+ return;
+
+ //------------------------------------------------------------------
+ // Canny
+ // Finds edges in an image using Canny algorithm.
+ // http://opencv.willowgarage.com/documentation/cpp/imgproc_feature_detection.html#cv-canny
+ //------------------------------------------------------------------
+
+ cv::Mat img_canny;
+ cv::Canny(
+ img_input, // image – Single-channel 8-bit input image
+ img_canny, // edges – The output edge map. It will have the same size and the same type as image
+ 100, // threshold1 – The first threshold for the hysteresis procedure
+ 200); // threshold2 – The second threshold for the hysteresis procedure
+ cv::threshold(img_canny, img_canny, 128, 255, cv::THRESH_BINARY_INV);
+
+ img_canny.copyTo(img_output);
+ }
+
+ void PreProcessor::saveConfig()
+ {
+ CvFileStorage* fs = cvOpenFileStorage("./config/PreProcessor.xml", 0, CV_STORAGE_WRITE);
+
+ cvWriteInt(fs, "equalizeHist", equalizeHist);
+ cvWriteInt(fs, "gaussianBlur", gaussianBlur);
+ cvWriteInt(fs, "enableShow", enableShow);
-void PreProcessor::setEqualizeHist(bool value)
-{
- equalizeHist = value;
-}
+ cvReleaseFileStorage(&fs);
+ }
-void PreProcessor::setGaussianBlur(bool value)
-{
- gaussianBlur = value;
-}
+ void PreProcessor::loadConfig()
+ {
+ CvFileStorage* fs = cvOpenFileStorage("./config/PreProcessor.xml", 0, CV_STORAGE_READ);
-cv::Mat PreProcessor::getGrayScale()
-{
- return img_gray.clone();
-}
+ equalizeHist = cvReadIntByName(fs, 0, "equalizeHist", false);
+ gaussianBlur = cvReadIntByName(fs, 0, "gaussianBlur", false);
+ enableShow = cvReadIntByName(fs, 0, "enableShow", true);
-void PreProcessor::process(const cv::Mat &img_input, cv::Mat &img_output)
-{
- if(img_input.empty())
- return;
-
- loadConfig();
-
- if(firstTime)
- saveConfig();
-
- img_input.copyTo(img_output);
-
- // Converts image from one color space to another
- // http://opencv.willowgarage.com/documentation/cpp/miscellaneous_image_transformations.html#cv-cvtcolor
- cv::cvtColor(img_input, img_gray, CV_BGR2GRAY);
- //img_gray.copyTo(img_output);
-
- // Equalizes the histogram of a grayscale image
- // http://opencv.willowgarage.com/documentation/cpp/histograms.html#cv-equalizehist
- if(equalizeHist)
- cv::equalizeHist(img_output, img_output);
-
- // Smoothes image using a Gaussian filter
- // http://opencv.willowgarage.com/documentation/cpp/imgproc_image_filtering.html#GaussianBlur
- if(gaussianBlur)
- cv::GaussianBlur(img_output, img_output, cv::Size(7,7), 1.5);
-
- if(enableShow)
- cv::imshow("Pre Processor", img_output);
-
- firstTime = false;
+ cvReleaseFileStorage(&fs);
+ }
}
-
-void PreProcessor::rotate(const cv::Mat &img_input, cv::Mat &img_output, float angle)
-{
- IplImage* image = new IplImage(img_input);
-
- //IplImage *rotatedImage = cvCreateImage(cvSize(480,320), IPL_DEPTH_8U, image->nChannels);
- //IplImage *rotatedImage = cvCreateImage(cvSize(image->width,image->height), IPL_DEPTH_8U, image->nChannels);
- IplImage* rotatedImage = cvCreateImage(cvSize(image->height,image->width), IPL_DEPTH_8U, image->nChannels);
-
- CvPoint2D32f center;
- //center.x = 160;
- //center.y = 160;
- center.x = (image->height / 2);
- center.y = (image->width / 2);
-
- CvMat* mapMatrix = cvCreateMat(2, 3, CV_32FC1);
-
- cv2DRotationMatrix(center, angle, 1.0, mapMatrix);
- cvWarpAffine(image, rotatedImage, mapMatrix, CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS, cvScalarAll(0));
-
- cv::Mat img_rot(rotatedImage);
- img_rot.copyTo(img_output);
-
- cvReleaseImage(&image);
- cvReleaseImage(&rotatedImage);
- cvReleaseMat(&mapMatrix);
-}
-
-void PreProcessor::applyCanny(const cv::Mat &img_input, cv::Mat &img_output)
-{
- if(img_input.empty())
- return;
-
- //------------------------------------------------------------------
- // Canny
- // Finds edges in an image using Canny algorithm.
- // http://opencv.willowgarage.com/documentation/cpp/imgproc_feature_detection.html#cv-canny
- //------------------------------------------------------------------
-
- cv::Mat img_canny;
- cv::Canny(
- img_input, // image – Single-channel 8-bit input image
- img_canny, // edges – The output edge map. It will have the same size and the same type as image
- 100, // threshold1 – The first threshold for the hysteresis procedure
- 200); // threshold2 – The second threshold for the hysteresis procedure
- cv::threshold(img_canny, img_canny, 128, 255, cv::THRESH_BINARY_INV);
-
- img_canny.copyTo(img_output);
-}
-
-void PreProcessor::saveConfig()
-{
- CvFileStorage* fs = cvOpenFileStorage("./config/PreProcessor.xml", 0, CV_STORAGE_WRITE);
-
- cvWriteInt(fs, "equalizeHist", equalizeHist);
- cvWriteInt(fs, "gaussianBlur", gaussianBlur);
- cvWriteInt(fs, "enableShow", enableShow);
-
- cvReleaseFileStorage(&fs);
-}
-
-void PreProcessor::loadConfig()
-{
- CvFileStorage* fs = cvOpenFileStorage("./config/PreProcessor.xml", 0, CV_STORAGE_READ);
-
- equalizeHist = cvReadIntByName(fs, 0, "equalizeHist", false);
- gaussianBlur = cvReadIntByName(fs, 0, "gaussianBlur", false);
- enableShow = cvReadIntByName(fs, 0, "enableShow", true);
-
- cvReleaseFileStorage(&fs);
-}
\ No newline at end of file
diff --git a/PreProcessor.h b/PreProcessor.h
index 9a04623..e001003 100644
--- a/PreProcessor.h
+++ b/PreProcessor.h
@@ -20,30 +20,32 @@ along with BGSLibrary. If not, see .
#include
#include
-class PreProcessor
+namespace bgslibrary
{
-private:
- bool firstTime;
- bool equalizeHist;
- bool gaussianBlur;
- cv::Mat img_gray;
- bool enableShow;
-
-public:
- PreProcessor();
- ~PreProcessor();
-
- void setEqualizeHist(bool value);
- void setGaussianBlur(bool value);
- cv::Mat getGrayScale();
-
- void process(const cv::Mat &img_input, cv::Mat &img_output);
-
- void rotate(const cv::Mat &img_input, cv::Mat &img_output, float angle);
- void applyCanny(const cv::Mat &img_input, cv::Mat &img_output);
-
-private:
- void saveConfig();
- void loadConfig();
-};
-
+ class PreProcessor
+ {
+ private:
+ bool firstTime;
+ bool equalizeHist;
+ bool gaussianBlur;
+ cv::Mat img_gray;
+ bool enableShow;
+
+ public:
+ PreProcessor();
+ ~PreProcessor();
+
+ void setEqualizeHist(bool value);
+ void setGaussianBlur(bool value);
+ cv::Mat getGrayScale();
+
+ void process(const cv::Mat &img_input, cv::Mat &img_output);
+
+ void rotate(const cv::Mat &img_input, cv::Mat &img_output, float angle);
+ void applyCanny(const cv::Mat &img_input, cv::Mat &img_output);
+
+ private:
+ void saveConfig();
+ void loadConfig();
+ };
+}
diff --git a/VideoAnalysis.cpp b/VideoAnalysis.cpp
index 0123933..604b3ce 100644
--- a/VideoAnalysis.cpp
+++ b/VideoAnalysis.cpp
@@ -16,115 +16,118 @@ along with BGSLibrary. If not, see .
*/
#include "VideoAnalysis.h"
-VideoAnalysis::VideoAnalysis() : use_file(false), use_camera(false), cameraIndex(0), use_comp(false), frameToStop(0)
+namespace bgslibrary
{
- std::cout << "VideoAnalysis()" << std::endl;
-}
-
-VideoAnalysis::~VideoAnalysis()
-{
- std::cout << "~VideoAnalysis()" << std::endl;
-}
-
-bool VideoAnalysis::setup(int argc, const char **argv)
-{
- bool flag = false;
-
- const char* keys =
- "{hp|help|false|Print help message}"
- "{uf|use_file|false|Use video file}"
- "{fn|filename||Specify video file}"
- "{uc|use_cam|false|Use camera}"
- "{ca|camera|0|Specify camera index}"
- "{co|use_comp|false|Use mask comparator}"
- "{st|stopAt|0|Frame number to stop}"
- "{im|imgref||Specify image file}"
- ;
- cv::CommandLineParser cmd(argc, argv, keys);
-
- if(argc <= 1 || cmd.get("help") == true)
+ VideoAnalysis::VideoAnalysis() : use_file(false), use_camera(false), cameraIndex(0), use_comp(false), frameToStop(0)
{
- std::cout << "Usage: " << argv[0] << " [options]" << std::endl;
- std::cout << "Avaible options:" << std::endl;
- cmd.printParams();
- return false;
+ std::cout << "VideoAnalysis()" << std::endl;
}
- use_file = cmd.get("use_file");
- if(use_file)
+ VideoAnalysis::~VideoAnalysis()
{
- filename = cmd.get("filename");
+ std::cout << "~VideoAnalysis()" << std::endl;
+ }
- if(filename.empty())
+ bool VideoAnalysis::setup(int argc, const char **argv)
+ {
+ bool flag = false;
+
+ const char* keys =
+ "{hp|help|false|Print help message}"
+ "{uf|use_file|false|Use video file}"
+ "{fn|filename||Specify video file}"
+ "{uc|use_cam|false|Use camera}"
+ "{ca|camera|0|Specify camera index}"
+ "{co|use_comp|false|Use mask comparator}"
+ "{st|stopAt|0|Frame number to stop}"
+ "{im|imgref||Specify image file}"
+ ;
+ cv::CommandLineParser cmd(argc, argv, keys);
+
+ if (argc <= 1 || cmd.get("help") == true)
{
- std::cout << "Specify filename"<< std::endl;
+ std::cout << "Usage: " << argv[0] << " [options]" << std::endl;
+ std::cout << "Avaible options:" << std::endl;
+ cmd.printParams();
return false;
}
-
- flag = true;
- }
- use_camera = cmd.get("use_cam");
- if(use_camera)
- {
- cameraIndex = cmd.get("camera");
- flag = true;
- }
-
- if(flag == true)
- {
- use_comp = cmd.get("use_comp");
- if(use_comp)
+ use_file = cmd.get("use_file");
+ if (use_file)
{
- frameToStop = cmd.get("stopAt");
- imgref = cmd.get("imgref");
+ filename = cmd.get("filename");
- if(imgref.empty())
+ if (filename.empty())
{
- std::cout << "Specify image reference"<< std::endl;
+ std::cout << "Specify filename" << std::endl;
return false;
}
+
+ flag = true;
}
- }
- return flag;
-}
+ use_camera = cmd.get("use_cam");
+ if (use_camera)
+ {
+ cameraIndex = cmd.get("camera");
+ flag = true;
+ }
-void VideoAnalysis::start()
-{
- do
+ if (flag == true)
+ {
+ use_comp = cmd.get("use_comp");
+ if (use_comp)
+ {
+ frameToStop = cmd.get("stopAt");
+ imgref = cmd.get("imgref");
+
+ if (imgref.empty())
+ {
+ std::cout << "Specify image reference" << std::endl;
+ return false;
+ }
+ }
+ }
+
+ return flag;
+ }
+
+ void VideoAnalysis::start()
{
- videoCapture = new VideoCapture;
- frameProcessor = new FrameProcessor;
+ do
+ {
+ videoCapture = new VideoCapture;
+ frameProcessor = new FrameProcessor;
+
+ frameProcessor->init();
+ frameProcessor->frameToStop = frameToStop;
+ frameProcessor->imgref = imgref;
+
+ videoCapture->setFrameProcessor(frameProcessor);
+
+ if (use_file)
+ videoCapture->setVideo(filename);
- frameProcessor->init();
- frameProcessor->frameToStop = frameToStop;
- frameProcessor->imgref = imgref;
+ if (use_camera)
+ videoCapture->setCamera(cameraIndex);
- videoCapture->setFrameProcessor(frameProcessor);
+ videoCapture->start();
- if(use_file)
- videoCapture->setVideo(filename);
-
- if(use_camera)
- videoCapture->setCamera(cameraIndex);
-
- videoCapture->start();
+ if (use_file || use_camera)
+ break;
- if(use_file || use_camera)
- break;
+ frameProcessor->finish();
- frameProcessor->finish();
+ int key = cvWaitKey(500);
+ if (key == KEY_ESC)
+ break;
- int key = cvWaitKey(500);
- if(key == KEY_ESC)
- break;
+ delete frameProcessor;
+ delete videoCapture;
+
+ } while (1);
delete frameProcessor;
delete videoCapture;
-
- }while(1);
-
- delete frameProcessor;
- delete videoCapture;
-}
\ No newline at end of file
+ }
+}
diff --git a/VideoAnalysis.h b/VideoAnalysis.h
index 74eacf7..f548a7b 100644
--- a/VideoAnalysis.h
+++ b/VideoAnalysis.h
@@ -22,24 +22,26 @@ along with BGSLibrary. If not, see .
#include "VideoCapture.h"
#include "FrameProcessor.h"
-class VideoAnalysis
+namespace bgslibrary
{
-private:
- VideoCapture* videoCapture;
- FrameProcessor* frameProcessor;
- bool use_file;
- std::string filename;
- bool use_camera;
- int cameraIndex;
- bool use_comp;
- long frameToStop;
- std::string imgref;
-
-public:
- VideoAnalysis();
- ~VideoAnalysis();
-
- bool setup(int argc, const char **argv);
- void start();
-};
-
+ class VideoAnalysis
+ {
+ private:
+ VideoCapture* videoCapture;
+ FrameProcessor* frameProcessor;
+ bool use_file;
+ std::string filename;
+ bool use_camera;
+ int cameraIndex;
+ bool use_comp;
+ long frameToStop;
+ std::string imgref;
+
+ public:
+ VideoAnalysis();
+ ~VideoAnalysis();
+
+ bool setup(int argc, const char **argv);
+ void start();
+ };
+}
diff --git a/VideoCapture.cpp b/VideoCapture.cpp
index 8952053..401fb27 100644
--- a/VideoCapture.cpp
+++ b/VideoCapture.cpp
@@ -16,260 +16,263 @@ along with BGSLibrary. If not, see .
*/
#include "VideoCapture.h"
-namespace VC_ROI
+namespace bgslibrary
{
- IplImage* img_input1 = 0;
- IplImage* img_input2 = 0;
- int roi_x0 = 0;
- int roi_y0 = 0;
- int roi_x1 = 0;
- int roi_y1 = 0;
- int numOfRec = 0;
- int startDraw = 0;
- bool roi_defined = false;
- bool use_roi = true;
- bool disable_event = false;
-
- void reset(void)
+ namespace VC_ROI
{
- disable_event = false;
- startDraw = false;
- }
+ IplImage* img_input1 = 0;
+ IplImage* img_input2 = 0;
+ int roi_x0 = 0;
+ int roi_y0 = 0;
+ int roi_x1 = 0;
+ int roi_y1 = 0;
+ int numOfRec = 0;
+ int startDraw = 0;
+ bool roi_defined = false;
+ bool use_roi = true;
+ bool disable_event = false;
+
+ void reset(void)
+ {
+ disable_event = false;
+ startDraw = false;
+ }
- void VideoCapture_on_mouse(int evt, int x, int y, int flag, void* param)
- {
- if(use_roi == false || disable_event == true)
- return;
-
- if(evt == CV_EVENT_LBUTTONDOWN)
+ void VideoCapture_on_mouse(int evt, int x, int y, int flag, void* param)
{
- if(!startDraw)
+ if (use_roi == false || disable_event == true)
+ return;
+
+ if (evt == CV_EVENT_LBUTTONDOWN)
{
- roi_x0 = x;
- roi_y0 = y;
- startDraw = 1;
+ if (!startDraw)
+ {
+ roi_x0 = x;
+ roi_y0 = y;
+ startDraw = 1;
+ }
+ else
+ {
+ roi_x1 = x;
+ roi_y1 = y;
+ startDraw = 0;
+ roi_defined = true;
+ disable_event = true;
+ }
}
- else
+
+ if (evt == CV_EVENT_MOUSEMOVE && startDraw)
{
- roi_x1 = x;
- roi_y1 = y;
- startDraw = 0;
- roi_defined = true;
- disable_event = true;
+ //redraw ROI selection
+ img_input2 = cvCloneImage(img_input1);
+ cvRectangle(img_input2, cvPoint(roi_x0, roi_y0), cvPoint(x, y), CV_RGB(255, 0, 0), 1);
+ cvShowImage("Input", img_input2);
+ cvReleaseImage(&img_input2);
+ //startDraw = false;
+ //disable_event = true;
}
}
-
- if(evt == CV_EVENT_MOUSEMOVE && startDraw)
- {
- //redraw ROI selection
- img_input2 = cvCloneImage(img_input1);
- cvRectangle(img_input2, cvPoint(roi_x0,roi_y0), cvPoint(x,y), CV_RGB(255,0,0), 1);
- cvShowImage("Input", img_input2);
- cvReleaseImage(&img_input2);
- //startDraw = false;
- //disable_event = true;
- }
}
-}
-VideoCapture::VideoCapture() : key(0), start_time(0), delta_time(0), freq(0), fps(0), frameNumber(0), stopAt(0),
- useCamera(false), useVideo(false), input_resize_percent(100), showOutput(true), enableFlip(false)
-{
- std::cout << "VideoCapture()" << std::endl;
-}
+ VideoCapture::VideoCapture() : key(0), start_time(0), delta_time(0), freq(0), fps(0), frameNumber(0), stopAt(0),
+ useCamera(false), useVideo(false), input_resize_percent(100), showOutput(true), enableFlip(false)
+ {
+ std::cout << "VideoCapture()" << std::endl;
+ }
-VideoCapture::~VideoCapture()
-{
- std::cout << "~VideoCapture()" << std::endl;
-}
+ VideoCapture::~VideoCapture()
+ {
+ std::cout << "~VideoCapture()" << std::endl;
+ }
-void VideoCapture::setFrameProcessor(IFrameProcessor* frameProcessorPtr)
-{
- frameProcessor = frameProcessorPtr;
-}
+ void VideoCapture::setFrameProcessor(IFrameProcessor* frameProcessorPtr)
+ {
+ frameProcessor = frameProcessorPtr;
+ }
-void VideoCapture::setCamera(int index)
-{
- useCamera = true;
- cameraIndex = index;
+ void VideoCapture::setCamera(int index)
+ {
+ useCamera = true;
+ cameraIndex = index;
- useVideo = false;
-}
+ useVideo = false;
+ }
-void VideoCapture::setUpCamera()
-{
- std::cout << "Camera index:" << cameraIndex << std::endl;
- capture = cvCaptureFromCAM(cameraIndex);
+ void VideoCapture::setUpCamera()
+ {
+ std::cout << "Camera index:" << cameraIndex << std::endl;
+ capture = cvCaptureFromCAM(cameraIndex);
- if(!capture)
- std::cerr << "Cannot open initialize webcam!\n" << std::endl;
-}
+ if (!capture)
+ std::cerr << "Cannot open initialize webcam!\n" << std::endl;
+ }
-void VideoCapture::setVideo(std::string filename)
-{
- useVideo = true;
- videoFileName = filename;
+ void VideoCapture::setVideo(std::string filename)
+ {
+ useVideo = true;
+ videoFileName = filename;
- useCamera = false;
-}
+ useCamera = false;
+ }
-void VideoCapture::setUpVideo()
-{
- capture = cvCaptureFromFile(videoFileName.c_str());
+ void VideoCapture::setUpVideo()
+ {
+ capture = cvCaptureFromFile(videoFileName.c_str());
- if(!capture)
- std::cerr << "Cannot open video file "<< videoFileName << std::endl;
-}
+ if (!capture)
+ std::cerr << "Cannot open video file " << videoFileName << std::endl;
+ }
-void VideoCapture::start()
-{
- loadConfig();
-
- if(useCamera) setUpCamera();
- if(useVideo) setUpVideo();
- if(!capture) std::cerr << "Capture error..." << std::endl;
-
- int input_fps = cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
- std::cout << "input->fps:" << input_fps << std::endl;
-
- IplImage* frame1 = cvQueryFrame(capture);
- frame = cvCreateImage(cvSize((int)((frame1->width*input_resize_percent)/100) , (int)((frame1->height*input_resize_percent)/100)), frame1->depth, frame1->nChannels);
- //cvCreateImage(cvSize(frame1->width/input_resize_factor, frame1->height/input_resize_factor), frame1->depth, frame1->nChannels);
- std::cout << "input->resize_percent:" << input_resize_percent << std::endl;
- std::cout << "input->width:" << frame->width << std::endl;
- std::cout << "input->height:" << frame->height << std::endl;
-
- double loopDelay = 33.333;
- if(input_fps > 0)
- loopDelay = (1./input_fps)*1000.;
- std::cout << "loopDelay:" << loopDelay << std::endl;
-
- bool firstTime = true;
- do
+ void VideoCapture::start()
{
- frameNumber++;
+ loadConfig();
+
+ if (useCamera) setUpCamera();
+ if (useVideo) setUpVideo();
+ if (!capture) std::cerr << "Capture error..." << std::endl;
- frame1 = cvQueryFrame(capture);
- if(!frame1) break;
+ int input_fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
+ std::cout << "input->fps:" << input_fps << std::endl;
- cvResize(frame1, frame);
+ IplImage* frame1 = cvQueryFrame(capture);
+ frame = cvCreateImage(cvSize((int)((frame1->width*input_resize_percent) / 100), (int)((frame1->height*input_resize_percent) / 100)), frame1->depth, frame1->nChannels);
+ //cvCreateImage(cvSize(frame1->width/input_resize_factor, frame1->height/input_resize_factor), frame1->depth, frame1->nChannels);
+ std::cout << "input->resize_percent:" << input_resize_percent << std::endl;
+ std::cout << "input->width:" << frame->width << std::endl;
+ std::cout << "input->height:" << frame->height << std::endl;
- if(enableFlip)
- cvFlip(frame, frame, 0);
-
- if(VC_ROI::use_roi == true && VC_ROI::roi_defined == false && firstTime == true)
+ double loopDelay = 33.333;
+ if (input_fps > 0)
+ loopDelay = (1. / input_fps)*1000.;
+ std::cout << "loopDelay:" << loopDelay << std::endl;
+
+ bool firstTime = true;
+ do
{
- VC_ROI::reset();
+ frameNumber++;
- do
- {
- cv::Mat img_input(frame);
-
- if(showOutput)
- {
- cv::imshow("Input", img_input);
+ frame1 = cvQueryFrame(capture);
+ if (!frame1) break;
- std::cout << "Set ROI (press ESC to skip)" << std::endl;
- VC_ROI::img_input1 = new IplImage(img_input);
- cvSetMouseCallback("Input", VC_ROI::VideoCapture_on_mouse, NULL);
- key = cvWaitKey(0);
- delete VC_ROI::img_input1;
- }
- else
- key = KEY_ESC;
+ cvResize(frame1, frame);
- if(key == KEY_ESC)
- {
- std::cout << "ROI disabled" << std::endl;
- VC_ROI::reset();
- VC_ROI::use_roi = false;
- break;
- }
+ if (enableFlip)
+ cvFlip(frame, frame, 0);
+
+ if (VC_ROI::use_roi == true && VC_ROI::roi_defined == false && firstTime == true)
+ {
+ VC_ROI::reset();
- if(VC_ROI::roi_defined)
+ do
{
- std::cout << "ROI defined (" << VC_ROI::roi_x0 << "," << VC_ROI::roi_y0 << "," << VC_ROI::roi_x1 << "," << VC_ROI::roi_y1 << ")" << std::endl;
- break;
- }
- else
- std::cout << "ROI undefined" << std::endl;
+ cv::Mat img_input(frame);
+
+ if (showOutput)
+ {
+ cv::imshow("Input", img_input);
+
+ std::cout << "Set ROI (press ESC to skip)" << std::endl;
+ VC_ROI::img_input1 = new IplImage(img_input);
+ cvSetMouseCallback("Input", VC_ROI::VideoCapture_on_mouse, NULL);
+ key = cvWaitKey(0);
+ delete VC_ROI::img_input1;
+ }
+ else
+ key = KEY_ESC;
+
+ if (key == KEY_ESC)
+ {
+ std::cout << "ROI disabled" << std::endl;
+ VC_ROI::reset();
+ VC_ROI::use_roi = false;
+ break;
+ }
+
+ if (VC_ROI::roi_defined)
+ {
+ std::cout << "ROI defined (" << VC_ROI::roi_x0 << "," << VC_ROI::roi_y0 << "," << VC_ROI::roi_x1 << "," << VC_ROI::roi_y1 << ")" << std::endl;
+ break;
+ }
+ else
+ std::cout << "ROI undefined" << std::endl;
+
+ } while (1);
+ }
- }while(1);
- }
+ if (VC_ROI::use_roi == true && VC_ROI::roi_defined == true)
+ {
+ CvRect rect = cvRect(VC_ROI::roi_x0, VC_ROI::roi_y0, VC_ROI::roi_x1 - VC_ROI::roi_x0, VC_ROI::roi_y1 - VC_ROI::roi_y0);
+ cvSetImageROI(frame, rect);
+ }
- if(VC_ROI::use_roi == true && VC_ROI::roi_defined == true)
- {
- CvRect rect = cvRect(VC_ROI::roi_x0, VC_ROI::roi_y0, VC_ROI::roi_x1 - VC_ROI::roi_x0, VC_ROI::roi_y1 - VC_ROI::roi_y0);
- cvSetImageROI(frame, rect);
- }
+ cv::Mat img_input(frame);
- cv::Mat img_input(frame);
-
- if(showOutput)
- cv::imshow("Input", img_input);
+ if (showOutput)
+ cv::imshow("Input", img_input);
- if(firstTime)
- saveConfig();
+ if (firstTime)
+ saveConfig();
- start_time = cv::getTickCount();
- frameProcessor->process(img_input);
- int64 delta_time = cv::getTickCount() - start_time;
- freq = cv::getTickFrequency();
- fps = freq / delta_time;
- //std::cout << "FPS: " << fps << std::endl;
+ start_time = cv::getTickCount();
+ frameProcessor->process(img_input);
+ int64 delta_time = cv::getTickCount() - start_time;
+ freq = cv::getTickFrequency();
+ fps = freq / delta_time;
+ //std::cout << "FPS: " << fps << std::endl;
- cvResetImageROI(frame);
+ cvResetImageROI(frame);
- key = cvWaitKey(loopDelay);
- //std::cout << "key: " << key << std::endl;
+ key = cvWaitKey(loopDelay);
+ //std::cout << "key: " << key << std::endl;
- if(key == KEY_SPACE)
- key = cvWaitKey(0);
+ if (key == KEY_SPACE)
+ key = cvWaitKey(0);
- if(key == KEY_ESC)
- break;
+ if (key == KEY_ESC)
+ break;
- if(stopAt > 0 && stopAt == frameNumber)
- key = cvWaitKey(0);
+ if (stopAt > 0 && stopAt == frameNumber)
+ key = cvWaitKey(0);
- firstTime = false;
- }while(1);
+ firstTime = false;
+ } while (1);
- cvReleaseCapture(&capture);
-}
+ cvReleaseCapture(&capture);
+ }
-void VideoCapture::saveConfig()
-{
- CvFileStorage* fs = cvOpenFileStorage("./config/VideoCapture.xml", 0, CV_STORAGE_WRITE);
-
- cvWriteInt(fs, "stopAt", stopAt);
- cvWriteInt(fs, "input_resize_percent", input_resize_percent);
- cvWriteInt(fs, "enableFlip", enableFlip);
- cvWriteInt(fs, "use_roi", VC_ROI::use_roi);
- cvWriteInt(fs, "roi_defined", VC_ROI::roi_defined);
- cvWriteInt(fs, "roi_x0", VC_ROI::roi_x0);
- cvWriteInt(fs, "roi_y0", VC_ROI::roi_y0);
- cvWriteInt(fs, "roi_x1", VC_ROI::roi_x1);
- cvWriteInt(fs, "roi_y1", VC_ROI::roi_y1);
- cvWriteInt(fs, "showOutput", showOutput);
-
- cvReleaseFileStorage(&fs);
-}
+ void VideoCapture::saveConfig()
+ {
+ CvFileStorage* fs = cvOpenFileStorage("./config/VideoCapture.xml", 0, CV_STORAGE_WRITE);
+
+ cvWriteInt(fs, "stopAt", stopAt);
+ cvWriteInt(fs, "input_resize_percent", input_resize_percent);
+ cvWriteInt(fs, "enableFlip", enableFlip);
+ cvWriteInt(fs, "use_roi", VC_ROI::use_roi);
+ cvWriteInt(fs, "roi_defined", VC_ROI::roi_defined);
+ cvWriteInt(fs, "roi_x0", VC_ROI::roi_x0);
+ cvWriteInt(fs, "roi_y0", VC_ROI::roi_y0);
+ cvWriteInt(fs, "roi_x1", VC_ROI::roi_x1);
+ cvWriteInt(fs, "roi_y1", VC_ROI::roi_y1);
+ cvWriteInt(fs, "showOutput", showOutput);
+
+ cvReleaseFileStorage(&fs);
+ }
-void VideoCapture::loadConfig()
-{
- CvFileStorage* fs = cvOpenFileStorage("./config/VideoCapture.xml", 0, CV_STORAGE_READ);
-
- stopAt = cvReadIntByName(fs, 0, "stopAt", 0);
- input_resize_percent = cvReadIntByName(fs, 0, "input_resize_percent", 100);
- enableFlip = cvReadIntByName(fs, 0, "enableFlip", false);
- VC_ROI::use_roi = cvReadIntByName(fs, 0, "use_roi", true);
- VC_ROI::roi_defined = cvReadIntByName(fs, 0, "roi_defined", false);
- VC_ROI::roi_x0 = cvReadIntByName(fs, 0, "roi_x0", 0);
- VC_ROI::roi_y0 = cvReadIntByName(fs, 0, "roi_y0", 0);
- VC_ROI::roi_x1 = cvReadIntByName(fs, 0, "roi_x1", 0);
- VC_ROI::roi_y1 = cvReadIntByName(fs, 0, "roi_y1", 0);
- showOutput = cvReadIntByName(fs, 0, "showOutput", true);
-
- cvReleaseFileStorage(&fs);
-}
\ No newline at end of file
+ void VideoCapture::loadConfig()
+ {
+ CvFileStorage* fs = cvOpenFileStorage("./config/VideoCapture.xml", 0, CV_STORAGE_READ);
+
+ stopAt = cvReadIntByName(fs, 0, "stopAt", 0);
+ input_resize_percent = cvReadIntByName(fs, 0, "input_resize_percent", 100);
+ enableFlip = cvReadIntByName(fs, 0, "enableFlip", false);
+ VC_ROI::use_roi = cvReadIntByName(fs, 0, "use_roi", true);
+ VC_ROI::roi_defined = cvReadIntByName(fs, 0, "roi_defined", false);
+ VC_ROI::roi_x0 = cvReadIntByName(fs, 0, "roi_x0", 0);
+ VC_ROI::roi_y0 = cvReadIntByName(fs, 0, "roi_y0", 0);
+ VC_ROI::roi_x1 = cvReadIntByName(fs, 0, "roi_x1", 0);
+ VC_ROI::roi_y1 = cvReadIntByName(fs, 0, "roi_y1", 0);
+ showOutput = cvReadIntByName(fs, 0, "showOutput", true);
+
+ cvReleaseFileStorage(&fs);
+ }
+}
diff --git a/VideoCapture.h b/VideoCapture.h
index caf6f6c..1a381a8 100644
--- a/VideoCapture.h
+++ b/VideoCapture.h
@@ -23,41 +23,43 @@ along with BGSLibrary. If not, see .
#include "Config.h"
#include "IFrameProcessor.h"
-class VideoCapture
+namespace bgslibrary
{
-private:
- IFrameProcessor* frameProcessor;
- CvCapture* capture;
- IplImage* frame;
- int key;
- int64 start_time;
- int64 delta_time;
- double freq;
- double fps;
- long frameNumber;
- long stopAt;
- bool useCamera;
- int cameraIndex;
- bool useVideo;
- std::string videoFileName;
- int input_resize_percent;
- bool showOutput;
- bool enableFlip;
-
-public:
- VideoCapture();
- ~VideoCapture();
-
- void setFrameProcessor(IFrameProcessor* frameProcessorPtr);
- void setCamera(int cameraIndex);
- void setVideo(std::string filename);
- void start();
-
-private:
- void setUpCamera();
- void setUpVideo();
-
- void saveConfig();
- void loadConfig();
-};
+ class VideoCapture
+ {
+ private:
+ IFrameProcessor* frameProcessor;
+ CvCapture* capture;
+ IplImage* frame;
+ int key;
+ int64 start_time;
+ int64 delta_time;
+ double freq;
+ double fps;
+ long frameNumber;
+ long stopAt;
+ bool useCamera;
+ int cameraIndex;
+ bool useVideo;
+ std::string videoFileName;
+ int input_resize_percent;
+ bool showOutput;
+ bool enableFlip;
+ public:
+ VideoCapture();
+ ~VideoCapture();
+
+ void setFrameProcessor(IFrameProcessor* frameProcessorPtr);
+ void setCamera(int cameraIndex);
+ void setVideo(std::string filename);
+ void start();
+
+ private:
+ void setUpCamera();
+ void setUpVideo();
+
+ void saveConfig();
+ void loadConfig();
+ };
+}
diff --git a/bgslibrary.exe b/bgslibrary.exe
new file mode 100644
index 0000000..5cbd4e2
Binary files /dev/null and b/bgslibrary.exe differ
diff --git a/config/FrameProcessor.xml b/config/FrameProcessor.xml
index c76f826..9ff1a61 100644
--- a/config/FrameProcessor.xml
+++ b/config/FrameProcessor.xml
@@ -30,9 +30,9 @@
0
0
0
-0
0
-0
0
0
+0
+0
diff --git a/package_analysis/ForegroundMaskAnalysis.cpp b/package_analysis/ForegroundMaskAnalysis.cpp
index 45645a0..4df9ed0 100644
--- a/package_analysis/ForegroundMaskAnalysis.cpp
+++ b/package_analysis/ForegroundMaskAnalysis.cpp
@@ -16,86 +16,89 @@ along with BGSLibrary. If not, see .
*/
#include "ForegroundMaskAnalysis.h"
-ForegroundMaskAnalysis::ForegroundMaskAnalysis() : firstTime(true), stopAt(0), showOutput(true), img_ref_path("")
+namespace bgslibrary
{
- std::cout << "ForegroundMaskAnalysis()" << std::endl;
-}
-
-ForegroundMaskAnalysis::~ForegroundMaskAnalysis()
-{
- std::cout << "~ForegroundMaskAnalysis()" << std::endl;
-}
-
-void ForegroundMaskAnalysis::process(const long &frameNumber, const std::string &name, const cv::Mat &img_input)
-{
- if(img_input.empty())
- return;
-
- if(stopAt == 0)
+ ForegroundMaskAnalysis::ForegroundMaskAnalysis() : firstTime(true), stopAt(0), showOutput(true), img_ref_path("")
{
- loadConfig();
-
- if(firstTime)
- saveConfig();
+ std::cout << "ForegroundMaskAnalysis()" << std::endl;
}
- if(stopAt == frameNumber && img_ref_path.empty() == false)
+ ForegroundMaskAnalysis::~ForegroundMaskAnalysis()
{
- cv::Mat img_ref = cv::imread(img_ref_path, 0);
-
- if(showOutput)
- cv::imshow("ForegroundMaskAnalysis", img_ref);
+ std::cout << "~ForegroundMaskAnalysis()" << std::endl;
+ }
- int rn = cv::countNonZero(img_ref);
- cv::Mat i;
- cv::Mat u;
+ void ForegroundMaskAnalysis::process(const long &frameNumber, const std::string &name, const cv::Mat &img_input)
+ {
+ if (img_input.empty())
+ return;
- if(rn > 0)
- {
- i = img_input & img_ref;
- u = img_input | img_ref;
- }
- else
+ if (stopAt == 0)
{
- i = (~img_input) & (~img_ref);
- u = (~img_input) | (~img_ref);
+ loadConfig();
+
+ if (firstTime)
+ saveConfig();
}
- int in = cv::countNonZero(i);
- int un = cv::countNonZero(u);
-
- double s = (((double)in) / ((double)un));
-
- if(showOutput)
+ if (stopAt == frameNumber && img_ref_path.empty() == false)
{
- cv::imshow("A^B", i);
- cv::imshow("AvB", u);
- }
+ cv::Mat img_ref = cv::imread(img_ref_path, 0);
+
+ if (showOutput)
+ cv::imshow("ForegroundMaskAnalysis", img_ref);
+
+ int rn = cv::countNonZero(img_ref);
+ cv::Mat i;
+ cv::Mat u;
- std::cout << name << " - Similarity Measure: " << s << " press ENTER to continue" << std::endl;
+ if (rn > 0)
+ {
+ i = img_input & img_ref;
+ u = img_input | img_ref;
+ }
+ else
+ {
+ i = (~img_input) & (~img_ref);
+ u = (~img_input) | (~img_ref);
+ }
- cv::waitKey(0);
+ int in = cv::countNonZero(i);
+ int un = cv::countNonZero(u);
+
+ double s = (((double)in) / ((double)un));
+
+ if (showOutput)
+ {
+ cv::imshow("A^B", i);
+ cv::imshow("AvB", u);
+ }
+
+ std::cout << name << " - Similarity Measure: " << s << " press ENTER to continue" << std::endl;
+
+ cv::waitKey(0);
+ }
+
+ firstTime = false;
}
- firstTime = false;
-}
+ void ForegroundMaskAnalysis::saveConfig()
+ {
+ CvFileStorage* fs = cvOpenFileStorage("./config/ForegroundMaskAnalysis.xml", 0, CV_STORAGE_WRITE);
-void ForegroundMaskAnalysis::saveConfig()
-{
- CvFileStorage* fs = cvOpenFileStorage("./config/ForegroundMaskAnalysis.xml", 0, CV_STORAGE_WRITE);
+ cvWriteInt(fs, "stopAt", stopAt);
+ cvWriteString(fs, "img_ref_path", img_ref_path.c_str());
- cvWriteInt(fs, "stopAt", stopAt);
- cvWriteString(fs, "img_ref_path", img_ref_path.c_str());
-
- cvReleaseFileStorage(&fs);
-}
+ cvReleaseFileStorage(&fs);
+ }
-void ForegroundMaskAnalysis::loadConfig()
-{
- CvFileStorage* fs = cvOpenFileStorage("./config/ForegroundMaskAnalysis.xml", 0, CV_STORAGE_READ);
-
- stopAt = cvReadIntByName(fs, 0, "stopAt", 0);
- img_ref_path = cvReadStringByName(fs, 0, "img_ref_path", "");
+ void ForegroundMaskAnalysis::loadConfig()
+ {
+ CvFileStorage* fs = cvOpenFileStorage("./config/ForegroundMaskAnalysis.xml", 0, CV_STORAGE_READ);
+
+ stopAt = cvReadIntByName(fs, 0, "stopAt", 0);
+ img_ref_path = cvReadStringByName(fs, 0, "img_ref_path", "");
- cvReleaseFileStorage(&fs);
-}
\ No newline at end of file
+ cvReleaseFileStorage(&fs);
+ }
+}
diff --git a/package_analysis/ForegroundMaskAnalysis.h b/package_analysis/ForegroundMaskAnalysis.h
index d6bfdae..399da68 100644
--- a/package_analysis/ForegroundMaskAnalysis.h
+++ b/package_analysis/ForegroundMaskAnalysis.h
@@ -21,22 +21,25 @@ along with BGSLibrary. If not, see .
#include
#include
-class ForegroundMaskAnalysis
+namespace bgslibrary
{
-private:
- bool firstTime;
- bool showOutput;
-
-public:
- ForegroundMaskAnalysis();
- ~ForegroundMaskAnalysis();
-
- long stopAt;
- std::string img_ref_path;
-
- void process(const long &frameNumber, const std::string &name, const cv::Mat &img_input);
-
-private:
- void saveConfig();
- void loadConfig();
-};
\ No newline at end of file
+ class ForegroundMaskAnalysis
+ {
+ private:
+ bool firstTime;
+ bool showOutput;
+
+ public:
+ ForegroundMaskAnalysis();
+ ~ForegroundMaskAnalysis();
+
+ long stopAt;
+ std::string img_ref_path;
+
+ void process(const long &frameNumber, const std::string &name, const cv::Mat &img_input);
+
+ private:
+ void saveConfig();
+ void loadConfig();
+ };
+}
diff --git a/vs2010/bgslibrary.v12.suo b/vs2010/bgslibrary.v12.suo
index e515299..318f033 100644
Binary files a/vs2010/bgslibrary.v12.suo and b/vs2010/bgslibrary.v12.suo differ
diff --git a/vs2010/bgslibrary.vcxproj b/vs2010/bgslibrary.vcxproj
index d9c829d..a1bddf6 100644
--- a/vs2010/bgslibrary.vcxproj
+++ b/vs2010/bgslibrary.vcxproj
@@ -78,7 +78,12 @@
-
+
+ true
+
+
+
+
@@ -145,8 +150,15 @@
+
+
+
+
+
+
+
@@ -221,6 +233,9 @@
+
+
+
diff --git a/vs2010/bgslibrary.vcxproj.filters b/vs2010/bgslibrary.vcxproj.filters
index 3960cbf..f91c2cc 100644
--- a/vs2010/bgslibrary.vcxproj.filters
+++ b/vs2010/bgslibrary.vcxproj.filters
@@ -43,11 +43,14 @@
{53f2c4fb-9468-44ce-b76e-e25ea018c084}
+
+ {23f1cd4a-e9b2-4338-a5e7-128f451d3c89}
+
+
+ {52a9f254-d817-4577-96c2-0b3b0a9527b7}
+
-
- Source Files
-
Header Files\package_bgs
@@ -207,12 +210,6 @@
Header Files\package_bgs\lb
-
- Header Files\package_bgs\pt
-
-
- Header Files\package_bgs\pt
-
Header Files\package_bgs\sjn
@@ -252,6 +249,27 @@
Header Files\package_bgs\tb
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files\demo
+
+
+ Header Files\package_analysis
+
@@ -437,12 +455,6 @@
Header Files\package_bgs\lb
-
- Header Files\package_bgs\pt
-
-
- Header Files\package_bgs\pt
-
Header Files\package_bgs\sjn
@@ -482,5 +494,26 @@
Header Files\package_bgs\tb
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files\package_analysis
+
\ No newline at end of file