From 05f54e6d2977de474d8209d91fc463a8aa4c866a Mon Sep 17 00:00:00 2001
From: Andrews Cordolino Sobral <andrewssobral@gmail.com>
Date: Wed, 20 Jul 2022 01:26:59 +0200
Subject: [PATCH] Updated opencv compatibility of the bgs algorithms

---
 src/algorithms/DPAdaptiveMedian.h      |  2 +-
 src/algorithms/DPEigenbackground.h     |  2 +-
 src/algorithms/DPGrimsonGMM.h          |  2 +-
 src/algorithms/DPMean.h                |  2 +-
 src/algorithms/DPPratiMediod.h         |  2 +-
 src/algorithms/DPTexture.h             |  2 +-
 src/algorithms/DPWrenGA.h              |  2 +-
 src/algorithms/DPZivkovicAGMM.h        |  2 +-
 src/algorithms/FuzzyChoquetIntegral.h  |  2 +-
 src/algorithms/FuzzySugenoIntegral.h   |  2 +-
 src/algorithms/IndependentMultimodal.h |  2 +-
 src/algorithms/KDE.h                   |  2 +-
 src/algorithms/LBAdaptiveSOM.h         |  2 +-
 src/algorithms/LBFuzzyAdaptiveSOM.h    |  2 +-
 src/algorithms/LBFuzzyGaussian.h       |  2 +-
 src/algorithms/LBMixtureOfGaussians.h  |  2 +-
 src/algorithms/LBP_MRF.h               |  2 +-
 src/algorithms/LBSimpleGaussian.h      |  2 +-
 src/algorithms/MultiCue.h              |  2 +-
 src/algorithms/MultiLayer.h            |  2 +-
 src/algorithms/T2FGMM_UM.h             |  2 +-
 src/algorithms/T2FGMM_UV.h             |  2 +-
 src/algorithms/T2FMRF_UM.h             |  2 +-
 src/algorithms/T2FMRF_UV.h             |  2 +-
 src/algorithms/VuMeter.h               |  2 +-
 src/algorithms/algorithms.h            | 52 +++++++++++++-------------
 26 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/src/algorithms/DPAdaptiveMedian.h b/src/algorithms/DPAdaptiveMedian.h
index 9d00cea..df8e716 100644
--- a/src/algorithms/DPAdaptiveMedian.h
+++ b/src/algorithms/DPAdaptiveMedian.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "IBGS.h"
 #include "dp/AdaptiveMedianBGS.h"
diff --git a/src/algorithms/DPEigenbackground.h b/src/algorithms/DPEigenbackground.h
index 6db3de4..cb86aad 100644
--- a/src/algorithms/DPEigenbackground.h
+++ b/src/algorithms/DPEigenbackground.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "dp/Eigenbackground.h"
 
diff --git a/src/algorithms/DPGrimsonGMM.h b/src/algorithms/DPGrimsonGMM.h
index 9516738..d95c8d6 100644
--- a/src/algorithms/DPGrimsonGMM.h
+++ b/src/algorithms/DPGrimsonGMM.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "dp/GrimsonGMM.h"
 
diff --git a/src/algorithms/DPMean.h b/src/algorithms/DPMean.h
index e251b7a..f2b2120 100644
--- a/src/algorithms/DPMean.h
+++ b/src/algorithms/DPMean.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "dp/MeanBGS.h"
 
diff --git a/src/algorithms/DPPratiMediod.h b/src/algorithms/DPPratiMediod.h
index e0098d4..a340b63 100644
--- a/src/algorithms/DPPratiMediod.h
+++ b/src/algorithms/DPPratiMediod.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "dp/PratiMediodBGS.h"
 
diff --git a/src/algorithms/DPTexture.h b/src/algorithms/DPTexture.h
index b78dffe..14c1cb0 100644
--- a/src/algorithms/DPTexture.h
+++ b/src/algorithms/DPTexture.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 // opencv legacy includes
 #include "opencv2/core/core_c.h"
diff --git a/src/algorithms/DPWrenGA.h b/src/algorithms/DPWrenGA.h
index 4aa1919..837d4ad 100644
--- a/src/algorithms/DPWrenGA.h
+++ b/src/algorithms/DPWrenGA.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "dp/WrenGA.h"
 
diff --git a/src/algorithms/DPZivkovicAGMM.h b/src/algorithms/DPZivkovicAGMM.h
index 3b2ddd9..df5d22b 100644
--- a/src/algorithms/DPZivkovicAGMM.h
+++ b/src/algorithms/DPZivkovicAGMM.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "dp/ZivkovicAGMM.h"
 
diff --git a/src/algorithms/FuzzyChoquetIntegral.h b/src/algorithms/FuzzyChoquetIntegral.h
index 992f651..bc8c408 100644
--- a/src/algorithms/FuzzyChoquetIntegral.h
+++ b/src/algorithms/FuzzyChoquetIntegral.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "../tools/FuzzyUtils.h"
 
