36 int id = rhs[0].toInt();
37 string method(rhs[1].toString());
40 if (method ==
"new") {
41 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
42 int length_threshold = 10;
43 float distance_threshold = 1.414213562f;
44 double canny_th1 = 50.0;
45 double canny_th2 = 50.0;
46 int canny_aperture_size = 3;
47 bool do_merge =
false;
48 for (
int i=2; i<nrhs; i+=2) {
49 string key(rhs[i].toString());
50 if (key ==
"LengthThreshold")
51 length_threshold = rhs[i+1].toInt();
52 else if (key ==
"DistanceThreshold")
53 distance_threshold = rhs[i+1].toFloat();
54 else if (key ==
"CannyThreshold1")
55 canny_th1 = rhs[i+1].toDouble();
56 else if (key ==
"CannyThreshold2")
57 canny_th2 = rhs[i+1].toDouble();
58 else if (key ==
"CannyApertureSize")
59 canny_aperture_size = rhs[i+1].toInt();
60 else if (key ==
"DoMerge")
61 do_merge = rhs[i+1].toBool();
64 "Unrecognized option %s", key.
c_str());
67 length_threshold, distance_threshold, canny_th1, canny_th2,
68 canny_aperture_size, do_merge);
78 if (method ==
"delete") {
83 else if (method ==
"clear") {
87 else if (method ==
"load") {
88 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
90 bool loadFromString =
false;
91 for (
int i=3; i<nrhs; i+=2) {
92 string key(rhs[i].toString());
94 objname = rhs[i+1].toString();
95 else if (key ==
"FromString")
96 loadFromString = rhs[i+1].toBool();
99 "Unrecognized option %s", key.
c_str());
108 FileStorage fs(rhs[2].toString(), FileStorage::READ +
109 (loadFromString ? FileStorage::MEMORY : 0));
118 else if (method ==
"save") {
120 obj->
save(rhs[2].toString());
122 else if (method ==
"empty") {
126 else if (method ==
"getDefaultName") {
130 else if (method ==
"detect") {
134 obj->
detect(image, lines);
137 else if (method ==
"drawSegments") {
138 nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=1);
139 bool draw_arrow =
false;
140 for (
int i=4; i<nrhs; i+=2) {
141 string key(rhs[i].toString());
142 if (key ==
"DrawArrow")
143 draw_arrow = rhs[i+1].toBool();
146 "Unrecognized option %s", key.
c_str());
156 "Unrecognized operation %s", method.
c_str());
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void detect(InputArray _image, OutputArray _lines)=0
Ptr< FastLineDetector > createFastLineDetector(int _length_threshold=10, float _distance_threshold=1.414213562f, double _canny_th1=50.0, double _canny_th2=50.0, int _canny_aperture_size=3, bool _do_merge=false)
virtual void drawSegments(InputOutputArray _image, InputArray lines, bool draw_arrow=false)=0
virtual void read(const FileNode &fn)
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...
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
int last_id
Last object id to allocate.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
FileNode getFirstTopLevelNode() const
virtual String getDefaultName() const
Global constant definitions.
virtual void save(const String &filename) const
virtual bool empty() const
map< int, Ptr< FastLineDetector > > obj_
Object container.