From f65078c621dfa70258b513a28eb8810b714ec07b Mon Sep 17 00:00:00 2001
From: Andrews Sobral <andrewssobral@gmail.com>
Date: Tue, 11 Sep 2018 00:00:24 +0200
Subject: [PATCH] fixed macro preprocessor for GMG method
---
FrameProcessor.cpp | 12 ++++++------
FrameProcessor.h | 2 +-
package_bgs/GMG.cpp | 2 +-
package_bgs/GMG.h | 2 +-
wrapper_python/bgslibrary_module.cpp | 2 +-
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/FrameProcessor.cpp b/FrameProcessor.cpp
index fb9445c..ca70d46 100644
--- a/FrameProcessor.cpp
+++ b/FrameProcessor.cpp
@@ -60,7 +60,7 @@ namespace bgslibrary
if (enableAdaptiveBackgroundLearning)
adaptiveBackgroundLearning = new AdaptiveBackgroundLearning;
-#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
if (enableGMG)
gmg = new GMG;
#endif
@@ -215,7 +215,7 @@ namespace bgslibrary
if (enableAdaptiveBackgroundLearning)
process("AdaptiveBackgroundLearning", adaptiveBackgroundLearning, img_preProcessor, img_adaptiveBackgroundLearning);
-#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
if (enableGMG)
process("GMG", gmg, img_preProcessor, img_gmg);
#endif
@@ -342,7 +342,7 @@ namespace bgslibrary
#endif
foregroundMaskAnalysis->process(frameNumber, "MixtureOfGaussianV2", img_mixtureOfGaussianV2);
foregroundMaskAnalysis->process(frameNumber, "AdaptiveBackgroundLearning", img_adaptiveBackgroundLearning);
-#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
foregroundMaskAnalysis->process(frameNumber, "GMG", img_gmg);
#endif
#if CV_MAJOR_VERSION >= 3
@@ -508,7 +508,7 @@ namespace bgslibrary
if (enableDPAdaptiveMedian)
delete dpAdaptiveMedian;
-#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
if (enableGMG)
delete gmg;
#endif
@@ -576,7 +576,7 @@ namespace bgslibrary
#endif
cvWriteInt(fs, "enableMixtureOfGaussianV2", enableMixtureOfGaussianV2);
cvWriteInt(fs, "enableAdaptiveBackgroundLearning", enableAdaptiveBackgroundLearning);
-#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
cvWriteInt(fs, "enableGMG", enableGMG);
#endif
#if CV_MAJOR_VERSION >= 3
@@ -642,7 +642,7 @@ namespace bgslibrary
#endif
enableMixtureOfGaussianV2 = cvReadIntByName(fs, 0, "enableMixtureOfGaussianV2", false);
enableAdaptiveBackgroundLearning = cvReadIntByName(fs, 0, "enableAdaptiveBackgroundLearning", false);
-#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
enableGMG = cvReadIntByName(fs, 0, "enableGMG", false);
#endif
#if CV_MAJOR_VERSION >= 3
diff --git a/FrameProcessor.h b/FrameProcessor.h
index 7bf688e..9f59f4f 100644
--- a/FrameProcessor.h
+++ b/FrameProcessor.h
@@ -69,7 +69,7 @@ namespace bgslibrary
AdaptiveBackgroundLearning* adaptiveBackgroundLearning;
bool enableAdaptiveBackgroundLearning;
-#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
cv::Mat img_gmg;
GMG* gmg;
bool enableGMG;
diff --git a/package_bgs/GMG.cpp b/package_bgs/GMG.cpp
index 19bd8ab..8fdc5a4 100644
--- a/package_bgs/GMG.cpp
+++ b/package_bgs/GMG.cpp
@@ -16,7 +16,7 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GMG.h"
-#if CV_MAJOR_VERSION == 2
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
using namespace bgslibrary::algorithms;
diff --git a/package_bgs/GMG.h b/package_bgs/GMG.h
index 1b4af30..0ff89c7 100644
--- a/package_bgs/GMG.h
+++ b/package_bgs/GMG.h
@@ -17,7 +17,7 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "opencv2/core/version.hpp"
-#if CV_MAJOR_VERSION == 2
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
#include "IBGS.h"
diff --git a/wrapper_python/bgslibrary_module.cpp b/wrapper_python/bgslibrary_module.cpp
index 893591a..ef09aae 100644
--- a/wrapper_python/bgslibrary_module.cpp
+++ b/wrapper_python/bgslibrary_module.cpp
@@ -207,7 +207,7 @@ PYBIND11_MODULE(bgs, m)
.def("getBackgroundModel", &LOBSTER::getBackgroundModel)
;
-#if CV_MAJOR_VERSION == 2
+#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
py::class_<MixtureOfGaussianV1>(m, "MixtureOfGaussianV1")
.def(py::init<>())
.def("apply", &MixtureOfGaussianV1::apply)
--
GitLab