diff --git a/src/algorithms/FuzzySugenoIntegral.h b/src/algorithms/FuzzySugenoIntegral.h
index fefd11b..dbde2c3 100644
--- a/src/algorithms/FuzzySugenoIntegral.h
+++ b/src/algorithms/FuzzySugenoIntegral.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "../tools/FuzzyUtils.h"
 
diff --git a/src/algorithms/IndependentMultimodal.h b/src/algorithms/IndependentMultimodal.h
index 6dc654d..0d05da2 100644
--- a/src/algorithms/IndependentMultimodal.h
+++ b/src/algorithms/IndependentMultimodal.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "IMBS/IMBS.hpp"
 
diff --git a/src/algorithms/KDE.h b/src/algorithms/KDE.h
index d0eee8a..c5bfa05 100644
--- a/src/algorithms/KDE.h
+++ b/src/algorithms/KDE.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "KDE/NPBGSubtractor.h"
 
diff --git a/src/algorithms/LBAdaptiveSOM.h b/src/algorithms/LBAdaptiveSOM.h
index 7141f91..97ba8e2 100644
--- a/src/algorithms/LBAdaptiveSOM.h
+++ b/src/algorithms/LBAdaptiveSOM.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "lb/BGModelSom.h"
 
diff --git a/src/algorithms/LBFuzzyAdaptiveSOM.h b/src/algorithms/LBFuzzyAdaptiveSOM.h
index 9c45382..c819b59 100644
--- a/src/algorithms/LBFuzzyAdaptiveSOM.h
+++ b/src/algorithms/LBFuzzyAdaptiveSOM.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "lb/BGModelFuzzySom.h"
 
diff --git a/src/algorithms/LBFuzzyGaussian.h b/src/algorithms/LBFuzzyGaussian.h
index 3725fda..84e9656 100644
--- a/src/algorithms/LBFuzzyGaussian.h
+++ b/src/algorithms/LBFuzzyGaussian.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "lb/BGModelFuzzyGauss.h"
 
diff --git a/src/algorithms/LBMixtureOfGaussians.h b/src/algorithms/LBMixtureOfGaussians.h
index b421156..4454adf 100644
--- a/src/algorithms/LBMixtureOfGaussians.h
+++ b/src/algorithms/LBMixtureOfGaussians.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "lb/BGModelMog.h"
 
diff --git a/src/algorithms/LBP_MRF.h b/src/algorithms/LBP_MRF.h
index b7a26c2..961529b 100644
--- a/src/algorithms/LBP_MRF.h
+++ b/src/algorithms/LBP_MRF.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3 && CV_MINOR_VERSION <= 4 && CV_VERSION_REVISION <= 7
+#if (CV_MAJOR_VERSION == 2) || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION <= 4 && CV_VERSION_REVISION <= 7)
 
 #include "LBP_MRF/MotionDetection.hpp"
 
diff --git a/src/algorithms/LBSimpleGaussian.h b/src/algorithms/LBSimpleGaussian.h
index b41d54d..f7c2d39 100644
--- a/src/algorithms/LBSimpleGaussian.h
+++ b/src/algorithms/LBSimpleGaussian.h
@@ -3,7 +3,7 @@
 #include "IBGS.h"
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "lb/BGModelGauss.h"
 
diff --git a/src/algorithms/MultiCue.h b/src/algorithms/MultiCue.h
index ca75a50..a31124c 100644
--- a/src/algorithms/MultiCue.h
+++ b/src/algorithms/MultiCue.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #if !defined(__APPLE__)
 #include <malloc.h>
diff --git a/src/algorithms/MultiLayer.h b/src/algorithms/MultiLayer.h
index 9392e7d..c4ffdab 100644
--- a/src/algorithms/MultiLayer.h
+++ b/src/algorithms/MultiLayer.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3 && CV_MINOR_VERSION <= 4 && CV_VERSION_REVISION <= 7
+#if (CV_MAJOR_VERSION == 2) || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION <= 4 && CV_VERSION_REVISION <= 7)
 
 #include "IBGS.h"
 #include "MultiLayer/CMultiLayerBGS.h"
diff --git a/src/algorithms/T2FGMM_UM.h b/src/algorithms/T2FGMM_UM.h
index 8221e66..0ea8aea 100644
--- a/src/algorithms/T2FGMM_UM.h
+++ b/src/algorithms/T2FGMM_UM.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "IBGS.h"
 #include "T2F/T2FGMM.h"
diff --git a/src/algorithms/T2FGMM_UV.h b/src/algorithms/T2FGMM_UV.h
index 627c423..60ecf29 100644
--- a/src/algorithms/T2FGMM_UV.h
+++ b/src/algorithms/T2FGMM_UV.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "IBGS.h"
 #include "T2F/T2FGMM.h"
