From cc483c609b956317bcbab3c5e754ff39225ef8ec Mon Sep 17 00:00:00 2001 From: Lieven Govaerts <lgo@apache.org> Date: Sat, 10 Feb 2018 23:29:13 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20a=20crash=20in=20the=20IndependentMultimo?= =?UTF-8?q?dal=20algorithm=20during=20setup.=20The=20=E2=80=A6=20(#108)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix a crash in the IndependentMultimodal algorithm during setup. The nframes member variable is not initialized, which means that occasionally the initialize() function is not called when the first frame is processed. * package_bgs/IMBS/IMBS.cpp (BackgroundSubtractorIMBS): Initialize nframes to 0. * Fix a crash when initializingn not using and the destroying the IndependentMultimodal algorithm. * package_bgs/IMBS/IMBS.cpp (BackgroundSubtractorIMBS): initialize bgBins, bgModel and persistenceMap pointers to NULL. --- package_bgs/IMBS/IMBS.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package_bgs/IMBS/IMBS.cpp b/package_bgs/IMBS/IMBS.cpp index b1e177b..d80c3b4 100644 --- a/package_bgs/IMBS/IMBS.cpp +++ b/package_bgs/IMBS/IMBS.cpp @@ -53,6 +53,10 @@ BackgroundSubtractorIMBS::BackgroundSubtractorIMBS() tau_s = 60; tau_h = 40; minArea = 30.; + nframes = 0; + bgBins = NULL; + bgModel = NULL; + persistenceMap = NULL; persistencePeriod = samplingPeriod*numSamples / 3.;//ms initial_tick_count = (double)getTickCount(); @@ -94,6 +98,10 @@ BackgroundSubtractorIMBS::BackgroundSubtractorIMBS( this->tau_s = tau_s; this->tau_h = tau_h; this->minArea = minArea; + nframes = 0; + bgBins = NULL; + bgModel = NULL; + persistenceMap = NULL; if (fps == 0.) initial_tick_count = (double)getTickCount(); -- GitLab