Added support of Clp for Windows

This commit is contained in:
Alexey Spizhevoy 2012-04-16 11:10:41 +00:00
parent 601d2843f4
commit 306248e444
3 changed files with 41 additions and 25 deletions

View File

@ -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 ###################

View File

@ -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)

View File

@ -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<Mat> &motions, pair<int,int> range,
Mat *stabilizationMotions)
int size, const vector<Mat> &motions, pair<int,int> range, Mat *stabilizationMotions)
{
vector<Mat> updatedMotions(motions.size());
for (size_t i = 0; i < motions.size(); ++i)
@ -118,8 +125,8 @@ Mat GaussianMotionFilter::stabilize(int idx, const vector<Mat> &motions, pair<in
const Mat &cur = at(idx, motions);
Mat res = Mat::zeros(cur.size(), cur.type());
float sum = 0.f;
int iMin = std::max(idx - radius_, range.first);
int iMax = std::min(idx + radius_, range.second);
int iMin = max(idx - radius_, range.first);
int iMax = min(idx + radius_, range.second);
for (int i = iMin; i <= iMax; ++i)
{
res += weight_[radius_ + i - idx] * getMotion(idx, i, motions);
@ -266,7 +273,7 @@ LpMotionStabilizer::LpMotionStabilizer(MotionModel model)
{
setMotionModel(model);
setFrameSize(Size(0,0));
setTrimRatio(0.1);
setTrimRatio(0.1f);
setWeight1(1);
setWeight2(10);
setWeight3(100);
@ -284,8 +291,7 @@ void LpMotionStabilizer::stabilize(int, const vector<Mat>&, pair<int,int>, Mat*)
#else
void LpMotionStabilizer::stabilize(
int size, const vector<Mat> &motions, pair<int,int> range,
Mat *stabilizationMotions)
int size, const vector<Mat> &motions, pair<int,int> 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);