前面几篇文章简单介绍了BgsLibrary的入口函数视频分析视频捕获模块,本文将简单介绍帧处理模块,即对每一帧进行处理的函数,也就是真正调用背景建模算法的接口处。

下面贴出源码供大家分析:

  1. #include "FrameProcessor.h"
  2. #include <iomanip>
  3. namespace bgslibrary
  4. {
  5. FrameProcessor::FrameProcessor() : firstTime(true), frameNumber(0), duration(0), tictoc(""), frameToStop(0)
  6. {
  7. std::cout << "FrameProcessor()" << std::endl;
  8. loadConfig();
  9. saveConfig();
  10. }
  11. FrameProcessor::~FrameProcessor()
  12. {
  13. std::cout << "~FrameProcessor()" << std::endl;
  14. }
  15. void FrameProcessor::init()
  16. {
  17. if (enablePreProcessor)
  18. preProcessor = new PreProcessor;
  19. if (enableFrameDifferenceBGS)
  20. frameDifference = new FrameDifferenceBGS;
  21. if (enableStaticFrameDifferenceBGS)
  22. staticFrameDifference = new StaticFrameDifferenceBGS;
  23. if (enableWeightedMovingMeanBGS)
  24. weightedMovingMean = new WeightedMovingMeanBGS;
  25. if (enableWeightedMovingVarianceBGS)
  26. weightedMovingVariance = new WeightedMovingVarianceBGS;
  27. if (enableMixtureOfGaussianV1BGS)
  28. mixtureOfGaussianV1BGS = new MixtureOfGaussianV1BGS;
  29. if (enableMixtureOfGaussianV2BGS)
  30. mixtureOfGaussianV2BGS = new MixtureOfGaussianV2BGS;
  31. if (enableAdaptiveBackgroundLearning)
  32. adaptiveBackgroundLearning = new AdaptiveBackgroundLearning;
  33. #if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
  34. if (enableGMG)
  35. gmg = new GMG;
  36. #endif
  37. if (enableDPAdaptiveMedianBGS)
  38. adaptiveMedian = new DPAdaptiveMedianBGS;
  39. if (enableDPGrimsonGMMBGS)
  40. grimsonGMM = new DPGrimsonGMMBGS;
  41. if (enableDPZivkovicAGMMBGS)
  42. zivkovicAGMM = new DPZivkovicAGMMBGS;
  43. if (enableDPMeanBGS)
  44. temporalMean = new DPMeanBGS;
  45. if (enableDPWrenGABGS)
  46. wrenGA = new DPWrenGABGS;
  47. if (enableDPPratiMediodBGS)
  48. pratiMediod = new DPPratiMediodBGS;
  49. if (enableDPEigenbackgroundBGS)
  50. eigenBackground = new DPEigenbackgroundBGS;
  51. if (enableDPTextureBGS)
  52. textureBGS = new DPTextureBGS;
  53. if (enableT2FGMM_UM)
  54. type2FuzzyGMM_UM = new T2FGMM_UM;
  55. if (enableT2FGMM_UV)
  56. type2FuzzyGMM_UV = new T2FGMM_UV;
  57. if (enableT2FMRF_UM)
  58. type2FuzzyMRF_UM = new T2FMRF_UM;
  59. if (enableT2FMRF_UV)
  60. type2FuzzyMRF_UV = new T2FMRF_UV;
  61. if (enableFuzzySugenoIntegral)
  62. fuzzySugenoIntegral = new FuzzySugenoIntegral;
  63. if (enableFuzzyChoquetIntegral)
  64. fuzzyChoquetIntegral = new FuzzyChoquetIntegral;
  65. if (enableLBSimpleGaussian)
  66. lbSimpleGaussian = new LBSimpleGaussian;
  67. if (enableLBFuzzyGaussian)
  68. lbFuzzyGaussian = new LBFuzzyGaussian;
  69. if (enableLBMixtureOfGaussians)
  70. lbMixtureOfGaussians = new LBMixtureOfGaussians;
  71. if (enableLBAdaptiveSOM)
  72. lbAdaptiveSOM = new LBAdaptiveSOM;
  73. if (enableLBFuzzyAdaptiveSOM)
  74. lbFuzzyAdaptiveSOM = new LBFuzzyAdaptiveSOM;
  75. if (enableLbpMrf)
  76. lbpMrf = new LbpMrf;
  77. if(enableMultiLayerBGS)
  78. multiLayerBGS = new MultiLayerBGS;
  79. //if(enablePBAS)
  80. //  pixelBasedAdaptiveSegmenter = new PixelBasedAdaptiveSegmenter;
  81. if (enableVuMeter)
  82. vuMeter = new VuMeter;
  83. if (enableKDE)
  84. kde = new KDE;
  85. if (enableIMBS)
  86. imbs = new IndependentMultimodalBGS;
  87. if (enableMultiCueBGS)
  88. mcbgs = new SJN_MultiCueBGS;
  89. if (enableSigmaDeltaBGS)
  90. sdbgs = new SigmaDeltaBGS;
  91. if (enableSuBSENSEBGS)
  92. ssbgs = new SuBSENSEBGS;
  93. if (enableLOBSTERBGS)
  94. lobgs = new LOBSTERBGS;
  95. if (enableForegroundMaskAnalysis)
  96. foregroundMaskAnalysis = new ForegroundMaskAnalysis;
  97. }
  98. void FrameProcessor::process(std::string name, IBGS *bgs, const cv::Mat &img_input, cv::Mat &img_bgs)
  99. {
  100. if (tictoc == name)
  101. tic(name);
  102. cv::Mat img_bkgmodel;
  103. bgs->process(img_input, img_bgs, img_bkgmodel);//直接调用各种背景建模算法
  104. if (tictoc == name)
  105. toc();
  106. }
  107. void FrameProcessor::process(const cv::Mat &img_input)
  108. {
  109. frameNumber++;
  110. ///enablePreProcessor///
  111. if (enablePreProcessor)
  112. preProcessor->process(img_input, img_prep);
  113. /******************************************************************/
  114. /*根据config文件使能各种背景建模算法,可以同时使用多种背景建模算法*/
  115. /******************************************************************/
  116. ///1:Frame Difference
  117. if (enableFrameDifferenceBGS)
  118. process("FrameDifferenceBGS", frameDifference, img_prep, img_framediff);
  119. ///2:Static Frame Difference
  120. if (enableStaticFrameDifferenceBGS)
  121. process("StaticFrameDifferenceBGS", staticFrameDifference, img_prep, img_staticfdiff);
  122. ///3:Weighted Moving Mean
  123. if (enableWeightedMovingMeanBGS)
  124. process("WeightedMovingMeanBGS", weightedMovingMean, img_prep, img_wmovmean);
  125. ///4:Weighted Moving Variance
  126. if (enableWeightedMovingVarianceBGS)
  127. process("WeightedMovingVarianceBGS", weightedMovingVariance, img_prep, img_movvar);
  128. ///5:Gaussian Mixture Model
  129. if (enableMixtureOfGaussianV1BGS)
  130. process("MixtureOfGaussianV1BGS", mixtureOfGaussianV1BGS, img_prep, img_mog1);
  131. ///6:Gaussian Mixture Model
  132. if (enableMixtureOfGaussianV2BGS)
  133. process("MixtureOfGaussianV2BGS", mixtureOfGaussianV2BGS, img_prep, img_mog2);
  134. ///7:Adaptive Background Learning
  135. if (enableAdaptiveBackgroundLearning)
  136. process("AdaptiveBackgroundLearning", adaptiveBackgroundLearning, img_prep, img_bkgl_fgmask);
  137. ///8:GMG
  138. #if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
  139. if (enableGMG)
  140. process("GMG", gmg, img_prep, img_gmg);
  141. #endif
  142. ///9:Adaptive Median
  143. if (enableDPAdaptiveMedianBGS)
  144. process("DPAdaptiveMedianBGS", adaptiveMedian, img_prep, img_adpmed);
  145. ///10:Gaussian Mixture Model
  146. if (enableDPGrimsonGMMBGS)
  147. process("DPGrimsonGMMBGS", grimsonGMM, img_prep, img_grigmm);
  148. ///11:Gaussian Mixture Model
  149. if (enableDPZivkovicAGMMBGS)
  150. process("DPZivkovicAGMMBGS", zivkovicAGMM, img_prep, img_zivgmm);
  151. ///12:Temporal Mean
  152. if (enableDPMeanBGS)
  153. process("DPMeanBGS", temporalMean, img_prep, img_tmpmean);
  154. ///13:Gaussian Average
  155. if (enableDPWrenGABGS)
  156. process("DPWrenGABGS", wrenGA, img_prep, img_wrenga);
  157. ///14:Temporal Median
  158. if (enableDPPratiMediodBGS)
  159. process("DPPratiMediodBGS", pratiMediod, img_prep, img_pramed);
  160. ///15:Eigen background / SL-PCA
  161. if (enableDPEigenbackgroundBGS)
  162. process("DPEigenbackgroundBGS", eigenBackground, img_prep, img_eigbkg);
  163. ///16:Texture BGS
  164. if (enableDPTextureBGS)
  165. process("DPTextureBGS", textureBGS, img_prep, img_texbgs);
  166. ///17:Type-2 Fuzzy GMM-UM
  167. if (enableT2FGMM_UM)
  168. process("T2FGMM_UM", type2FuzzyGMM_UM, img_prep, img_t2fgmm_um);
  169. ///18:Type-2 Fuzzy GMM-UV
  170. if (enableT2FGMM_UV)
  171. process("T2FGMM_UV", type2FuzzyGMM_UV, img_prep, img_t2fgmm_uv);
  172. ///19:Type-2 Fuzzy GMM-UM with MRF
  173. if (enableT2FMRF_UM)
  174. process("T2FMRF_UM", type2FuzzyMRF_UM, img_prep, img_t2fmrf_um);
  175. ///20:Type-2 Fuzzy GMM-UV with MRF
  176. if (enableT2FMRF_UV)
  177. process("T2FMRF_UV", type2FuzzyMRF_UV, img_prep, img_t2fmrf_uv);
  178. ///21:Fuzzy Sugeno Integral
  179. if (enableFuzzySugenoIntegral)
  180. process("FuzzySugenoIntegral", fuzzySugenoIntegral, img_prep, img_fsi);
  181. ///22:Fuzzy Choquet Integral
  182. if (enableFuzzyChoquetIntegral)
  183. process("FuzzyChoquetIntegral", fuzzyChoquetIntegral, img_prep, img_fci);
  184. ///23:Simple Gaussian
  185. if (enableLBSimpleGaussian)
  186. process("LBSimpleGaussian", lbSimpleGaussian, img_prep, img_lb_sg);
  187. ///24:Fuzzy Gaussian of Laurence Bender
  188. if (enableLBFuzzyGaussian)
  189. process("LBFuzzyGaussian", lbFuzzyGaussian, img_prep, img_lb_fg);
  190. ///25:Gaussian Mixture Model
  191. if (enableLBMixtureOfGaussians)
  192. process("LBMixtureOfGaussians", lbMixtureOfGaussians, img_prep, img_lb_mog);
  193. ///26:Adaptive SOM
  194. if (enableLBAdaptiveSOM)
  195. process("LBAdaptiveSOM", lbAdaptiveSOM, img_prep, img_lb_som);
  196. ///27:Fuzzy Adaptive SOM
  197. if (enableLBFuzzyAdaptiveSOM)
  198. process("LBFuzzyAdaptiveSOM", lbFuzzyAdaptiveSOM, img_prep, img_lb_fsom);
  199. ///28:LbpMrf
  200. if (enableLbpMrf)
  201. process("LbpMrf", lbpMrf, img_prep, img_lbp_mrf);
  202. ///29:Multi-Layer BGS
  203. if(enableMultiLayerBGS)
  204. {
  205. multiLayerBGS->setStatus(MultiLayerBGS::MLBGS_LEARN);
  206. //multiLayerBGS->setStatus(MultiLayerBGS::MLBGS_DETECT);
  207. process("MultiLayerBGS", multiLayerBGS, img_prep, img_mlbgs);
  208. }
  209. ///30:Pixel-Based Adaptive Segmenter
  210. //if(enablePBAS)
  211. //  process("PBAS", pixelBasedAdaptiveSegmenter, img_prep, img_pt_pbas);
  212. ///31:VuMeter
  213. if (enableVuMeter)
  214. process("VuMeter", vuMeter, img_prep, img_vumeter);
  215. ///32:Kernel Density Estimation
  216. if (enableKDE)
  217. process("KDE", kde, img_prep, img_kde);
  218. ///33:Independent Multimodal BGS
  219. if (enableIMBS)
  220. process("IMBS", imbs, img_prep, img_imbs);
  221. ///34:MultiCue BGS
  222. if (enableMultiCueBGS)
  223. process("MultiCueBGS", mcbgs, img_prep, img_mcbgs);
  224. ///35:Sigma-Delta
  225. if (enableSigmaDeltaBGS)
  226. process("SigmaDeltaBGS", sdbgs, img_prep, img_sdbgs);
  227. ///36:SuBSENSE
  228. if (enableSuBSENSEBGS)
  229. process("SuBSENSEBGS", ssbgs, img_prep, img_ssbgs);
  230. ///37:LOBSTER
  231. if (enableLOBSTERBGS)
  232. process("LOBSTERBGS", lobgs, img_prep, img_lobgs);
  233. ///enableForegroundMaskAnalysis///
  234. if (enableForegroundMaskAnalysis)
  235. {
  236. foregroundMaskAnalysis->stopAt = frameToStop;
  237. foregroundMaskAnalysis->img_ref_path = imgref;
  238. foregroundMaskAnalysis->process(frameNumber, "FrameDifferenceBGS", img_framediff);
  239. foregroundMaskAnalysis->process(frameNumber, "StaticFrameDifferenceBGS", img_staticfdiff);
  240. foregroundMaskAnalysis->process(frameNumber, "WeightedMovingMeanBGS", img_wmovmean);
  241. foregroundMaskAnalysis->process(frameNumber, "WeightedMovingVarianceBGS", img_movvar);
  242. foregroundMaskAnalysis->process(frameNumber, "MixtureOfGaussianV1BGS", img_mog1);
  243. foregroundMaskAnalysis->process(frameNumber, "MixtureOfGaussianV2BGS", img_mog2);
  244. foregroundMaskAnalysis->process(frameNumber, "AdaptiveBackgroundLearning", img_bkgl_fgmask);
  245. #if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
  246. foregroundMaskAnalysis->process(frameNumber, "GMG", img_gmg);
  247. #endif
  248. foregroundMaskAnalysis->process(frameNumber, "DPAdaptiveMedianBGS", img_adpmed);
  249. foregroundMaskAnalysis->process(frameNumber, "DPGrimsonGMMBGS", img_grigmm);
  250. foregroundMaskAnalysis->process(frameNumber, "DPZivkovicAGMMBGS", img_zivgmm);
  251. foregroundMaskAnalysis->process(frameNumber, "DPMeanBGS", img_tmpmean);
  252. foregroundMaskAnalysis->process(frameNumber, "DPWrenGABGS", img_wrenga);
  253. foregroundMaskAnalysis->process(frameNumber, "DPPratiMediodBGS", img_pramed);
  254. foregroundMaskAnalysis->process(frameNumber, "DPEigenbackgroundBGS", img_eigbkg);
  255. foregroundMaskAnalysis->process(frameNumber, "DPTextureBGS", img_texbgs);
  256. foregroundMaskAnalysis->process(frameNumber, "T2FGMM_UM", img_t2fgmm_um);
  257. foregroundMaskAnalysis->process(frameNumber, "T2FGMM_UV", img_t2fgmm_uv);
  258. foregroundMaskAnalysis->process(frameNumber, "T2FMRF_UM", img_t2fmrf_um);
  259. foregroundMaskAnalysis->process(frameNumber, "T2FMRF_UV", img_t2fmrf_uv);
  260. foregroundMaskAnalysis->process(frameNumber, "FuzzySugenoIntegral", img_fsi);
  261. foregroundMaskAnalysis->process(frameNumber, "FuzzyChoquetIntegral", img_fci);
  262. foregroundMaskAnalysis->process(frameNumber, "LBSimpleGaussian", img_lb_sg);
  263. foregroundMaskAnalysis->process(frameNumber, "LBFuzzyGaussian", img_lb_fg);
  264. foregroundMaskAnalysis->process(frameNumber, "LBMixtureOfGaussians", img_lb_mog);
  265. foregroundMaskAnalysis->process(frameNumber, "LBAdaptiveSOM", img_lb_som);
  266. foregroundMaskAnalysis->process(frameNumber, "LBFuzzyAdaptiveSOM", img_lb_fsom);
  267. foregroundMaskAnalysis->process(frameNumber, "LbpMrf", img_lbp_mrf);
  268. foregroundMaskAnalysis->process(frameNumber, "MultiLayerBGS", img_mlbgs);
  269. //foregroundMaskAnalysis->process(frameNumber, "PBAS", img_pt_pbas);
  270. foregroundMaskAnalysis->process(frameNumber, "VuMeter", img_vumeter);
  271. foregroundMaskAnalysis->process(frameNumber, "KDE", img_kde);
  272. foregroundMaskAnalysis->process(frameNumber, "IMBS", img_imbs);
  273. foregroundMaskAnalysis->process(frameNumber, "MultiCueBGS", img_mcbgs);
  274. foregroundMaskAnalysis->process(frameNumber, "SigmaDeltaBGS", img_sdbgs);
  275. foregroundMaskAnalysis->process(frameNumber, "SuBSENSEBGS", img_ssbgs);
  276. foregroundMaskAnalysis->process(frameNumber, "LOBSTERBGS", img_lobgs);
  277. }
  278. firstTime = false;
  279. }
  280. void FrameProcessor::finish(void)
  281. {
  282. /*if(enableMultiLayerBGS)
  283. multiLayerBGS->finish();
  284. if(enableLBSimpleGaussian)
  285. lbSimpleGaussian->finish();
  286. if(enableLBFuzzyGaussian)
  287. lbFuzzyGaussian->finish();
  288. if(enableLBMixtureOfGaussians)
  289. lbMixtureOfGaussians->finish();
  290. if(enableLBAdaptiveSOM)
  291. lbAdaptiveSOM->finish();
  292. if(enableLBFuzzyAdaptiveSOM)
  293. lbFuzzyAdaptiveSOM->finish();*/
  294. if (enableForegroundMaskAnalysis)
  295. delete foregroundMaskAnalysis;
  296. if (enableLOBSTERBGS)
  297. delete lobgs;
  298. if (enableSuBSENSEBGS)
  299. delete ssbgs;
  300. if (enableSigmaDeltaBGS)
  301. delete sdbgs;
  302. if (enableMultiCueBGS)
  303. delete mcbgs;
  304. if (enableIMBS)
  305. delete imbs;
  306. if (enableKDE)
  307. delete kde;
  308. if (enableVuMeter)
  309. delete vuMeter;
  310. //if(enablePBAS)
  311. //  delete pixelBasedAdaptiveSegmenter;
  312. if (enableMultiLayerBGS)
  313. delete multiLayerBGS;
  314. if (enableLBFuzzyAdaptiveSOM)
  315. delete lbFuzzyAdaptiveSOM;
  316. if (enableLBAdaptiveSOM)
  317. delete lbAdaptiveSOM;
  318. if (enableLBMixtureOfGaussians)
  319. delete lbMixtureOfGaussians;
  320. if (enableLBFuzzyGaussian)
  321. delete lbFuzzyGaussian;
  322. if (enableLBSimpleGaussian)
  323. delete lbSimpleGaussian;
  324. #if !defined(_WIN32)
  325. if (enableLbpMrf)
  326. delete lbpMrf;
  327. #endif
  328. if(enableFuzzyChoquetIntegral)
  329. delete fuzzyChoquetIntegral;
  330. if (enableFuzzySugenoIntegral)
  331. delete fuzzySugenoIntegral;
  332. if (enableT2FMRF_UV)
  333. delete type2FuzzyMRF_UV;
  334. if (enableT2FMRF_UM)
  335. delete type2FuzzyMRF_UM;
  336. if (enableT2FGMM_UV)
  337. delete type2FuzzyGMM_UV;
  338. if (enableT2FGMM_UM)
  339. delete type2FuzzyGMM_UM;
  340. if (enableDPTextureBGS)
  341. delete textureBGS;
  342. if (enableDPEigenbackgroundBGS)
  343. delete eigenBackground;
  344. if (enableDPPratiMediodBGS)
  345. delete pratiMediod;
  346. if (enableDPWrenGABGS)
  347. delete wrenGA;
  348. if (enableDPMeanBGS)
  349. delete temporalMean;
  350. if (enableDPZivkovicAGMMBGS)
  351. delete zivkovicAGMM;
  352. if (enableDPGrimsonGMMBGS)
  353. delete grimsonGMM;
  354. if (enableDPAdaptiveMedianBGS)
  355. delete adaptiveMedian;
  356. #if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
  357. if (enableGMG)
  358. delete gmg;
  359. #endif
  360. if (enableAdaptiveBackgroundLearning)
  361. delete adaptiveBackgroundLearning;
  362. if (enableMixtureOfGaussianV2BGS)
  363. delete mixtureOfGaussianV2BGS;
  364. if (enableMixtureOfGaussianV1BGS)
  365. delete mixtureOfGaussianV1BGS;
  366. if (enableWeightedMovingVarianceBGS)
  367. delete weightedMovingVariance;
  368. if (enableWeightedMovingMeanBGS)
  369. delete weightedMovingMean;
  370. if (enableStaticFrameDifferenceBGS)
  371. delete staticFrameDifference;
  372. if (enableFrameDifferenceBGS)
  373. delete frameDifference;
  374. if (enablePreProcessor)
  375. delete preProcessor;
  376. }
  377. void FrameProcessor::tic(std::string value)
  378. {
  379. processname = value;
  380. duration = static_cast<double>(cv::getTickCount());
  381. }
  382. void FrameProcessor::toc()
  383. {
  384. duration = (static_cast<double>(cv::getTickCount()) - duration) / cv::getTickFrequency();
  385. std::cout << processname << "\ttime(sec):" << std::fixed << std::setprecision(6) << duration << std::endl;
  386. }
  387. void FrameProcessor::saveConfig()
  388. {
  389. CvFileStorage* fs = cvOpenFileStorage("./config/FrameProcessor.xml", 0, CV_STORAGE_WRITE);
  390. cvWriteString(fs, "tictoc", tictoc.c_str());
  391. cvWriteInt(fs, "enablePreProcessor", enablePreProcessor);
  392. cvWriteInt(fs, "enableForegroundMaskAnalysis", enableForegroundMaskAnalysis);
  393. cvWriteInt(fs, "enableFrameDifferenceBGS", enableFrameDifferenceBGS);
  394. cvWriteInt(fs, "enableStaticFrameDifferenceBGS", enableStaticFrameDifferenceBGS);
  395. cvWriteInt(fs, "enableWeightedMovingMeanBGS", enableWeightedMovingMeanBGS);
  396. cvWriteInt(fs, "enableWeightedMovingVarianceBGS", enableWeightedMovingVarianceBGS);
  397. cvWriteInt(fs, "enableMixtureOfGaussianV1BGS", enableMixtureOfGaussianV1BGS);
  398. cvWriteInt(fs, "enableMixtureOfGaussianV2BGS", enableMixtureOfGaussianV2BGS);
  399. cvWriteInt(fs, "enableAdaptiveBackgroundLearning", enableAdaptiveBackgroundLearning);
  400. #if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
  401. cvWriteInt(fs, "enableGMG", enableGMG);
  402. #endif
  403. cvWriteInt(fs, "enableDPAdaptiveMedianBGS", enableDPAdaptiveMedianBGS);
  404. cvWriteInt(fs, "enableDPGrimsonGMMBGS", enableDPGrimsonGMMBGS);
  405. cvWriteInt(fs, "enableDPZivkovicAGMMBGS", enableDPZivkovicAGMMBGS);
  406. cvWriteInt(fs, "enableDPMeanBGS", enableDPMeanBGS);
  407. cvWriteInt(fs, "enableDPWrenGABGS", enableDPWrenGABGS);
  408. cvWriteInt(fs, "enableDPPratiMediodBGS", enableDPPratiMediodBGS);
  409. cvWriteInt(fs, "enableDPEigenbackgroundBGS", enableDPEigenbackgroundBGS);
  410. cvWriteInt(fs, "enableDPTextureBGS", enableDPTextureBGS);
  411. cvWriteInt(fs, "enableT2FGMM_UM", enableT2FGMM_UM);
  412. cvWriteInt(fs, "enableT2FGMM_UV", enableT2FGMM_UV);
  413. cvWriteInt(fs, "enableT2FMRF_UM", enableT2FMRF_UM);
  414. cvWriteInt(fs, "enableT2FMRF_UV", enableT2FMRF_UV);
  415. cvWriteInt(fs, "enableFuzzySugenoIntegral", enableFuzzySugenoIntegral);
  416. cvWriteInt(fs, "enableFuzzyChoquetIntegral", enableFuzzyChoquetIntegral);
  417. cvWriteInt(fs, "enableLBSimpleGaussian", enableLBSimpleGaussian);
  418. cvWriteInt(fs, "enableLBFuzzyGaussian", enableLBFuzzyGaussian);
  419. cvWriteInt(fs, "enableLBMixtureOfGaussians", enableLBMixtureOfGaussians);
  420. cvWriteInt(fs, "enableLBAdaptiveSOM", enableLBAdaptiveSOM);
  421. cvWriteInt(fs, "enableLBFuzzyAdaptiveSOM", enableLBFuzzyAdaptiveSOM);
  422. cvWriteInt(fs, "enableLbpMrf", enableLbpMrf);
  423. cvWriteInt(fs, "enableMultiLayerBGS", enableMultiLayerBGS);
  424. //cvWriteInt(fs, "enablePBAS", enablePBAS);
  425. cvWriteInt(fs, "enableVuMeter", enableVuMeter);
  426. cvWriteInt(fs, "enableKDE", enableKDE);
  427. cvWriteInt(fs, "enableIMBS", enableIMBS);
  428. cvWriteInt(fs, "enableMultiCueBGS", enableMultiCueBGS);
  429. cvWriteInt(fs, "enableSigmaDeltaBGS", enableSigmaDeltaBGS);
  430. cvWriteInt(fs, "enableSuBSENSEBGS", enableSuBSENSEBGS);
  431. cvWriteInt(fs, "enableLOBSTERBGS", enableLOBSTERBGS);
  432. cvReleaseFileStorage(&fs);
  433. }
  434. void FrameProcessor::loadConfig()
  435. {
  436. CvFileStorage* fs = cvOpenFileStorage("./config/FrameProcessor.xml", 0, CV_STORAGE_READ);
  437. tictoc = cvReadStringByName(fs, 0, "tictoc", "");
  438. enablePreProcessor = cvReadIntByName(fs, 0, "enablePreProcessor", true);
  439. enableForegroundMaskAnalysis = cvReadIntByName(fs, 0, "enableForegroundMaskAnalysis", false);
  440. enableFrameDifferenceBGS = cvReadIntByName(fs, 0, "enableFrameDifferenceBGS", false);
  441. enableStaticFrameDifferenceBGS = cvReadIntByName(fs, 0, "enableStaticFrameDifferenceBGS", false);
  442. enableWeightedMovingMeanBGS = cvReadIntByName(fs, 0, "enableWeightedMovingMeanBGS", false);
  443. enableWeightedMovingVarianceBGS = cvReadIntByName(fs, 0, "enableWeightedMovingVarianceBGS", false);
  444. enableMixtureOfGaussianV1BGS = cvReadIntByName(fs, 0, "enableMixtureOfGaussianV1BGS", false);
  445. enableMixtureOfGaussianV2BGS = cvReadIntByName(fs, 0, "enableMixtureOfGaussianV2BGS", false);
  446. enableAdaptiveBackgroundLearning = cvReadIntByName(fs, 0, "enableAdaptiveBackgroundLearning", false);
  447. #if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
  448. enableGMG = cvReadIntByName(fs, 0, "enableGMG", false);
  449. #endif
  450. enableDPAdaptiveMedianBGS = cvReadIntByName(fs, 0, "enableDPAdaptiveMedianBGS", false);
  451. enableDPGrimsonGMMBGS = cvReadIntByName(fs, 0, "enableDPGrimsonGMMBGS", false);
  452. enableDPZivkovicAGMMBGS = cvReadIntByName(fs, 0, "enableDPZivkovicAGMMBGS", false);
  453. enableDPMeanBGS = cvReadIntByName(fs, 0, "enableDPMeanBGS", false);
  454. enableDPWrenGABGS = cvReadIntByName(fs, 0, "enableDPWrenGABGS", false);
  455. enableDPPratiMediodBGS = cvReadIntByName(fs, 0, "enableDPPratiMediodBGS", false);
  456. enableDPEigenbackgroundBGS = cvReadIntByName(fs, 0, "enableDPEigenbackgroundBGS", false);
  457. enableDPTextureBGS = cvReadIntByName(fs, 0, "enableDPTextureBGS", false);
  458. enableT2FGMM_UM = cvReadIntByName(fs, 0, "enableT2FGMM_UM", false);
  459. enableT2FGMM_UV = cvReadIntByName(fs, 0, "enableT2FGMM_UV", false);
  460. enableT2FMRF_UM = cvReadIntByName(fs, 0, "enableT2FMRF_UM", false);
  461. enableT2FMRF_UV = cvReadIntByName(fs, 0, "enableT2FMRF_UV", false);
  462. enableFuzzySugenoIntegral = cvReadIntByName(fs, 0, "enableFuzzySugenoIntegral", false);
  463. enableFuzzyChoquetIntegral = cvReadIntByName(fs, 0, "enableFuzzyChoquetIntegral", false);
  464. enableLBSimpleGaussian = cvReadIntByName(fs, 0, "enableLBSimpleGaussian", false);
  465. enableLBFuzzyGaussian = cvReadIntByName(fs, 0, "enableLBFuzzyGaussian", false);
  466. enableLBMixtureOfGaussians = cvReadIntByName(fs, 0, "enableLBMixtureOfGaussians", false);
  467. enableLBAdaptiveSOM = cvReadIntByName(fs, 0, "enableLBAdaptiveSOM", false);
  468. enableLBFuzzyAdaptiveSOM = cvReadIntByName(fs, 0, "enableLBFuzzyAdaptiveSOM", false);
  469. enableLbpMrf = cvReadIntByName(fs, 0, "enableLbpMrf", false);
  470. enableMultiLayerBGS = cvReadIntByName(fs, 0, "enableMultiLayerBGS", false);
  471. //enablePBAS = cvReadIntByName(fs, 0, "enablePBAS", false);
  472. enableVuMeter = cvReadIntByName(fs, 0, "enableVuMeter", false);
  473. enableKDE = cvReadIntByName(fs, 0, "enableKDE", false);
  474. enableIMBS = cvReadIntByName(fs, 0, "enableIMBS", false);
  475. enableMultiCueBGS = cvReadIntByName(fs, 0, "enableMultiCueBGS", false);
  476. enableSigmaDeltaBGS = cvReadIntByName(fs, 0, "enableSigmaDeltaBGS", false);
  477. enableSuBSENSEBGS = cvReadIntByName(fs, 0, "enableSuBSENSEBGS", false);
  478. enableLOBSTERBGS = cvReadIntByName(fs, 0, "enableLOBSTERBGS", false);
  479. cvReleaseFileStorage(&fs);
  480. }
  481. }

