mexopencv  0.1
mex interface for opencv library
initWideAngleProjMap.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  ("int16", CV_16SC2)
16  ("single1", CV_32FC1)
17  ("single2", CV_32FC2);
18 
21  ("Ortho", cv::PROJ_SPHERICAL_ORTHO)
22  ("EqRect", cv::PROJ_SPHERICAL_EQRECT);
23 }
24 
32 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
33 {
34  // Check the number of arguments
35  nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=3);
36 
37  // Argument vector
38  vector<MxArray> rhs(prhs, prhs+nrhs);
39 
40  // Option processing
41  int m1type = -1;
42  int projType = cv::PROJ_SPHERICAL_EQRECT;
43  double alpha = 0;
44  for (int i=4; i<nrhs; i+=2) {
45  string key(rhs[i].toString());
46  if (key == "M1Type")
47  m1type = (rhs[i+1].isChar()) ?
48  M1Type[rhs[i+1].toString()] : rhs[i+1].toInt();
49  else if (key == "ProjType")
50  projType = ProjTypeMap[rhs[i+1].toString()];
51  else if (key == "Alpha")
52  alpha = rhs[i+1].toDouble();
53  else
54  mexErrMsgIdAndTxt("mexopencv:error",
55  "Unrecognized option %s", key.c_str());
56  }
57 
58  // Process
59  Mat cameraMatrix(rhs[0].toMat(CV_64F)),
60  distCoeffs(rhs[1].toMat(CV_64F)),
61  map1, map2;
62  Size imageSize(rhs[2].toSize());
63  int destImageWidth = rhs[3].toInt();
64  float scale = initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize,
65  destImageWidth, m1type, map1, map2, projType, alpha);
66  plhs[0] = MxArray(map1);
67  if (nlhs > 1)
68  plhs[1] = MxArray(map2);
69  if (nlhs > 2)
70  plhs[2] = MxArray(scale);
71 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
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.
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927