From 306248e4443ebc1d0b5d85fdcac3296995db784d Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Mon, 16 Apr 2012 11:10:41 +0000 Subject: [PATCH] Added support of Clp for Windows --- CMakeLists.txt | 32 ++++++++++++++++++---------- modules/videostab/src/global_motion.cpp | 2 +- modules/videostab/src/motion_stabilizing.cpp | 32 +++++++++++++++++----------- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c43b07c..83ef3ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON OCV_OPTION(WITH_VIDEOINPUT "Build HighGUI with DirectShow support" ON IF WIN32 ) OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF WIN32 ) OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) ) -OCV_OPTION(WITH_CLP "Include Clp support (EPL)" OFF IF (UNIX AND NOT ANDROID AND NOT IOS) ) +OCV_OPTION(WITH_CLP "Include Clp support (EPL)" OFF IF (NOT ANDROID AND NOT IOS) ) # OpenCV build components # =================================================== @@ -572,26 +572,36 @@ endif() set(HAVE_CLP FALSE) if(WITH_CLP) - PKG_CHECK_MODULES(CLP clp) - if(CLP_FOUND) - set(HAVE_CLP TRUE) - if(NOT ${CLP_INCLUDE_DIRS} STREQUAL "") - ocv_include_directories(${CLP_INCLUDE_DIRS}) + + if(UNIX) + PKG_CHECK_MODULES(CLP clp) + if(CLP_FOUND) + set(HAVE_CLP TRUE) + if(NOT ${CLP_INCLUDE_DIRS} STREQUAL "") + ocv_include_directories(${CLP_INCLUDE_DIRS}) + endif() + link_directories(${CLP_LIBRARY_DIRS}) + set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CLP_LIBRARIES}) endif() - link_directories(${CLP_LIBRARY_DIRS}) - set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CLP_LIBRARIES}) - else() + endif() + + if(NOT CLP_FOUND) find_path(CLP_INCLUDE_PATH "coin" PATHS "/usr/local/include" "/usr/include" "/opt/include" DOC "The path to Clp headers") if(CLP_INCLUDE_PATH) - ocv_include_directories(${CLP_INCLUDE_PATH}) + ocv_include_directories(${CLP_INCLUDE_PATH} "${CLP_INCLUDE_PATH}/coin") set(CLP_LIBRARY_DIR "${CLP_INCLUDE_PATH}/../lib" CACHE PATH "Full path of Clp library directory") link_directories(${CLP_LIBRARY_DIR}) - set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} Clp CoinUtils bz2 z lapack blas m) + if(UNIX) + set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} Clp CoinUtils bz2 z lapack blas m) + else() + set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} libClp libCoinUtils) + endif() set(HAVE_CLP TRUE) endif() endif() + endif() ################## Extra HighGUI libs on Windows ################### diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index 806abad..b347426 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -447,7 +447,7 @@ Mat PyrLkRobustMotionEstimator::estimate(const Mat &frame0, const Mat &frame1, b ninliers = 0; rmse = 0; - Point2d p0, p1; + Point2f p0, p1; float x, y, z; for (size_t i = 0; i < pointsGood_.size(); ++i) diff --git a/modules/videostab/src/motion_stabilizing.cpp b/modules/videostab/src/motion_stabilizing.cpp index 3a420e7..36af76c 100644 --- a/modules/videostab/src/motion_stabilizing.cpp +++ b/modules/videostab/src/motion_stabilizing.cpp @@ -46,13 +46,21 @@ #include "opencv2/videostab/ring_buffer.hpp" #ifdef HAVE_CLP -#include "coin/ClpSimplex.hpp" -#include "coin/ClpPresolve.hpp" -#include "coin/ClpPrimalColumnSteepest.hpp" -#include "coin/ClpDualRowSteepest.hpp" + #include "ClpSimplex.hpp" + #include "ClpPresolve.hpp" + #include "ClpPrimalColumnSteepest.hpp" + #include "ClpDualRowSteepest.hpp" + #define INF 1e10 #endif -#define INF 1e10 +// Clp replaces min and max with ?: globally, we can't use std::min and std::max in case +// when HAVE_CLP is true, otherwise we create the defines by ourselves +#ifndef min + #define min(a,b) std::min(a,b) +#endif +#ifndef max + #define max(a,b) std::max(a,b) +#endif using namespace std; @@ -62,8 +70,7 @@ namespace videostab { void MotionStabilizationPipeline::stabilize( - int size, const vector &motions, pair range, - Mat *stabilizationMotions) + int size, const vector &motions, pair range, Mat *stabilizationMotions) { vector updatedMotions(motions.size()); for (size_t i = 0; i < motions.size(); ++i) @@ -118,8 +125,8 @@ Mat GaussianMotionFilter::stabilize(int idx, const vector &motions, pair&, pair, Mat*) #else void LpMotionStabilizer::stabilize( - int size, const vector &motions, pair range, - Mat *stabilizationMotions) + int size, const vector &motions, pair range, Mat *stabilizationMotions) { CV_Assert(model_ == MM_LINEAR_SIMILARITY); @@ -662,7 +668,7 @@ void LpMotionStabilizer::stabilize( CoinPackedMatrix A(true, &rows_[0], &cols_[0], &elems_[0], elems_.size()); A.setDimensions(nrows, ncols); - ClpSimplex model; + ClpSimplex model(false); model.loadProblem(A, &collb_[0], &colub_[0], &obj_[0], &rowlb_[0], &rowub_[0]); ClpDualRowSteepest dualSteep(1); -- 2.7.4