其实,从源码中可以看出,本函数所做的工作并不多,主要就是调用背景建模算法的接口,其接口处是:bgs->process(img_input, img_bgs, img_bkgmodel);

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

背景建模技术(六):帧处理(FrameProcessor)模块的更多相关文章

  1. 背景建模技术(三):背景减法库(BGS Library)的基本框架与入口函数main()的功能

    背景减法库(BGS Library = background subtraction library)包含了37种背景建模算法,也是目前国际上关于背景建模技术研究最全也最权威的资料.本文将更加详细的介 ...

  2. 背景建模技术(二):BgsLibrary的框架、背景建模的37种算法性能分析、背景建模技术的挑战

    背景建模技术(二):BgsLibrary的框架.背景建模的37种算法性能分析.背景建模技术的挑战 1.基于MFC的BgsLibrary软件下载 下载地址:http://download.csdn.ne ...

  3. 背景建模技术(七):预处理(PreProcessor)模块

    预处理(PreProcessor)模块是BgsLibrary中一个必选的模块,是真正进入背景建模算法的“预处理”过程,其主要功能包括‘去模糊’.‘获得灰度图’.'应用Canny算子‘等可选模块. 下面 ...

  4. 背景建模技术(五):视频捕获(VideoCapture)模块

    本次对“视频捕获(VideoCapture)模块”做出分析,给出源代码和对应的程序流程框架. 视频捕获模块的主要功能是设置视频或相机参数,并读取设置配置参数,最后进入帧处理模块的process进程,该 ...

  5. 背景建模技术(四):视频分析(VideoAnalysis)模块

    视频分析模块主要包含两个函数,一个是VideoAnalysis::setup(....),其主要功能就是确定测试的视频是视频文件或摄像头输入亦或是采用命令行参数:第二个函数是VideoAnalysis ...

  6. 【计算机视觉】背景建模--Vibe 算法优缺点分析

    一.Vibe 算法的优点 Vibe背景建模为运动目标检测研究邻域开拓了新思路,是一种新颖.快速及有效的运动目标检测算法.其优点有以下两点: 1.思想简单,易于实现.Vibe通常随机选取邻域20个样本为 ...

  7. 浅析软件工程中的UML建模技术

    一.基本信息 标题:浅析软件工程中的UML建模技术 时间:2018 出版源:电子世界 领域分类:软件工程:UML建模技术:需求分析 二.研究背景 问题定义:软件工程中UML建模技术的研究 难点:明确软 ...

  8. 背景建模或前景检測之PBAS

    申明,本文非笔者原创,原文转载自:http://blog.csdn.net/kcust/article/details/9931575 Pixel-Based Adaptive Segmenter(P ...

  9. 【计算机视觉】背景建模之PBAS

    本文是根据M. Hofmann等人在2012年的IEEE Workshop on Change Detection上发表的"Background Segmentation with Feed ...

