From 5ed8f7797b543bd42511a19e7e4c1716eaf4e798 Mon Sep 17 00:00:00 2001
From: Holger Friedrich <friedrich@fias.uni-frankfurt.de>
Date: Tue, 22 Jul 2014 14:04:54 +0200
Subject: [PATCH] remove opencv1 dependencies. bgslib now compiles on Linux
 systems without libcv-dev installed. Almost all calls and incudes have been
 ported to opencv2, some are still used via opencv2/legacy/compat.hpp (e.g.
 cvFillImage). Hope I got everything fine also for mingw since I removed two
 mingw related defines. I don't have a mingw install to check it against.

---
 Demo.cpp                                          |  4 ++--
 Demo2.cpp                                         |  4 ++--
 FrameProcessor.cpp                                |  1 +
 IFrameProcessor.h                                 |  2 +-
 PreProcessor.h                                    |  4 ++--
 VideoCapture.h                                    |  4 ++--
 demos/DemoFrameDifferenceBGS.cpp                  |  4 ++--
 demos/DemoMultiLayerBGS.cpp                       |  4 ++--
 package_analysis/ForegroundMaskAnalysis.h         |  4 ++--
 package_bgs/AdaptiveBackgroundLearning.h          |  4 ++--
 package_bgs/AdaptiveSelectiveBackgroundLearning.h |  4 ++--
 package_bgs/FrameDifferenceBGS.h                  |  4 ++--
 package_bgs/IBGS.h                                |  2 +-
 package_bgs/MixtureOfGaussianV1BGS.h              |  4 ++--
 package_bgs/MixtureOfGaussianV2BGS.h              |  4 ++--
 package_bgs/StaticFrameDifferenceBGS.h            |  4 ++--
 package_bgs/WeightedMovingMeanBGS.h               |  4 ++--
 package_bgs/WeightedMovingVarianceBGS.h           |  4 ++--
 package_bgs/ae/KDE.h                              |  4 ++--
 package_bgs/av/TBackground.cpp                    |  8 ++++----
 package_bgs/av/TBackground.h                      |  4 ++--
 package_bgs/av/TBackgroundVuMeter.cpp             | 10 +++++-----
 package_bgs/av/VuMeter.h                          |  4 ++--
 package_bgs/bl/SigmaDeltaBGS.h                    |  4 ++--
 package_bgs/ck/MEHistogram.cpp                    |  6 +-----
 package_bgs/ck/MEImage.cpp                        |  8 +-------
 package_bgs/ck/MotionDetection.cpp                |  6 +-----
 package_bgs/db/IndependentMultimodalBGS.h         |  4 ++--
 package_bgs/dp/DPAdaptiveMedianBGS.h              |  4 ++--
 package_bgs/dp/DPEigenbackgroundBGS.h             |  4 ++--
 package_bgs/dp/DPGrimsonGMMBGS.h                  |  4 ++--
 package_bgs/dp/DPMeanBGS.h                        |  4 ++--
 package_bgs/dp/DPPratiMediodBGS.h                 |  4 ++--
 package_bgs/dp/DPTextureBGS.h                     |  4 ++--
 package_bgs/dp/DPWrenGABGS.h                      |  4 ++--
 package_bgs/dp/DPZivkovicAGMMBGS.h                |  4 ++--
 package_bgs/dp/Image.h                            |  6 +++---
 package_bgs/jmo/BGS.h                             |  2 +-
 package_bgs/jmo/BackgroundSubtractionAPI.h        |  2 +-
 package_bgs/jmo/BlobExtraction.cpp                |  1 +
 package_bgs/jmo/BlobResult.h                      |  3 ++-
 package_bgs/jmo/CMultiLayerBGS.cpp                |  1 +
 package_bgs/jmo/LocalBinaryPattern.h              |  2 +-
 package_bgs/jmo/MultiLayerBGS.h                   |  4 ++--
 package_bgs/jmo/OpenCvDataConversion.h            |  2 +-
 package_bgs/jmo/blob.cpp                          |  2 +-
 package_bgs/jmo/blob.h                            |  4 ++--
 package_bgs/lb/BGModel.h                          |  2 +-
 package_bgs/lb/LBAdaptiveSOM.h                    |  4 ++--
 package_bgs/lb/LBFuzzyAdaptiveSOM.h               |  4 ++--
 package_bgs/lb/LBFuzzyGaussian.h                  |  4 ++--
 package_bgs/lb/LBMixtureOfGaussians.h             |  4 ++--
 package_bgs/lb/LBSimpleGaussian.h                 |  4 ++--
 package_bgs/lb/Types.h                            |  2 +-
 package_bgs/my/MyBGS.h                            |  4 ++--
 package_bgs/sjn/SJN_MultiCueBGS.h                 |  4 ++--
 package_bgs/tb/FuzzyChoquetIntegral.cpp           |  3 ++-
 package_bgs/tb/FuzzyChoquetIntegral.h             |  4 ++--
 package_bgs/tb/FuzzySugenoIntegral.cpp            |  3 ++-
 package_bgs/tb/FuzzySugenoIntegral.h              |  4 ++--
 package_bgs/tb/MRF.cpp                            |  2 +-
 package_bgs/tb/PerformanceUtils.cpp               |  3 ++-
 package_bgs/tb/PerformanceUtils.h                 |  4 ++--
 package_bgs/tb/PixelUtils.cpp                     |  2 +-
 package_bgs/tb/PixelUtils.h                       |  4 ++--
 package_bgs/tb/T2FGMM_UM.h                        |  4 ++--
 package_bgs/tb/T2FGMM_UV.h                        |  4 ++--
 package_bgs/tb/T2FMRF_UM.cpp                      |  6 +++---
 package_bgs/tb/T2FMRF_UM.h                        |  4 ++--
 package_bgs/tb/T2FMRF_UV.cpp                      |  6 +++---
 package_bgs/tb/T2FMRF_UV.h                        |  4 ++--
 71 files changed, 133 insertions(+), 140 deletions(-)

