Page MenuHomePhabricator

MigrationToOpenCV_3_0_0.diff

Authored By
mercea
Oct 2 2015, 3:22 PM
Size
9 KB
Referenced Files
None
Subscribers
None

MigrationToOpenCV_3_0_0.diff

From ba9501274139720590d8d14b8e0ae0122032f3db Mon Sep 17 00:00:00 2001
From: Paul Mercea <p.mercea@dkfz-heidelberg.de>
Date: Fri, 2 Oct 2015 15:18:36 +0200
Subject: [PATCH] Migrated OpenCV includes and code for use with OpenCV 3.0.0
---
.../Commands/mitkConvertGrayscaleOpenCVImageFilter.cpp | 2 +-
.../OpenCVVideoSupport/Commands/mitkGrabCutOpenCVImageFilter.h | 2 +-
.../Testing/mitkBasicCombinationOpenCVImageFilterTest.cpp | 7 ++++---
.../Testing/mitkConvertGrayscaleOpenCVImageFilterTest.cpp | 8 ++++----
.../OpenCVVideoSupport/Testing/mitkCropOpenCVImageFilterTest.cpp | 8 ++++----
.../Testing/mitkGrabCutOpenCVImageFilterTest.cpp | 9 ++++-----
Modules/OpenCVVideoSupport/mitkImageToOpenCVImageFilter.cpp | 2 +-
Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.cpp | 3 ++-
Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.h | 2 +-
Modules/US/USFilters/mitkUSImageVideoSource.cpp | 3 ---
Modules/US/USFilters/mitkUSImageVideoSource.h | 2 +-
11 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/Modules/OpenCVVideoSupport/Commands/mitkConvertGrayscaleOpenCVImageFilter.cpp b/Modules/OpenCVVideoSupport/Commands/mitkConvertGrayscaleOpenCVImageFilter.cpp
index ade3c3d..271a7b0 100644
--- a/Modules/OpenCVVideoSupport/Commands/mitkConvertGrayscaleOpenCVImageFilter.cpp
+++ b/Modules/OpenCVVideoSupport/Commands/mitkConvertGrayscaleOpenCVImageFilter.cpp
@@ -16,7 +16,7 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "mitkConvertGrayscaleOpenCVImageFilter.h"
-#include "cv.h"
+#include <opencv2/imgproc.hpp>
namespace mitk {
diff --git a/Modules/OpenCVVideoSupport/Commands/mitkGrabCutOpenCVImageFilter.h b/Modules/OpenCVVideoSupport/Commands/mitkGrabCutOpenCVImageFilter.h
index 1bea4c0..81327e0 100644
--- a/Modules/OpenCVVideoSupport/Commands/mitkGrabCutOpenCVImageFilter.h
+++ b/Modules/OpenCVVideoSupport/Commands/mitkGrabCutOpenCVImageFilter.h
@@ -26,7 +26,7 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "itkMutexLock.h"
// opencv headers
-#include "cv.h"
+#include <opencv2/imgproc.hpp>
namespace itk {
template<unsigned int T> class Index;
diff --git a/Modules/OpenCVVideoSupport/Testing/mitkBasicCombinationOpenCVImageFilterTest.cpp b/Modules/OpenCVVideoSupport/Testing/mitkBasicCombinationOpenCVImageFilterTest.cpp
index e7853b4..f9d5ead 100644
--- a/Modules/OpenCVVideoSupport/Testing/mitkBasicCombinationOpenCVImageFilterTest.cpp
+++ b/Modules/OpenCVVideoSupport/Testing/mitkBasicCombinationOpenCVImageFilterTest.cpp
@@ -19,8 +19,9 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "mitkCropOpenCVImageFilter.h"
#include <mitkTestingMacros.h>
-#include <highgui.h>
-#include <cv.h>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/imgcodecs.hpp>
+
static bool ImagesAreEqualInGray(const cv::Mat& img1, const cv::Mat& img2)
{
@@ -36,7 +37,7 @@ static bool ImagesAreEqualInGray(const cv::Mat& img1, const cv::Mat& img2)
static void ConvertTestLoadedImage(std::string mitkImagePath)
{
- cv::Mat image = cvLoadImage(mitkImagePath.c_str());
+ cv::Mat image = cv::imread(mitkImagePath.c_str());
cv::Mat compareImg = image.clone();
diff --git a/Modules/OpenCVVideoSupport/Testing/mitkConvertGrayscaleOpenCVImageFilterTest.cpp b/Modules/OpenCVVideoSupport/Testing/mitkConvertGrayscaleOpenCVImageFilterTest.cpp
index f98f7c4..c50de23 100644
--- a/Modules/OpenCVVideoSupport/Testing/mitkConvertGrayscaleOpenCVImageFilterTest.cpp
+++ b/Modules/OpenCVVideoSupport/Testing/mitkConvertGrayscaleOpenCVImageFilterTest.cpp
@@ -17,13 +17,13 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "mitkConvertGrayscaleOpenCVImageFilter.h"
#include <mitkTestingMacros.h>
-#include <highgui.h>
-#include <cv.h>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/imgcodecs.hpp>
static void ConvertTestLoadedImage(std::string mitkImagePath, std::string mitkGrayscaleImagePath)
{
- cv::Mat image = cvLoadImage(mitkImagePath.c_str());
- cv::Mat compareImg = cvLoadImage(mitkGrayscaleImagePath.c_str());
+ cv::Mat image = cv::imread(mitkImagePath.c_str());
+ cv::Mat compareImg = cv::imread(mitkGrayscaleImagePath.c_str());
// directly convert the image for comparison
cv::Mat comparisonImg;
diff --git a/Modules/OpenCVVideoSupport/Testing/mitkCropOpenCVImageFilterTest.cpp b/Modules/OpenCVVideoSupport/Testing/mitkCropOpenCVImageFilterTest.cpp
index 6650c73..1338c70 100644
--- a/Modules/OpenCVVideoSupport/Testing/mitkCropOpenCVImageFilterTest.cpp
+++ b/Modules/OpenCVVideoSupport/Testing/mitkCropOpenCVImageFilterTest.cpp
@@ -17,8 +17,8 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "mitkCropOpenCVImageFilter.h"
#include <mitkTestingMacros.h>
-#include <highgui.h>
-#include <cv.h>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/imgcodecs.hpp>
static bool ImagesAreEqualInGray(const cv::Mat& img1, const cv::Mat& img2)
{
@@ -33,8 +33,8 @@ static bool ImagesAreEqualInGray(const cv::Mat& img1, const cv::Mat& img2)
static void CropTestLoadedImage(std::string mitkImagePath, std::string mitkCroppedImagePath)
{
- cv::Mat image = cvLoadImage(mitkImagePath.c_str());
- cv::Mat croppedImage = cvLoadImage(mitkCroppedImagePath.c_str());
+ cv::Mat image = cv::imread(mitkImagePath.c_str());
+ cv::Mat croppedImage = cv::imread(mitkCroppedImagePath.c_str());
MITK_INFO << mitkImagePath.c_str();
MITK_INFO << mitkCroppedImagePath.c_str();
diff --git a/Modules/OpenCVVideoSupport/Testing/mitkGrabCutOpenCVImageFilterTest.cpp b/Modules/OpenCVVideoSupport/Testing/mitkGrabCutOpenCVImageFilterTest.cpp
index 5329d25..d297089 100644
--- a/Modules/OpenCVVideoSupport/Testing/mitkGrabCutOpenCVImageFilterTest.cpp
+++ b/Modules/OpenCVVideoSupport/Testing/mitkGrabCutOpenCVImageFilterTest.cpp
@@ -20,17 +20,16 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "itkIndex.h"
#include <itksys/SystemTools.hxx>
-#include <highgui.h>
-#include <cv.h>
+#include <opencv2/imgcodecs.hpp>
#include "mitkOpenCVToMitkImageFilter.h"
static void GrabCutTestLoadedImage(std::string imagePath, std::string maskPath, std::string resultMaskPath)
{
// load test images
- cv::Mat image = cvLoadImage(imagePath.c_str());
- cv::Mat maskImage = cvLoadImage(maskPath.c_str());
- cv::Mat resultMaskImage = cvLoadImage(resultMaskPath.c_str());
+ cv::Mat image = cv::imread(imagePath.c_str());
+ cv::Mat maskImage = cv::imread(maskPath.c_str());
+ cv::Mat resultMaskImage = cv::imread(resultMaskPath.c_str());
// make sure that the loaded mask is a gray scale image
cv::Mat maskImageGray;
diff --git a/Modules/OpenCVVideoSupport/mitkImageToOpenCVImageFilter.cpp b/Modules/OpenCVVideoSupport/mitkImageToOpenCVImageFilter.cpp
index 72f8166..b540d83 100644
--- a/Modules/OpenCVVideoSupport/mitkImageToOpenCVImageFilter.cpp
+++ b/Modules/OpenCVVideoSupport/mitkImageToOpenCVImageFilter.cpp
@@ -86,7 +86,7 @@ namespace mitk{
if( img )
{
// do not copy data, then release just the header
- mat = cv::Mat ( img, false );
+ mat = cv::cvarrToMat( img, false );
cvReleaseImageHeader( &img );
}
diff --git a/Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.cpp b/Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.cpp
index da4f03f..363d7bb 100644
--- a/Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.cpp
+++ b/Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.cpp
@@ -18,6 +18,7 @@ See LICENSE.txt or http://www.mitk.org for details.
#include <iostream>
#include <algorithm>
+
mitk::OpenCVVideoSource::OpenCVVideoSource()
: m_VideoCapture(nullptr),
m_CurrentImage(nullptr),
@@ -95,7 +96,7 @@ cv::Mat mitk::OpenCVVideoSource::GetImage()
{
if(m_CurrentImage)
{
- cv::Mat copy( m_CurrentImage, false );
+ cv::Mat copy = cv::cvarrToMat( m_CurrentImage, false );
return copy.clone();
}
return cv::Mat();
diff --git a/Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.h b/Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.h
index 7f6a7a6..8f1b6dc 100644
--- a/Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.h
+++ b/Modules/OpenCVVideoSupport/mitkOpenCVVideoSource.h
@@ -23,7 +23,7 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "mitkUndistortCameraImage.h"
// HighGui camera interface: a convenient way for grabbing from a video capture (on windows VfW is used)
-#include "highgui.h"
+#include <opencv2/highgui.hpp>
// For Providing ITK Image Interface
#include "itkRGBPixel.h"
diff --git a/Modules/US/USFilters/mitkUSImageVideoSource.cpp b/Modules/US/USFilters/mitkUSImageVideoSource.cpp
index 41f592a..934a0d6 100644
--- a/Modules/US/USFilters/mitkUSImageVideoSource.cpp
+++ b/Modules/US/USFilters/mitkUSImageVideoSource.cpp
@@ -18,9 +18,6 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "mitkUSImageVideoSource.h"
#include "mitkImage.h"
-//OpenCV HEADER
-#include <cv.h>
-#include <highgui.h>
//Other
#include <stdio.h>
diff --git a/Modules/US/USFilters/mitkUSImageVideoSource.h b/Modules/US/USFilters/mitkUSImageVideoSource.h
index 525dcf3..3ce02f8 100644
--- a/Modules/US/USFilters/mitkUSImageVideoSource.h
+++ b/Modules/US/USFilters/mitkUSImageVideoSource.h
@@ -27,7 +27,7 @@ See LICENSE.txt or http://www.mitk.org for details.
#include "mitkBasicCombinationOpenCVImageFilter.h"
// OpenCV
-#include <highgui.h>
+#include <opencv2/videoio.hpp>
namespace mitk {
/**
--
1.9.5.msysgit.1

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1234
Default Alt Text
MigrationToOpenCV_3_0_0.diff (9 KB)

Event Timeline

Patch to get MITK 2015.05.02 working with external OpenCV 3.0.0