From d21861bbc7888f7988779bcb612e47f532957fcc Mon Sep 17 00:00:00 2001
From: Andrews Cordolino Sobral <andrewssobral@gmail.com>
Date: Sat, 4 Mar 2023 17:17:49 +0100
Subject: [PATCH] Enabled 9 algorithms compatible with OpenCV 4.x

---
 bgslibrary/algorithms/FuzzyChoquetIntegral.cpp  | 4 ----
 bgslibrary/algorithms/FuzzyChoquetIntegral.h    | 6 ------
 bgslibrary/algorithms/FuzzySugenoIntegral.cpp   | 4 ----
 bgslibrary/algorithms/FuzzySugenoIntegral.h     | 6 ------
 bgslibrary/algorithms/IndependentMultimodal.cpp | 4 ----
 bgslibrary/algorithms/IndependentMultimodal.h   | 6 ------
 bgslibrary/algorithms/KDE.cpp                   | 4 ----
 bgslibrary/algorithms/KDE.h                     | 6 ------
 bgslibrary/algorithms/LBAdaptiveSOM.cpp         | 4 ----
 bgslibrary/algorithms/LBAdaptiveSOM.h           | 6 ------
 bgslibrary/algorithms/LBFuzzyAdaptiveSOM.cpp    | 4 ----
 bgslibrary/algorithms/LBFuzzyAdaptiveSOM.h      | 6 ------
 bgslibrary/algorithms/LBFuzzyGaussian.cpp       | 4 ----
 bgslibrary/algorithms/LBFuzzyGaussian.h         | 6 ------
 bgslibrary/algorithms/LBSimpleGaussian.cpp      | 4 ----
 bgslibrary/algorithms/LBSimpleGaussian.h        | 6 ------
 bgslibrary/algorithms/VuMeter.cpp               | 4 ----
 bgslibrary/algorithms/VuMeter.h                 | 5 -----
 bgslibrary/algorithms/algorithms.h              | 2 +-
 bgslibrary/algorithms/lb/BGModelSom.h           | 6 +++---
 20 files changed, 4 insertions(+), 93 deletions(-)

diff --git a/bgslibrary/algorithms/FuzzyChoquetIntegral.cpp b/bgslibrary/algorithms/FuzzyChoquetIntegral.cpp
index 18494f8..09e3b68 100644
--- a/bgslibrary/algorithms/FuzzyChoquetIntegral.cpp
+++ b/bgslibrary/algorithms/FuzzyChoquetIntegral.cpp
@@ -1,7 +1,5 @@
 #include "FuzzyChoquetIntegral.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 FuzzyChoquetIntegral::FuzzyChoquetIntegral() :
