From 9e53f03968a92ed668ca4cd7677adc8b80fc64dd Mon Sep 17 00:00:00 2001 From: Gilles Rochefort Date: Sun, 29 May 2016 17:25:02 +0200 Subject: [PATCH] Fixed BackgroundSubstractorMOG2 in opencv_video. The number of gaussians involved in a mixture is supposed to be dynamically adjusted. After being increased, the number of gaussians can't be reduced anymore. It seems to be a regression as the legacy code located in modules/legacy/src/bgfg_gaussmix.cpp allows to reduce such number of gaussians. --- modules/video/src/bgfg_gaussmix2.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/video/src/bgfg_gaussmix2.cpp b/modules/video/src/bgfg_gaussmix2.cpp index 2720e50e42..8faeb2026b 100644 --- a/modules/video/src/bgfg_gaussmix2.cpp +++ b/modules/video/src/bgfg_gaussmix2.cpp @@ -594,7 +594,7 @@ public: //internal: bool fitsPDF = false;//if it remains zero a new GMM mode will be added - int nmodes = modesUsed[x], nNewModes = nmodes;//current number of modes in GMM + int nmodes = modesUsed[x];//current number of modes in GMM float totalWeight = 0.f; float* mean_m = mean; @@ -700,8 +700,6 @@ public: gmm[mode].weight *= totalWeight; } - nmodes = nNewModes; - //make new mode if needed and exit if( !fitsPDF && alphaT > 0.f ) {