mexopencv  0.1
mex interface for opencv library
linearPolar.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
19 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
20 {
21  // Check the number of arguments
22  nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26 
27  // Option processing
28  int flags = cv::INTER_LINEAR;
29  bool fillOutliersFlag = true;
30  bool invMapFlag = false;
31  for (int i=3; i<nrhs; i+=2) {
32  string key(rhs[i].toString());
33  if (key == "Interpolation")
34  flags = (rhs[i+1].isChar()) ?
35  InterpType[rhs[i+1].toString()] : rhs[i+1].toInt();
36  else if (key == "FillOutliers")
37  fillOutliersFlag = rhs[i+1].toBool();
38  else if (key == "InverseMap")
39  invMapFlag = rhs[i+1].toBool();
40  else
41  mexErrMsgIdAndTxt("mexopencv:error",
42  "Unrecognized option %s", key.c_str());
43  }
44  flags |= (fillOutliersFlag ? cv::WARP_FILL_OUTLIERS : 0);
45  flags |= (invMapFlag ? cv::WARP_INVERSE_MAP : 0);
46 
47  // Process
48  Mat src(rhs[0].toMat()), dst;
49  Point2f center(rhs[1].toPoint2f());
50  double maxRadius = rhs[2].toDouble();
51  linearPolar(src, dst, center, maxRadius, flags);
52  plhs[0] = MxArray(dst);
53 }
const ConstMap< std::string, int > InterpType
Interpolation type map for option processing.
Definition: mexopencv.hpp:71
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: linearPolar.cpp:19