mexopencv  3.4.1
MEX interface for OpenCV library
HoughPoint2Line.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/ximgproc.hpp"
10 using namespace std;
11 using namespace cv;
12 using namespace cv::ximgproc;
13 
14 namespace {
17  ("ARO_0_45", cv::ximgproc::ARO_0_45)
18  ("ARO_45_90", cv::ximgproc::ARO_45_90)
19  ("ARO_90_135", cv::ximgproc::ARO_90_135)
20  ("ARO_315_0", cv::ximgproc::ARO_315_0)
21  ("ARO_315_45", cv::ximgproc::ARO_315_45)
22  ("ARO_45_135", cv::ximgproc::ARO_45_135)
23  ("ARO_315_135", cv::ximgproc::ARO_315_135)
24  ("ARO_CTR_HOR", cv::ximgproc::ARO_CTR_HOR)
25  ("ARO_CTR_VER", cv::ximgproc::ARO_CTR_VER);
26 
29  ("Raw", cv::ximgproc::HDO_RAW)
30  ("Deskew", cv::ximgproc::HDO_DESKEW);
31 
34  ("Strict", cv::ximgproc::RO_STRICT)
35  ("IgnoreBorders", cv::ximgproc::RO_IGNORE_BORDERS);
36 }
37 
45 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
46 {
47  // Check the number of arguments
48  nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
49 
50  // Argument vector
51  vector<MxArray> rhs(prhs, prhs+nrhs);
52 
53  // Option processing
54  int angleRange = cv::ximgproc::ARO_315_135;
55  int makeSkew = cv::ximgproc::HDO_DESKEW;
57  for (int i=2; i<nrhs; i+=2) {
58  string key(rhs[i].toString());
59  if (key == "AngleRange")
60  angleRange = AngleRangeOptionMap[rhs[i+1].toString()];
61  else if (key == "MakeSkew")
62  makeSkew = HoughDeskewOptionMap[rhs[i+1].toString()];
63  else if (key == "Rules")
64  rules = RulesOptionMap[rhs[i+1].toString()];
65  else
66  mexErrMsgIdAndTxt("mexopencv:error",
67  "Unrecognized option %s", key.c_str());
68  }
69 
70  // Process
71  Point houghPoint(rhs[0].toPoint());
72  Mat src(rhs[1].toMat());
73  Vec4i line = HoughPoint2Line(houghPoint, src, angleRange, makeSkew, rules);
74  plhs[0] = MxArray(line);
75 }
const ConstMap< string, int > RulesOptionMap
Option values hough transform rules options.
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
Vec4i HoughPoint2Line(const Point &houghPoint, InputArray srcImgInfo, int angleRange=ARO_315_135, int makeSkew=HDO_DESKEW, int rules=RO_IGNORE_BORDERS)
const ConstMap< string, int > AngleRangeOptionMap
Option values hough transform angle range options.
void line(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
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)
const ConstMap< string, int > HoughDeskewOptionMap
Option values hough transform deskew options.
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
cv::Mat toMat() const