mexopencv  0.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 {
14 const ConstMap<int,string> SolveLPResultInvMap = ConstMap<int,string>
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 }
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Definition: mexopencv.hpp:166
Global constant definitions.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: solveLP.cpp:28
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927