mexopencv  3.4.1
MEX interface for OpenCV library
HoughLinesPointSet.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>=1 && (nrhs%2)==1 && nlhs<=1);
24 
25  // Argument vector
26  vector<MxArray> rhs(prhs, prhs+nrhs);
27 
28  // Option processing
29  int lines_max = 200;
30  int threshold = 10;
31  double min_rho = 0;
32  double max_rho = 100;
33  double rho_step = 1;
34  double min_theta = 0;
35  double max_theta = CV_PI/2;
36  double theta_step = CV_PI/180;
37  for (int i=1; i<nrhs; i+=2) {
38  string key(rhs[i].toString());
39  if (key == "LinesMax")
40  lines_max = rhs[i+1].toInt();
41  else if (key == "Threshold")
42  threshold = rhs[i+1].toInt();
43  else if (key == "RhoMin")
44  min_rho = rhs[i+1].toDouble();
45  else if (key == "RhoMax")
46  max_rho = rhs[i+1].toDouble();
47  else if (key == "RhoStep")
48  rho_step = rhs[i+1].toDouble();
49  else if (key == "ThetaMin")
50  min_theta = rhs[i+1].toDouble();
51  else if (key == "ThetaMax")
52  max_theta = rhs[i+1].toDouble();
53  else if (key == "ThetaStep")
54  theta_step = rhs[i+1].toDouble();
55  else
56  mexErrMsgIdAndTxt("mexopencv:error",
57  "Unrecognized option %s", key.c_str());
58  }
59 
60  // Process
61  vector<Point2f> points(rhs[0].toVector<Point2f>());
62  vector<Vec3d> lines;
63  HoughLinesPointSet(points, lines, lines_max, threshold,
64  min_rho, max_rho, rho_step, min_theta, max_theta, theta_step);
65  plhs[0] = MxArray(lines);
66 }
#define CV_PI
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
void HoughLinesPointSet(InputArray _point, OutputArray _lines, int lines_max, int threshold, double min_rho, double max_rho, double rho_step, double min_theta, double max_theta, double theta_step)
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...
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.
T c_str(T... args)
double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.