diff --git a/src/algorithms/T2FMRF_UM.h b/src/algorithms/T2FMRF_UM.h
index 6a3b1d9..e290dea 100644
--- a/src/algorithms/T2FMRF_UM.h
+++ b/src/algorithms/T2FMRF_UM.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "IBGS.h"
 #include "T2F/MRF.h"
diff --git a/src/algorithms/T2FMRF_UV.h b/src/algorithms/T2FMRF_UV.h
index 062cf97..7d91982 100644
--- a/src/algorithms/T2FMRF_UV.h
+++ b/src/algorithms/T2FMRF_UV.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "IBGS.h"
 #include "T2F/MRF.h"
diff --git a/src/algorithms/VuMeter.h b/src/algorithms/VuMeter.h
index 50f6238..1157e4d 100644
--- a/src/algorithms/VuMeter.h
+++ b/src/algorithms/VuMeter.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+#if CV_MAJOR_VERSION == 2 || CV_MAJOR_VERSION == 3
 
 #include "IBGS.h"
 #include "VuMeter/TBackgroundVuMeter.h"
diff --git a/src/algorithms/algorithms.h b/src/algorithms/algorithms.h
index 0db7953..03d0527 100644
--- a/src/algorithms/algorithms.h
+++ b/src/algorithms/algorithms.h
@@ -9,33 +9,33 @@
 #include "AdaptiveBackgroundLearning.h"
 #include "AdaptiveSelectiveBackgroundLearning.h"
 #include "KNN.h" // Only for OpenCV >= 3
-#include "GMG.h" // Only for OpenCV >= 2.4.3
-#include "DPAdaptiveMedian.h"
-#include "DPGrimsonGMM.h"
-#include "DPZivkovicAGMM.h"
-#include "DPMean.h"
-#include "DPWrenGA.h"
-#include "DPPratiMediod.h"
-#include "DPEigenbackground.h"
-#include "DPTexture.h"
-#include "T2FGMM_UM.h"
-#include "T2FGMM_UV.h"
-#include "T2FMRF_UM.h"
-#include "T2FMRF_UV.h"
-#include "FuzzySugenoIntegral.h"
-#include "FuzzyChoquetIntegral.h"
-#include "LBSimpleGaussian.h"
-#include "LBFuzzyGaussian.h"
-#include "LBMixtureOfGaussians.h"
-#include "LBAdaptiveSOM.h"
-#include "LBFuzzyAdaptiveSOM.h"
-#include "LBP_MRF.h"
-#include "MultiLayer.h"
+#include "GMG.h" // Only for OpenCV >= 2.4.3 and OpenCV < 3
+#include "DPAdaptiveMedian.h" // Only for OpenCV 2 or 3
+#include "DPGrimsonGMM.h" // Only for OpenCV 2 or 3
+#include "DPZivkovicAGMM.h" // Only for OpenCV 2 or 3
+#include "DPMean.h" // Only for OpenCV 2 or 3
+#include "DPWrenGA.h" // Only for OpenCV 2 or 3
+#include "DPPratiMediod.h" // Only for OpenCV 2 or 3
+#include "DPEigenbackground.h" // Only for OpenCV 2 or 3
+#include "DPTexture.h" // Only for OpenCV 2 or 3
+#include "T2FGMM_UM.h" // Only for OpenCV 2 or 3
+#include "T2FGMM_UV.h" // Only for OpenCV 2 or 3
+#include "T2FMRF_UM.h" // Only for OpenCV 2 or 3
+#include "T2FMRF_UV.h" // Only for OpenCV 2 or 3
+#include "FuzzySugenoIntegral.h" // Only for OpenCV 2 or 3
+#include "FuzzyChoquetIntegral.h" // Only for OpenCV 2 or 3
+#include "LBSimpleGaussian.h" // Only for OpenCV 2 or 3
+#include "LBFuzzyGaussian.h" // Only for OpenCV 2 or 3
+#include "LBMixtureOfGaussians.h" // Only for OpenCV 2 or 3
+#include "LBAdaptiveSOM.h" // Only for OpenCV 2 or 3
+#include "LBFuzzyAdaptiveSOM.h" // Only for OpenCV 2 or 3
+#include "LBP_MRF.h" // Only for OpenCV 2 or OpenCV <= 3.4.7
+#include "MultiLayer.h" // Only for OpenCV 2 or OpenCV <= 3.4.7
 #include "PixelBasedAdaptiveSegmenter.h"
-#include "VuMeter.h"
-#include "KDE.h"
-#include "IndependentMultimodal.h"
-#include "MultiCue.h"
+#include "VuMeter.h" // Only for OpenCV 2 or 3
+#include "KDE.h" // Only for OpenCV 2 or 3
+#include "IndependentMultimodal.h" // Only for OpenCV 2 or 3
+#include "MultiCue.h" // Only for OpenCV 2 or 3
 #include "SigmaDelta.h"
 #include "SuBSENSE.h"
 #include "LOBSTER.h"
-- 
GitLab