mexopencv  3.4.1
MEX interface for OpenCV library
solveLP.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
12 namespace {
15  (cv::SOLVELP_UNBOUNDED, "Unbound")
16  (cv::SOLVELP_UNFEASIBLE, "Unfeasible")
17  (cv::SOLVELP_SINGLE, "Single")
18  (cv::SOLVELP_MULTI, "Multi");
19 }
20 
28 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
29 {
30  // Check the number of arguments
31  nargchk(nrhs==2 && nlhs<=2);
32 
33  // Argument vector
34  vector<MxArray> rhs(prhs, prhs+nrhs);
35 
36  // Process
37  Mat Func(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
38  Constr(rhs[1].toMat(rhs[1].isSingle() ? CV_32F : CV_64F)),
39  z;
40  int result = solveLP(Func, Constr, z);
41  plhs[0] = MxArray(z);
42  if (nlhs>1)
43  plhs[1] = MxArray(SolveLPResultInvMap[result]);
44 }
SOLVELP_MULTI
SOLVELP_SINGLE
const ConstMap< int, string > SolveLPResultInvMap
SolveLPResult map for option processing.
Definition: solveLP.cpp:14
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
#define CV_32F
#define CV_64F
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/output arguments number check.
Definition: mexopencv.hpp:181
STL class.
Global constant definitions.
int solveLP(const Mat &Func, const Mat &Constr, Mat &z)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: solveLP.cpp:28
z
SOLVELP_UNBOUNDED
SOLVELP_UNFEASIBLE
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
cv::Mat toMat() const