前面几篇文章简单介绍了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. lesson 20 pioneer pilots

    lesson 20 Pioneer pilots driver pilot rider cyclist 骑自行车的人 介词后不加that cover + 距离 = travel 了一段距离 by su ...

  2. Unity OBB分包(基础APK+OBB) 与apk签名

    1.OBB (Opaque Binary Blob)文件格式,是安卓游戏通用数据包.在一些大型游戏上较为常见,同时还附以Data文件,亦或是md5.dat文件出现 产生原因:由于某些平台对于apk上传 ...

  3. Grid 网格布局

    CSS 网格布局(Grid Layout) 是CSS中最强大的布局系统. 这是一个二维系统,这意味着它可以同时处理列和行,不像 flexbox 那样主要是一维系统. 你可以通过将CSS规则应用于父元素 ...

  4. RL_Learning

    Key Concepts in RL 标签(空格分隔): RL_learning OpenAI Spinning Up原址 states and observations (状态和观测) action ...

  5. 5.hadoop常用命令

    1. 单独启动和关闭hadoop服务 启动名称节点 #hadoop-daemon.sh start namenode 启动数据节点 #hadoop-daemons.sh start datanode ...

  6. Alpha冲刺——第二天

    Alpha第二天 听说 031502543 周龙荣(队长) 031502615 李家鹏 031502632 伍晨薇 031502637 张柽 031502639 郑秦 1.前言 任务分配是VV.ZQ. ...

  7. lintcode-184-最大数

    184-最大数 给出一组非负整数,重新排列他们的顺序把他们组成一个最大的整数. 注意事项 最后的结果可能很大,所以我们返回一个字符串来代替这个整数. #### 样例 给出 [1, 20, 23, 4, ...

  8. HDU 2115 I Love This Game

    http://acm.hdu.edu.cn/showproblem.php?pid=2115 Problem Description Do you like playing basketball ? ...

  9. SQL SERVER技术内幕之8 分组集

    分组集就是分组(GROUP BY子句)使用的一组属性,在传统的SQL中,一个聚合查询只能定义一个分组集: 假设现在不想生成4个单独的结果集,而是希望生成一个统一的结果集,其中包含所有4个分组集的聚合 ...

  10. vc6.0批量加注释

    MATLAB批量加注释的方法非常简单明了,加注释是ctrl+R,去注释是ctrl+T 然后在VC中我对一条一条加注释的方法非常烦恼,我想也许会有简单的方法可以批量家注释.果然,先贴代码 '------ ...