随机推荐

  1. 【WXS全局对象】JSON

    方法: 原型:JSON.stringify( Object ) 说明:将 object 对象转换为 JSON 字符串,并返回该字符串. 返回:[String] 原型:JSON.parse( [Stri ...

  2. 凸包算法(Graham扫描法)详解

    先说下基础知识,不然不好理解后面的东西 两向量的X乘p1(x1,y1),p2(x2,y2) p1Xp2如果小于零则说明  p1在p2的逆时针方向 如果大于零则说明 p1在p2的顺时针方向 struct ...

  3. Apache--Override参数详解

    1  AuthConfig  允许使用所有的权限指令,他们包括AuthDBMGroupFile AuthDBMUserFile  AuthGroupFile  AuthName AuthTypeAut ...

  4. CP文件覆盖问题

    # \cp -r -a aaa/* /bbb[这次是完美的,没有提示按Y.传递了目录属性.没有略过目录]

  5. Linearization of the kernel functions in SVM(多项式模拟)

    Description SVM(Support Vector Machine)is an important classification tool, which has a wide range o ...

  6. 利用JavaScriptSerializer类 进行Json对象的序列化和反序列化和过滤

    项目下载:JavaScriptSerializer_对JSON对象序列化与反序列化及过滤器 利用<JavascriptSerializer类> 进行Json对象的序列化和反序列化 1. 首 ...

  7. linux系统中如何进入退出vim编辑器的方法及区别

    在linux家族中,vim编辑器是系统自带的文本编辑器,其功能强大自不必说了. 偶有小白,刚接触linux,要修改某个文本文件,不可能像WINDOWS那样操作,更有甚者,进入VI编辑器后,无法退出以致 ...

  8. KindEditor是一套很方便的html编译器插件

    KindEditor是一套很方便的html编译器插件.在这里做一个简单的使用介绍. 首先在官网上下载最新的KindEditor文件(里面有jsp,asp等不同版本文件夹,可以删掉你不需要的版本), 把 ...

  9. django设置首页

    1.在views中添加一个def 为homepage basepath=os.getcwd()+'\\dockerApp\\app\\templates\\';def homepage(request ...

  10. Microsoft Edge goes Chromium

    Microsoft Edge goes Chromium https://techcrunch.com/2018/12/06/microsoft-edge-goes-chromium-and-maco ...