From be92256a44ab856bbdadf9dbaa0a0bfad1959654 Mon Sep 17 00:00:00 2001
From: Andrews Cordolino Sobral <andrewssobral@gmail.com>
Date: Sun, 31 Jul 2022 13:33:13 +0200
Subject: [PATCH] [important] Fixed memory leak on  LB* algorithms

5 algorithms: LBAdaptiveSOM, LBFuzzyAdaptiveSOM, LBFuzzyGaussian, LBMixtureOfGaussians,LBSimpleGaussian
---
 src/algorithms/LBAdaptiveSOM.cpp        | 1 +
 src/algorithms/LBFuzzyAdaptiveSOM.cpp   | 1 +
 src/algorithms/LBFuzzyGaussian.cpp      | 1 +
 src/algorithms/LBMixtureOfGaussians.cpp | 1 +
 src/algorithms/LBSimpleGaussian.cpp     | 1 +
 5 files changed, 5 insertions(+)

diff --git a/src/algorithms/LBAdaptiveSOM.cpp b/src/algorithms/LBAdaptiveSOM.cpp
index afc0292..342d380 100644
--- a/src/algorithms/LBAdaptiveSOM.cpp
+++ b/src/algorithms/LBAdaptiveSOM.cpp
@@ -54,6 +54,7 @@ void LBAdaptiveSOM::process(const cv::Mat &img_input, cv::Mat &img_output, cv::M
 
   img_foreground.copyTo(img_output);
   img_background.copyTo(img_bgmodel);
+  cvReleaseImage(&frame);
 
   firstTime = false;
 }
diff --git a/src/algorithms/LBFuzzyAdaptiveSOM.cpp b/src/algorithms/LBFuzzyAdaptiveSOM.cpp
index 00047af..78d7121 100644
--- a/src/algorithms/LBFuzzyAdaptiveSOM.cpp
+++ b/src/algorithms/LBFuzzyAdaptiveSOM.cpp
@@ -53,6 +53,7 @@ void LBFuzzyAdaptiveSOM::process(const cv::Mat &img_input, cv::Mat &img_output,
 
   img_foreground.copyTo(img_output);
   img_background.copyTo(img_bgmodel);
+  cvReleaseImage(&frame);
 
   firstTime = false;
 }
diff --git a/src/algorithms/LBFuzzyGaussian.cpp b/src/algorithms/LBFuzzyGaussian.cpp
index 00f3fef..2dd081d 100644
--- a/src/algorithms/LBFuzzyGaussian.cpp
+++ b/src/algorithms/LBFuzzyGaussian.cpp
@@ -52,6 +52,7 @@ void LBFuzzyGaussian::process(const cv::Mat &img_input, cv::Mat &img_output, cv:
 
   img_foreground.copyTo(img_output);
   img_background.copyTo(img_bgmodel);
+  cvReleaseImage(&frame);
 
   firstTime = false;
 }
diff --git a/src/algorithms/LBMixtureOfGaussians.cpp b/src/algorithms/LBMixtureOfGaussians.cpp
index 82d9f1e..eaa2709 100644
--- a/src/algorithms/LBMixtureOfGaussians.cpp
+++ b/src/algorithms/LBMixtureOfGaussians.cpp
@@ -52,6 +52,7 @@ void LBMixtureOfGaussians::process(const cv::Mat &img_input, cv::Mat &img_output
 
   img_foreground.copyTo(img_output);
   img_background.copyTo(img_bgmodel);
+  cvReleaseImage(&frame);
 
   firstTime = false;
 }
diff --git a/src/algorithms/LBSimpleGaussian.cpp b/src/algorithms/LBSimpleGaussian.cpp
index 5df2c81..c9271bf 100644
--- a/src/algorithms/LBSimpleGaussian.cpp
+++ b/src/algorithms/LBSimpleGaussian.cpp
@@ -50,6 +50,7 @@ void LBSimpleGaussian::process(const cv::Mat &img_input, cv::Mat &img_output, cv
 
   img_foreground.copyTo(img_output);
   img_background.copyTo(img_bgmodel);
+  cvReleaseImage(&frame);
 
   firstTime = false;
 }
-- 
GitLab