diff --git a/src/algorithms/DPAdaptiveMedian.h b/src/algorithms/DPAdaptiveMedian.h
index 9d00cea0c9998764dcc4702778f33f03fec34d97..df8e7163a6cbc5e04e7e671574b0ccd3cf36da47 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 6db3de41846e69bdd973be3ec8daffd4576e7506..cb86aadae76643dc25739baca0a9e9572c4e55bd 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 95167384d28df4e409aee9078501520a18310c88..d95c8d68c9c6effa8b50099d88eb5b76a022a5e1 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 e251b7ab425965d9fbb0046eeeda44301a00fe21..f2b212004c3732b3c9e2dc84065d1577e5e2d9e6 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 e0098d45fb995e73ae5344b1b7fa92a453045e02..a340b6312f4e1f1e88063145ee1a67059ca2ce1b 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 b78dffeca593a7fae41486d9262b4248eb0ffc9e..14c1cb03fc045c93992624aaa5fa887dc426842b 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 4aa191935b1c60424ccbb5c5f18b93085dac1022..837d4adef67454bcd2a2414b6d2c320f6c293924 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 3b2ddd97829a8b6dbf2cfacb12605f1439ad5cce..df5d22b7ed7d142abf797779e49cd514cfeb0d49 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 992f65148b61a15579b020a3f69aa6679920a3e0..bc8c408349524fe0d400c2f6fa856aca25f6282d 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 fefd11be42bcea2e44d7045971d1ec155d1c3827..dbde2c36a3de96cee7f811539d43e6e8eda2a34a 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 6dc654da5e02dcca98f2121a36090cbbf7bb06a0..0d05da265c0d37bdcdaa5c0530e213faf261145a 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 d0eee8ab46be6fd7a5acd3536013e8f6da205ca0..c5bfa05f1098bb91eb02be0476a1ed6e05bfe3ac 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 7141f91e0fcda5cd0b831c28883835a111774cb7..97ba8e280d3abb026023f1055a0d28d8cfa6f316 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 9c45382913d35ca941b05f2cc29be89b1216fb6c..c819b59e9eaf9689c12ebefb150f7f31807ecd21 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 3725fda48aff1e7641d85e28d4d514a2883f36a6..84e965655f93504eae2c5ed2e320c969cca313fc 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 b4211561ba04442c6b5ed0a6effd43b4fa6821bb..4454adfc7ef6fc3500c7f4a79134b0edc0ef48b8 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 b7a26c26f09d69d11f9c296f97bce0ee8b20f515..961529b0f6bd37bb1f0db0d93bfee43570fbea2c 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 b41d54d7be4287d30464105ccee56bfc7b95ad45..f7c2d392c67ba7d5f23d2a797507d4703acee132 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 ca75a50eff404f33b9d4ae924114e47149b84f24..a31124cfac6ec33b7995fbb85927c3465d2d9252 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 9392e7d262a65e8cbf3c95749c66db881e023b6c..c4ffdabeac1c59e21d1cdf7140fe9021e2a62c2e 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 8221e66aaecaefd8285d9698454dd83175c89b90..0ea8aeac4b6b2e7b8d7747cc15ac041fb9f60292 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 627c423a248c372813c8b02562d238db532b5bbf..60ecf293e59322bf255db3b3d65c08e6db9ed477 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 6a3b1d95ea810d0efb1121589b210f15bf97bdd6..e290dea6047a1720d91ea7cc2f899a019104e30d 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 062cf97f300ab5b87b303bf516bc832b3588172d..7d91982240d2d93e81999e7758445b6057f56658 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 50f62382940346b47852384654c2519b906e369a..1157e4d55e4ef2b06bbd8cd11dae46554645b4be 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 0db7953baeb2624b1ad48b86c3065dbe97b03a6a..03d0527e077fe53dcd4e1bf0834f4a9576ac6f83 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"