41 int id = rhs[0].toInt();
42 string method(rhs[1].toString());
45 if (method ==
"new") {
46 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
49 double sigma_scale = 0.6;
53 double density_th = 0.7;
55 for (
int i=2; i<nrhs; i+=2) {
56 string key(rhs[i].toString());
59 else if (key ==
"Scale")
60 scale = rhs[i+1].toDouble();
61 else if (key ==
"SigmaScale")
62 sigma_scale = rhs[i+1].toDouble();
63 else if (key ==
"QuantError")
64 quant = rhs[i+1].toDouble();
65 else if (key ==
"AngleTol")
66 ang_th = rhs[i+1].toDouble();
67 else if (key ==
"DetectionThreshold")
68 log_eps = rhs[i+1].toDouble();
69 else if (key ==
"MinDensity")
70 density_th = rhs[i+1].toDouble();
71 else if (key ==
"NBins")
72 n_bins = rhs[i+1].toInt();
75 "Unrecognized option %s", key.
c_str());
78 sigma_scale, quant, ang_th, log_eps, density_th, n_bins);
88 if (method ==
"delete") {
93 else if (method ==
"clear") {
97 else if (method ==
"load") {
98 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
100 bool loadFromString =
false;
101 for (
int i=3; i<nrhs; i+=2) {
102 string key(rhs[i].toString());
103 if (key ==
"ObjName")
104 objname = rhs[i+1].toString();
105 else if (key ==
"FromString")
106 loadFromString = rhs[i+1].toBool();
109 "Unrecognized option %s", key.
c_str());
118 FileStorage fs(rhs[2].toString(), FileStorage::READ +
119 (loadFromString ? FileStorage::MEMORY : 0));
128 else if (method ==
"save") {
130 obj->
save(rhs[2].toString());
132 else if (method ==
"empty") {
136 else if (method ==
"getDefaultName") {
140 else if (method ==
"detect") {
156 else if (method ==
"drawSegments") {
164 else if (method ==
"compareSegments") {
165 nargchk(nrhs>=5 && (nrhs%2)==1 && nlhs<=2);
168 for (
int i=5; i<nrhs; i+=2) {
169 string key(rhs[i].toString());
171 image = rhs[i+1].toMat();
174 "Unrecognized option %s", key.
c_str());
183 lines2(rhs[4].toVector<Vec4f>());
191 "Unrecognized operation %s", method.
c_str());
virtual int compareSegments(const Size &size, InputArray lines1, InputArray lines2, InputOutputArray _image=noArray())=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual void drawSegments(InputOutputArray _image, InputArray lines)=0
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
int last_id
Last object id to allocate.
Ptr< LineSegmentDetector > createLineSegmentDetector(int _refine=LSD_REFINE_STD, double _scale=0.8, double _sigma_scale=0.6, double _quant=2.0, double _ang_th=22.5, double _log_eps=0, double _density_th=0.7, int _n_bins=1024)
virtual void read(const FileNode &fn)
InputOutputArray noArray()
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...
const ConstMap< string, int > LineSegmentDetectorModesMap
Line Segment Detector modes for option processing.
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
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 detect(InputArray _image, OutputArray _lines, OutputArray width=noArray(), OutputArray prec=noArray(), OutputArray nfa=noArray())=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
void create(int rows, int cols, int type)
Mat & setTo(InputArray value, InputArray mask=noArray())
virtual void save(const String &filename) const
virtual bool empty() const
static Scalar_< double > all(double v0)
std::map wrapper with one-line initialization and lookup method.
map< int, Ptr< LineSegmentDetector > > obj_
Object container.