diff --git a/Demo.cpp b/Demo.cpp
index c5abcf7..b676fff 100644
--- a/Demo.cpp
+++ b/Demo.cpp
@@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License
 along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "package_bgs/FrameDifferenceBGS.h"
 #include "package_bgs/StaticFrameDifferenceBGS.h"
diff --git a/Demo2.cpp b/Demo2.cpp
index af9bb83..2708be9 100644
--- a/Demo2.cpp
+++ b/Demo2.cpp
@@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License
 along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "package_bgs/FrameDifferenceBGS.h"
 #include "package_bgs/StaticFrameDifferenceBGS.h"
diff --git a/FrameProcessor.cpp b/FrameProcessor.cpp
index 85cfab9..d8320c7 100644
--- a/FrameProcessor.cpp
+++ b/FrameProcessor.cpp
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "FrameProcessor.h"
+#include <iomanip>
 
 namespace bgslibrary
 {
diff --git a/IFrameProcessor.h b/IFrameProcessor.h
index b3a4441..61bdf3a 100644
--- a/IFrameProcessor.h
+++ b/IFrameProcessor.h
@@ -16,7 +16,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 */
 #pragma once
 
-#include <cv.h>
+#include <opencv2/opencv.hpp>
 
 namespace bgslibrary
 {
diff --git a/PreProcessor.h b/PreProcessor.h
index e001003..da46cce 100644
--- a/PreProcessor.h
+++ b/PreProcessor.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 namespace bgslibrary
 {
diff --git a/VideoCapture.h b/VideoCapture.h
index 1a381a8..a8ba2ff 100644
--- a/VideoCapture.h
+++ b/VideoCapture.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "Config.h"
 #include "IFrameProcessor.h"
diff --git a/demos/DemoFrameDifferenceBGS.cpp b/demos/DemoFrameDifferenceBGS.cpp
index 5f81242..5a449e2 100644
--- a/demos/DemoFrameDifferenceBGS.cpp
+++ b/demos/DemoFrameDifferenceBGS.cpp
@@ -1,6 +1,6 @@
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "package_bgs/FrameDifferenceBGS.h"
 
diff --git a/demos/DemoMultiLayerBGS.cpp b/demos/DemoMultiLayerBGS.cpp
index bf2bbad..08abe30 100644
--- a/demos/DemoMultiLayerBGS.cpp
+++ b/demos/DemoMultiLayerBGS.cpp
@@ -1,6 +1,6 @@
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "package_bgs/jmo/MultiLayerBGS.h"
 
diff --git a/package_analysis/ForegroundMaskAnalysis.h b/package_analysis/ForegroundMaskAnalysis.h
index 399da68..a0797d7 100644
--- a/package_analysis/ForegroundMaskAnalysis.h
+++ b/package_analysis/ForegroundMaskAnalysis.h
@@ -18,8 +18,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <iostream>
 #include <string>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 namespace bgslibrary
 {
diff --git a/package_bgs/AdaptiveBackgroundLearning.h b/package_bgs/AdaptiveBackgroundLearning.h
index eb07a64..4bbac54 100644
--- a/package_bgs/AdaptiveBackgroundLearning.h
+++ b/package_bgs/AdaptiveBackgroundLearning.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "IBGS.h"
 
diff --git a/package_bgs/AdaptiveSelectiveBackgroundLearning.h b/package_bgs/AdaptiveSelectiveBackgroundLearning.h
index cb9f4d5..2276747 100644
--- a/package_bgs/AdaptiveSelectiveBackgroundLearning.h
+++ b/package_bgs/AdaptiveSelectiveBackgroundLearning.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "IBGS.h"
 
diff --git a/package_bgs/FrameDifferenceBGS.h b/package_bgs/FrameDifferenceBGS.h
index 3fab44d..338979f 100644
--- a/package_bgs/FrameDifferenceBGS.h
+++ b/package_bgs/FrameDifferenceBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "IBGS.h"
 
diff --git a/package_bgs/IBGS.h b/package_bgs/IBGS.h
index 0b57658..073ce18 100644
--- a/package_bgs/IBGS.h
+++ b/package_bgs/IBGS.h
@@ -16,7 +16,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 */
 #pragma once
 
-#include <cv.h>
+#include <opencv2/opencv.hpp>
 
 class IBGS
 {
diff --git a/package_bgs/MixtureOfGaussianV1BGS.h b/package_bgs/MixtureOfGaussianV1BGS.h
index 8a67acc..f735a13 100644
--- a/package_bgs/MixtureOfGaussianV1BGS.h
+++ b/package_bgs/MixtureOfGaussianV1BGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 #include <opencv2/video/background_segm.hpp>
 
 #include "IBGS.h"
diff --git a/package_bgs/MixtureOfGaussianV2BGS.h b/package_bgs/MixtureOfGaussianV2BGS.h
index 495d701..a14ff0b 100644
--- a/package_bgs/MixtureOfGaussianV2BGS.h
+++ b/package_bgs/MixtureOfGaussianV2BGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 #include <opencv2/video/background_segm.hpp>
 
 #include "IBGS.h"
diff --git a/package_bgs/StaticFrameDifferenceBGS.h b/package_bgs/StaticFrameDifferenceBGS.h
index 416d13b..55f7bf1 100644
--- a/package_bgs/StaticFrameDifferenceBGS.h
+++ b/package_bgs/StaticFrameDifferenceBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "IBGS.h"
 
diff --git a/package_bgs/WeightedMovingMeanBGS.h b/package_bgs/WeightedMovingMeanBGS.h
index a6684e7..6f72306 100644
--- a/package_bgs/WeightedMovingMeanBGS.h
+++ b/package_bgs/WeightedMovingMeanBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "IBGS.h"
 
diff --git a/package_bgs/WeightedMovingVarianceBGS.h b/package_bgs/WeightedMovingVarianceBGS.h
index f07cf59..10ff653 100644
--- a/package_bgs/WeightedMovingVarianceBGS.h
+++ b/package_bgs/WeightedMovingVarianceBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "IBGS.h"
 
diff --git a/package_bgs/ae/KDE.h b/package_bgs/ae/KDE.h
index 39f01dc..adcc659 100644
--- a/package_bgs/ae/KDE.h
+++ b/package_bgs/ae/KDE.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "NPBGSubtractor.h"
 #include "../IBGS.h"
diff --git a/package_bgs/av/TBackground.cpp b/package_bgs/av/TBackground.cpp
index 2e97d93..d10fac0 100644
--- a/package_bgs/av/TBackground.cpp
+++ b/package_bgs/av/TBackground.cpp
@@ -70,11 +70,11 @@ int TBackground::Init(IplImage * pSource)
 
 bool TBackground::isInitOk(IplImage * pSource, IplImage *pBackground, IplImage *pMotionMask)
 {
-  bool bResult = TRUE;
+  bool bResult = true;
   int nbl, nbc;
 
   if(pSource == NULL || pSource->nChannels != 1 || pSource->depth != IPL_DEPTH_8U)
-    bResult = FALSE;
+    bResult = false;
 
   if(bResult)
   {
@@ -82,10 +82,10 @@ bool TBackground::isInitOk(IplImage * pSource, IplImage *pBackground, IplImage *
     nbc = pSource->width;
     
     if(pBackground == NULL || pBackground->width != nbc || pBackground->height != nbl || pBackground->imageSize != pSource->imageSize)
-      bResult = FALSE;
+      bResult = false;
     
     if(pMotionMask == NULL || pMotionMask->width != nbc || pMotionMask->height != nbl || pMotionMask->imageSize != pSource->imageSize)
-      bResult = FALSE;
+      bResult = false;
   }
 
   return bResult;
diff --git a/package_bgs/av/TBackground.h b/package_bgs/av/TBackground.h
index 974cab9..463063f 100644
--- a/package_bgs/av/TBackground.h
+++ b/package_bgs/av/TBackground.h
@@ -24,8 +24,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 class TBackground
 {
diff --git a/package_bgs/av/TBackgroundVuMeter.cpp b/package_bgs/av/TBackgroundVuMeter.cpp
index 4597621..5aab897 100644
--- a/package_bgs/av/TBackgroundVuMeter.cpp
+++ b/package_bgs/av/TBackgroundVuMeter.cpp
@@ -227,24 +227,24 @@ int TBackgroundVuMeter::Init(IplImage * pSource)
 
 bool TBackgroundVuMeter::isInitOk(IplImage * pSource, IplImage *pBackground, IplImage *pMotionMask)
 {
-  bool bResult = TRUE;
+  bool bResult = true;
   int i;
   int nbl, nbc;
 
   bResult = TBackground::isInitOk(pSource, pBackground, pMotionMask);
 
   if(pSource == NULL)
-    bResult = FALSE;
+    bResult = false;
 
   if(m_nBinSize == 0)
-    bResult = FALSE;
+    bResult = false;
 
   if(bResult)
   {
     i = (m_nBinSize != 0) ? 256 / m_nBinSize : 0;
 
     if(i != m_nBinCount || m_pHist == NULL)
-      bResult = FALSE;
+      bResult = false;
   }
 
   if(bResult)
@@ -255,7 +255,7 @@ bool TBackgroundVuMeter::isInitOk(IplImage * pSource, IplImage *pBackground, Ipl
     for(i = 0; i < m_nBinCount; ++i)
     {
       if(m_pHist[i] == NULL || m_pHist[i]->width != nbc || m_pHist[i]->height != nbl)
-        bResult = FALSE;
+        bResult = false;
     }
   }
 
diff --git a/package_bgs/av/VuMeter.h b/package_bgs/av/VuMeter.h
index 7884ff6..a2334ca 100644
--- a/package_bgs/av/VuMeter.h
+++ b/package_bgs/av/VuMeter.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "TBackgroundVuMeter.h"
 #include "../IBGS.h"
diff --git a/package_bgs/bl/SigmaDeltaBGS.h b/package_bgs/bl/SigmaDeltaBGS.h
index 9e8dab3..a4be271 100644
--- a/package_bgs/bl/SigmaDeltaBGS.h
+++ b/package_bgs/bl/SigmaDeltaBGS.h
@@ -1,8 +1,8 @@
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 
diff --git a/package_bgs/ck/MEHistogram.cpp b/package_bgs/ck/MEHistogram.cpp
index 126fd25..09a9672 100644
--- a/package_bgs/ck/MEHistogram.cpp
+++ b/package_bgs/ck/MEHistogram.cpp
@@ -27,11 +27,7 @@
 
 #include "MEHistogram.hpp"
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
-#include <cv.h>
-#else
-#include <opencv/cv.h>
-#endif
+#include <opencv2/opencv.hpp>
 
 #include "MEDefs.hpp"
 #include "MEImage.hpp"
diff --git a/package_bgs/ck/MEImage.cpp b/package_bgs/ck/MEImage.cpp
index 5a625a9..9693e9b 100644
--- a/package_bgs/ck/MEImage.cpp
+++ b/package_bgs/ck/MEImage.cpp
@@ -21,13 +21,7 @@
 
 #include "MEImage.hpp"
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
-#include <cv.h>
-#include <highgui.h>
-#else
-#include <opencv/cv.h>
-#include <opencv/highgui.h>
-#endif
+#include <opencv2/opencv.hpp>
 
 #include "MEDefs.hpp"
 
diff --git a/package_bgs/ck/MotionDetection.cpp b/package_bgs/ck/MotionDetection.cpp
index 9cb8e79..7fe4b7e 100644
--- a/package_bgs/ck/MotionDetection.cpp
+++ b/package_bgs/ck/MotionDetection.cpp
@@ -25,11 +25,7 @@
 
 #include "graph.h"
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
-#include <cvaux.h>
-#else
-#include <opencv/cvaux.h>
-#endif
+#include <opencv2/opencv.hpp>
 
 #include "MEHistogram.hpp"
 #include "MEImage.hpp"
diff --git a/package_bgs/db/IndependentMultimodalBGS.h b/package_bgs/db/IndependentMultimodalBGS.h
index b6f9a5d..64b83bd 100644
--- a/package_bgs/db/IndependentMultimodalBGS.h
+++ b/package_bgs/db/IndependentMultimodalBGS.h
@@ -1,7 +1,7 @@
 #pragma once
 
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "imbs.hpp"
 
diff --git a/package_bgs/dp/DPAdaptiveMedianBGS.h b/package_bgs/dp/DPAdaptiveMedianBGS.h
index 05ac9c3..a5dd387 100644
--- a/package_bgs/dp/DPAdaptiveMedianBGS.h
+++ b/package_bgs/dp/DPAdaptiveMedianBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "AdaptiveMedianBGS.h"
diff --git a/package_bgs/dp/DPEigenbackgroundBGS.h b/package_bgs/dp/DPEigenbackgroundBGS.h
index df558fe..cd4e54c 100644
--- a/package_bgs/dp/DPEigenbackgroundBGS.h
+++ b/package_bgs/dp/DPEigenbackgroundBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "Eigenbackground.h"
diff --git a/package_bgs/dp/DPGrimsonGMMBGS.h b/package_bgs/dp/DPGrimsonGMMBGS.h
index 37e2a33..4f955b9 100644
--- a/package_bgs/dp/DPGrimsonGMMBGS.h
+++ b/package_bgs/dp/DPGrimsonGMMBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "GrimsonGMM.h"
diff --git a/package_bgs/dp/DPMeanBGS.h b/package_bgs/dp/DPMeanBGS.h
index b119ac4..8829686 100644
--- a/package_bgs/dp/DPMeanBGS.h
+++ b/package_bgs/dp/DPMeanBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "MeanBGS.h"
diff --git a/package_bgs/dp/DPPratiMediodBGS.h b/package_bgs/dp/DPPratiMediodBGS.h
index 657dc1b..8aa6416 100644
--- a/package_bgs/dp/DPPratiMediodBGS.h
+++ b/package_bgs/dp/DPPratiMediodBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "PratiMediodBGS.h"
diff --git a/package_bgs/dp/DPTextureBGS.h b/package_bgs/dp/DPTextureBGS.h
index daa6a55..c29e7e9 100644
--- a/package_bgs/dp/DPTextureBGS.h
+++ b/package_bgs/dp/DPTextureBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "TextureBGS.h"
diff --git a/package_bgs/dp/DPWrenGABGS.h b/package_bgs/dp/DPWrenGABGS.h
index 7e545c5..30ab614 100644
--- a/package_bgs/dp/DPWrenGABGS.h
+++ b/package_bgs/dp/DPWrenGABGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "WrenGA.h"
diff --git a/package_bgs/dp/DPZivkovicAGMMBGS.h b/package_bgs/dp/DPZivkovicAGMMBGS.h
index d213341..775226a 100644
--- a/package_bgs/dp/DPZivkovicAGMMBGS.h
+++ b/package_bgs/dp/DPZivkovicAGMMBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "ZivkovicAGMM.h"
diff --git a/package_bgs/dp/Image.h b/package_bgs/dp/Image.h
index 40d327b..58fe50d 100644
--- a/package_bgs/dp/Image.h
+++ b/package_bgs/dp/Image.h
@@ -30,8 +30,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef _IMAGE_H_
 #define _IMAGE_H_
 
-#include <cv.h>
-#include <cxcore.h>
+#include <opencv2/opencv.hpp>
+//#include <cxcore.h>
 
 // --- Image Iterator ---------------------------------------------------------
 
@@ -361,4 +361,4 @@ public:
 
 void DensityFilter(BwImage& image, BwImage& filtered, int minDensity, unsigned char fgValue);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/package_bgs/jmo/BGS.h b/package_bgs/jmo/BGS.h
index d528b9e..c506df2 100644
--- a/package_bgs/jmo/BGS.h
+++ b/package_bgs/jmo/BGS.h
@@ -43,7 +43,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #if !defined(_BGS_H_)
 #define _BGS_H_
 
-#include <cv.h>
+#include <opencv2/opencv.hpp>
 
 
 // TODO check these defines are not used (or not redundant with real params)
diff --git a/package_bgs/jmo/BackgroundSubtractionAPI.h b/package_bgs/jmo/BackgroundSubtractionAPI.h
index 5035f35..bb39611 100644
--- a/package_bgs/jmo/BackgroundSubtractionAPI.h
+++ b/package_bgs/jmo/BackgroundSubtractionAPI.h
@@ -65,7 +65,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #if !defined(_BACKGROUND_SUBTRACTION_API_H_)
 #define _BACKGROUND_SUBTRACTION_API_H_
 
-#include "cv.h"
+#include <opencv2/opencv.hpp>
 
 class CBackgroundSubtractionAPI
 {
diff --git a/package_bgs/jmo/BlobExtraction.cpp b/package_bgs/jmo/BlobExtraction.cpp
index 4f4c74f..cd728fe 100644
--- a/package_bgs/jmo/BlobExtraction.cpp
+++ b/package_bgs/jmo/BlobExtraction.cpp
@@ -70,6 +70,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "BlobResult.h"
 #include "BlobExtraction.h"
+#include <opencv2/legacy/compat.hpp>
 
 namespace Blob
 {
diff --git a/package_bgs/jmo/BlobResult.h b/package_bgs/jmo/BlobResult.h
index d23ace6..b232a97 100644
--- a/package_bgs/jmo/BlobResult.h
+++ b/package_bgs/jmo/BlobResult.h
@@ -59,9 +59,10 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "BlobLibraryConfiguration.h"
 #include <math.h>
-#include "cxcore.h"
+//#include "cxcore.h"
 #include <vector>
 #include <functional>
+#include <opencv2/core/types_c.h>
 #include "blob.h"
 
 typedef std::vector<double> double_stl_vector;
diff --git a/package_bgs/jmo/CMultiLayerBGS.cpp b/package_bgs/jmo/CMultiLayerBGS.cpp
index 9ae1230..6daa9b9 100644
--- a/package_bgs/jmo/CMultiLayerBGS.cpp
+++ b/package_bgs/jmo/CMultiLayerBGS.cpp
@@ -53,6 +53,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #include <fstream>						// file I/O
 #include <cmath>						// math includes
 #include <iostream>                                             // I/O streams
+#include <opencv2/legacy/compat.hpp>
 
 using namespace Blob;
 
diff --git a/package_bgs/jmo/LocalBinaryPattern.h b/package_bgs/jmo/LocalBinaryPattern.h
index 28680e3..987a2c2 100644
--- a/package_bgs/jmo/LocalBinaryPattern.h
+++ b/package_bgs/jmo/LocalBinaryPattern.h
@@ -47,7 +47,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #if !defined(_LOCAL_BINARY_PATTERN_H_)
 #define _LOCAL_BINARY_PATTERN_H_
 
-#include <cv.h>
+#include <opencv2/opencv.hpp>
 #include "BGS.h"
 
 
diff --git a/package_bgs/jmo/MultiLayerBGS.h b/package_bgs/jmo/MultiLayerBGS.h
index 05d14c3..29db946 100644
--- a/package_bgs/jmo/MultiLayerBGS.h
+++ b/package_bgs/jmo/MultiLayerBGS.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "CMultiLayerBGS.h"
diff --git a/package_bgs/jmo/OpenCvDataConversion.h b/package_bgs/jmo/OpenCvDataConversion.h
index 28117c7..a47563e 100644
--- a/package_bgs/jmo/OpenCvDataConversion.h
+++ b/package_bgs/jmo/OpenCvDataConversion.h
@@ -47,7 +47,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #if !defined(_OPENCV_DATA_CONVERSION_H_)
 #define _OPENCV_DATA_CONVERSION_H_
 
-#include <cv.h>
+#include <opencv2/opencv.hpp>
 #include <stdio.h>
 
 template <class TI, class TM>		/* class TI - the type of image data, class TM - the type of matrix data */
diff --git a/package_bgs/jmo/blob.cpp b/package_bgs/jmo/blob.cpp
index 8ad3204..e76b676 100644
--- a/package_bgs/jmo/blob.cpp
+++ b/package_bgs/jmo/blob.cpp
@@ -58,7 +58,7 @@ MODIFICATIONS (Modification, Author, Date):
 
 #include <limits.h>
 #include "blob.h"
-#include "cv.h"
+#include <opencv2/opencv.hpp>
 
 namespace Blob
 {
diff --git a/package_bgs/jmo/blob.h b/package_bgs/jmo/blob.h
index ab739d6..67bdf11 100644
--- a/package_bgs/jmo/blob.h
+++ b/package_bgs/jmo/blob.h
@@ -60,12 +60,12 @@ MODIFICATIONS (Modification, Author, Date):
 #ifndef CBLOB_INSPECTA_INCLUDED
 #define CBLOB_INSPECTA_INCLUDED
 
-#include "cxcore.h"
+//#include "cxcore.h"
 #include "BlobLibraryConfiguration.h"
 #include <functional>
 #include <vector>
 #include <algorithm>
-
+#include <opencv2/core/types_c.h>
 //! Factor de conversi� de graus a radians
 #define DEGREE2RAD		(CV_PI / 180.0)
 
diff --git a/package_bgs/lb/BGModel.h b/package_bgs/lb/BGModel.h
index d53b52e..77f0490 100644
--- a/package_bgs/lb/BGModel.h
+++ b/package_bgs/lb/BGModel.h
@@ -37,7 +37,7 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef BGMODEL_H
 #define BGMODEL_H
 
-#include <cv.h>
+#include <opencv2/opencv.hpp>
 #include <math.h>
 #include <float.h>
 
diff --git a/package_bgs/lb/LBAdaptiveSOM.h b/package_bgs/lb/LBAdaptiveSOM.h
index 6e001df..beaf77b 100644
--- a/package_bgs/lb/LBAdaptiveSOM.h
+++ b/package_bgs/lb/LBAdaptiveSOM.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "BGModelSom.h"
 
diff --git a/package_bgs/lb/LBFuzzyAdaptiveSOM.h b/package_bgs/lb/LBFuzzyAdaptiveSOM.h
index 76dec2f..9c11d75 100644
--- a/package_bgs/lb/LBFuzzyAdaptiveSOM.h
+++ b/package_bgs/lb/LBFuzzyAdaptiveSOM.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "BGModelFuzzySom.h"
 
diff --git a/package_bgs/lb/LBFuzzyGaussian.h b/package_bgs/lb/LBFuzzyGaussian.h
index 408c4a5..f76156e 100644
--- a/package_bgs/lb/LBFuzzyGaussian.h
+++ b/package_bgs/lb/LBFuzzyGaussian.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "BGModelFuzzyGauss.h"
 
diff --git a/package_bgs/lb/LBMixtureOfGaussians.h b/package_bgs/lb/LBMixtureOfGaussians.h
index 71ab5f0..3b1a96d 100644
--- a/package_bgs/lb/LBMixtureOfGaussians.h
+++ b/package_bgs/lb/LBMixtureOfGaussians.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "BGModelMog.h"
 
diff --git a/package_bgs/lb/LBSimpleGaussian.h b/package_bgs/lb/LBSimpleGaussian.h
index ea8317c..bfefd3e 100644
--- a/package_bgs/lb/LBSimpleGaussian.h
+++ b/package_bgs/lb/LBSimpleGaussian.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "BGModelGauss.h"
 
diff --git a/package_bgs/lb/Types.h b/package_bgs/lb/Types.h
index 5b1fd5b..cb318a2 100644
--- a/package_bgs/lb/Types.h
+++ b/package_bgs/lb/Types.h
@@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #ifndef TYPES_H
 #define TYPES_H
 
-#include <cv.h>
+#include <opencv2/opencv.hpp>
 
 namespace lb_library
 {
diff --git a/package_bgs/my/MyBGS.h b/package_bgs/my/MyBGS.h
index daba730..fa27484 100644
--- a/package_bgs/my/MyBGS.h
+++ b/package_bgs/my/MyBGS.h
@@ -1,7 +1,7 @@
 #pragma once
 
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 
diff --git a/package_bgs/sjn/SJN_MultiCueBGS.h b/package_bgs/sjn/SJN_MultiCueBGS.h
index 63f7a93..e81ab1a 100644
--- a/package_bgs/sjn/SJN_MultiCueBGS.h
+++ b/package_bgs/sjn/SJN_MultiCueBGS.h
@@ -42,8 +42,8 @@ using std::vector;
 #include <algorithm>
 using std::sort;
 
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 
diff --git a/package_bgs/tb/FuzzyChoquetIntegral.cpp b/package_bgs/tb/FuzzyChoquetIntegral.cpp
index 7d0bf90..f5d98a8 100644
--- a/package_bgs/tb/FuzzyChoquetIntegral.cpp
+++ b/package_bgs/tb/FuzzyChoquetIntegral.cpp
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "FuzzyChoquetIntegral.h"
+#include <opencv2/legacy/compat.hpp>
 
 FuzzyChoquetIntegral::FuzzyChoquetIntegral() : firstTime(true), frameNumber(0), showOutput(true),
   framesToLearn(10), alphaLearn(0.1), alphaUpdate(0.01), colorSpace(1), option(2), smooth(true), threshold(0.67)
@@ -201,4 +202,4 @@ void FuzzyChoquetIntegral::loadConfig()
   threshold = cvReadRealByName(fs, 0, "threshold", 0.67);
 
   cvReleaseFileStorage(&fs);
-}
\ No newline at end of file
+}
diff --git a/package_bgs/tb/FuzzyChoquetIntegral.h b/package_bgs/tb/FuzzyChoquetIntegral.h
index a52a52d..76ba158 100644
--- a/package_bgs/tb/FuzzyChoquetIntegral.h
+++ b/package_bgs/tb/FuzzyChoquetIntegral.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 
diff --git a/package_bgs/tb/FuzzySugenoIntegral.cpp b/package_bgs/tb/FuzzySugenoIntegral.cpp
index 34b1c02..e311d41 100644
--- a/package_bgs/tb/FuzzySugenoIntegral.cpp
+++ b/package_bgs/tb/FuzzySugenoIntegral.cpp
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "FuzzySugenoIntegral.h"
+#include <opencv2/legacy/compat.hpp>
 
 FuzzySugenoIntegral::FuzzySugenoIntegral() : firstTime(true), frameNumber(0), showOutput(true),
   framesToLearn(10), alphaLearn(0.1), alphaUpdate(0.01), colorSpace(1), option(2), smooth(true), threshold(0.67)
@@ -201,4 +202,4 @@ void FuzzySugenoIntegral::loadConfig()
   threshold = cvReadRealByName(fs, 0, "threshold", 0.67);
   
   cvReleaseFileStorage(&fs);
-}
\ No newline at end of file
+}
diff --git a/package_bgs/tb/FuzzySugenoIntegral.h b/package_bgs/tb/FuzzySugenoIntegral.h
index 1144559..cfa91b7 100644
--- a/package_bgs/tb/FuzzySugenoIntegral.h
+++ b/package_bgs/tb/FuzzySugenoIntegral.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 
diff --git a/package_bgs/tb/MRF.cpp b/package_bgs/tb/MRF.cpp
index 1dbc69e..fcd3f48 100644
--- a/package_bgs/tb/MRF.cpp
+++ b/package_bgs/tb/MRF.cpp
@@ -215,7 +215,7 @@ void MRF_TC::InitEvidence2(GMM *gmm, HMM *hmm, IplImage *labeling)
   int i, j;
 
   background = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
-  cvCopyImage(background2,background.Ptr());
+  cvCopy(background2,background.Ptr());
 
   unsigned char *in_data = (unsigned char *)(in_image->imageData);
   unsigned char *labeling_data = (unsigned char *)(labeling->imageData);
diff --git a/package_bgs/tb/PerformanceUtils.cpp b/package_bgs/tb/PerformanceUtils.cpp
index 30f89b7..0d7cf77 100644
--- a/package_bgs/tb/PerformanceUtils.cpp
+++ b/package_bgs/tb/PerformanceUtils.cpp
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "PerformanceUtils.h"
+#include <opencv2/legacy/compat.hpp>
 
 PerformanceUtils::PerformanceUtils(void){}
 
@@ -518,4 +519,4 @@ void PerformanceUtils::PerformanceEvaluation(IplImage *image, IplImage *ground_t
       f.close();
     }
   }
-}
\ No newline at end of file
+}
diff --git a/package_bgs/tb/PerformanceUtils.h b/package_bgs/tb/PerformanceUtils.h
index c608264..9257098 100644
--- a/package_bgs/tb/PerformanceUtils.h
+++ b/package_bgs/tb/PerformanceUtils.h
@@ -29,8 +29,8 @@ http://sites.google.com/site/thierrybouwmans/
 */
 #include <stdio.h>
 #include <fstream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "PixelUtils.h"
 
diff --git a/package_bgs/tb/PixelUtils.cpp b/package_bgs/tb/PixelUtils.cpp
index bc61cc5..d647e05 100644
--- a/package_bgs/tb/PixelUtils.cpp
+++ b/package_bgs/tb/PixelUtils.cpp
@@ -23,7 +23,7 @@ void PixelUtils::ColorConversion(IplImage* RGBImage, IplImage* ConvertedImage, i
 {
   // Space Color RGB - Nothing to do!
   if(color_space == 1)
-    cvCopyImage(RGBImage, ConvertedImage);
+    cvCopy(RGBImage, ConvertedImage);
 
   // Space Color Ohta
   if(color_space == 2) 
diff --git a/package_bgs/tb/PixelUtils.h b/package_bgs/tb/PixelUtils.h
index efbfdd9..a2d3a4a 100644
--- a/package_bgs/tb/PixelUtils.h
+++ b/package_bgs/tb/PixelUtils.h
@@ -28,8 +28,8 @@ tbouwman@univ-lr.fr
 http://sites.google.com/site/thierrybouwmans/
 */
 #include <stdio.h>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 class PixelUtils
 {
diff --git a/package_bgs/tb/T2FGMM_UM.h b/package_bgs/tb/T2FGMM_UM.h
index 17e06c5..ae6e29f 100644
--- a/package_bgs/tb/T2FGMM_UM.h
+++ b/package_bgs/tb/T2FGMM_UM.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "T2FGMM.h"
diff --git a/package_bgs/tb/T2FGMM_UV.h b/package_bgs/tb/T2FGMM_UV.h
index 23c0bf1..79edcc2 100644
--- a/package_bgs/tb/T2FGMM_UV.h
+++ b/package_bgs/tb/T2FGMM_UV.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "T2FGMM.h"
diff --git a/package_bgs/tb/T2FMRF_UM.cpp b/package_bgs/tb/T2FMRF_UM.cpp
index 768db39..cf7b5d8 100644
--- a/package_bgs/tb/T2FMRF_UM.cpp
+++ b/package_bgs/tb/T2FMRF_UM.cpp
@@ -77,7 +77,7 @@ void T2FMRF_UM::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &
   }
 
   bgs.Subtract(frameNumber, frame_data, lowThresholdMask, highThresholdMask);
-  cvCopyImage(lowThresholdMask.Ptr(), old);
+  cvCopy(lowThresholdMask.Ptr(), old);
 
   /************************************************************************/
 	/* the code for MRF, it can be noted when using other methods   */
@@ -92,10 +92,10 @@ void T2FMRF_UM::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &
 		mrf.out_image = lowThresholdMask.Ptr();
 		mrf.InitEvidence2(gmm,hmm,old_labeling);
 		mrf.ICM2();
-		cvCopyImage(mrf.out_image, lowThresholdMask.Ptr());
+		cvCopy(mrf.out_image, lowThresholdMask.Ptr());
 	}
 
-  cvCopyImage(old, old_labeling);
+  cvCopy(old, old_labeling);
 
   lowThresholdMask.Clear();
   bgs.Update(frameNumber, frame_data, lowThresholdMask);
diff --git a/package_bgs/tb/T2FMRF_UM.h b/package_bgs/tb/T2FMRF_UM.h
index 6066834..fd0da7b 100644
--- a/package_bgs/tb/T2FMRF_UM.h
+++ b/package_bgs/tb/T2FMRF_UM.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "MRF.h"
diff --git a/package_bgs/tb/T2FMRF_UV.cpp b/package_bgs/tb/T2FMRF_UV.cpp
index 6b6fcc0..da9984d 100644
--- a/package_bgs/tb/T2FMRF_UV.cpp
+++ b/package_bgs/tb/T2FMRF_UV.cpp
@@ -77,7 +77,7 @@ void T2FMRF_UV::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &
   }
 
   bgs.Subtract(frameNumber, frame_data, lowThresholdMask, highThresholdMask);
-  cvCopyImage(lowThresholdMask.Ptr(), old);
+  cvCopy(lowThresholdMask.Ptr(), old);
 
   /************************************************************************/
 	/* the code for MRF, it can be noted when using other methods   */
@@ -92,10 +92,10 @@ void T2FMRF_UV::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &
 		mrf.out_image = lowThresholdMask.Ptr();
 		mrf.InitEvidence2(gmm,hmm,old_labeling);
 		mrf.ICM2();
-		cvCopyImage(mrf.out_image, lowThresholdMask.Ptr());
+		cvCopy(mrf.out_image, lowThresholdMask.Ptr());
 	}
 
-  cvCopyImage(old, old_labeling);
+  cvCopy(old, old_labeling);
 
   lowThresholdMask.Clear();
   bgs.Update(frameNumber, frame_data, lowThresholdMask);
diff --git a/package_bgs/tb/T2FMRF_UV.h b/package_bgs/tb/T2FMRF_UV.h
index b8c0ff0..28fcb67 100644
--- a/package_bgs/tb/T2FMRF_UV.h
+++ b/package_bgs/tb/T2FMRF_UV.h
@@ -17,8 +17,8 @@ along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 #pragma once
 
 #include <iostream>
-#include <cv.h>
-#include <highgui.h>
+#include <opencv2/opencv.hpp>
+
 
 #include "../IBGS.h"
 #include "MRF.h"
-- 
GitLab