mexopencv  3.4.1
MEX interface for OpenCV library
linearPolar.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/imgproc.hpp"
10 using namespace std;
11 using namespace cv;
12 
20 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
21 {
22  // Check the number of arguments
23  nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
24 
25  // Argument vector
26  vector<MxArray> rhs(prhs, prhs+nrhs);
27 
28  // Option processing
29  int flags = cv::INTER_LINEAR;
30  bool fillOutliersFlag = true;
31  bool invMapFlag = false;
32  for (int i=3; i<nrhs; i+=2) {
33  string key(rhs[i].toString());
34  if (key == "Interpolation")
35  flags = (rhs[i+1].isChar()) ?
36  InterpType[rhs[i+1].toString()] : rhs[i+1].toInt();
37  else if (key == "FillOutliers")
38  fillOutliersFlag = rhs[i+1].toBool();
39  else if (key == "InverseMap")
40  invMapFlag = rhs[i+1].toBool();
41  else
42  mexErrMsgIdAndTxt("mexopencv:error",
43  "Unrecognized option %s", key.c_str());
44  }
45  flags |= (fillOutliersFlag ? cv::WARP_FILL_OUTLIERS : 0);
46  flags |= (invMapFlag ? cv::WARP_INVERSE_MAP : 0);
47 
48  // Process
49  Mat src(rhs[0].toMat()), dst;
50  Point2f center(rhs[1].toPoint2f());
51  double maxRadius = rhs[2].toDouble();
52  linearPolar(src, dst, center, maxRadius, flags);
53  plhs[0] = MxArray(dst);
54 }
WARP_FILL_OUTLIERS
const ConstMap< std::string, int > InterpType
Interpolation type map for option processing.
Definition: mexopencv.hpp:85
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
WARP_INVERSE_MAP
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.
INTER_LINEAR
T c_str(T... args)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: linearPolar.cpp:20
void linearPolar(InputArray src, OutputArray dst, Point2f center, double maxRadius, int flags)
cv::Mat toMat() const