@@ -189,5 +187,3 @@ void FuzzyChoquetIntegral::load_config(cv::FileStorage &fs) {
   fs["smooth"] >> smooth;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/FuzzyChoquetIntegral.h b/bgslibrary/algorithms/FuzzyChoquetIntegral.h
index bc8c408..ba4ae75 100644
--- a/bgslibrary/algorithms/FuzzyChoquetIntegral.h
+++ b/bgslibrary/algorithms/FuzzyChoquetIntegral.h
@@ -1,10 +1,6 @@
 #pragma once
 
 #include "IBGS.h"
-
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "../tools/FuzzyUtils.h"
 
 namespace bgslibrary
@@ -39,5 +35,3 @@ namespace bgslibrary
     bgs_register(FuzzyChoquetIntegral);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/FuzzySugenoIntegral.cpp b/bgslibrary/algorithms/FuzzySugenoIntegral.cpp
index ff03451..c4b96da 100644
--- a/bgslibrary/algorithms/FuzzySugenoIntegral.cpp
+++ b/bgslibrary/algorithms/FuzzySugenoIntegral.cpp
@@ -1,7 +1,5 @@
 #include "FuzzySugenoIntegral.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 FuzzySugenoIntegral::FuzzySugenoIntegral() :
@@ -188,5 +186,3 @@ void FuzzySugenoIntegral::load_config(cv::FileStorage &fs) {
   fs["smooth"] >> smooth;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/FuzzySugenoIntegral.h b/bgslibrary/algorithms/FuzzySugenoIntegral.h
index dbde2c3..0bb5490 100644
--- a/bgslibrary/algorithms/FuzzySugenoIntegral.h
+++ b/bgslibrary/algorithms/FuzzySugenoIntegral.h
@@ -1,10 +1,6 @@
 #pragma once
 
 #include "IBGS.h"
-
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "../tools/FuzzyUtils.h"
 
 namespace bgslibrary
@@ -39,5 +35,3 @@ namespace bgslibrary
     bgs_register(FuzzySugenoIntegral);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/IndependentMultimodal.cpp b/bgslibrary/algorithms/IndependentMultimodal.cpp
index 10d3cca..6297f01 100644
--- a/bgslibrary/algorithms/IndependentMultimodal.cpp
+++ b/bgslibrary/algorithms/IndependentMultimodal.cpp
@@ -1,7 +1,5 @@
 #include "IndependentMultimodal.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 IndependentMultimodal::IndependentMultimodal() : 
@@ -49,5 +47,3 @@ void IndependentMultimodal::load_config(cv::FileStorage &fs) {
   fs["fps"] >> fps;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/IndependentMultimodal.h b/bgslibrary/algorithms/IndependentMultimodal.h
index 0d05da2..3af489e 100644
--- a/bgslibrary/algorithms/IndependentMultimodal.h
+++ b/bgslibrary/algorithms/IndependentMultimodal.h
@@ -1,10 +1,6 @@
 #pragma once
 
 #include "IBGS.h"
-
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "IMBS/IMBS.hpp"
 
 namespace bgslibrary
@@ -31,5 +27,3 @@ namespace bgslibrary
     bgs_register(IndependentMultimodal);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/KDE.cpp b/bgslibrary/algorithms/KDE.cpp
index ac6832a..faca1ef 100644
--- a/bgslibrary/algorithms/KDE.cpp
+++ b/bgslibrary/algorithms/KDE.cpp
@@ -1,7 +1,5 @@
 #include "KDE.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 KDE::KDE() :
@@ -104,5 +102,3 @@ void KDE::load_config(cv::FileStorage &fs) {
   fs["alpha"] >> alpha;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/KDE.h b/bgslibrary/algorithms/KDE.h
index c5bfa05..acb7ace 100644
--- a/bgslibrary/algorithms/KDE.h
+++ b/bgslibrary/algorithms/KDE.h
@@ -1,10 +1,6 @@
 #pragma once
 
 #include "IBGS.h"
-
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "KDE/NPBGSubtractor.h"
 
 namespace bgslibrary
@@ -45,5 +41,3 @@ namespace bgslibrary
     bgs_register(KDE);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/LBAdaptiveSOM.cpp b/bgslibrary/algorithms/LBAdaptiveSOM.cpp
index 342d380..ba98689 100644
--- a/bgslibrary/algorithms/LBAdaptiveSOM.cpp
+++ b/bgslibrary/algorithms/LBAdaptiveSOM.cpp
@@ -1,7 +1,5 @@
 #include "LBAdaptiveSOM.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 LBAdaptiveSOM::LBAdaptiveSOM() :
@@ -76,5 +74,3 @@ void LBAdaptiveSOM::load_config(cv::FileStorage &fs) {
   fs["trainingSteps"] >> trainingSteps;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/LBAdaptiveSOM.h b/bgslibrary/algorithms/LBAdaptiveSOM.h
index 97ba8e2..9faed79 100644
--- a/bgslibrary/algorithms/LBAdaptiveSOM.h
+++ b/bgslibrary/algorithms/LBAdaptiveSOM.h
@@ -1,10 +1,6 @@
 #pragma once
 
 #include "IBGS.h"
-
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "lb/BGModelSom.h"
 
 namespace bgslibrary
@@ -35,5 +31,3 @@ namespace bgslibrary
     bgs_register(LBAdaptiveSOM);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/LBFuzzyAdaptiveSOM.cpp b/bgslibrary/algorithms/LBFuzzyAdaptiveSOM.cpp
index 78d7121..e907f7c 100644
--- a/bgslibrary/algorithms/LBFuzzyAdaptiveSOM.cpp
+++ b/bgslibrary/algorithms/LBFuzzyAdaptiveSOM.cpp
@@ -1,7 +1,5 @@
 #include "LBFuzzyAdaptiveSOM.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 LBFuzzyAdaptiveSOM::LBFuzzyAdaptiveSOM() :
@@ -75,5 +73,3 @@ void LBFuzzyAdaptiveSOM::load_config(cv::FileStorage &fs) {
   fs["trainingSteps"] >> trainingSteps;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/LBFuzzyAdaptiveSOM.h b/bgslibrary/algorithms/LBFuzzyAdaptiveSOM.h
index c819b59..02bc24d 100644
--- a/bgslibrary/algorithms/LBFuzzyAdaptiveSOM.h
+++ b/bgslibrary/algorithms/LBFuzzyAdaptiveSOM.h
@@ -1,10 +1,6 @@
 #pragma once
 
 #include "IBGS.h"
-
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "lb/BGModelFuzzySom.h"
 
 namespace bgslibrary
@@ -35,5 +31,3 @@ namespace bgslibrary
     bgs_register(LBFuzzyAdaptiveSOM);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/LBFuzzyGaussian.cpp b/bgslibrary/algorithms/LBFuzzyGaussian.cpp
index 2dd081d..a2846a1 100644
--- a/bgslibrary/algorithms/LBFuzzyGaussian.cpp
+++ b/bgslibrary/algorithms/LBFuzzyGaussian.cpp
@@ -1,7 +1,5 @@
 #include "LBFuzzyGaussian.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 LBFuzzyGaussian::LBFuzzyGaussian() :
@@ -72,5 +70,3 @@ void LBFuzzyGaussian::load_config(cv::FileStorage &fs) {
   fs["noiseVariance"] >> noiseVariance;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/LBFuzzyGaussian.h b/bgslibrary/algorithms/LBFuzzyGaussian.h
index 84e9656..549b098 100644
--- a/bgslibrary/algorithms/LBFuzzyGaussian.h
+++ b/bgslibrary/algorithms/LBFuzzyGaussian.h
@@ -1,10 +1,6 @@
 #pragma once
 
 #include "IBGS.h"
-
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "lb/BGModelFuzzyGauss.h"
 
 namespace bgslibrary
@@ -34,5 +30,3 @@ namespace bgslibrary
     bgs_register(LBFuzzyGaussian);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/LBSimpleGaussian.cpp b/bgslibrary/algorithms/LBSimpleGaussian.cpp
index c9271bf..65e638f 100644
--- a/bgslibrary/algorithms/LBSimpleGaussian.cpp
+++ b/bgslibrary/algorithms/LBSimpleGaussian.cpp
@@ -1,7 +1,5 @@
 #include "LBSimpleGaussian.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 LBSimpleGaussian::LBSimpleGaussian() :
@@ -68,5 +66,3 @@ void LBSimpleGaussian::load_config(cv::FileStorage &fs) {
   fs["learningRate"] >> learningRate;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/LBSimpleGaussian.h b/bgslibrary/algorithms/LBSimpleGaussian.h
index f7c2d39..e06762b 100644
--- a/bgslibrary/algorithms/LBSimpleGaussian.h
+++ b/bgslibrary/algorithms/LBSimpleGaussian.h
@@ -1,10 +1,6 @@
 #pragma once
 
 #include "IBGS.h"
-
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "lb/BGModelGauss.h"
 
 namespace bgslibrary
@@ -33,5 +29,3 @@ namespace bgslibrary
     bgs_register(LBSimpleGaussian);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/VuMeter.cpp b/bgslibrary/algorithms/VuMeter.cpp
index 0321015..e480343 100644
--- a/bgslibrary/algorithms/VuMeter.cpp
+++ b/bgslibrary/algorithms/VuMeter.cpp
@@ -1,7 +1,5 @@
 #include "VuMeter.h"
 
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-
 using namespace bgslibrary::algorithms;
 
 VuMeter::VuMeter() :
@@ -85,5 +83,3 @@ void VuMeter::load_config(cv::FileStorage &fs) {
   fs["threshold"] >> threshold;
   fs["showOutput"] >> showOutput;
 }
-
-#endif
diff --git a/bgslibrary/algorithms/VuMeter.h b/bgslibrary/algorithms/VuMeter.h
index 1157e4d..b1992e9 100644
--- a/bgslibrary/algorithms/VuMeter.h
+++ b/bgslibrary/algorithms/VuMeter.h
@@ -1,8 +1,5 @@
 #pragma once
 
-#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
-
 #include "IBGS.h"
 #include "VuMeter/TBackgroundVuMeter.h"
 
@@ -37,5 +34,3 @@ namespace bgslibrary
     bgs_register(VuMeter);
   }
 }
-
-#endif
diff --git a/bgslibrary/algorithms/algorithms.h b/bgslibrary/algorithms/algorithms.h
index 03d0527..4a59bfa 100644
--- a/bgslibrary/algorithms/algorithms.h
+++ b/bgslibrary/algorithms/algorithms.h
@@ -44,6 +44,6 @@
 #include "ViBe.h"
 #include "CodeBook.h"
 
-//#include "_template_/MyBGS.h"
+// #include "_template_/MyBGS.h"
 
 using namespace bgslibrary::algorithms;
diff --git a/bgslibrary/algorithms/lb/BGModelSom.h b/bgslibrary/algorithms/lb/BGModelSom.h
index 9774fca..6020537 100644
--- a/bgslibrary/algorithms/lb/BGModelSom.h
+++ b/bgslibrary/algorithms/lb/BGModelSom.h
@@ -12,7 +12,7 @@ namespace bgslibrary
         const int M = 3;         // width SOM (per pixel)
         const int N = 3;         // height SOM (per pixel)
         const int KERNEL = 3;    // size Gaussian kernel
-        const bool SPAN_NEIGHBORS = false; // true if update neighborhood spans different pixels			//
+        const bool SPAN_NEIGHBORS = false; // true if update neighborhood spans different pixels
         const int TRAINING_STEPS = 100;    // number of training steps
         const float EPS1 = 100.0; // model match distance during training
         const float EPS2 = 20.0;  // model match distance
@@ -43,8 +43,8 @@ namespace bgslibrary
         double m_alpha1;
         double m_alpha2;
 
-        DBLRGB** m_ppSOM;					// SOM grid
-        double** m_ppW;						// Weights
+        DBLRGB** m_ppSOM; // SOM grid
+        double** m_ppW; // Weights
 
         void Init();
         void Update();
-- 
GitLab