From bd9d3dd561764f4e6993cd0b7b0b1aba7b27b099 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 3 Dec 2013 13:16:44 +0400 Subject: [PATCH 1/3] fixing build of 2.4 branch with VC12 (aka 2013) (master branch was fixed before, no need to merge this to master!) - disable openexr (numerous undefined std::min & std::max) - workaround for two compilator bugs --- CMakeLists.txt | 2 +- modules/features2d/src/features2d_init.cpp | 2 +- modules/features2d/src/orb.cpp | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a7c730bc0..14353dccb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ OCV_OPTION(WITH_IMAGEIO "ImageIO support for OS X" OFF OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) ) OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) ) OCV_OPTION(WITH_JPEG "Include JPEG support" ON) -OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) ) +OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS AND NOT MSVC12) ) OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT APPLE) ) OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_PNG "Include PNG support" ON) diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index ebac9cb54f..9fcbcd6c59 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -181,7 +181,7 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense", obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale)); CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid", - obj.info()->addParam(obj, "detector", obj.detector); + obj.info()->addParam(obj, "detector", (Ptr&)obj.detector); obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints); obj.info()->addParam(obj, "gridRows", obj.gridRows); obj.info()->addParam(obj, "gridCols", obj.gridCols)); diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index 8aeea829a8..dd81c5f682 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -138,13 +138,16 @@ static void computeOrbDescriptor(const KeyPoint& kpt, const uchar* center = &img.at(cvRound(kpt.pt.y), cvRound(kpt.pt.x)); int step = (int)img.step; + float x, y; + int ix, iy; #if 1 #define GET_VALUE(idx) \ - center[cvRound(pattern[idx].x*b + pattern[idx].y*a)*step + \ - cvRound(pattern[idx].x*a - pattern[idx].y*b)] + (x = pattern[idx].x*a - pattern[idx].y*b, \ + y = pattern[idx].x*b + pattern[idx].y*a, \ + ix = cvRound(x), \ + iy = cvRound(y), \ + *(center + iy*step + ix) ) #else - float x, y; - int ix, iy; #define GET_VALUE(idx) \ (x = pattern[idx].x*a - pattern[idx].y*b, \ y = pattern[idx].x*b + pattern[idx].y*a, \ From b5dbe9e04bc69e966168a33a5f96f44b7e064502 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 3 Dec 2013 16:08:57 +0400 Subject: [PATCH 2/3] Added patch from master for fixing VS2013 in 3rd party lib OpenEXR --- 3rdparty/openexr/IlmImf/ImfAcesFile.cpp | 1 + 3rdparty/openexr/IlmImf/ImfOutputFile.cpp | 1 + .../openexr/IlmImf/ImfScanLineInputFile.cpp | 1 + 3rdparty/openexr/IlmImf/ImfTiledMisc.cpp | 1 + .../openexr/IlmImf/ImfTiledOutputFile.cpp | 1 + 3rdparty/openexr/Imath/ImathMatrixAlgo.cpp | 1 + 3rdparty/openexr/fix_msvc2013_errors.patch | 72 +++++++++++++++++++ CMakeLists.txt | 2 +- 8 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 3rdparty/openexr/fix_msvc2013_errors.patch diff --git a/3rdparty/openexr/IlmImf/ImfAcesFile.cpp b/3rdparty/openexr/IlmImf/ImfAcesFile.cpp index de4bf83c6a..9418b9d2a1 100644 --- a/3rdparty/openexr/IlmImf/ImfAcesFile.cpp +++ b/3rdparty/openexr/IlmImf/ImfAcesFile.cpp @@ -42,6 +42,7 @@ #include #include #include +#include // for std::max() using namespace std; using namespace Imath; diff --git a/3rdparty/openexr/IlmImf/ImfOutputFile.cpp b/3rdparty/openexr/IlmImf/ImfOutputFile.cpp index 8831ec94d1..e69b92bd57 100644 --- a/3rdparty/openexr/IlmImf/ImfOutputFile.cpp +++ b/3rdparty/openexr/IlmImf/ImfOutputFile.cpp @@ -58,6 +58,7 @@ #include #include #include +#include // for std::max() namespace Imf { diff --git a/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp b/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp index f7a12a3476..5d8b52201b 100644 --- a/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp +++ b/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp @@ -56,6 +56,7 @@ #include #include #include +#include // for std::max() namespace Imf { diff --git a/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp b/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp index 57f52f17f8..9588e789f6 100644 --- a/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp +++ b/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp @@ -43,6 +43,7 @@ #include "Iex.h" #include #include +#include // for std::max() namespace Imf { diff --git a/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp b/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp index 08821060d8..0bc3cb3c30 100644 --- a/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp +++ b/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp @@ -63,6 +63,7 @@ #include #include #include +#include // for std::max() namespace Imf { diff --git a/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp b/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp index f0d2ed679f..7ddc64968f 100644 --- a/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp +++ b/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp @@ -44,6 +44,7 @@ #include "ImathMatrixAlgo.h" #include +#include // for std::max() #if defined(OPENEXR_DLL) #define EXPORT_CONST __declspec(dllexport) diff --git a/3rdparty/openexr/fix_msvc2013_errors.patch b/3rdparty/openexr/fix_msvc2013_errors.patch new file mode 100644 index 0000000000..0ce106f13b --- /dev/null +++ b/3rdparty/openexr/fix_msvc2013_errors.patch @@ -0,0 +1,72 @@ +diff --git a/3rdparty/openexr/IlmImf/ImfAcesFile.cpp b/3rdparty/openexr/IlmImf/ImfAcesFile.cpp +index de4bf83..9418b9d 100644 +--- a/3rdparty/openexr/IlmImf/ImfAcesFile.cpp ++++ b/3rdparty/openexr/IlmImf/ImfAcesFile.cpp +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include // for std::max() + + using namespace std; + using namespace Imath; +diff --git a/3rdparty/openexr/IlmImf/ImfOutputFile.cpp b/3rdparty/openexr/IlmImf/ImfOutputFile.cpp +index 8831ec9..e69b92b 100644 +--- a/3rdparty/openexr/IlmImf/ImfOutputFile.cpp ++++ b/3rdparty/openexr/IlmImf/ImfOutputFile.cpp +@@ -58,6 +58,7 @@ + #include + #include + #include ++#include // for std::max() + + + namespace Imf { +diff --git a/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp b/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp +index f7a12a3..5d8b522 100644 +--- a/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp ++++ b/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp +@@ -56,6 +56,7 @@ + #include + #include + #include ++#include // for std::max() + + + namespace Imf { +diff --git a/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp b/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp +index 57f52f1..9588e78 100644 +--- a/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp ++++ b/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp +@@ -43,6 +43,7 @@ + #include "Iex.h" + #include + #include ++#include // for std::max() + + + namespace Imf { +diff --git a/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp b/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp +index 0882106..0bc3cb3 100644 +--- a/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp ++++ b/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp +@@ -63,6 +63,7 @@ + #include + #include + #include ++#include // for std::max() + + + namespace Imf { +diff --git a/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp b/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp +index f0d2ed6..7ddc649 100644 +--- a/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp ++++ b/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp +@@ -44,6 +44,7 @@ + + #include "ImathMatrixAlgo.h" + #include ++#include // for std::max() + + #if defined(OPENEXR_DLL) + #define EXPORT_CONST __declspec(dllexport) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14353dccb6..2a7c730bc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ OCV_OPTION(WITH_IMAGEIO "ImageIO support for OS X" OFF OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) ) OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) ) OCV_OPTION(WITH_JPEG "Include JPEG support" ON) -OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS AND NOT MSVC12) ) +OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) ) OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT APPLE) ) OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_PNG "Include PNG support" ON) From 1966e7cea9d6dd38db39f29f53b4ca96d56ce2d1 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 3 Dec 2013 17:46:09 +0400 Subject: [PATCH 3/3] fixing compilation on Linux --- modules/features2d/src/features2d_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index 9fcbcd6c59..13ef0f8ae5 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -181,7 +181,7 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense", obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale)); CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid", - obj.info()->addParam(obj, "detector", (Ptr&)obj.detector); + obj.info()->addParam(obj, "detector", obj.detector, false, 0, 0); // Extra params added to avoid VS2013 fatal error in opencv2/core.hpp (decl. of addParam) obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints); obj.info()->addParam(obj, "gridRows", obj.gridRows); obj.info()->addParam(obj, "gridCols", obj.gridCols));