mexopencv  0.1
mex interface for opencv library
HoughLines.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>=1 && (nrhs%2)==1 && nlhs<=1);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26 
27  // Option processing
28  double rho = 1;
29  double theta = CV_PI/180;
30  int threshold = 80;
31  double srn = 0;
32  double stn = 0;
33  double min_theta = 0;
34  double max_theta = CV_PI;
35  for (int i=1; i<nrhs; i+=2) {
36  string key(rhs[i].toString());
37  if (key=="Rho")
38  rho = rhs[i+1].toDouble();
39  else if (key=="Theta")
40  theta = rhs[i+1].toDouble();
41  else if (key=="Threshold")
42  threshold = rhs[i+1].toInt();
43  else if (key=="SRN")
44  srn = rhs[i+1].toDouble();
45  else if (key=="STN")
46  stn = rhs[i+1].toDouble();
47  else if (key=="MinTheta")
48  min_theta = rhs[i+1].toDouble();
49  else if (key=="MaxTheta")
50  max_theta = rhs[i+1].toDouble();
51  else
52  mexErrMsgIdAndTxt("mexopencv:error","Unrecognized option");
53  }
54 
55  // Process
56  Mat image(rhs[0].toMat(CV_8U));
57  vector<Vec2f> lines;
58  HoughLines(image, lines, rho, theta, threshold, srn, stn,
59  min_theta, max_theta);
60  plhs[0] = MxArray(lines);
61 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: HoughLines.cpp:19
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.