diff --git a/Demo.cpp b/Demo.cpp
index c5abcf7f6dd40a94229e9bbcbc703c7a3a6405f7..b676ffffb9f25f78f67e0e587b44de583adf196a 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 af9bb836cf3e0a9d9b92536654b801f2260a7d6b..2708be93fc49ac69d3ad6fa00053daf788efd34b 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 85cfab92b0b3683696747a4d092796d6b79f4d08..d8320c7d3a77d724777ca4790e6d6a6369351374 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 b3a44411ecc1c73011a1664370a593acfb3550d8..61bdf3ad401dc1816e2b1b142f368ff0e3b1e619 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 e00100369cfbf49d480481bab173683f93f9e5fe..da46cce7e0955e19130499e159707d23f5f721d0 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 1a381a8a9f566826fb99b2e39f9655c817756626..a8ba2ff25017203d9b800006515675ec5766ed7a 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 5f81242be085a5b6b150a4e5dc6f4cdf2c7a475f..5a449e21dda93981e91b1a4758bb8247882cb897 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 bf2bbad06817f9aebc14db2244e4cc09b29e4e42..08abe30df39d937e8210c1311fa5a89976d6fe1d 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 399da68c211d8fd8f93ef96beecca1452d532a24..a0797d76b8fc4a6fe915fa9457f57ab1e97f880c 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 eb07a643ecc09a3acee8dcc24d0f2e2f81fc1395..4bbac54ae0f4c3e42499a9878afd764e9c34ab48 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 cb9f4d57320be6c0e4df50808af576ff4f869772..227674751ae4eccf452094f680c43adf72dca961 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 3fab44d1f8250be50d62b5dd7a3662b2567e7b54..338979f1966eac943984eb1b326d58a63df0581a 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 0b57658660950d70bc6902bcfbfeea4bee5cd695..073ce185b59734f2e8cfb25ab26051746386a3f0 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 8a67acc27fbb9859d6fd2b60a5dd1ea15d0ffcb4..f735a1357e321de6ba5acbb0b9b76c4fb1534d1a 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 495d70128f183df709a60d030916a48543af96b3..a14ff0b788fb4e161e9d4acd7a2855a71f68a2c6 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 416d13be3a4fc21fffe7bd86ab155b978499a3c2..55f7bf1e360419c1dd7bfce6f19facae07fd7431 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 a6684e7ab8cb866ae4517fab27707e8004d2ae14..6f72306c10a18debc70d5e87a1cc8f5b20fd08e9 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 f07cf592fcecdc33c115e2e391b5ce55f5f70910..10ff6537f9f416408ae908ac0c33ba5578a6cb00 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 39f01dc196d57245faef08b88b2d2b6a5d9367d1..adcc659f1a0bc93f00962eb4039dcb3a751e0724 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 2e97d93804b29507cb7eb8b4c95276c7a0497e34..d10fac059e4b27ba48486d57701b6307a562e263 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 974cab955cdddca8fa8bd1e59345544533eb7125..463063f6e15046398dcfd5ea8867fd66bafedfd2 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 45976213a3a0ff23f7d855d4f5977b966824d04d..5aab897295cf28ba5e3bb771ba3a3ada4baaee18 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 7884ff68aa5ac41eb42225b1d6defa2ddcda3b58..a2334cafdc99e695a8d36dcdef200ceaf4d80d91 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 9e8dab3c83dbff56dcb2864c2d1ba973022a7659..a4be2711d634982d9e3af8266476e91ec85efeaf 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 126fd259fefb6ee853fe354235972cd6a4e964ff..09a96724763d527a63f3dd6167dcf7d1b7815e3a 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 5a625a9686d42ba27f63aa115ec9343ed2d63ea6..9693e9b359e1beebeebcd9661d59f09dfeb9509c 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 9cb8e79bcb4e8059d99ded840906f9020da6f394..7fe4b7e2653a0e4c530b9d6d0441f7edd8500b4a 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 b6f9a5de9abd15441a2ad7a1127427f45df07628..64b83bde099398725cffea0dc26bf69843ae61f7 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 05ac9c3364be2b0a9689af12b1116c4e4c9d3ede..a5dd3879b383f91664b22341e433a6683aed4407 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 df558fe45cdbea23199685eafc5e2d44a54fec01..cd4e54c3eb433640ff58895e1349660ce5ee3089 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 37e2a33ab31e791ddb6371ad37e4f77d64ce71ed..4f955b970e7557f9406d458ac5db0dc83abccb28 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 b119ac4d6667478d37ceab0e234032f915834649..88296860f11f1462df6bbfbc8a31b097cc57c24b 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 657dc1b3e51b95cf4033329344ce3aba037fa57f..8aa641622bf1d57c7e4e3540ceafcf7ed4b5fdcf 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 daa6a554481811cf3fa1218f16e5612359cc1579..c29e7e92d5048348d67e080b377ed227b1874967 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 7e545c5fe0038a560b452f9dc778267239aa2f66..30ab614b0789abbbbe432150b26c5991fdb4751c 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 d213341e745ee0e6fd771660933a73a56da8f46e..775226a3807311224ea66b48c9f33ac05820b4b4 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 40d327b2fec50d685e3562f8720f46f7484490f6..58fe50d922442141de026d128b4d0cc99335e1cd 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 d528b9e68629e7e9176e09ecbb48c973e135850d..c506df2ba9a6e4fa68f821fd92be2a2cbc771ed5 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 5035f351caf50f0c5c3209db7240c598ba6fe378..bb396119623dc9a794821b395e46af5c4adcd366 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 4f4c74fb2559403b7bd5dcef21d0c9b213137744..cd728fe34314dedda69e2bcb509fab22d97e77b3 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 d23ace60b3de9d9d68a483e076ecf2f3a1ce9351..b232a978d03b748d6d58df0b80c593d26dc757ad 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 9ae1230995fb1d7fe001e7db523ef674ac7d6b88..6daa9b9bf1480194166cc131ca4dc9ddde20f9a0 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 28680e35e0398dc5b42dcb9db70537b48ac5c586..987a2c2655052a7ea3961bae8b8a899e6f32aaf0 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 05d14c31675596cbe6821264f4fd9956efa018f4..29db9466281f8c12eda1997552f1f5adff05378c 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 28117c7e82d823d2fc3db3df44b2a4b6595746e7..a47563e59b74be9ee95c46ce0279368465158631 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 8ad32042404750969c6c8ed9852081300328c807..e76b676e75280badc6456fb14a1e77b11df0f706 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 ab739d617b646da4020c5cf1ad0ab5ed1f938e6f..67bdf11f856c6b0b00814be6872b6d16a03e10e1 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 d53b52e7729e9ecdfbe326054c0bc2fff1fc1a86..77f04902ca3dab6fce668d87490a77dfb3bd41b6 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 6e001dfcffc35cfbc609d7f0bb4905f4b2008852..beaf77b62a44cecc0ce4d43f754843847306efab 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 76dec2f87bd4679c690c5bb0d3be2f9e0640ad83..9c11d7568c46e8463424145cc6aae72c99ed58c0 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 408c4a51d50ad36c0df49e092ea3f36d51ee2b6d..f76156ef20ed1152e280a8de60f5fca966119ed7 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 71ab5f0c3f5309df637732dd563b26edc6c1f1af..3b1a96d9cc166dbd89804c86a75df68f646e00ff 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 ea8317c49496fac4e60fb42595d075fcf75218cd..bfefd3e12cf9bd03b9b14585d512f6b3d1c54adc 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 5b1fd5b358a7cf84c663a435a4c52e20530fefe5..cb318a238b7ba97f0c455fbab3b4732f177d1031 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 daba73043a777e7ba97b60f539b4eaa4871b7d38..fa27484aafd413343913720b7695695e916cd624 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 63f7a932381255a6b6d627a17cd69246a2cf19da..e81ab1a430a2e0453c81b03034bb4213639aa19b 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 7d0bf908041a308543aff7c7510466bcb84a09bd..f5d98a8fbd0f221087e757397a5deb49092b4abe 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 a52a52d804aea91b9873994f3e59bcec02652a40..76ba15829bf493a19f75e5f7a77e87e3ca5dcdf7 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 34b1c027ddd3a578afa13bd230deb2b448c014d1..e311d417403b3e756aa0c93633e8195704d74b8f 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 11445596948f402d8ccea0ebd18f4f3cccc7590c..cfa91b7bb07dd4eeb2feba10a0f7832ef590a6d1 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 1dbc69ed7993f20a3519f57c904880d8d814bd4b..fcd3f48f41c43914b355bc350408efb8d13cbd25 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 30f89b774a8e6959c23cde6f8bb45a036325d13e..0d7cf771dee40bc06b5192718710f78587d99441 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 c60826422aab262d37aa4d7edde841e00cc4cdf8..9257098386e13a2d2a1cb61382affa074ab981a6 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 bc61cc5f738e5184b08e475f3f96128a74050ffd..d647e05089369117ec38dcec215d532b72825715 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 efbfdd9c9c3d5af95329a5fc0ce51659578e357f..a2d3a4af3d5838fc0e1b870507ecacbcacf9d955 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 17e06c58877333d06f3bc5bc779641819eea7aa2..ae6e29f89c52af779cd20a04afde16a5cd271e57 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 23c0bf1a4bfbbe88913d4808aaabdbdfc742f4b8..79edcc229900ca6cef612e82661ec2c78f68e60d 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 768db3931902d908664045c30ea46ff86838e504..cf7b5d84f2539787d04874bee6bff458d2caf4bb 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 6066834957460f6a787a1672f68332eee010d06e..fd0da7b1c2b68850d6b624ca489d38abdba462cf 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 6b6fcc012e719097fed353638862a034d7ccdb9c..da9984dfae1b0887b6d0dd6972cb85146ab7176a 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 b8c0ff072a1cba191e6d848faf06a81c12d42db5..28fcb679c9c698ce5bde59b54d4e8fb5577cc411 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"