mexopencv  0.1
mex interface for opencv library
getGaborKernel.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%2)==0 && nlhs<=1);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26 
27  // Option processing
28  Size ksize(21,21);
29  double sigma = 5.0;
30  double theta = CV_PI*0.25;
31  double lambd = 10.0;
32  double gamma = 0.75;
33  double psi = CV_PI*0.5;
34  int ktype = CV_64F;
35  for (int i=0; i<nrhs; i+=2) {
36  string key(rhs[i].toString());
37  if (key == "KSize")
38  ksize = rhs[i+1].toSize();
39  else if (key == "Sigma")
40  sigma = rhs[i+1].toDouble();
41  else if (key == "Theta")
42  theta = rhs[i+1].toDouble();
43  else if (key == "Lambda")
44  lambd = rhs[i+1].toDouble();
45  else if (key == "Gamma")
46  gamma = rhs[i+1].toDouble();
47  else if (key == "Psi")
48  psi = rhs[i+1].toDouble();
49  else if (key == "KType")
50  ktype = (rhs[i+1].isChar()) ?
51  ClassNameMap[rhs[i+1].toString()] : rhs[i+1].toInt();
52  else
53  mexErrMsgIdAndTxt("mexopencv:error",
54  "Unrecognized option %s", key.c_str());
55  }
56 
57  // Process
58  Mat kernel = getGaborKernel(ksize, sigma, theta, lambd, gamma, psi, ktype);
59  plhs[0] = MxArray(kernel);
60 }
const ConstMap< std::string, int > ClassNameMap
Translates class name used in MATLAB to equivalent OpenCV depth.
Definition: mexopencv.hpp:27
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.